Learn R Programming

dycdtools (version 0.3.1)

plot_cont_comp: Contour plot of a variable simulation, with observed data shown as dots in the generated contour plot.

Description

Contour plot a matrix of a bio-geochemical variable values, which can be generated through "interpol" function.

Usage

plot_cont_comp(
  sim = temp.interpolated,
  obs = obs_temp,
  file_name = "Contour_temp.png",
  sim.start = "2002-01-23",
  sim.end = "2016-12-31",
  plot.start = "2017-06-06",
  plot.end = "2017-06-15",
  legend.title = "T C",
  min.depth = 0,
  max.depth = 13,
  by.value = 0.5,
  nlevels = 20,
  plot.save = TRUE,
  height = 5,
  width = 8,
  ppi = 150
)

Arguments

sim

a matrix of simulated variables that have been interpolated

obs

observed values of variable.

file_name

the file path to save the generated contour figure.

sim.start, sim.end

the start and end of the simulation period for the DYRESM-CAEDYM model run of interest. The date format must be "%Y-%m-%d".

plot.start, plot.end

the start and end of the plot period, in the format of "%Y-%m-%d"

legend.title

the legend title of the contour figure.

min.depth, max.depth, by.value

minimum and maximum depth used to be the start of y axis of the contour plot, at the increment of by.value.

nlevels

a set of levels which are used to partition the range of simulation variable.

plot.save

if TRUE, the plot is saved with the "height","width", and "ppi" parameters.

height, width

the relative height/width of the figure.

ppi

the ppi value of the figure.

Value

a graph file of contour plot saved in the Figure folder.

Examples

Run this code
# NOT RUN {
# extract simulated temperature values from DYRESM-CAEDYM simulation file
 var.values<-ext.output(dycd.output=system.file("extdata", "dysim.nc", package = "dycdtools"),
                       var.extract=c("TEMP"))

  for(i in 1:length(var.values)){
     expres<-paste0(names(var.values)[i],"<-data.frame(var.values[[",i,"]])")
     eval(parse(text=expres))
  }

# interpolate temperature for depths from 0 to 13 m at increment of 0.5 m
  temp.interpolated<-interpol(layerHeights = dyresmLAYER_HTS_Var,
                             var = dyresmTEMPTURE_Var,
                             min.dept = 0,max.dept = 13,by.value = 0.5)

  data(obs_temp)
# contour plot of temperature simulations with observed data shown as colour-coded dots
  plot_cont_comp(sim=temp.interpolated,
                 obs=obs_temp,
                 sim.start = "2017-06-06",
                 sim.end = "2017-06-15",
                 plot.start="2017-06-06",
                 plot.end="2017-06-15",
                 legend.title="T \u00B0C",
                 min.depth=0,max.depth=13,by.value=0.5,
                 nlevels=20,
                 plot.save=FALSE,
                 file_name="Contour_temp.png",
                 height=5,width=8,ppi=150)

# }

Run the code above in your browser using DataLab