Skip to contents

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

TNETresult_compare(
  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 and date_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.

add_data

vector of strings. list of file readable by TNETresult_read(). The mean of the data in the file will be added to the results

folder_shapefile

Path to the folder where the shapefile used for the TNET calculation of both NetCDF_reference and NetCDF_toCompare. If NULL, the argument simulation_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()

Value

Shapefile if export_file = NULL

Details

The calculations are the following:

  • If date is set, date_start = date and date_end = date + hours(23)

  • Open both shapefiles used by T-NET to create NetCDF_reference and NetCDF_toCompare. Select columns set in column_keep

  • Reading data of NetCDF_reference and NetCDF_toCompare on all IDs between date_start and date_end using TNETresult_read().

  • 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 in TNET_modifyVeget(filename = infoSimu$shapeName, density = +30): could not find function "TNET_modifyVeget"

# 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)
TNETresult_compare(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)
TNETresult_compare(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