climate_ref_pmp.pmp_driver
#
build_glob_pattern(paths)
#
Generate a glob pattern that matches files based on common path, prefix, and suffix.
Generate a glob pattern that matches all files in the given list of paths, based on their common directory, filename prefix, and suffix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paths
|
list of str
|
A list of full file paths. The paths should point to actual files, and should have enough similarity in their structure and naming to extract common patterns. |
required |
Returns:
| Type | Description |
|---|---|
str
|
A glob pattern string that can be used with |
Examples:
>>> paths = [
... "/home/user/data/folder1/file1.txt",
... "/home/user/data/folder1/file2.txt",
... "/home/user/data/folder2/file3.txt",
... ]
>>> pattern = build_glob_pattern(paths)
>>> print(pattern)
/home/user/data/**/file*.txt
Source code in packages/climate-ref-pmp/src/climate_ref_pmp/pmp_driver.py
build_pmp_command(driver_file, parameter_file, **kwargs)
#
Run a PMP driver script via a conda environment
This function runs a PMP driver script using a specific conda environment. The driver script is responsible for running the PMP diagnostics and producing output. The output consists of a JSON file that contains the executions of the PMP diagnostics, and a set of PNG and data files that are produced by the diagnostics.
The PMP driver scripts are installed in the PMP conda environment, but absolute paths should be used for non-PMP scripts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
driver_file
|
str
|
Filename of the PMP driver script to run |
required |
parameter_file
|
str
|
Filename of the parameter file to use |
required |
kwargs
|
str | int | float | list[str] | None
|
Additional arguments to pass to the driver script |
{}
|
Source code in packages/climate-ref-pmp/src/climate_ref_pmp/pmp_driver.py
process_json_result(json_filename, png_files, data_files)
#
Process a PMP JSON result into the appropriate CMEC bundles
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_filename
|
Path
|
Filename of the JSON file that is written out by PMP |
required |
png_files
|
list[Path]
|
List of PNG files to be included in the output |
required |
data_files
|
list[Path]
|
List of data files to be included in the output |
required |
Returns:
| Type | Description |
|---|---|
tuple of CMEC output and diagnostic bundles
|
|