Skip to contents

Modify data in a T-NET NetCDF file

Usage

TNET_modifyData(
  filename,
  expression,
  rename_oldfile = NULL,
  rename_newfile = NULL
)

Arguments

filename

Path to the NetCDF file to modify

expression

Expression to use to modify the data. Expression can have numbers, computing caracters ( "+", "-", "*", "/", "(" and ")") and variable names contains in the file.

rename_oldfile

Rename the used file after the modification

rename_newfile

Specify the name of the created file.

Examples


#Exemple 1
TNET_modifyData(filename = "path/to/Qaval.nc",
                expression = "Qaval * 2")
#> Warning: cannot rename file 'path/to/Qaval.nc' to 'path/to/Qaval.nc', reason 'No such file or directory'
#> Error in R_nc4_open: No such file or directory
#> Error in nc_open(nc_file): Error in nc_open trying to open file path/to/Qaval.nc (return_on_error= FALSE )
# -> Create a file "Qaval_new.nc" in the same directory with data multiplyed by 2

#Exemple 2
TNET_modifyData(filename = "path/to/Qaval.nc",
                expression = "Qaval * 1.2",
                rename_oldfile = "Qaval_ref.nc")
#> Warning: cannot rename file 'path/to/Qaval.nc' to 'path/to/Qaval_ref.nc', reason 'No such file or directory'
#> Error in R_nc4_open: No such file or directory
#> Error in nc_open(nc_file): Error in nc_open trying to open file path/to/Qaval_ref.nc (return_on_error= FALSE )
# -> Rename Qaval.nc => Qaval_ref.nc and create a new Qaval.nc file with data increased by 20%

#Exemple 3
TNET_modifyData(filename = "path/to/Qaval.nc",
                expression = "Qaval + 10",
                rename_oldfile = "Qaval_ref.nc",
                rename_newfile = "Qaval_plus10.nc")
#> Warning: cannot rename file 'path/to/Qaval.nc' to 'path/to/Qaval_ref.nc', reason 'No such file or directory'
#> Error in R_nc4_open: No such file or directory
#> Error in nc_open(nc_file): Error in nc_open trying to open file path/to/Qaval_ref.nc (return_on_error= FALSE )
# -> Rename Qaval.nc => Qaval_ref.nc and create a new Qaval_plus10.nc file with 10 added to the data.