Function to read data in NetCDF files created by T-NET. Permits to export only some IDs or some dates
Arguments
- filename
Name to the NetCDF file
- ID
vector of IDs to read. if NULL, all IDs in the file will be read
- date_start
Starting date as POSIXct or character. Every dates in the file before will be ignore. If NULL, first date of the file will be use.
- date_end
Ending date as POSIXct or character. Every dates in the file after will be ignore. If NULL, last date of the file will be use.
- format_long
If TRUE, data will be exported in a data.table with 3 colomns: Dates, ID and value. If FALSE, a data.table with dates for line and ID for colomns will be exported
Examples
filename <- "path/to/ncfile.nc"
#this will read all file
data_read <- TNET_readResults(filename)
#> Error in R_nc4_open: No such file or directory
#> Error in nc_open(filename): Error in nc_open trying to open file path/to/ncfile.nc (return_on_error= FALSE )
#read all dates on only some IDs
ID_toRead = c(152,365,145)
data_read <- TNET_readResults(filename, ID = ID_toRead)
#> Error in R_nc4_open: No such file or directory
#> Error in nc_open(filename): Error in nc_open trying to open file path/to/ncfile.nc (return_on_error= FALSE )
#read all all IDs between 2 dates in long format
data_read <- TNET_readResults(filename, date_start = "2015-08-01", date_end = "2016-07-31", format_long = TRUE)
#> Error in R_nc4_open: No such file or directory
#> Error in nc_open(filename): Error in nc_open trying to open file path/to/ncfile.nc (return_on_error= FALSE )