diff --git a/R/plot_OutputsModel.R b/R/plot_OutputsModel.R index 6af27419689c871d3ec33564dee99a57af2e6954..4b34e528cc42de44dba43ef28a6fc8f1258e03e5 100644 --- a/R/plot_OutputsModel.R +++ b/R/plot_OutputsModel.R @@ -1,4 +1,4 @@ -plot_OutputsModel <- function(OutputsModel,Qobs=NULL,IndPeriod_Plot=NULL,BasinArea=NULL,PlotChoice="all", verbose = TRUE){ +plot_OutputsModel <- function(OutputsModel, Qobs = NULL, IndPeriod_Plot = NULL, BasinArea = NULL, PlotChoice = "all", log_scale = FALSE, verbose = TRUE){ if(!inherits(OutputsModel,"GR") & !inherits(OutputsModel,"CemaNeige")){ stop(paste("OutputsModel not in the correct format for default plotting \n",sep="")); return(NULL); } @@ -174,7 +174,39 @@ plot_OutputsModel <- function(OutputsModel,Qobs=NULL,IndPeriod_Plot=NULL,BasinAr ##Flows - if(BOOLPLOT_Flows){ + if(BOOLPLOT_Flows & log_scale){ + kPlot <- kPlot+1; mar <- c(3,5,1,5); + par(new=FALSE,mar=mar,las=0) + + DATA2 <- Qobs + DATA2[!SelectQobsNotZero] <- mean(Qobs, na.rm=TRUE) / 10000 + DATA2 <- log(DATA2) + + DATA3 <- OutputsModel$Qsim + DATA2[!SelectQsimNotZero] <- mean(OutputsModel$Qsim, na.rm=TRUE) / 10000 + DATA3 <- log(DATA3) + + ylim1 <- range(DATA3[IndPeriod_Plot],na.rm=TRUE); + if(BOOL_Qobs){ ylim1 <- range(c(ylim1,DATA2[IndPeriod_Plot]),na.rm=TRUE); } + ylim2 <- c(ylim1[1],1.2*ylim1[2]); + plot(Xaxis,rep(NA,length(Xaxis)),type="n",ylim=ylim2,xlab="",ylab="",xaxt="n",yaxt="n"); + txtleg <- NULL; colleg <- NULL; + if(BOOL_Qobs){ lines(Xaxis,DATA2[IndPeriod_Plot],lwd=lwdLine,lty=1,col="black"); txtleg <- c(txtleg,"observed"); colleg <- c(colleg,"black"); } + if(BOOL_Qsim){ lines(Xaxis,DATA3[IndPeriod_Plot],lwd=lwdLine,lty=1,col="orangered"); txtleg <- c(txtleg,"simulated"); colleg <- c(colleg,"orangered"); } + axis(side=2,at=pretty(ylim1),labels=pretty(ylim1),cex.axis=cexaxis) + par(las=0); mtext(side=2,paste("flow ",plotunit,sep=""),line=lineY,cex=cexlab); par(las=0); + if(!is.null(BasinArea)){ + Factor <- Factor_UNIT_M3S; + axis(side=4,at=pretty(ylim1*Factor)/Factor,labels=pretty(ylim1*Factor),cex.axis=cexaxis); + par(las=0); mtext(side=4,paste("flow ","m3/s",sep=""),line=lineY,cex=cexlab); par(las=0); } + if(BOOL_Dates){ + axis(side=1,at=Seq1,labels=FALSE,cex.axis=cexaxis); + axis(side=1,at=Seq2,labels=Labels2,lwd.ticks=1.5,cex.axis=cexaxis); + } else { axis(side=1,at=pretty(Xaxis),labels=pretty(Xaxis),cex.axis=cexaxis); } + legend("topright",txtleg,col=colleg,lty=1,lwd=lwdLine,bty="o",bg=bgleg,box.col=bgleg,cex=cexleg) + box() + } + if(BOOLPLOT_Flows & !log_scale){ kPlot <- kPlot+1; mar <- c(3,5,1,5); par(new=FALSE,mar=mar,las=0) ylim1 <- range(OutputsModel$Qsim[IndPeriod_Plot],na.rm=TRUE); diff --git a/man/plot_OutputsModel.Rd b/man/plot_OutputsModel.Rd index 8f3289cb90a785aded62fe452f98870ef33b12ea..7adb4f54045b3ac5707455546b549e17580cd32a 100644 --- a/man/plot_OutputsModel.Rd +++ b/man/plot_OutputsModel.Rd @@ -4,7 +4,7 @@ \title{Default preview of model outputs} \usage{ plot_OutputsModel(OutputsModel, Qobs = NULL, IndPeriod_Plot = NULL, - BasinArea = NULL, PlotChoice = "all", verbose = TRUE) + BasinArea = NULL, PlotChoice = "all", log_scale = FALSE, verbose = TRUE) } \arguments{ \item{OutputsModel}{[object of class \emph{OutputsModel}] list of model outputs (which must at least include DatesR, Precip and Qsim) [POSIXlt, mm, mm]} @@ -17,7 +17,9 @@ plot_OutputsModel(OutputsModel, Qobs = NULL, IndPeriod_Plot = NULL, \item{PlotChoice}{(optional) [character] choice of plots \cr (e.g. c("Precip", "SnowPack", "Flows", "Regime", "CumFreq", "CorQQ")), default="all"} -\item{verbose}{(optional) [boolean] boolean indicating if the function is run in verbose mode or not, default=TRUE} +\item{log_scale}{(optional) [boolean] boolean indicating if the flow axis is to be logarithmic, default = FALSE} + +\item{verbose}{(optional) [boolean] boolean indicating if the function is run in verbose mode or not, default = TRUE} } \value{ screen plot window