geoips.utils package#
Subpackages#
- geoips.utils.coverage_checkers package
- geoips.utils.memusg package
- geoips.utils.types package
- Submodules
- geoips.utils.types.converter_registry module
- geoips.utils.types.converters module
- Metadata policy
FamilyConversionSpecdataarray_to_dataset()dataset_dict_to_dataset()dataset_to_dataarray()dataset_to_dataset_dict()dataset_to_dict()dataset_to_list()dataset_to_masked_array()dataset_to_numpy()dataset_vars_to_numpy_list()dict_to_dataset()list_to_dataset()masked_array_to_dataset()numpy_to_dataset()
- geoips.utils.types.datatree_converters module
- geoips.utils.types.datatree_ditto module
DataTreeDittoDataTreeDitto.filter()DataTreeDitto.from_datatree()DataTreeDitto.get()DataTreeDitto.get_original()DataTreeDitto.items()DataTreeDitto.keys()DataTreeDitto.list_converted_nodes()DataTreeDitto.map_over_datasets()DataTreeDitto.match()DataTreeDitto.mean()DataTreeDitto.to_datatree()DataTreeDitto.values()
- geoips.utils.types.datatree_helpers module
- geoips.utils.types.family_conversions module
- geoips.utils.types.obp_conduits module
- geoips.utils.types.partial_lexeme module
- geoips.utils.types.script_datatree module
- geoips.utils.types.tokenization module
- geoips.utils.types.yaml_plugin_callable module
- Module contents
Submodules#
geoips.utils.cache_files module#
Module for handling cached files in GeoIPS.
This modules provides functions to manage cache files in GeoIPS. Cache files will be stored in the user cache directory, which is platform-dependent. The correct cache directory is determined using the GEOIPS_CACHE_DIR environment variable which defaults to platformdirs.user_cache_dir(“geoips”) if not set.
- geoips.utils.cache_files.create_cached_json_from_yaml(source, cache_dir=None)[source]#
Create a cached JSON file from a YAML file.
This function reads a YAML file and writes its contents to a JSON file in the user cache directory. The JSON file will be created if it does not already exist, or updated if the source YAML file’s contents have changed since it was last cached.
- Parameters:
source (str) – The path to the source YAML file.
cache_dir (str, optional) – The path to the cache directory. If not provided, the default user cache directory will be used.
- Returns:
The path to the cached JSON file.
- Return type:
str
- geoips.utils.cache_files.get_cached_json(source, cache_dir=None)[source]#
Get the cached JSON file corresponding to a YAML file.
Some files in GeoIPS are stored in YAML format, but we want to use JSON at runtime because loading JSON is faster than loading YAML. This function checks if the cached JSON file exists and is up to date. If it does not exist or is out of date, it creates a new cached JSON file from the YAML file. It then returns the contents of the cached JSON file.
- Parameters:
source (str) – The path to the source YAML file.
cache_dir (str, optional) – The path to the cache directory. If not provided, the default user cache directory will be used.
- geoips.utils.cache_files.source_modified(source, dest)[source]#
Check if the source file was modified more recently than the destination file.
This uses os.path.getmtime() to determine whether the source file has been modified more recently than the destination file. Returns True if the source file was modified more recently than the destination file, False otherwise.
- Parameters:
source (str) – The path to the source file we are monitoring for changes.
dest (str) – The path to the destination file we will update if the source file changes.
- Returns:
True if the source file was modified more recently than the destination file, False otherwise.
- Return type:
bool
geoips.utils.composite module#
Utilities for swath compositing in GeoIPS.
- geoips.utils.composite.find_preproc_alg_files(product_time, composite_window, sector_name, product, sensor, platform, file_format='netcdf', product_db=False, db_query_plugin=None, db_schemas=None, db_tables=None)[source]#
Find pre-processed algorithm files that were saved to disk.
- Parameters:
product_time (datetime.datetime) – Product time
composite_window (str) – How far back to search for pre-processed files. Window needs to be specified in iso8601 duration format (e.g. PT4H)
sector_name (str) – Name of sector to composite
product (str) – Name of product to composite
sensor (str) – Name of sensor to composite
platform (str) – Name of platform to composite
file_format (str, optional) – Pre-processed file format, by default “netcdf”
product_db (bool, optional) – Use product database to find any pre-processed file, by default False
db_query_plugin (str, optional) – Name of product database query plugin, by default None
db_schemas (list, optional) – Names of postgres schema to query, by default None
db_tables (list, optional) – Names of table to query under schema, by default None
- Returns:
List of pre-processed algorithm files
- Return type:
list
- geoips.utils.composite.find_preproc_alg_netcdfs(product_time_start, product_time_end, sector_name, product, sensor, platform, product_db=False, postgres_query_plugin=None, postgres_schemas=None, postgres_tables=None)[source]#
Find pre-processed algorithm netCDF files that were saved to disk.
- Parameters:
product_time_start (datetime.datetime) – Earliest product time to search for valid files
product_time_start – Latest product time to search for valid files
sector_name (str) – Name of sector to composite
product (str) – Name of product to composite
sensor (str) – Name of sensor to composite
platform (str) – Name of platform to composite
file_format (str, optional) – Pre-processed file format, by default “netcdf”
product_db (bool, optional) – Use product database to find any pre-processed file, by default False
db_query_plugin (str, optional) – Name of product database query plugin, by default None
db_schemas (list, optional) – Names of postgres schema to query, by default None
db_tables (list, optional) – Names of table to query under schema, by default None
- Returns:
List of pre-processed netCDF algorithm files
- Return type:
list
geoips.utils.context_managers module#
Module for handling optional dependencies throughout GeoIPS.
geoips.utils.decorators module#
GeoIPS decorators module.
geoips.utils.file_utils module#
Filesystem path helpers used across GeoIPS.
- geoips.utils.file_utils.path_exists(path: str | Path) bool[source]#
Return True if a filesystem path exists.
- Parameters:
file_path (str) –
- File or Directory path to evaluate. This could be a file, directory, or other
filesystem object.
- Returns:
True if path exists on the filesystem, otherwise False.
- Return type:
bool
Module contents#
Geoips utilities init file.