pysiral.auxdata.region

Important Note:

All region data handlers must be subclasses of pysiral.auxdata.AuxdataBaseClass in order to work for the Level-2 Processor. If the auxiliary class is based on a static dataset, this should be parsed in __init__.

Please review the variables and properties in the parent class, as well as the corresponding config and support classes for grid track interpolation in the pysiral.auxdata module for additional guidance.

The only other hard requirements is the presence of on specific method in order to be a valid subclass of AuxdataBaseClass:

get_l2_track_vars(l2)

This method will be called during the Level-2 processor. The argument is the Level-2 data object and the purpose of the method is to compute the auxilary variable(s) and associated uncertainty. These variable need to be registered using the register_auxvar(id, name, value, uncertainty) method of the base class. All MSS subclasses need to register at minimum the following variable:

region code (integer):

id: reg_code name: region_code

e.g., this code line is mandatory for get_l2_track_vars (uncertainty is None):

# Register Variables self.register_auxvar(“reg_code”, “region_code”, value, None)

Classes

NSIDCRegionMask

Provides region codes from NSIDC style region grids

NSIDCRegionMask2021

Provides region codes from NSIDC regions grids in version 2021

AntarcticSeas

Provides region codes for the southern hemisphere only based on longitude ranges

Module Contents

class pysiral.auxdata.region.NSIDCRegionMask(*args: Any | None, **kwargs: Any | None)

Bases: pysiral.auxdata.AuxdataBaseClass

Provides region codes from NSIDC style region grids

nc
get_l2_track_vars(l2: Level2Data) None

API method to map gridded region id on the trajectory :param l2: :return:

class pysiral.auxdata.region.NSIDCRegionMask2021(*args: Any | None, **kwargs: Any | None)

Bases: pysiral.auxdata.AuxdataBaseClass

Provides region codes from NSIDC regions grids in version 2021

filepath
nc
attr_dict: Dict
grid_def: Dict
get_l2_track_vars(l2: Level2Data) None

API method to map gridded region id on the trajectory :param l2: :return:

get_trajectory(longitude: numpy.ndarray, latitude: numpy.ndarray) numpy.ndarray

Extract the region code along a trajectory defined by longitude & latitude.

Parameters:
  • longitude – Longitude of the trajectory points

  • latitude – Latitude of the trajectory points

Raises:

None

Returns:

The region code extracted along the trajectory

_get_filepath_from_config() pathlib.Path

Get the full file path from the options dictionary

Returns:

Full path to the mask file

_extract_grid_information() Dict

Extract the grid definition from the netCDF file.

Example for a grid definition dictionary

projection:

proj: stere lon_0: -45 lat_0: 90 lat_ts: 70 a: 6378273 b: 6356889.44891

dimension:

n_cols: 304 n_lines: 448 dx: 25000 dy: 25000

Returns:

grid definition dictionary

_extract_grid_attributes() Dict

Extract the attributes for the region id variable from the netCDF file

Returns:

grid variable attribute dictionary

class pysiral.auxdata.region.AntarcticSeas(*args: Any | None, **kwargs: Any | None)

Bases: pysiral.auxdata.AuxdataBaseClass

Provides region codes for the southern hemisphere only based on longitude ranges from Antarctic Seas (source: Stefanie Arndt, AWI, pers comm).

get_l2_track_vars(l2: Level2Data) None

API method, will return the region cose based on longitude and latitude values. The location of the sea, the corresponding code and names are defined in the auxiliary data catalog auxdata_def.yaml in the pysiral resources directory.

The expected structure of the options is:

options:

ice_free_ocean_code: 1 region_def:

# To be read as: [region code, region label, lon_min, lon_max, lat_limit] - [1, “Indian Ocean”, 20.0, 90.0, -50.] - …

Parameters:

l2

Returns:

static get_angular_distance(lon1: float | int | numpy.array, lon2: float | int | numpy.array) float | int | numpy.array

Return the angular distance between two longitude values that follow come in units of degrees east and degrees west :param lon1: :param lon2: :return: angular distance