Commit c4694419 authored by unknown's avatar unknown
Browse files

"log_scale" argument indicating if the flow axis is to be logarithmic

parent aa8139f0
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);
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment