[Stacomir-commits] r333 - in pkg/stacomir: . R inst/examples man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Apr 3 14:31:09 CEST 2017
Author: briand
Date: 2017-04-03 14:31:09 +0200 (Mon, 03 Apr 2017)
New Revision: 333
Added:
pkg/stacomir/man/plot-BilanMigrationMult-missing-method.Rd
Removed:
pkg/stacomir/man/model-Bilan_poids_moyen-method.Rd.tex
pkg/stacomir/man/plot-BilanMigrationMult-ANY-method.Rd
pkg/stacomir/po/
Modified:
pkg/stacomir/R/BilanMigrationMult.r
pkg/stacomir/R/Bilan_poids_moyen.r
pkg/stacomir/R/RefCoe.r
pkg/stacomir/inst/examples/bilan_poids_moyen_example.R
pkg/stacomir/man/Bilan_poids_moyen-class.Rd
pkg/stacomir/man/choice_c-Bilan_poids_moyen-method.Rd
pkg/stacomir/man/model-Bilan_poids_moyen-method.Rd
pkg/stacomir/man/write_database-Bilan_poids_moyen-method.Rd
Log:
Modified: pkg/stacomir/R/BilanMigrationMult.r
===================================================================
--- pkg/stacomir/R/BilanMigrationMult.r 2017-04-01 13:02:34 UTC (rev 332)
+++ pkg/stacomir/R/BilanMigrationMult.r 2017-04-03 12:31:09 UTC (rev 333)
@@ -384,7 +384,7 @@
# getGeneric("plot")
# showMethods("plot")
# methods("plot")
-setMethod("plot",signature(x = "BilanMigrationMult", y = "ANY"),definition=function(x, y,plot.type="standard",silent=FALSE,...){
+setMethod("plot",signature(x = "BilanMigrationMult", y = "missing"),definition=function(x, plot.type="standard",silent=FALSE,...){
#browser()
#print("entering plot function")
#bilanMigrationMult<-bMM_Arzal
@@ -540,6 +540,11 @@
))+
ggtitle(gettextf("Cumulative count %s, %s, %s, %s",dis_commentaire,lestaxons,lesstades,annee))
print(p)
+ assign("p",p,envir=envir_stacomi)
+ assign("grdata",grdata_without_hole,envir_stacomi)
+ funout(gettext("The plot has been assigned to p in envir_stacomi,write p<-get('p',envir_stacomi) to retreive the object"))
+ funout(gettext("The data for the plot have been assigned to envir_stacomi,write grdata<-get('grdata',envir_stacomi) to retreive the object"))
+
}
#==========================type=3=============================
if (plot.type=="multiple"){
@@ -592,7 +597,12 @@
}
print(p)
- }
+ assign("p",p,envir=envir_stacomi)
+ funout(gettext("The plot has been assigned to p in envir_stacomi,write p<-get('p',envir_stacomi) to retreive the object"))
+ assign("grdata",grdata,envir_stacomi)
+ funout(gettext("The data for the plot have been assigned to envir_stacomi,write grdata<-get('grdata',envir_stacomi) to retreive the object"))
+
+ }
#==========================end / type=3=============================
})
Modified: pkg/stacomir/R/Bilan_poids_moyen.r
===================================================================
--- pkg/stacomir/R/Bilan_poids_moyen.r 2017-04-01 13:02:34 UTC (rev 332)
+++ pkg/stacomir/R/Bilan_poids_moyen.r 2017-04-03 12:31:09 UTC (rev 333)
@@ -55,7 +55,7 @@
# loading mean weights
requete=new("RequeteODBCwheredate")
requete at baseODBC=get("baseODBC",envir=envir_stacomi)
- requete at datedebut=strptime(paste(object at anneedebut@annee_selectionnee-1,"-08-01",sep=""),format="%Y-%m-%d")
+ requete at datedebut=strptime(paste(object at anneedebut@annee_selectionnee,"-08-01",sep=""),format="%Y-%m-%d")
requete at datefin=strptime(paste(object at anneefin@annee_selectionnee,"-08-01",sep=""),format="%Y-%m-%d")
requete at colonnedebut="ope_date_debut"
requete at colonnefin="ope_date_fin"
@@ -120,7 +120,7 @@
#' @param object An object of class \link{Bilan_poids_moyen-class}
#' @param dc A numeric or integer, the code of the dc, coerced to integer,see \link{choice_c,RefDC-method}
#' @param anneedebut The starting the first year, passed as charcter or integer
-#' @param anneefin the finishing year
+#' @param anneefin the finishing year, must be > anneedebut (minimum one year in august to the next in august)
#' @param selectedvalue A character to select and object in the \link{RefListe-class}
#' @param silent Boolean, if TRUE, information messages are not displayed
#' @return An object of class \link{Bilan_poids_moyen-class}
@@ -138,6 +138,7 @@
#dc=c(5,6);anneedebut="2015";anneefin="2016";selectedvalue=">1";silent=FALSE
if (length(selectedvalue)!=1) stop ("selectedvalue must be of length one")
bilPM<-object
+ stopifnot(anneefin>anneedebut)
bilPM at dc=charge(bilPM at dc)
# loads and verifies the dc
# this will set dc_selectionne slot
@@ -292,8 +293,8 @@
#' \itemize{
#'\item{model.type="seasonal".}{ The simplest model uses a seasonal variation, it is
#' fitted with a sine wave curve allowing a cyclic variation
-#' w ~ a*cos(2*pi*(doy-T)/365)+b with a period T. The julian time d0 used is this model is set
-#' at zero 1st of November d = d + d0; d0 = 305.}
+#' w ~ a*cos(2*pi*(d'-T)/365)+b with a period T. The modified day d' used is this model is set
+#' at 1 the 1st of august doy = d' + d0; d0 = 212, doy=julian days}
#'\item{model.type="seasonal1".}{ A time component is introduced in the model, which allows
#' for a long term variation along with the seasonal variation. This long term variation is
#' is fitted with a gam, the time variable is set at zero at the beginning of the first day of observed values.
@@ -329,7 +330,7 @@
data$year<-lubridate::year(data$date)
# lubridate::yday(lubridate::dmy(01082008))
data$yday=lubridate::yday(data$date)
- data$doy=data$yday-214 # year begins in august to be consistent with the class
+ data$doy=data$yday-212 # year begins in august to be consistent with the class
data$season<-stringr::str_c(lubridate::year(data$date)-1,"-",lubridate::year(data$date)) # year-1-year
data$season[data$doy>0]<-stringr::str_c(lubridate::year(data$date),"-",lubridate::year(data$date)+1)[data$doy>0] # for november and december it's year - year+1
data$yearbis<-data$year # same as season but with a numeric
@@ -545,11 +546,14 @@
#' from the database, those will be deleted first.
#' @param object An object of class \link{Bilan_poids_moyen-class}
#' @param silent Boolean, if TRUE, information messages are not displayed
+#' @param dbname default "bd_contmig_nat"
#' @return An object of class \link{Bilan_poids_moyen-class}
#' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
#' @export
-setMethod("write_database",signature=signature("Bilan_poids_moyen"),definition=function(object,silent=FALSE,dbname="bd_contmig_nat",host="localhost",port=5432){
+setMethod("write_database",signature=signature("Bilan_poids_moyen"),definition=function(object,silent=FALSE,dbname="bd_contmig_nat"){
#silent=FALSE;dbname="bd_contmig_nat";host="localhost";port=5432
+ host=get("sqldf.options",envir=envir_stacomi)["sqldf.host"]
+ port=get("sqldf.options",envir=envir_stacomi)["sqldf.port"]
bilPM<-object
if (!"import_coe"%in% names(bilPM at calcdata)) funout(gettext("Attention, you must fit a model before trying to write the predictions in the database",domain="R-stacomiR"),arret=TRUE)
# first delete existing data from the database
Modified: pkg/stacomir/R/RefCoe.r
===================================================================
--- pkg/stacomir/R/RefCoe.r 2017-04-01 13:02:34 UTC (rev 332)
+++ pkg/stacomir/R/RefCoe.r 2017-04-03 12:31:09 UTC (rev 333)
@@ -42,9 +42,7 @@
requete at datefin=object at datefin
requete at colonnedebut="coe_date_debut"
requete at colonnefin="coe_date_fin"
- # the coefficients are only loaded for bilanMigration
- # to be consistent with current programming, we need to add it as a timestamp
- requete at datefin=as.POSIXlt(object at datefin+as.difftime("23:59:59"))
+ requete at datefin=as.POSIXlt(object at datefin)
requete at select=stringr::str_c("select * from ",
get("sch",envir=envir_stacomi),
"tj_coefficientconversion_coe")
Modified: pkg/stacomir/inst/examples/bilan_poids_moyen_example.R
===================================================================
--- pkg/stacomir/inst/examples/bilan_poids_moyen_example.R 2017-04-01 13:02:34 UTC (rev 332)
+++ pkg/stacomir/inst/examples/bilan_poids_moyen_example.R 2017-04-03 12:31:09 UTC (rev 333)
@@ -13,6 +13,8 @@
assign("sch","iav.",envir_stacomi)
bilPM at liste<-charge(object=bilPM at liste,listechoice=c("=1",">1","tous"),label="")
# here I'm using weights when number are larger than 1 ie wet weight
+ # always choose a date from one year to the next eg 2010 to 2011
+ # as the dates are from august to august
bilPM<-choice_c(bilPM,
dc=c(6),
anneedebut="2009",
Modified: pkg/stacomir/man/Bilan_poids_moyen-class.Rd
===================================================================
--- pkg/stacomir/man/Bilan_poids_moyen-class.Rd 2017-04-01 13:02:34 UTC (rev 332)
+++ pkg/stacomir/man/Bilan_poids_moyen-class.Rd 2017-04-03 12:31:09 UTC (rev 333)
@@ -52,6 +52,8 @@
assign("sch","iav.",envir_stacomi)
bilPM at liste<-charge(object=bilPM at liste,listechoice=c("=1",">1","tous"),label="")
# here I'm using weights when number are larger than 1 ie wet weight
+ # always choose a date from one year to the next eg 2010 to 2011
+ # as the dates are from august to august
bilPM<-choice_c(bilPM,
dc=c(6),
anneedebut="2009",
Modified: pkg/stacomir/man/choice_c-Bilan_poids_moyen-method.Rd
===================================================================
--- pkg/stacomir/man/choice_c-Bilan_poids_moyen-method.Rd 2017-04-01 13:02:34 UTC (rev 332)
+++ pkg/stacomir/man/choice_c-Bilan_poids_moyen-method.Rd 2017-04-03 12:31:09 UTC (rev 333)
@@ -15,7 +15,7 @@
\item{anneedebut}{The starting the first year, passed as charcter or integer}
-\item{anneefin}{the finishing year}
+\item{anneefin}{the finishing year, must be > anneedebut (minimum one year in august to the next in august)}
\item{selectedvalue}{A character to select and object in the \link{RefListe-class}}
Modified: pkg/stacomir/man/model-Bilan_poids_moyen-method.Rd
===================================================================
--- pkg/stacomir/man/model-Bilan_poids_moyen-method.Rd 2017-04-01 13:02:34 UTC (rev 332)
+++ pkg/stacomir/man/model-Bilan_poids_moyen-method.Rd 2017-04-03 12:31:09 UTC (rev 333)
@@ -24,22 +24,22 @@
\details{
Depending on model.type several models are produced
\itemize{
- \item{model.type="seasonal".}{ The simplest model uses a seasonal variation, it is
+\item{model.type="seasonal".}{ The simplest model uses a seasonal variation, it is
fitted with a sine wave curve allowing a cyclic variation
- w ~ a*cos(2*pi*(doy-T)/365)+b with a period T. The julian time d0 used is this model is set
- at zero 1st of November d = d + d0; d0 = 305.}
- \item{model.type="seasonal1".}{ A time component is introduced in the model, which allows
+ w ~ a*cos(2*pi*(d'-T)/365)+b with a period T. The modified day d' used is this model is set
+ at 1 the 1st of august doy = d' + d0; d0 = 212, doy=julian days}
+\item{model.type="seasonal1".}{ A time component is introduced in the model, which allows
for a long term variation along with the seasonal variation. This long term variation is
is fitted with a gam, the time variable is set at zero at the beginning of the first day of observed values.
The seasonal variation is modeled on the same modified julian time as model.type="seasonal"
but here we use a cyclic cubic spline cc, which allows to return at the value of d0=0 at d=365.
This model was considered as the best to model size variations by Diaz & Briand in prep. but using a large set of values
over years.}
-\item{model.type="seasonal2"}{The seasonal trend in the previous model is now modelled with a sine
+\item{model.type="seasonal2".}{The seasonal trend in the previous model is now modelled with a sine
curve similar to the sine curve used in seasonal. The formula for this is \eqn{sin(\omega vt) + cos(\omega vt)}{sin(omega vt) + cos(omega vt)},
where vt is the time index variable \eqn{\omega}{omega} is a constant that describes how the index variable relates to the full period
- (here, \eqn{2\pi/365=0.0172}{2pi/365=0.0172}. The model is written as following \eqn{w~cos(0.0172*doy)+sin(0.0172*doy)+s(time).}}
- \item{model.type="manual"}{ The dataset don (the raw data), coe (the coefficients already present in the
+ (here, \eqn{2\pi/365=0.0172}{2pi/365=0.0172}). The model is written as following \eqn{w~cos(0.0172*doy)+sin(0.0172*doy)+s(time).}}
+\item{model.type="manual".}{ The dataset don (the raw data), coe (the coefficients already present in the
database, and newcoe the dataset to make the predictions from, are written to the environment envir_stacomi.
please see example for further description on how to fit your own model, build the table of coefficients,
and write it to the database.}
Deleted: pkg/stacomir/man/model-Bilan_poids_moyen-method.Rd.tex
===================================================================
--- pkg/stacomir/man/model-Bilan_poids_moyen-method.Rd.tex 2017-04-01 13:02:34 UTC (rev 332)
+++ pkg/stacomir/man/model-Bilan_poids_moyen-method.Rd.tex 2017-04-03 12:31:09 UTC (rev 333)
@@ -1,51 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/Bilan_poids_moyen.r
-\docType{methods}
-\name{model,Bilan_poids_moyen-method}
-\alias{model,Bilan_poids_moyen-method}
-\alias{model.Bilan_poids_moyen}
-\alias{model.bilPM}
-\title{model method for Bilan_poids_moyen'
-this method uses samples collected over the season to model the variation in weight of
-glass eel or yellow eels.}
-\usage{
-model(object,model.type=c("seasonal","seasonal1","seasonal2","manual"),silent=FALSE)
-}
-\arguments{
-\item{object}{An object of class \link{Bilan_pois_moyen-class}}
-
-\item{model.type}{default "seasonal", "seasonal1","seasonal2","manual".}
-}
-\description{
-model method for Bilan_poids_moyen'
-this method uses samples collected over the season to model the variation in weight of
-glass eel or yellow eels.
-}
-\details{
-Depending on model.type several models are produced
-\itemize{
- \item{model.type="seasonal".}{ The simplest model uses a seasonal variation, it is
- fitted with a sine wave curve allowing a cyclic variation
- w ~ a*cos(2*pi*(doy-T)/365)+b with a period T. The julian time d0 used is this model is set
- at zero 1st of November d = d + d0; d0 = 305.}
- \item{model.type="seasonal1".}{ A time component is introduced in the model, which allows
- for a long term variation along with the seasonal variation. This long term variation is
- is fitted with a gam, the time variable is set at zero at the beginning of the first day of observed values.
- The seasonal variation is modeled on the same modified julian time as model.type="seasonal"
- but here we use a cyclic cubic spline cc, which allows to return at the value of d0=0 at d=365.
- This model was considered as the best to model size variations by Diaz & Briand in prep. but using a large set of values
- over years.}
-\item{model.type="seasonal2"}{The seasonal trend in the previous model is now modelled with a sine
- curve similar to the sine curve used in seasonal. The formula for this is \eqn{sin(\omega vt) + cos(\omega vt)}{sin(omega vt) + cos(omega vt)},
- where vt is the time index variable \eqn{\omega}{omega} is a constant that describes how the index variable relates to the full period
- (here, \eqn{2\pi/365=0.0172}{2pi/365=0.0172}. The model is written as following \eqn{w~cos(0.0172*doy)+sin(0.0172*doy)+s(time).}}
- \item{model.type="manual"}{ The dataset don (the raw data), coe (the coefficients already present in the
- database, and newcoe the dataset to make the predictions from, are written to the environment envir_stacomi.
- please see example for further description on how to fit your own model, build the table of coefficients,
- and write it to the database.}
-}
-}
-\author{
-Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
-}
-
Deleted: pkg/stacomir/man/plot-BilanMigrationMult-ANY-method.Rd
===================================================================
--- pkg/stacomir/man/plot-BilanMigrationMult-ANY-method.Rd 2017-04-01 13:02:34 UTC (rev 332)
+++ pkg/stacomir/man/plot-BilanMigrationMult-ANY-method.Rd 2017-04-03 12:31:09 UTC (rev 333)
@@ -1,34 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/BilanMigrationMult.r
-\docType{methods}
-\name{plot,BilanMigrationMult,ANY-method}
-\alias{plot,BilanMigrationMult,ANY-method}
-\title{Plots of various type for BilanMigrationMult}
-\usage{
-\S4method{plot}{BilanMigrationMult,ANY}(x, y, plot.type = "standard",
- silent = FALSE, ...)
-}
-\arguments{
-\item{x}{An object of class BilanMigrationMult}
-
-\item{y}{From the formals but missing}
-
-\item{plot.type}{One of "standard","step","multiple". Defaut to \code{standard} the standard BilanMigration with dc and operation displayed, can also be \code{step} or
-\code{multiple}}
-
-\item{silent}{Stops most messages from being displayed}
-
-\item{...}{Additional arguments, see \code{plot}, \code{plot.default} and \code{par}}
-}
-\description{
-\itemize{
- \item{plot.type="standard"}{calls \code{\link{fungraph}} and \code{\link{fungraph_civelle}} functions to plot as many "bilanmigration"
- as needed, the function will test for the existence of data for one dc, one taxa, and one stage}
- \item{plot.type="step"}{creates Cumulated graphs for BilanMigrationMult. Data are summed per day for different dc taxa and stages}
- \item{plot.type="multiple"}{Method to overlay graphs for BilanMigrationMult (multiple dc/taxa/stage in the same plot)}
-}
-}
-\author{
-Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
-}
-
Added: pkg/stacomir/man/plot-BilanMigrationMult-missing-method.Rd
===================================================================
--- pkg/stacomir/man/plot-BilanMigrationMult-missing-method.Rd (rev 0)
+++ pkg/stacomir/man/plot-BilanMigrationMult-missing-method.Rd 2017-04-03 12:31:09 UTC (rev 333)
@@ -0,0 +1,34 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/BilanMigrationMult.r
+\docType{methods}
+\name{plot,BilanMigrationMult,missing-method}
+\alias{plot,BilanMigrationMult,missing-method}
+\title{Plots of various type for BilanMigrationMult}
+\usage{
+\S4method{plot}{BilanMigrationMult,missing}(x, plot.type = "standard",
+ silent = FALSE, ...)
+}
+\arguments{
+\item{x}{An object of class BilanMigrationMult}
+
+\item{plot.type}{One of "standard","step","multiple". Defaut to \code{standard} the standard BilanMigration with dc and operation displayed, can also be \code{step} or
+\code{multiple}}
+
+\item{silent}{Stops most messages from being displayed}
+
+\item{...}{Additional arguments, see \code{plot}, \code{plot.default} and \code{par}}
+
+\item{y}{From the formals but missing}
+}
+\description{
+\itemize{
+ \item{plot.type="standard"}{calls \code{\link{fungraph}} and \code{\link{fungraph_civelle}} functions to plot as many "bilanmigration"
+ as needed, the function will test for the existence of data for one dc, one taxa, and one stage}
+ \item{plot.type="step"}{creates Cumulated graphs for BilanMigrationMult. Data are summed per day for different dc taxa and stages}
+ \item{plot.type="multiple"}{Method to overlay graphs for BilanMigrationMult (multiple dc/taxa/stage in the same plot)}
+}
+}
+\author{
+Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
+}
+
Modified: pkg/stacomir/man/write_database-Bilan_poids_moyen-method.Rd
===================================================================
--- pkg/stacomir/man/write_database-Bilan_poids_moyen-method.Rd 2017-04-01 13:02:34 UTC (rev 332)
+++ pkg/stacomir/man/write_database-Bilan_poids_moyen-method.Rd 2017-04-03 12:31:09 UTC (rev 333)
@@ -6,12 +6,14 @@
\title{Function to write data to the stacomi database for \link{Bilan_poids_moyen-class}}
\usage{
\S4method{write_database}{Bilan_poids_moyen}(object, silent = FALSE,
- dbname = "bd_contmig_nat", host = "localhost", port = 5432)
+ dbname = "bd_contmig_nat")
}
\arguments{
\item{object}{An object of class \link{Bilan_poids_moyen-class}}
\item{silent}{Boolean, if TRUE, information messages are not displayed}
+
+\item{dbname}{default "bd_contmig_nat"}
}
\value{
An object of class \link{Bilan_poids_moyen-class}
More information about the Stacomir-commits
mailing list