io.netcdf
io.netcdf
NetCDF input and output for the preprocessing of the SEAS5 / DCSM-5 model data.
ncvar_getandnc_dim_timeread the model output as R’s ncdf4 does (ncvar_get, nc\(dim\)time).write_ncandread_ncstore the preprocessed series. Python cannot write R lists to .RData, so the Python preprocessing writes netCDF files with the same variable names as the .RData files of the R scripts. Times are stored as seconds since 1970-01-01 UTC (R’s POSIXct).
Attributes
| Name | Description |
|---|---|
| EPOCH_UNITS |
Functions
| Name | Description |
|---|---|
| nc_dim_time | Times of dimension name as seconds since 1970-01-01 UTC (R: ymd_hm(…) + dminutes(vals)). |
| nc_dim_vals | nc\(dim\) |
| ncvar_get | ncdf4::ncvar_get(nc, name): values as double, missing values as NaN, scale_factor and |
| read_nc | Read all variables of a file written by write_nc -> {name: 1-D numpy array}. With |
| seconds_to_datetime64 | POSIXct seconds -> datetime64[us] (NaN -> NaT), as pyreadr returns POSIXct. |
| write_nc | Write 1-D series of equal length (and scalars) to a compressed netCDF file. Variables in |
nc_dim_time
io.netcdf.nc_dim_time(ds, name='time')Times of dimension name as seconds since 1970-01-01 UTC (R: ymd_hm(…) + dminutes(vals)). Returns None if the reference time in the units cannot be read (R: off is NA).
nc_dim_vals
io.netcdf.nc_dim_vals(ds, name)nc\(dim\)
ncvar_get
io.netcdf.ncvar_get(ds, name, index=None)ncdf4::ncvar_get(nc, name): values as double, missing values as NaN, scale_factor and add_offset applied (in double, as in R). index maps dimension names to an index, e.g. {“lon”: ilon, “lat”: ilat} for ncvar_get(…, start = c(ilon, ilat, 1), count = c(1, 1, -1)). Degenerate dimensions are dropped (R: collapse_degen = TRUE).
read_nc
io.netcdf.read_nc(path, decode_times=True)Read all variables of a file written by write_nc -> {name: 1-D numpy array}. With decode_times, time variables are returned as datetime64[us] (as pyreadr returns POSIXct).
seconds_to_datetime64
io.netcdf.seconds_to_datetime64(t)POSIXct seconds -> datetime64[us] (NaN -> NaT), as pyreadr returns POSIXct.
write_nc
io.netcdf.write_nc(path, data, time_vars=(), dim='index', attrs=None)Write 1-D series of equal length (and scalars) to a compressed netCDF file. Variables in time_vars are POSIXct seconds and get the units ‘seconds since 1970-01-01 00:00:00’.