opendrift.readers.reader_netCDF_CF_generic
Attributes
Classes
A reader for CF-compliant netCDF files. It can take a single file, a file pattern, a URL or an xarray Dataset. |
Module Contents
- opendrift.readers.reader_netCDF_CF_generic.logger
- class opendrift.readers.reader_netCDF_CF_generic.Reader(filename=None, zarr_storage_options=None, name=None, proj4=None, standard_name_mapping={}, ensemble_member=None)[source]
Bases:
opendrift.readers.basereader.StructuredReader
,opendrift.readers.basereader.BaseReader
A reader for CF-compliant netCDF files. It can take a single file, a file pattern, a URL or an xarray Dataset.
- Args:
- param filename:
A single netCDF file, a pattern of files, or a xr.Dataset. The netCDF file can also be an URL to an OPeNDAP server.
- type filename:
string, xr.Dataset (required).
- param name:
Name of reader
- type name:
string, optional
- param proj4:
PROJ.4 string describing projection of data.
- type proj4:
string, optional
Example:
from opendrift.readers.reader_netCDF_CF_generic import Reader r = Reader("arome_subset_16Nov2015.nc")
Several files can be specified by using a pattern:
from opendrift.readers.reader_netCDF_CF_generic import Reader r = Reader("*.nc")
An OPeNDAP URL can be used:
from opendrift.readers.reader_netCDF_CF_generic import Reader r = Reader('https://thredds.met.no/thredds/dodsC/mepslatest/meps_lagged_6_h_latest_2_5km_latest.nc')
A xr.Dataset or a zarr dataset in an object store with auth can be used:
from opendrift.readers.reader_netCDF_CF_generic import Reader r = Reader(ds, zarr_storage_options)
Common constructor for all readers
- unitfactor = 1
- realizations = None
- ensemble_dimension = None
- dimensions
- variable_mapping
- variables
- get_variables(requested_variables, time=None, x=None, y=None, z=None, indrealization=None)[source]
Obtain a _block_ of values of the requested variables at all positions (x, y, z) closest to given time. These will be stored in
opendrift.readers.interpolation.structured.ReaderBlock
and accessed from there.- Arguments:
variables: list of variables.
time: datetime or None, time at which data are requested.
x, y: float or ndarrays; coordinates of requested points.
z: float or ndarray; vertical position (in meters, positive up)
- Returns:
Dictionary
keywords: variables (string) values: 2D ndarray bounding x and y.