subsettools.clm

Functions to configure CLM for coupled ParFlow-CLM simulations.

Functions

config_clm(ij_bounds, start, end, dataset, write_dir)

Modify template CLM driver files for a desired subdomain and run duration.

vegm_to_land_cover(vegm_path[, write_pfb_path])

Convert a vegm.dat file in CLM format into a land cover array.

subsettools.clm.config_clm(ij_bounds, start, end, dataset, write_dir, time_zone='UTC')[source]

Modify template CLM driver files for a desired subdomain and run duration.

This function will obtain template clm driver files (specifically vegm, vep and drv_clmin) from the existing national simulations on HydroData and modify them to reflect the desired subdomain (indicated by the ij_bounds) and run duration (indicated by the start and end dates). The modified files will be written out to a user specified directory. These files are required if you are going to run a ParFlow-CLM simulation.

Parameters:
  • ij_bounds (tuple[int]) – bounding box for subset. This should be given as i,j index values where 0,0 is the lower left hand corner of a domain. ij_bounds are given relative to whatever grid is being used for the subset.

  • start (str) – start date (inclusive), in the form ‘yyyy-mm-dd’

  • end (str) – end date (exlusive), in the form ‘yyyy-mm-dd’

  • dataset (str) – the dataset that the files should be obtained from name e.g. “conus1_baseline_mod”

  • write_dir (str) – directory where the subset files will be written

  • time_zone (str) – timezone information for start and end dates. This should be a zoneinfo-supported time zone. Defaults to “UTC”.

Returns:

A dictionary mapping the CLM file types (“vegp”, “vegm”, “drv_clm”) to the corresponging filepaths where the CLM files were written.

Example:

filepaths = config_clm(
    ij_bounds=(375, 239, 487, 329),
    start="2005-10-01",
    end="2006-10-01",
    dataset="conus1_baseline_mod",
    write_dir="/path/to/your/chosen/directory"
)
subsettools.clm.vegm_to_land_cover(vegm_path, write_pfb_path=None)[source]

Convert a vegm.dat file in CLM format into a land cover array.

This function assumes the vegm.dat file is in the standard format. That is, the file has 1 row per grid cell and each row contains 25 columns The columns are ordered as: x, y, lat, lon, sand, clay, color, then 18 columns representing the fractional coverage of the grid cell by vegetation class (these final 18 columns add to 1.0 for each row). The rows are in ascending order by grid cell index with y as the outer loop and x as the inner loop.

In cases in which the fractional vegetation coverage results in a tie between multiple vegetation classes, the final land cover array will use the first (lowest) land cover designation to break the tie (ie. the land cover array will contain designation 1 for a grid cell in which the vegetation distribution is 0.5 class 1 and 0.5 class 5).

Parameters:
  • vegm_path (str) – path to vegm file

  • write_pfb_path (str; optional) – path to write output .pfb file to disk

Returns:

NumPy array containing the calculated land cover type for each domain grid cell.

If pfb_path is provided, .pfb file is written to disk at the specified path.

Example:

land_cover_array = vegm_to_land_cover("/path/to/vegm/vegm.dat")