gfdlvitals.util.gmeantools module¶
Generic Suite of Utilities
-
gfdlvitals.util.gmeantools.area_mean(var, cell_area, geolat, geolon, region='global', cell_depth=None)¶ Computes area mean of a variable
- Parameters
var (np.ma.MaskedArray) – Input array
cell_area (np.ma.MaskedArray) – Array of cell areas
geolat (np.ma.MaskedArray) – Array of latitude coordinates
geolon (np.ma.MaskedArray) – Array of longitude coordinates
region (str, optional) – Region of “global”, “nh”, “sh”, or “tropics”, by default “global”
cell_depth (np.ma.MaskedArray, optional) – Array of cell depths for 4D-data, by default None
- Returns
Scalar area mean of the variable and cell area
- Return type
np.ma.MaskedArray
-
gfdlvitals.util.gmeantools.cube_sphere_aggregate(var, tiles)¶ [summary]
- Parameters
var (str) – Variable name
tiles (netCDF4.Dataset) – Datasets for each cubesphere tile
- Returns
Concatenated array of data across of cubesphere faces
- Return type
np.ma.MaskedArray
-
gfdlvitals.util.gmeantools.extract_metadata(dset, varname, attr)¶ Obtain a specific variable attribute
- Parameters
dset (netCDF4.Dataset) – Input NetCDF dataset
varname (str) – Variable name
attr (str) – Requested attribute
- Returns
Variable attribute string
- Return type
str
-
gfdlvitals.util.gmeantools.get_web_vars_dict()¶ Returns dictionary of legacy LM3 variables
- Returns
LM3 variable module mappings and metadata
- Return type
dict
-
gfdlvitals.util.gmeantools.legacy_area_mean(var, cell_area, geolat, geolon, cell_frac=None, soil_frac=None, region='global', varname=None, cell_depth=None, component=None)¶ Legacy version of area mean calculation
- Parameters
var (np.ma.MaskedArray) – Input array
cell_area (np.ma.MaskedArray) – Array of cell areas
geolat (np.ma.MaskedArray) – Array of latitude coordinates
geolon (np.ma.MaskedArray) – Array of longitude coordinates
cell_frac (np.ma.MaskedArray, optional) – Array of land cell fraction per grid cell, by default None
soil_frac (np.ma.MaskedArray, optional) – Array of soil fraction per grid cell, by default None
region (str, optional) – Region of “global”, “nh”, “sh”, or “tropics”, by default “global”
varname (str, optional) – Variable name, by default None
cell_depth (np.ma.MaskedArray, optional) – Array of cell depths for 4D-data, by default None
component (str, optional) – Model component, by default None
- Returns
Scalar area mean of the variable and cell area
- Return type
np.ma.MaskedArray
-
gfdlvitals.util.gmeantools.mask_latitude_bands(var, cell_area, geolat, region='global')¶ Masks a variable and associated cell area based on region
- Parameters
var (np.ma.MaskedArray) – Input array
cell_area (np.ma.MaskedArray) – Array of cell areas
geolat (np.ma.MaskedArray) – Array of latitude coordinates
region (str, optional) – Region of “global”, “nh”, “sh”, or “tropics”, by default “global”
- Returns
var, cell_area masked by region
- Return type
np.ma.MaskedArray
- Raises
ValueError – Unknown region specified
-
gfdlvitals.util.gmeantools.parse_cell_measures(attr, key)¶ Parse cell measures attribute
- Parameters
attr (str) – Cell measurues attribute string
key (str) – Variable name key
- Returns
Returns truncated cell measures string
- Return type
str
-
gfdlvitals.util.gmeantools.write_metadata(sqlfile, varname, attr, value)¶ Writes dataset metadata to sqlite file
- Parameters
sqlfile (str, path-like) – Path to output sqlite file
varname (str) – Variable name
attr (str) – Attribute name
value (str) – Attribute string
-
gfdlvitals.util.gmeantools.write_sqlite_data(sqlfile, varname, fyear, varmean=None, varsum=None, component=None)¶ Writes data to sqlite file
- Parameters
sqlfile (str, path-like) – Path to output sqlite file
varname (str) – Variable name
fyear (str) – Year being processed
varmean (float, optional) – Mean of the data, by default None
varsum (float, optional) – Sum of variable of the data, by default None
component (str, optional) – Model component, by default None