Skip to contents

Reformats ERA5 .nc data into a data frame.

Usage

netcdf_df_formatter(nc_file_path = NULL)

Arguments

nc_file_path

(character) File path to ERA5 NetCDF file.

Value

(data.frame) Data frame of the following characteristics:

  • Datetime stamp column named "time".

  • UTC timezones converted to local time.

  • SiteID is determined from lat and lon coordinates in df.sitemetadata.

  • Time column formatted as yyyyMMddHHmm, time zone determined using coordinates.

  • Variables names from ERA5 dataset maintained.

  • ERA5 units converted to Ameriflux units:

    • Solar radiation (ssrd) from Jm-2 to Wm-2.

    • Air Temperature (t2m) from Kelvin to Celsius.

    • Total precipitation (tp) from meters to millimeters.

Examples

# Point to a NetCDF file
nc_file_path <- system.file("extdata","data_stream-oper_stepType-accum1.nc", package = "ERA5Flux")
# Reformat the NetCDF
result <- netcdf_df_formatter(nc_file_path)
head(result)
#>           time ssrd
#> 1 201612311900    0
#> 2 201612312000    0
#> 3 201612312100    0
#> 4 201612312200    0
#> 5 201612312300    0
#> 6 201701010000    0