Compare 2 NetCDF files created by T-NET on a periode of time
Source:R/TNET_compareResult.R
TNET_compareResult.Rd
This function will compare 2 NetCDF with the same variable created by 2 runs of TNET in order to put in evidence the difference between the 2 files in a shapefile
All shapefiles used to run T-NET will be read, so be sure to keep them
Usage
TNET_compareResult(
NetCDF_reference,
NetCDF_toCompare,
export_file = NULL,
date = NULL,
date.start = NULL,
date.end = NULL,
add_data = NULL,
folder_shapefile = NULL,
column.keep = NULL
)
Arguments
- NetCDF_reference
Path to a NetCDF file created by TNET to used as a reference
- NetCDF_toCompare
Path to a NetCDF file created by TNET to compare
- export_file
Path to the shapefile to create with results
- date
string or POSIXct. Date where the comparison will take place (24 hours are taken). if
NULL
,date.start
anddate.end
must be set.- date.start
string or POSIXct. Date where the comparison will will start. If
NULL
,date
must be set.- date.end
string or POSIXct. Date where the comparison will end. if
NULL
,date
must be set.- folder_shapefile
Path to the folder where the shapefile used for the TNET calculation of both
NetCDF_reference
andNetCDF_toCompare
. IfNULL
, the argumentsimulation_path_shapeDirectory
created by TNET in each NetCDF file is used.- column.keep
Column in both shapefile to be kept. If values in both shapefiles are différentes, a column "diff" is created with the value \(diff = toCompare - reference\). To see all possible columns name, see
TNET_createShape()
Details
The calculations are the following:
If
date
is set,date.start = date
anddate.end = date + hours(23)
Open both shapefiles used by T-NET to create
NetCDF_reference
andNetCDF_toCompare
. Select columns set incolumn.keep
Reading data of
NetCDF_reference
andNetCDF_toCompare
on all IDs betweendate.start
anddate.end
usingTNET_readResults()
.Calculate mean value for each IDs for both data
Calculate \(diff = toCompare - reference\).
Save shapefile.
Examples
## Exemple: Compair 2 ripisylve density scenarios ##
#Create simulation
infoSimu <- TNET_initializeSim(...)
#> Error: '...' used in an incorrect context
#Create Shapefile
TNET_createShape(...)
#> Error: '...' used in an incorrect context
#Run TNET
TNET_run(infoSimu,
...)
#> Error: '...' used in an incorrect context
# --> Be careful to rename the file created by T-NET, or it will be
# erased at the next run of TNET: here the new name is Tw_NFS_VEG_ref.nc
#Change the vegetation density
infoSimu$shapeName <- TNET_modifyVeget(filename = infoSimu$shapeName,
density = +30)
#> Error: object 'infoSimu' not found
# Re-run TNET
TNET_run(infoSimu,
...)
#> Error: '...' used in an incorrect context
# --> Here the file name is set at Tw_NFS_VEG_Density_+30.nc
#Compare both files on a day (between 2018-08-01 00:00 to 2018-08-01 23:00)
TNET_compareResult(NetCDF_reference = file.path(infoSimu$TNET_result_Path,"Tw_NFS_VEG_ref.nc"),
NetCDF_toCompare = file.path(infoSimu$TNET_result_Path,"Tw_NFS_VEG_Density_+30.nc"),
date = "2018-08-01",
column.keep = c("OSTRAHL", "vegPctL", "vegPctR"))
#> Error: object 'infoSimu' not found
#Compare both files on a month (between 2018-08-01 00:00 to 2018-09-11 00:00)
TNET_compareResult(NetCDF_reference = file.path(infoSimu$TNET_result_Path,"Tw_NFS_VEG_ref.nc"),
NetCDF_toCompare = file.path(infoSimu$TNET_result_Path,"Tw_NFS_VEG_Density_+30.nc"),
date.start = "2018-08-01",
date.end = "2018-09-01")
#> Error: object 'infoSimu' not found