pysiral.mask

All about mask files

Created on Thu Sep 28 14:00:52 2017

@author: shendric

Classes

MaskSourceBase

Parent class for various source masks. Main functionality is to

MaskLandSea2Min

A land/sea mask based on a binary file on a 2 minute grid.

MaskW99Valid

A valid mask for the Warren climatology

L3Mask

Container for Level-3 mask compliant netCDF files

L1PHighResolutionLandMask

Level-1 processor item providing access to a high resolution

Functions

MaskSourceFile(mask_name, mask_cfg)

Wrapper method for different mask source file classes

Module Contents

pysiral.mask.MaskSourceFile(mask_name, mask_cfg)

Wrapper method for different mask source file classes

class pysiral.mask.MaskSourceBase(mask_dir, mask_name, cfg)

Bases: pysiral.core.legacy_classes.DefaultLoggingClass

Parent class for various source masks. Main functionality is to create gridded mask netCDF for level-3 grid definitions

_cfg
_mask_dir
_mask_name
_mask = None
_area_def = None
_post_flipud = False
set_mask(mask, area_def)

Set grid definition for the mask source grid using pyresample. The argument area_def needs to have the attributes needed as arguments for pyresample.geometry.AreaDefinition or be of the pyresampe types (geometry.AreaDefinition, geometry.GridDefinition)

export_l3_mask(griddef, nc_filepath=None)

Create a gridded mask product in pysiral compliant filenaming. The argument griddef is needs to be a pysiral.grid.GridDefinition instance

_write_netcdf(nc_filepath, griddef, mask)

Write a netCDF file with the mask in the target grid projections

property cfg
property mask_name
property mask_dir
property source_mask
property source_area_def
class pysiral.mask.MaskLandSea2Min(mask_dir, mask_name, cfg)

Bases: MaskSourceBase

A land/sea mask based on a binary file on a 2 minute grid. Content of orignial mask: (0: sea, 1: lakes, 2: land ice: 3: land) There seems to be a few issues with the land ice mask in some places, therefore we limit the mask to 0: sea, 1: mixed, 2: non-sea (land)

construct_source_mask()

Read the binary file and set the mask

static pp_classify(resampled_mask, *args)

Post-processing method after resampling to target grid The resampled mask contains a land fraction (datatype float), which needs to be simplified to the flags (0: ocean, 1: mixed, 2: land)

property mask_filepath
class pysiral.mask.MaskW99Valid(mask_dir, mask_name, cfg)

Bases: MaskSourceBase

A valid mask for the Warren climatology

static pp_limit_lat(resampled_mask, griddef)

There are some artefacts in the source mask that need to be filtered out based on a simple latitude threshold filter. We also set all NaN values to 0 and fix a small problem at the north pole

property mask_filepath
class pysiral.mask.L3Mask(mask_name, grid_id, flipud=False)

Bases: pysiral.core.legacy_classes.DefaultLoggingClass

Container for Level-3 mask compliant netCDF files (see output of pysiral.mask.MaskSourceBase.export_l3_mask)

error
_mask_name
_grid_id
_flipud = False
_read_mask_netcdf()

Read the mask

property mask
property lat
property lon
property mask_name
property grid_id
property mask_filepath
class pysiral.mask.L1PHighResolutionLandMask(**cfg)

Bases: pysiral.l1preproc.procitems.L1PProcItem

Level-1 processor item providing access to a high resolution land mask and distance to land fields

apply(l1: pysiral.l1data.Level1bData) None

Extract land/ocean flag and distance to coast along the l1p trajectory if a mask exists for the corresponding hemisphere of the l1p data object.

The parameters are stored in the classifier data group among the original surface type value, which is then update for the mask coverage

Parameters:

l1

Returns:

None

get_trajectory(longitude: numpy.typing.NDArray, latitude: numpy.typing.NDArray) Tuple[numpy.typing.NDArray, numpy.typing.NDArray]

Get extract of the land/ocean flag and the distance to coast value for an array of (longitude, latitude) positions.

If longitude, latitude is outside the grid, a pre-defined dummy value will be returned.

Parameters:
  • longitude – Longitude values in degrees

  • latitude – latitude values in degrees

Raises:

None

Returns:

land ocean flag & distance to coast values for longitude, latitude positions