subsettools.parflow_run --------------------------------- .. py:module:: subsettools.parflow_run .. autoapi-nested-parse:: Functions to get and customize a ParFlow runscript. Functions ~~~~~~~~ .. autoapisummary:: subsettools.parflow_run.get_template_runscript subsettools.parflow_run.edit_runscript_for_subset subsettools.parflow_run.copy_files subsettools.parflow_run.change_filename_values subsettools.parflow_run.dist_run .. py:function:: get_template_runscript(grid, mode, input_file_type, write_dir) Get a ParFlow template runscript. The runscript is selected based on the grid, mode and input file type and is copied to write_dir. :param grid: The spatial grid that the ij indices are calculated relative to and that the subset data will be returned on. Possible values: “conus1” or “conus2” :type grid: str :param mode: The type of simulation you would like to do. Possible values: "spinup" (run ParFlow with a constant recharge forcing at the upper boundary) and "transient" (coupled ParFlow-CLM run) :type mode: str :param input_file_type: The type of domain you will run. Possible values: "box" or "solid" :type input_file_type: str :param write_dir: directory where the template runscript file will be copied :type write_dir: str :returns: A path to the template runscript. Example: .. code-block:: python runscript_path = get_template_runscript( grid="conus1", mode="spinup", input_file_type="solid", write_dir="/path/to/your/chosen/directory" ) .. py:function:: edit_runscript_for_subset(ij_bounds, runscript_path, write_dir=None, runname=None, forcing_dir=None) Modify a ParFlow run script for a new subdomain run. This function is designed to start from a national ParFlow runscript template and perform the following three modifications. 1. Modify the geometry to reflect the bounds of the desired ij_bounds (i.e. the number of grid cells in the x and y direction and the upper bounds of the geometry) 2. Update the runname to for the desired new run. 3. Update the location of the climate forcings for the new run. If the runname is None and write_dir is the directory containing the runscript file, the runscript file will be overwritten. :param ij_bounds: 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. :type ij_bounds: tuple[int] :param runscript_path: absolute path to the template parflow runscript file :type runscript_path: str :param write_dir: directory where the new template file will be written. If it is None, defaults to the directory containing the runscript. :type write_dir: str :param runname: name for the new parflow run. If it is None, defaults to the runscript's previous runname. :type runname: str :param forcing_dir: path to the directory containing the subset forcing files. If it is None, defaults to the runscript's previous forcing directory path. :type forcing_dir: str :returns: A path to the new runscript file that will be created. Example: .. code-block:: python runscript_path = edit_runscript_for_subset( ij_bounds=(375, 239, 487, 329), runscript_path="/path/to/your/original/runscript", runname="my_conus1_run", forcing_dir="/path/to/your/forcing/directory" ) .. py:function:: copy_files(read_dir, write_dir) Copy all files from read_dir to write_dir. :param read_dir: read-from directory path :type read_dir: str :param write_dir: write-to directory path :type write_dir: str Example: .. code-block:: python copy_files( read_dir="/path/to/read-from/directory", write_dir="/path/to/write-to/directory" ) .. py:function:: change_filename_values(runscript_path, write_dir=None, runname=None, slopex=None, slopey=None, solidfile=None, init_press=None, indicator=None, depth_to_bedrock=None, mannings=None, evap_trans=None) Change the filenames of input files in the ParFlow runscript. This function will update the paths to input files in a ParFlow runscript. The provided arguments will reset the corresponding parflow keys to match the user specified paths to input files. File names can be specified with or without relative or absolute file paths. If no path is provided ParFlow will expect the input files to be present in the run directory at the time of simulation. Note that this will only change paths for keys that already exist in the template ParFlow run script you are starting from and will not reconfigure a run to use new keys (for example if you are not starting from a run script that uses a solid file, adding a new solid file path will not configure the run to use a solid file). Refer to the ParFlow manual for additional information on any of the keys listed above. If the runname is None and write_dir is the directory containing the runscript file, the runscript file will be overwritten. :param runscript_path: path to the runscript file (yaml or pfidb) :type runscript_path: str :param write_dir: directory where the new template file will be written. If it is None, defaults to the directory containing the runscript file. :type write_dir: str :param runname: name of the new parflow run :type runname: str :param slopex: new slopex filename (and path) :type slopex: str :param slopey: new slopey filename (and path) :type slopey: str :param solidfile: new solidfile filename (and path) :type solidfile: str :param init_press: new initial pressure filename (and path) :type init_press: str :param indicator: new indicator input filename (and path) :type indicator: str :param depth_to_bedrock: new depth to bedrock filename (and path) :type depth_to_bedrock: str :param mannings: new mannings filename (and path) :type mannings: str :param evap_trans: new evapotranspiration filename (and path) :type evap_trans: str :returns: A path to the new runscript file that will be created. Example: .. code-block:: python runscript_path = change_filename_values( runscript_path="/path/to/your/original/runscript", runname="my_conus1_run", init_press="/filename/of/initial/pressure/pfb/file" ) .. py:function:: dist_run(topo_p, topo_q, runscript_path, working_dir=None, dist_clim_forcing=True) Distribute ParFlow input files for parallel computing. This function will distribute input files to topo_p grids in the x direction and topo_q grids in the y direction. If dist_clim_forcing is true, forcing files will be distributed as well according to the same topology. If working_dir is different that the directory containing the runscript file, the edited runscipt file will be written to working_dir. :param topo_p: number of grids (processes) to create in the x direction :type topo_p: int :param topo_q: number of grids (processes) to create in the y direction :type topo_q: int :param runscript_path: path to the runscript file (yaml or pfidb) :type runscript_path: str :param working_dir: directory containing the files to be distributed. If it is None, it defaults to the directory containing the runscript file. :type working_dir: str :param dist_clim_forcing: if true, distribute forcing files :type dist_clim_forcing: bool :returns: Path to the edited runscript file that will be created. :rtype: str Example: .. code-block:: python runscript_path = dist_run( topo_p=2, topo_q=2, runscript_path="/path/to/your/original/runscript", dist_clim_forcing=False )