convert_sim_var: convert an existing simulation variable into a different one

View source: R/convert_sim_var.R

convert_sim_varR Documentation

convert an existing simulation variable into a different one

Description

allows you to provide specific variable or unit conversions to create a new variable that can be used with plot_var_compare, and others.

Usage

convert_sim_var(
  nc_file = "output/output.nc",
  ...,
  unit = "",
  longname = "",
  overwrite = FALSE
)

Arguments

nc_file

the netcdf output file

...

an expression to convert variable based on other variables or offsets

unit

the units for the new variable

longname

the longname for the new variable

overwrite

logical overwrite existing variable data

Examples

## Not run: 
sim_folder <- run_example_sim(verbose = FALSE)
nc_file <- file.path(sim_folder, 'output/output.nc')
convert_sim_var(nc_file, tempF = temp/5*9+32, unit='degF',longname='temperature degrees Farenheit')
plot_var(nc_file, 'tempF')
convert_sim_var(nc_file, crazy_var = temp-u_mean*1000)
plot_var(nc_file, 'crazy_var')

temp2f <- function(c) c/5*9+32
convert_sim_var(nc_file, tempf = temp2f(temp), unit='degF',longname='temperature degrees Farenheit')

## End(Not run)


USGS-R/glmtools documentation built on March 26, 2024, 5:43 p.m.