geoips package#

Subpackages#

Submodules#

geoips.cli module#

GeoIPS

The Geolocated Information Processing System (GeoIPS) is a generalized processing system, providing a collection of algorithm and product implementations facilitating consistent and reliable application of specific products across a variety of sensors and data types.

GeoIPS acts as a toolbox for internal GeoIPS-based product development - all modules are expected to have simple inputs and outputs (Python numpy or dask arrays or xarrays, dictionaries, strings, lists), to enable portability and simplified interfacing between modules.

class geoips.cli.RawDescriptionArgumentDefaultsHelpFormatter(prog, indent_increment=2, max_help_position=24, width=None)[source]#

Bases: ArgumentDefaultsHelpFormatter, RawDescriptionHelpFormatter

Compound formatter class for user-readable help.

  • preserves the raw description formatting

  • adds defaults to helps.

geoips.cli.add_list_interface_parser(subparsers, name, aliases=None)[source]#

Add list interface parser.

geoips.cli.formclass#

alias of RawDescriptionArgumentDefaultsHelpFormatter

geoips.cli.get_interface(name)[source]#

Get interface.

geoips.cli.list_dev_interfaces()[source]#

Return a list of all developmental interfaces.

geoips.cli.list_interface_plugins(interface_name)[source]#

List interface plugins.

geoips.cli.list_interfaces(dev=False)[source]#

List interfaces.

geoips.cli.main()[source]#

Command line interface main function.

geoips.cli.print_table(title, headings, rows)[source]#

Print a column formatted table.

Parameters:
  • title (str) – A title for the table

  • headings (list of str) – A list of strings to use as column headings

  • rows (list of tupl of str) – A list of equal-length tuples

geoips.compare_outputs module#

Test script for representative product comparisons.

geoips.compare_outputs.compare_outputs(compare_path, output_products, test_product_func=None)[source]#

Compare the “correct” imagery found the list of current output_products.

Compares files produced in the current processing run with the list of “correct” files contained in “compare_path”.

Parameters:
  • compare_path (str) – Path to directory of “correct” products - filenames must match output_products

  • output_products (list of str) – List of strings of current output products, to compare with products in compare_path

  • test_product_func (function, default=None) –

    Alternative function to be used for testing output product

    • Call signature must be:

      • output_product, compare_product, goodcomps, badcomps, compare_strings

    • Return must be:

      • goodcomps, badcomps, compare_strings

    • If None, use geoips.compare_outputs.test_product)

Returns:

Binary code: 0 if all comparisons were completed successfully.

Return type:

int

geoips.compare_outputs.geoips_netcdf_match(output_product, compare_product)[source]#

Check if two geoips formatted netcdf files match.

Parameters:
  • output_product (str) – Full path to current output product

  • compare_product (str) – Full path to comparison product

Returns:

Return True if products match, False if they differ

Return type:

bool

geoips.compare_outputs.geotiffs_match(output_product, compare_product)[source]#

Use diff system command to compare currently produced image to correct image.

Parameters:
  • output_product (str) – Full path to current output product

  • compare_product (str) – Full path to comparison product

Returns:

Return True if images match, False if they differ

Return type:

bool

geoips.compare_outputs.get_out_diff_fname(compare_product, output_product, ext=None, flag=None)[source]#

Obtain the filename for output and comparison product diff.

Parameters:
  • compare_product (str) – Full path to product filename in the comparison directory

  • output_product (str) – Full path to product filename in the current output directory

  • ext (str, default=None) – Extension to use as an alternative to the original file extension

  • flag (str, default=None) – Additional identifying string to include in output diff filename

Returns:

out_diff_fname – Full path to output diff file.

Return type:

str

geoips.compare_outputs.gunzip_product(fname)[source]#

Gunzip file fname.

Parameters:

fname (str) – File to gunzip.

Returns:

Filename after gunzipping

Return type:

str

geoips.compare_outputs.gzip_product(fname)[source]#

Gzip file fname.

Parameters:

fname (str) – File to gzip.

Returns:

Filename after gzipping

Return type:

str

geoips.compare_outputs.images_match(output_product, compare_product, fuzz='5%')[source]#

Use imagemagick compare system command to compare two images.

Parameters:
  • output_product (str) – Current output product

  • compare_product (str) – Path to comparison product

  • fuzz (str, optional) – “fuzz” argument to pass to compare - larger “fuzz” factor to make comparison less strict, by default 5%.

Returns:

Return True if images match, False if they differ

Return type:

bool

geoips.compare_outputs.is_geoips_netcdf(fname)[source]#

Check if fname is a geoips formatted netcdf file.

Parameters:

fname (str) – Name of file to check.

Returns:

True if it is a geoips netcdf file, False otherwise.

Return type:

bool

geoips.compare_outputs.is_geotiff(fname)[source]#

Determine if fname is a geotiff file.

Parameters:

fname (str) – Name of file to check.

Returns:

True if it is a geotiff file, False otherwise.

Return type:

bool

geoips.compare_outputs.is_gz(fname)[source]#

Check if fname is a gzip file.

Parameters:

fname (str) – Name of file to check.

Returns:

True if it is a gz file, False otherwise.

Return type:

bool

geoips.compare_outputs.is_image(fname)[source]#

Determine if fname is an image file.

Parameters:

fname (str) – Name of file to check.

Returns:

True if it is an image file, False otherwise.

Return type:

bool

geoips.compare_outputs.is_text(fname)[source]#

Check if fname is a text file.

Parameters:

fname (str) – Name of file to check.

Returns:

True if it is a text file, False otherwise.

Return type:

bool

geoips.compare_outputs.print_gunzip_to_file(fobj, gunzip_fname)[source]#

Write the command to gunzip the passed “gunzip_fname” to file.

Writes to the currently open file object, if required.

geoips.compare_outputs.print_gzip_to_file(fobj, gzip_fname)[source]#

Write the command to gzip the passed “gzip_fname” to file.

Writes to the currently open file object, if required.

geoips.compare_outputs.test_product(output_product, compare_product, goodcomps, badcomps, compare_strings)[source]#

Test output_product against “good” product stored in “compare_path”.

Parameters:
  • output_product (str) –

    • Full path to current output product

  • compare_product (str) –

    • Full path to “good” comparison product

  • goodcomps (list of str) –

    • List of full paths to all “good” successful comparisons (output and compare images match)

    • Each str is prepended with a “compare_string” tag to identify which comparison type was performed.

  • badcomps (list of str) –

    • List of full paths to all “bad” unsuccessful comparisons (output and compare images differ)

    • Each str is prepended with a “compare_string” tag to identify which comparison type was performed.

  • compare_strings (list of str) –

    • List of all comparison “tags” included in goodcomps and badcomps lists.

    • This list is used to remove the comparison tags from goodcomps and badcomps to retrieve only the file path.

Returns:

  • goodcomps (list of str) – All current good comparisons appended to the list passed in.

  • badcomps (list of str) – All current bad comparisons appended to the list passed in.

  • compare_strings (list of str) – All current comparison “tags” added to the list passed in.

Raises:

TypeError – Raised when current output product does not have an associated comparison test defined.

geoips.compare_outputs.text_match(output_product, compare_product)[source]#

Check if two text files match.

Parameters:
  • output_product (str) – Full path to current output product

  • compare_product (str) – Full path to “good” comparison product

Returns:

Return True if products match, False if they differ

Return type:

bool

geoips.errors module#

GeoIPS error module.

exception geoips.errors.CoverageError[source]#

Bases: Exception

Raise exception on data coverage error.

exception geoips.errors.EntryPointError[source]#

Bases: Exception

Exception to be raised when an entry-point cannot be found.

exception geoips.errors.PluginError[source]#

Bases: Exception

Exception to be raised when there is an error in a plugin module.

geoips.geoips_utils module#

General high level utilities for geoips processing.

geoips.geoips_utils.copy_standard_metadata(orig_xarray, dest_xarray, extra_attrs=None, force=True)[source]#

Copy standard metadata from orig_xarray to dest_xarray.

Parameters:
  • orig_xarray (xarray.Dataset) – Original xarray to copy attributes from

  • dest_xarray (xarray.Dataset) – Destination xarray to copy attributes to

  • extra_attrs (list of str, optional) – Additional attributes to copy, beyond the standard metadata, by default None

  • force (bool, optional) – If force is True, overwrite existing attributes, by default True

Returns:

dest_xarray with standard metadata copied in place from orig_xarray.

Return type:

xarray.Dataset

geoips.geoips_utils.deprecation(message)[source]#

Print a deprecation warning during runtime.

geoips.geoips_utils.find_all_txt_plugins(subdir='')[source]#

Find all txt plugins in registered plugin packages.

Search the plugins directory of each registered plugin package for files ending in .txt. Return list of files

geoips.geoips_utils.find_ascii_palette(name)[source]#

Find ASCII palette named “name”.

Search the plugins/txt/ascii_palettes directory for ASCII palettes to use as colormaps.

geoips.geoips_utils.find_config(subpackage_name, config_basename, txt_suffix='.yaml')[source]#

Find matching config file within GEOIPS packages.

Given ‘subpackage_name’, ‘config_basename’, and txt_suffix, find matching text file within GEOIPS packages.

Parameters:
  • subpackage_name (str) – subdirectory under GEOIPS package to look for text file ie text_fname = geoips/<subpackage_name>/<config_basename><txt_suffix>

  • config_basename (str) – text basename to look for, ie text_fname = geoips/<subpackage_name>/<config_basename><txt_suffix>

  • txt_suffix (str) – suffix to look for on config file, defaults to “.yaml” ie text_fname = geoips/<subpackage_name>/<config_basename><txt_suffix>

Returns:

text_fname – Full path to text filename

Return type:

str

geoips.geoips_utils.find_entry_point(namespace, name, default=None)[source]#

Find object matching ‘name’ using GEOIPS entry point namespace ‘namespace’.

Automatically add ‘geoips’ prefix to namespace for disambiguation.

Parameters:
  • namespace (str) – Entry point namespace (e.g. ‘readers’)

  • name (str) – Entry point name (e.g. ‘amsr2_netcdf’)

  • default (entry point, optional) – Default value if no match is found. If this is not set (i.e. None), then no match will result in an exception

geoips.geoips_utils.get_all_entry_points(namespace)[source]#

Return all entry points in GEOIPS entry point namespace ‘namespace’.

Automatically add ‘geoips’ prefix to namespace for disambiguation.

Parameters:

namespace (str) – Entry point namespace (e.g. ‘readers’)

geoips.geoips_utils.get_entry_point_group(group)[source]#

Get entry point group.

geoips.geoips_utils.get_required_geoips_xarray_attrs()[source]#

Interface deprecated v2.0.

geoips.geoips_utils.list_entry_points(namespace)[source]#

List names of objects in GEOIPS entry point namespace ‘namespace’.

Automatically add ‘geoips’ prefix to namespace for disambiguation.

Parameters:

namespace (str) – Entry point namespace (e.g. ‘readers’)

geoips.geoips_utils.list_product_source_dict_yamls()[source]#

List all YAML files containing product source specifications.

Search in all geoips packages.

Returns:

List of all product source dict YAMLs in all geoips packages

Return type:

list

geoips.geoips_utils.list_product_specs_dict_yamls()[source]#

List all YAML files containing product params in all geoips packages.

Returns:

List of all product params dict YAMLs in all geoips packages

Return type:

list

geoips.geoips_utils.load_all_yaml_plugins()[source]#

Find all YAML plugins in registered plugin packages.

Search the plugins directory of each registered plugin package for files ending in .yaml. Read each plugin file

geoips.geoips_utils.merge_nested_dicts(dest, src, in_place=True)[source]#

Perform an in-place merge of src into dest.

Performs an in-place merge of src into dest while preserving any values that already exist in dest.

geoips.geoips_utils.output_process_times(process_datetimes, num_jobs=None, job_str='GeoIPS 2')[source]#

Calculate and print the process times from the process_datetimes dictionary.

Parameters:

process_datetimes (dict) –

dictionary formatted as follows:

  • process_datetimes['overall_start'] - overall start datetime of the entire script

  • process_datetimes['overall_end'] - overall end datetime of the entire script

  • process_datetimes[process_name]['start'] - start time of an individual process

  • process_datetimes[process_name]['end'] - end time of an individual process

geoips.geoips_utils.replace_geoips_paths(fname, replace_paths=None, base_paths=None)[source]#

Replace standard environment variables with their non-expanded equivalents.

Ie, replace

  • $HOME/geoproc/geoips_packages with $GEOIPS_PACKAGES_DIR

  • $HOME/geoproc/geoips_outdirs with $GEOIPS_OUTDIRS

  • $HOME/geoproc with $GEOIPS_BASEDIR

This allows generating output YAML fields / NetCDF attributes that can match between different instantiations.

Parameters:
  • fname (str) – Full path to a filename on disk

  • replace_paths (list, default=None) –

    • Explicit list of standard variable names you would like replaced.

    • If None, replace ['GEOIPS_OUTDIRS', 'GEOIPS_PACKAGES_DIR', 'GEOIPS_TESTDATA_DIR', 'GEOIPS_DEPENDENCIES_DIR', 'GEOIPS_BASEDIR']

  • base_paths (list, default=None) –

    • List of PATHS dictionaries in which to find the “replace_paths” variables

    • If None, use geoips.filenames.base_paths

Returns:

fname – Path to file on disk, with explicit path replaced with environment variable name and/or full URL.

Return type:

str

Notes

Note it replaces ALL standard variables that have a corresponding <key>_URL variable.

Additionally, it replaces variables specified in “replace_paths” list with the unexpanded environment variable name.

Module contents#

The Geolocated Information Processing System (GeoIPS).

GeoIPS ® Base Package#

The GeoIPS Base Package provides a Python 3 based architecture supporting a wide variety of satellite and weather data processing. The modular nature of the GeoIPS base infrastructure also allows plug-and-play capability for user-specified custom functionality.

Homepage: NRLMMD-GEOIPS/geoips