opendrift.readers.reader_ROMS_native

Attributes

logger

Classes

Reader

A reader for ROMS Output files. It can take a single file, a file pattern, a URL or an xarray Dataset.

Functions

rotate_vectors_angle(u, v, radians)

Module Contents

opendrift.readers.reader_ROMS_native.logger
class opendrift.readers.reader_ROMS_native.Reader(filename=None, name=None, gridfile=None, standard_name_mapping={}, save_interpolator=False, interpolator_filename=None)[source]

Bases: opendrift.readers.basereader.BaseReader, opendrift.readers.basereader.StructuredReader

A reader for ROMS Output 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 save_interpolator:

Whether or not to save the interpolator that goes from lon/lat to x/y (calculated in structured.py)

type save_interpolator:

bool

param interpolator_filename:

If save_interpolator is True, user can input this string to control where interpolator is saved.

type interpolator_filename:

Path, str, optional

Example:

from opendrift.readers.reader_ROMS_native import Reader
r = Reader("roms.nc")

Several files can be specified by using a pattern:

from opendrift.readers.reader_ROMS_native import Reader
r = Reader("*.nc")

An OPeNDAP URL can be used:

from opendrift.readers.reader_ROMS_native import Reader
r = Reader('https://thredds.met.no/thredds/dodsC/mepslatest/meps_lagged_6_h_latest_2_5km_latest.nc')

A xr.Dataset can be used:

from opendrift.readers.reader_ROMS_native import Reader
ds = xr.open_dataset(filename, decode_times=False)
r = Reader(ds)

Common constructor for all readers

_mask_rho = None
_mask_u = None
_mask_v = None
_zeta = None
_angle = None
land_binary_mask = None
sea_floor_depth_below_sea_level = None
z_rho_tot = None
s2z_A = None
ROMS_variable_mapping
zlevels
name
save_interpolator
interpolator_filename
Vtransform
times

Setting this to True overrides temporal and spatial bounds checks. Also useful for readers that are constant and do not have a temporal dimension.

start_time
end_time
precalculate_s2z_coefficients = True
standard_name_mapping
do_not_rotate = []
variables
property mask_rho

Mask for the rho-points.

Uses wetdry_mask_rho (which should be 3D) if available, otherwise mask_rho (2D). If this mask is 2D, read it in this one time and use going forward in simulation. If 3D, will read in parts of the mask each loop.

property mask_u

Mask for the u-points.

Uses wetdry_mask_u (which should be 3D) if available, otherwise mask_u (2D). If this mask is 2D, read it in this one time and use going forward in simulation. If 3D, will read in parts of the mask each loop.

property mask_v

Mask for the v-points.

Uses wetdry_mask_v (which should be 3D) if available, otherwise mask_v (2D). If this mask is 2D, read it in this one time and use going forward in simulation. If 3D, will read in parts of the mask each loop.

property zeta

Sea surface height.

property angle

Grid angle if curvilinear.

get_variables(requested_variables, time=None, x=None, y=None, z=None, testing=False)[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.

opendrift.readers.reader_ROMS_native.rotate_vectors_angle(u, v, radians)[source]