Satellite module

This module handles netCDF file operations. Functions are not to be used directly, except geoenrich.exports.dump_metadata().

Main functions

geoenrich.satellite.dump_metadata(var_id, out_path=PosixPath('.'))

Dump metadata related to the given variable.

Parameters:
  • var_id (str) – ID of the variable to retrieve metadata for.

  • out_path (str or pathlib.Path) – Path where metadata file will be saved.

Returns:

None

Other functions (for internal use)

geoenrich.satellite.create_nc(var)

Create empty netcdf file for requested variable for subsequent local storage. Same dimensions as the online dataset.

Parameters:

var (dict) – Variable dictionary, as returned by geoenrich.satellite.get_var_catalog().

Returns:

None

geoenrich.satellite.create_nc_calculated(var_id)

Create empty netcdf file for requested variable for subsequent local storage. Same dimensions as the online dataset.

Parameters:

var_id (str) – ID of the variable to calculate.

Returns:

None

geoenrich.satellite.ellipsoid_mask(data, coords, center, geo_buff)

Calculate ellipsoid mask for the given point and data array.

Parameters:
Returns:

Mask.

Return type:

numpy.array

geoenrich.satellite.get_metadata(ds, varname)

Download and format useful metadata on dimensions and variables. Generate a dictionary where dimensions can be accessed both with their original name and their standard name (if available).

Parameters:
  • ds (netCDF4.Dataset) – Dataset of interest.

  • varname (str) – Name of the variable of interest in the dataset.

Returns:

dictionary with standardized information on dimensions, dictionary with information on the variable.

Return type:

dict, dict

geoenrich.satellite.get_var_catalog()

Return available variables, with dataset attributes. catalog.csv can be edited to add additional variables.

Parameters:

None

Returns:

Dictionary with variable id, variable name in dataset, and dataset url

Return type:

dict

geoenrich.satellite.insert_multidimensional_slice(nc_dataset, varname, data, ind, lons, lon_pos)

Insert a slice into a local dataset.

Parameters:
  • nc_dataset (netCDF4.Dataset) – Dataset to query.

  • varname (str) – Variable name in the dataset.

  • data (numpy.array) – Data to insert.

  • ind (dict list) – List with ordered slicing indices for all dimensions.

  • lons (list) – Longitude values.

  • lon_pos (int) – Position of longitude in the dataset’s dimensions.

Returns:

None

geoenrich.satellite.multidimensional_slice(nc_dataset, varname, ind, lons, lon_pos)

Return a slice from a dataset (can be local or remote).

Parameters:
  • nc_dataset (netCDF4.Dataset) – Dataset to query.

  • varname (str) – Variable name in the dataset.

  • ind (dict) – Dictionary with ordered slicing indices for all dimensions.

  • lons (list) – Longitude values.

  • lon_pos (int) – Position of longitude in the dataset’s dimensions.

Returns:

Requested data.

Return type:

numpy.ma.MaskedArray

class geoenrich.satellite.NpEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)

Custom encoder to handle numpy data formats in json dump.