opendrift.readers.reader_netCDF_CF_generic

Module Contents

Classes

Reader

A reader for CF-compliant netCDF files. It can take a single file, or a file pattern.

Functions

proj_from_CF_dict(c)

Attributes

logger

opendrift.readers.reader_netCDF_CF_generic.logger
opendrift.readers.reader_netCDF_CF_generic.proj_from_CF_dict(c)[source]
class opendrift.readers.reader_netCDF_CF_generic.Reader(filename=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, or a file pattern.

Args:
param filename:

A single netCDF file, or a pattern of files. The netCDF file can also be an URL to an OPeNDAP server.

type filename:

string, requiered.

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")

or 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')

Common constructor for all readers

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.