7.3. PFTools API Reference

Each entry below includes a short description from the object’s docstring. Click a name to open the full documentation.

Parflow Module

ParflowBinaryReader

The ParflowBinaryReader, unsurprisingly, provides functionality for reading parflow binary files.

Run

Main object that can be used to define a ParFlow simulation

read_pfb

Read a single pfb file, and return the data therein

write_pfb

Write a single pfb file.

read_pfb_sequence

An efficient wrapper to read a sequence of pfb files.

pf_test_file

Python version of the tcl pftestFile procedure.

pf_test_file_with_abs

Python version of the tcl pftestFileWithAbs procedure.

Run Class

Run.from_definition

Method to generate a Run object from a file.

Run.get_name

Returns name of run

Run.set_name

Setting new name for a run

Run.write

Method to write database file to disk

Run.write_subsurface_table

Write a table of subsurface properties assigned to each unit.

Run.clone

Method to generate a clone of a run (for generating run ensembles, etc.)

Run.run

Method to run simulation

Run.check_nans

Check the input files for NaNs.

Run.dist

Distribute a PFB file using the P/Q/R settings from the run or override them with the provided arguments.

Run.undist

Undistribute a PFB file.

Run.details

Return details based on a location.

Run.doc

Return docs based on a location.

Run.get_children_of_type

Return a list of PFDBObj of a given type that are part of our children.

Run.get_context_settings

Return global settings for our current parflow run.

Run.keys

Gets the key names necessary for the run while skipping unset ones

Run.pfset

Allow to define any parflow key so it can be exported. Many formats are supported: - key/value: To set a single value relative to our current PFDBObj. - yaml_file: YAML file path to load and import using the current PFDBObj as root. - yaml_content: YAML string to load and import using the current PFDBObj as root. - hierarchical_map: Nested dict containing several key/value pair using the current PFDBObj as root. - flat_map: Flat dict with parflow key/value pair to set using the current PFDBObj as root.

Run.select

Return a PFDBObj object based on a location.

Run.to_dict

Method that will return a flat map of all the ParFlow keys.

Run.to_pf_name

Helper method returning the key to use for Parflow on a given field key.

Run.validate

Method to validate sub hierarchy

Run.value

Return a value based on a location.

Run.data_accessor

Return a DataAccessor to streamline access to numpy array of the various field this run is linked to.

Run.full_name

Helper method returning the full name of a given ParFlow key.

check_parflow_execution

Helper function that can be used to parse ParFlow output file

get_current_parflow_version

Helper function to extract ParFlow version

get_process_args

General processing of script arguments

update_run_from_args

Push processed args onto run properties.

Builders

SolidFileBuilder

SubsurfacePropertiesBuilder

ReservoirPropertiesBuilder

VegParamBuilder

DomainBuilder

CLMImporter

TableToProperties

IO Module

ParflowBinaryReader

The ParflowBinaryReader, unsurprisingly, provides functionality for reading parflow binary files.

DataAccessor

Helper for extracting numpy array from a given run

read_pfb

Read a single pfb file, and return the data therein

write_pfb

Write a single pfb file.

read_pfb_sequence

An efficient wrapper to read a sequence of pfb files.

read_pfsb

Read a ParFlow scattered binary file (pfsb) and return the data.

write_dist

Write a distfile.

undist

Undistribute PFB files.

load_patch_matrix_from_image_file

load_patch_matrix_from_asc_file

load_patch_matrix_from_sa_file

write_patch_matrix_as_asc

Write asc for pfsol

write_patch_matrix_as_sa

Write asc for pfsol

read_pfidb

Load pfidb file into a Python dict

read_yaml

Load yaml file into a Python dict

read_clm

write_dict

Write a Python dict into a file_name using the extension to determine its format.

write_dict_as_pfidb

Write a Python dict in a pfidb format inside the provided file_name

write_dict_as_yaml

Write a Python dict in a pfidb format inside the provided file_name

write_dict_as_json

Write a Python dict in a json format inside the provided file_name

to_native_type

Converting a string to a value in native format.

get_maingrid_and_remainder

Determines the sizes of the subgrids.

get_subgrid_loc

Translate an integer subgrid to the location in 3d subgrid space.

subgrid_lower_left

Get the index of the lower left corner of a subgrid.

subgrid_size

Get the size of a subgrid

precalculate_subgrid_info

Computes all necessary subgrid information to index and read or write a pfb file.

Hydrology Module

calculate_evapotranspiration

Calculate gridded evapotranspiration across several layers.

calculate_overland_flow

Calculate overland outflow out of a domain

calculate_overland_flow_grid

Calculate overland outflow per grid cell of a domain

calculate_overland_fluxes

Calculate overland fluxes across grid faces

calculate_subsurface_storage

Calculate gridded subsurface storage across several layers.

calculate_surface_storage

Calculate gridded surface storage on the top layer.

calculate_water_table_depth

Calculate water table depth from the land surface :param pressure: A nz-by-ny-by-nx ndarray of pressure values (bottom layer to top layer) :param saturation: A nz-by-ny-by-nx ndarray of saturation values (bottom layer to top layer) :param dz: An ndarray of shape (nz,) of thickness values (bottom layer to top layer) :return: A ny-by-nx ndarray of water table depth values (measured from the top)

compute_hydraulic_head

Compute hydraulic head from a 3D pressure ndarray considering elevation.

compute_water_table_depth

Computes the water table depth as the first cell with a saturation=1 starting from top.

FS Module

cp

Copying file/directory within python script

get_absolute_path

Helper function to resolve a file path while using the proper working directory.

mkdir

mkdir within python script

rm

Deleting file/directory within python script

get_text_file_content

Read a text file and return its contents as a string.

exists

Return True if the given path exists.

chdir

Change the current working directory.

Export Module

SubsurfacePropertiesExporter

CLMExporter

NotOverwritableException

Compare Module

pf_test_file

Python version of the tcl pftestFile procedure.

pf_test_file_with_abs

Python version of the tcl pftestFileWithAbs procedure.

pf_test_equal

msig_diff

Python version of the C MSigDiff function.

Top Module

compute_top

Python version of the C ComputeTop function.

extract_top

Python version of the C ExtractTop function.

Settings Module

get_working_directory

set_working_directory

This will set the working directory to use for all the relative file path.

enable_line_error

Calling that method will enable line feedback on validation error

disable_line_error

Calling that method will disable line feedback on validation error

enable_exit_error

Calling that method will force the program to exit on validation error.

disable_exit_error

Calling that method will force the program to not exit on validation error.

set_parflow_version

Globally store the ParFlow version to test against

PF Backend Module

ParflowBackendEntrypoint

Provides an entrypoint for xarray to read Parflow input/output Note: Users should never instantiate, import, or call any of this code directly.

ParflowBackendArray

Backend array that allows for lazy indexing on pfb-based data.