NEDAS.models.noresm package

Submodules

NEDAS.models.noresm.proj module

NEDAS.models.noresm.proj.lonlat2sxy(lon, lat)

convert lon,lat to stereographic plane x,y

NEDAS.models.noresm.proj.sxy2lonlat(sx, sy)

convert stereographic plane x,y to lon,lat

NEDAS.models.noresm.proj.spherdist(lon1, lat1, lon2, lat2)

Calculate distance between (lon1,lat1) and (lon2,lat2)

This function treats the Earth as a perfect sphere, it is not as accurate as pyproj.Geod.inv which takes the ellipse into account. But for the purpose of searching for positions in the domain, this function is accurate enough and faster.

Inputs: lon1, lat1, lon2, lat2: float, degrees Output: dist: float, meters

NEDAS.models.noresm.proj.tri_area(a, b, c)

compute triangle area given edge lengths

NEDAS.models.noresm.proj.pivotp(glon, glat, neighbors, lon, lat, ipiv=0, jpiv=0)

in model glon,glat, find the pivot point for lon,lat

NEDAS.models.noresm.proj.find_grid_index(glon, glat, gx, gy, neighbors, lon, lat, ipiv, jpiv)

convert a point lon,lat to grid space x,y

NEDAS.models.noresm.proj.lonlat2xy(glon, glat, gx, gy, neighbors, lon, lat)[source]

convert from lon,lat to grid space index x,y

NEDAS.models.noresm.proj.xy2lonlat(glon, glat, gx, gy, neighbors, x, y)[source]

convert from grid space index x,y to lon,lat

Module contents

class NEDAS.models.noresm.NorESM(context: Context | None = None, io_mode: Literal['online', 'offline'] | None = None, config_file: str | None = None, parse_args: bool = False, **kwargs)[source]

Bases: Model

NEDAS.models.noresm.filename(path, **kwargs)[source]

Parse kwargs and find matching filename for keys in kwargs that are not set, here we define the default values key values in kwargs will also be checked for erroneous values

NEDAS.models.noresm.grid_info(grid_file: str, grid_type: str, scale_x: float = 1.0, scale_y: float = 1.0, stagger: str = 'p')[source]

Fetch grid info from a given grid_file, or generate from locally stored data.

Parameters:
  • grid_file (str) – The path to the grid.nc file containing plat,plon…

  • grid_type (str) – Type of grid, ‘bipolar’ or ‘tripolar’.

  • scale_x (float) – Resolution scaling in x direction.

  • scale_y (float) – Resolution scaling in y direction.

  • stagger (str) – Staggering type, ‘p’, ‘u’, ‘v’, or ‘q’.

Returns:

A tuple containing:
  • lon (np.ndarray): Longitude defined on the grid points, of shape (ny, nx).

  • lat (np.ndarray): Latitude defined on the grid points

  • x (np.ndarray): X-coordinates of the grid points.

  • y (np.ndarray): Y-coordinates of the grid points.

  • neighbor (np.ndarray): Neighbor indices of shape (2, 4, ny, nx).

    For each point (j, i) in (ny,nx), grid_neighbors[0,:,j,i] are the j-indices for the 4 neighbors (east, north, west and south) to point (j, i) and grid_neighbors[1,:,j,i] are the corresponding i-indices

Return type:

tuple

NEDAS.models.noresm.read_grid(path, **kwargs)[source]

Generate a Grid object for the NorESM model grid

NEDAS.models.noresm.write_grid(path, **kwargs)[source]
NEDAS.models.noresm.read_var(path, grid, **kwargs)[source]
NEDAS.models.noresm.write_var()[source]