pylag.roms_data_reader module

Data reader for input data generated by ROMS

Note

roms_data_reader is implemented in Cython. Only a small portion of the API is exposed in Python with accompanying documentation. However, more details can be found in pylag.data_reader, where a set of python wrappers have been implemented.

class pylag.roms_data_reader.ROMSDataReader(config, mediator)

Bases: DataReader

DataReader for inputs generated by ROMS

Objects of type ROMSDataReader are intended to manage all access to data objects defined on ROMS’s Arakawa C-grid , including data describing the model grid itself as well as model output variables. Provided are methods for searching the model grid for host horizontal elements and for interpolating gridded field data to a given point in space and time.

On an Arakawa C-grid, u, v, w and rho points are offset. PyLag’s approach to dealing with such grids is to create separate unstructured grids for each of the three different horizontal grids (for u, v and rho points), with the w horizontal grid being the same as the rho grid. With respect to grid boundary crossings, the rho grid is treated as the edge of the model domain.

Parameters
  • config (ConfigParser) – Configuration object.

  • mediator (Mediator) – Mediator object for managing access to data read from file.

compute_depths(self, depth_grid, h, zeta)

Compute depth levels

Compute ROMS depth levels using h and zeta. Supports ROMS vertical coordinate transform option one and two. See ROMS documentation for more details.

Parameters
  • depth_grid (str) – The depth grid. Options are grid_rho or grid_w.

  • h (1D memory view) – Bathymetry at nodes

  • zeta (1D memory view) – Sea surface elevation at nodes

Returns

depth

Return type

2D NumPy NDArray

get_grid_names(self)

Return a list of grid names

Returns

List of grid names on which which input data are defined.

Return type

list [str]

get_xmin(self) DTYPE_FLOAT_t

Get minimum x-value for the domain

Returns

The minimum value of x across the grid.

Return type

float

get_ymin(self) DTYPE_FLOAT_t

Get minimum y-value for the domain

Returns

The minimum value of y across the grid.

Return type

float

read_data(self, DTYPE_FLOAT_t time)

Read in time dependent variable data from file?

time is used to test if new data should be read in from file. If this is the case, arrays containing time-dependent variable data are updated.

Parameters

time (float) – The current time.

rotate_vector(self, u, v, angle)

Rotate a vector field by the given angle

Function adapted from the seapy library (https://github.com/powellb/seapy/blob/master/seapy).

Parameters
  • u (array like) – Input u component

  • v (array like) – Input v component

  • angle (array like) – Input angle of rotation in radians

Returns

rotated_u, rotated_v

Return type

array

setup_data_access(self, start_datetime, end_datetime)

Set up access to time-dependent variables.

Parameters
  • start_datetime (Datetime) – Datetime object corresponding to the simulation start time.

  • end_datetime (Datetime) – Datetime object corresponding to the simulation end time.

u_to_rho(self, u)

Put the u field onto the rho field for the c-grid

Function adapted from the seapy library (https://github.com/powellb/seapy/blob/master/seapy).

Parameters

u (masked array like) – Input u field

Returns

rho

Return type

masked array

v_to_rho(self, v)

Put the v field onto the rho field for the c-grid

Function adapted from the seapy library (https://github.com/powellb/seapy/blob/master/seapy).

Parameters

v (masked array like) – Input v field

Returns

rho

Return type

masked array