fre.app.mask_atmos_plevel.mask_atmos_plevel module
functionality and routines associated with masking pressure level data fre app mask-atmos-plevel
- fre.app.mask_atmos_plevel.mask_atmos_plevel.mask_atmos_plevel_subtool(infile: str = None, psfile: str = None, outfile: str = None, warn_no_ps: bool = False) None
Mask pressure-level diagnostic output below land surface. One of two possible triggers for applying a pressure mask to the data must pass.
The first trigger is input variables must have a string-valued attribute pressure_mask that is a case-insensitive match for false, implying the data has not yet had a pressure mask applied. The data will then be masked, and the pressure_mask attribute set to true. if false does not match, the variable is skipped for processing.
The second trigger is only checked in the absence of a pressure_mask attribute, i.e. the first trigger takes precedence over the second. If the variable name ends in _unmsk, the data is assumed to be unmasked, a copy of the dataset variable is created without _unmsk in the name, the data is masked, and the pressure_mask attribute is added accordingly.
- Parameters:
infile (str) – Input NetCDF file containing pressure-level output to be masked
psfile (str) – Input NetCDF file containing surface pressure ‘ps’
outfile (str) – Output NetCDF file containing masked output
- Raises:
ValueError – Pressure input file does not contain ps
FileNotFound – Input file does not exist
- Return type:
None
- fre.app.mask_atmos_plevel.mask_atmos_plevel.mask_field_above_surface_pressure(ds: xarray.Dataset, var: str, ds_ps: xarray.Dataset) xarray.Dataset
Mask data with pressure greater than surface pressure. Requires the target variable’s encoding for ‘missing_value’
- Parameters:
ds – Input dataset to be masked
var (str) – Input variable to be masked
- Returns:
Output masked dataset
- Return type:
xarray.Dataset
Note
Missing values are set to 1.0e20.
Error
if the missing_value key does not exist within the variable’s encoding.
- fre.app.mask_atmos_plevel.mask_atmos_plevel.pressure_coordinate(ds: xarray.Dataset, varname: str) xarray.DataArray
Return the pressure coordinate of the Dataset or None if the Dataset does not have a pressure coordinate. A coordinate is deemed a pressure coordinate if long_name attribute is ‘pressure’, or if a variable with units of pressure is described as a z-axis with an attribute named ‘positive’. The first variable looped over found to match these criteria are returned.
- Parameters:
ds (xarray.Dataset) – Input dataset to inspect
var (str) – Input variable name to inspect
- Returns:
Pressure coordinate variable
- Return type:
xarray.DataArray
Warning
Returns None if no pressure coordinate variable can be found
- fre.app.mask_atmos_plevel.mask_atmos_plevel.write_dataset(ds: xarray.Dataset, template: xarray.Dataset, outfile: str) None
Prepare the dataset and write NetCDF file
- Parameters:
ds – Input dataset to write to disk
template (xarray.Dataset) – Remainder dataset to also write to disk
- Return type:
None