From c4e39d6b2849428a4c766f4b968c56a519b401b8 Mon Sep 17 00:00:00 2001 From: Ahmad Rezaii Date: Wed, 11 Nov 2020 15:54:02 -0700 Subject: [PATCH] add patches to solidfiles, #16, implement Run object, #22, incr ver, fix author, url, update docs --- README.md | 20 +- docs/html/parflow/cli/index.html | 70 + docs/html/parflow/cli/pfdist_sort.html | 121 + docs/html/parflow/cli/tcl2py.html | 239 + docs/html/parflow/index.html | 26 +- docs/html/parflow/subset/bbox.html | 46 + docs/html/parflow/subset/clipper.html | 59 +- docs/html/parflow/subset/data/index.html | 12 + docs/html/parflow/subset/domain.html | 72 +- docs/html/parflow/subset/index.html | 5 - docs/html/parflow/subset/mask.html | 74 +- docs/html/parflow/subset/rasterizer.html | 8 +- .../parflow/subset/tools/bulk_clipper.html | 42 +- .../parflow/subset/tools/subset_conus.html | 187 +- docs/html/parflow/subset/utils/io.html | 16 +- docs/html/parflow/tools/builders.html | 3597 ++++ docs/html/parflow/tools/core.html | 1281 ++ docs/html/parflow/tools/database/core.html | 2284 ++ docs/html/parflow/tools/database/domains.html | 1884 ++ .../parflow/tools/database/generated.html | 17155 ++++++++++++++++ .../html/parflow/tools/database/handlers.html | 599 + docs/html/parflow/tools/database/index.html | 87 + docs/html/parflow/tools/export.html | 348 + docs/html/parflow/tools/fs.html | 317 + docs/html/parflow/tools/helper.html | 351 + docs/html/parflow/tools/index.html | 119 + docs/html/parflow/tools/io.html | 736 + docs/html/parflow/tools/settings.html | 260 + docs/html/parflow/tools/terminal.html | 259 + parflow/subset/builders/__init__.py | 1 - parflow/subset/builders/tcl.py | 435 - parflow/subset/data/conus_manifest.yaml | 16 +- parflow/subset/data/parking_lot_template.py | 279 + parflow/subset/data/parking_lot_template.tcl | 362 - parflow/subset/domain.py | 17 +- parflow/subset/tools/subset_conus.py | 90 +- setup.py | 12 +- tests/subset_conus_tests.py | 4 +- .../HUC10190004/conus1/WBDHU8_conus1_ref.vtk | 1106 +- 39 files changed, 31030 insertions(+), 1566 deletions(-) create mode 100644 docs/html/parflow/cli/index.html create mode 100644 docs/html/parflow/cli/pfdist_sort.html create mode 100644 docs/html/parflow/cli/tcl2py.html create mode 100644 docs/html/parflow/tools/builders.html create mode 100644 docs/html/parflow/tools/core.html create mode 100644 docs/html/parflow/tools/database/core.html create mode 100644 docs/html/parflow/tools/database/domains.html create mode 100644 docs/html/parflow/tools/database/generated.html create mode 100644 docs/html/parflow/tools/database/handlers.html create mode 100644 docs/html/parflow/tools/database/index.html create mode 100644 docs/html/parflow/tools/export.html create mode 100644 docs/html/parflow/tools/fs.html create mode 100644 docs/html/parflow/tools/helper.html create mode 100644 docs/html/parflow/tools/index.html create mode 100644 docs/html/parflow/tools/io.html create mode 100644 docs/html/parflow/tools/settings.html create mode 100644 docs/html/parflow/tools/terminal.html delete mode 100644 parflow/subset/builders/__init__.py delete mode 100644 parflow/subset/builders/tcl.py create mode 100644 parflow/subset/data/parking_lot_template.py delete mode 100755 parflow/subset/data/parking_lot_template.tcl diff --git a/README.md b/README.md index 4196cb6..654113a 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ For CONUS1 and CONUS2 domains, local copies of model input files are required. PME: PmE.flux.pfb SLOPE_X: slopex.pfb SLOPE_Y: slopey.pfb + CELL_TYPES: Domain_Blank_Mask.tif optional_files: LAND_COVER: conus1_landcover.sa LAT_LON: conus1_Grid_Centers_Short_Deg.format.sa @@ -74,20 +75,15 @@ For CONUS1 and CONUS2 domains, local copies of model input files are required. #### CONUS2 Files required_files: - DOMAIN_MASK: conus_1km_PFmask2.tif + DOMAIN_MASK: CONUS2.0.Final1km.SinksAndSelectLakes.Mask.tif SUBSURFACE_DATA: 3d-grid.v3.tif PME: PME.tif - SLOPE_X: Str3Ep0_smth.rvth_1500.mx0.5.mn5.sec0.up_slopex.tif - SLOPE_Y: Str3Ep0_smth.rvth_1500.mx0.5.mn5.sec0.up_slopey.tif - SINKS: conus_1km_PFmask_manualsinks.tif - RESERVOIRS: conus_1km_PFmask_reservoirs.tif - LAKE_BORDER: conus_1km_PFmask_selectLakesborder.tif - LAKE_MASK: conus_1km_PFmask_selectLakesmask.tif - CHANNELS: 1km_upscaledNWM_ChannelOrder5_mod2.tif - CELL_TYPES: 1km_PF_BorderCellType.tif + SLOPE_X: CONUS2.0.Final1km.slopex.tif + SLOPE_Y: CONUS2.0.Final1km.slopey.tif + CELL_TYPES: CONUS2.0.Final1km.Border.Type.tif optional_files: LAND_COVER: 1km_CONUS2_landcover_IGBP.tif - LAT_LON: latlonCONUS2.sa + LAT_LON: CONUS2.0.Final.LatLong.sa DEM: CONUS2.0_RawDEM.tif **Local Filenames** @@ -147,13 +143,13 @@ python -m parflow.subset.tools.rasterize_shape -i -s < Re-project the shapefile at ~/downloads/shapfiles/WBDHU8.shp to the CONUS1 projection and extent ``` -python -m parflow.subset.tools.rasterize_shape -i ~/downloads/shapefiles -s WBDHU8 +python -m parflow.subset.tools.rasterize_shape -i ~/downloads/shapefiles -s WBDHU8 -r ~/conus_inputs/1/Domain_Blank_Mask.tif ``` #### Use a mask to clip multiple files to PFB or TIF -assumes all files are identically gridded and same as the mask file, if write_tifs=1 then you +assumes all files are identically gridded and same as the mask file. If setting the `--tif_outs` flag then you must supply at least one tif with correct projection and transform information as either the mask file, as a reference dataset with the -r option, or in the list of datafiles to clip ``` diff --git a/docs/html/parflow/cli/index.html b/docs/html/parflow/cli/index.html new file mode 100644 index 0000000..8e1f01f --- /dev/null +++ b/docs/html/parflow/cli/index.html @@ -0,0 +1,70 @@ + + + + + + +parflow.cli API documentation + + + + + + + + + + + +
+ + +
+ + + \ No newline at end of file diff --git a/docs/html/parflow/cli/pfdist_sort.html b/docs/html/parflow/cli/pfdist_sort.html new file mode 100644 index 0000000..3e43e4b --- /dev/null +++ b/docs/html/parflow/cli/pfdist_sort.html @@ -0,0 +1,121 @@ + + + + + + +parflow.cli.pfdist_sort API documentation + + + + + + + + + + + +
+
+
+

Module parflow.cli.pfdist_sort

+
+
+
+ +Expand source code + +
import os
+import sys
+import argparse
+
+from parflow.tools.io import read_pfidb, write_dict_as_pfidb
+from parflow.tools.helper import sort_dict
+
+def writeSortedPFIDB(input_file, output_file=None):
+  if not os.path.exists(input_file):
+    print(f'Input file does not exist: {input_file}')
+    return
+
+  if output_file is None:
+    output_file = input_file
+
+  write_dict_as_pfidb(sort_dict(read_pfidb(input_file)), output_file)
+
+
+if __name__ == "__main__":
+  parser = argparse.ArgumentParser(description="Parflow PFidb sorter")
+  parser.add_argument("--input-file", "-i",
+                       default=None,
+                       dest="input",
+                       help="Path to ParFlow database file to sort")
+  parser.add_argument("--output-file", "-o",
+                       default=None,
+                       dest="output",
+                       help="Output file path to write sorted result to")
+  args = parser.parse_args()
+
+  if args.input is None:
+    parser.print_help()
+    sys.exit(0)
+
+  writeSortedPFIDB(args.input, args.output)
+
+
+
+
+
+
+
+

Functions

+
+
+def writeSortedPFIDB(input_file, output_file=None) +
+
+
+
+ +Expand source code + +
def writeSortedPFIDB(input_file, output_file=None):
+  if not os.path.exists(input_file):
+    print(f'Input file does not exist: {input_file}')
+    return
+
+  if output_file is None:
+    output_file = input_file
+
+  write_dict_as_pfidb(sort_dict(read_pfidb(input_file)), output_file)
+
+
+
+
+
+
+
+ +
+ + + \ No newline at end of file diff --git a/docs/html/parflow/cli/tcl2py.html b/docs/html/parflow/cli/tcl2py.html new file mode 100644 index 0000000..1bd1c07 --- /dev/null +++ b/docs/html/parflow/cli/tcl2py.html @@ -0,0 +1,239 @@ + + + + + + +parflow.cli.tcl2py API documentation + + + + + + + + + + + +
+
+
+

Module parflow.cli.tcl2py

+
+
+
+ +Expand source code + +
import os
+import sys
+import argparse
+
+def tclToPython(inputFile, outputFile = None, runname = None):
+  try:
+    if runname is None:
+      basename = os.path.basename(inputFile)
+      lastIndex = basename.rindex('.')
+      runname = basename[:lastIndex]
+
+    if outputFile is None:
+      lastIndex = inputFile.rindex('.')
+      outputFile = f'{inputFile[:lastIndex]}.py'
+  except:
+    print(f'Invalid input file: {inputFile}')
+    return
+
+  if not os.path.exists(inputFile):
+    print(f'Input file does not exist: {inputFile}')
+    return
+
+  runstr = str(runname) + '.'
+  with open(inputFile, 'r') as fin:
+    with open(outputFile, 'w') as fout:
+      lines = fin.readlines()
+      prevLine = ''
+      for line in lines:
+        newline = line
+        if 'lappend auto_path $env(PARFLOW_DIR)/bin' in newline:
+          newline = 'from parflow import Run\n'
+
+        if 'package require parflow' in newline:
+          newline = ''
+
+        if 'namespace import Parflow::*' in newline:
+          newline = f'{runname} = Run("{runname}", __file__)\n'
+
+        if newline[0:6] == 'pfset ':
+          newline = newline.replace('pfset ', runstr)
+          newline_subs = newline.split()
+          newline_subs[0] = newline_subs[0].replace('-', '_')
+          if newline_subs[1][0].isalpha() or newline_subs[1][0] == "\"":
+            newline = newline_subs[0] + ' = ' + "'" + ' '.join(newline_subs[1:]) + "'" + '\n'
+            newline = newline.replace('-', '_').replace('\"', '').replace("'False'", "False").replace("'True'", "True")
+          elif newline_subs[1][0] == '$' and len(newline_subs) == 2:
+            newline = newline_subs[0] + ' = ' + newline_subs[1][1:] + '\n'
+          else:
+            newline = newline_subs[0] + ' = ' + ' '.join(newline_subs[1:]) + '\n'
+
+        if newline[0:4] == 'set ' and 'runname' not in newline:
+          newline = newline.replace('set ', '')
+          newline_subs = newline.split()
+          if newline_subs[1][0].isalpha():
+            newline = newline_subs[0] + ' = ' + "'" + ' '.join(newline_subs[1:]) + "'" + '\n'
+          else:
+            newline = newline_subs[0] + ' = ' + ' '.join(newline_subs[1:]) + '\n'
+
+        # commenting out all lines of code that haven't been edited yet
+        if newline[0:1] != '#' and newline[0:1] != '\n' and newline == line:
+          # testing for lines that continue to the next line
+          if len(prevLine) >= 2 and prevLine[-2] == "\\":
+            pass
+          else:
+            newline = '# ' + newline
+
+        prevLine = newline
+
+        fout.write(newline)
+
+      fout.write(f'{runname}.run()\n')
+
+
+if __name__ == "__main__":
+  parser = argparse.ArgumentParser(description="Parflow TCL script converter")
+  parser.add_argument("--name", "-n",
+                       default=None,
+                       dest="name",
+                       help="Name of the run to use")
+  parser.add_argument("--input-file", "-i",
+                       default=None,
+                       dest="input",
+                       help="Path to ParFlow TCL script to convert")
+  parser.add_argument("--output-file", "-o",
+                       default=None,
+                       dest="output",
+                       help="Python file path to use for writting the converted input")
+
+  args = parser.parse_args()
+
+  if args.input is None:
+    parser.print_help()
+    sys.exit(0)
+
+  tclToPython(args.input, args.output, args.name)
+
+
+
+
+
+
+
+

Functions

+
+
+def tclToPython(inputFile, outputFile=None, runname=None) +
+
+
+
+ +Expand source code + +
def tclToPython(inputFile, outputFile = None, runname = None):
+  try:
+    if runname is None:
+      basename = os.path.basename(inputFile)
+      lastIndex = basename.rindex('.')
+      runname = basename[:lastIndex]
+
+    if outputFile is None:
+      lastIndex = inputFile.rindex('.')
+      outputFile = f'{inputFile[:lastIndex]}.py'
+  except:
+    print(f'Invalid input file: {inputFile}')
+    return
+
+  if not os.path.exists(inputFile):
+    print(f'Input file does not exist: {inputFile}')
+    return
+
+  runstr = str(runname) + '.'
+  with open(inputFile, 'r') as fin:
+    with open(outputFile, 'w') as fout:
+      lines = fin.readlines()
+      prevLine = ''
+      for line in lines:
+        newline = line
+        if 'lappend auto_path $env(PARFLOW_DIR)/bin' in newline:
+          newline = 'from parflow import Run\n'
+
+        if 'package require parflow' in newline:
+          newline = ''
+
+        if 'namespace import Parflow::*' in newline:
+          newline = f'{runname} = Run("{runname}", __file__)\n'
+
+        if newline[0:6] == 'pfset ':
+          newline = newline.replace('pfset ', runstr)
+          newline_subs = newline.split()
+          newline_subs[0] = newline_subs[0].replace('-', '_')
+          if newline_subs[1][0].isalpha() or newline_subs[1][0] == "\"":
+            newline = newline_subs[0] + ' = ' + "'" + ' '.join(newline_subs[1:]) + "'" + '\n'
+            newline = newline.replace('-', '_').replace('\"', '').replace("'False'", "False").replace("'True'", "True")
+          elif newline_subs[1][0] == '$' and len(newline_subs) == 2:
+            newline = newline_subs[0] + ' = ' + newline_subs[1][1:] + '\n'
+          else:
+            newline = newline_subs[0] + ' = ' + ' '.join(newline_subs[1:]) + '\n'
+
+        if newline[0:4] == 'set ' and 'runname' not in newline:
+          newline = newline.replace('set ', '')
+          newline_subs = newline.split()
+          if newline_subs[1][0].isalpha():
+            newline = newline_subs[0] + ' = ' + "'" + ' '.join(newline_subs[1:]) + "'" + '\n'
+          else:
+            newline = newline_subs[0] + ' = ' + ' '.join(newline_subs[1:]) + '\n'
+
+        # commenting out all lines of code that haven't been edited yet
+        if newline[0:1] != '#' and newline[0:1] != '\n' and newline == line:
+          # testing for lines that continue to the next line
+          if len(prevLine) >= 2 and prevLine[-2] == "\\":
+            pass
+          else:
+            newline = '# ' + newline
+
+        prevLine = newline
+
+        fout.write(newline)
+
+      fout.write(f'{runname}.run()\n')
+
+
+
+
+
+
+
+ +
+ + + \ No newline at end of file diff --git a/docs/html/parflow/index.html b/docs/html/parflow/index.html index f6775f8..1e4579f 100644 --- a/docs/html/parflow/index.html +++ b/docs/html/parflow/index.html @@ -5,8 +5,7 @@ parflow API documentation - + @@ -23,25 +22,36 @@

Package parflow

-

Python tools for working the ParFlow Hydrologic Model -(virtual namespace added for package)

+

parflow module

+

Export Run() object

Expand source code -
"""Python tools for working the ParFlow Hydrologic Model
-(virtual namespace added for package)
+
# -*- coding: utf-8 -*-
+"""parflow module
+
+Export Run() object
+
 """
-__import__("pkg_resources").declare_namespace(__name__)
+from .tools import Run

Sub-modules

+
parflow.cli
+
+
+
parflow.subset

Tools for clipping gridded ParFlow inputs and outputs

+
parflow.tools
+
+

parflow.tools module …

+
@@ -59,7 +69,9 @@

Index

diff --git a/docs/html/parflow/subset/bbox.html b/docs/html/parflow/subset/bbox.html index 659e1eb..79acc5a 100644 --- a/docs/html/parflow/subset/bbox.html +++ b/docs/html/parflow/subset/bbox.html @@ -116,6 +116,16 @@

Module parflow.subset.bbox

y_end = y_0 + self.pad_top + self.pad_bottom + self.ny return y_0, y_end, x_0, x_end + def get_padding(self): + """ get the padding values for the bbox + + Returns + ------- + tuple of ints + padding values in (top, right, bot, left) format + """ + return tuple([self.pad_top, self.pad_right, self.pad_bottom, self.pad_left]) + def get_system_bbox(self): """get 0's based bbox values """ @@ -257,6 +267,16 @@

Returns

y_end = y_0 + self.pad_top + self.pad_bottom + self.ny return y_0, y_end, x_0, x_end + def get_padding(self): + """ get the padding values for the bbox + + Returns + ------- + tuple of ints + padding values in (top, right, bot, left) format + """ + return tuple([self.pad_top, self.pad_right, self.pad_bottom, self.pad_left]) + def get_system_bbox(self): """get 0's based bbox values """ @@ -364,6 +384,31 @@

Returns

return y_0, y_end, x_0, x_end +
+def get_padding(self) +
+
+

get the padding values for the bbox

+

Returns

+
+
tuple of ints
+
padding values in (top, right, bot, left) format
+
+
+ +Expand source code + +
def get_padding(self):
+    """ get the padding values for the bbox
+
+    Returns
+    -------
+    tuple of ints
+        padding values in (top, right, bot, left) format
+    """
+    return tuple([self.pad_top, self.pad_right, self.pad_bottom, self.pad_left])
+
+
def get_system_bbox(self)
@@ -403,6 +448,7 @@

B
  • get_human_bbox
  • get_inner_extents
  • get_padded_extents
  • +
  • get_padding
  • get_system_bbox
  • diff --git a/docs/html/parflow/subset/clipper.html b/docs/html/parflow/subset/clipper.html index 4977b01..38ed6e6 100644 --- a/docs/html/parflow/subset/clipper.html +++ b/docs/html/parflow/subset/clipper.html @@ -59,18 +59,6 @@

    Module parflow.subset.clipper

    class BoxClipper(Clipper): """Clip a rectangular data region specified by a bounding box - self.padding = padding - self.no_data = no_data - self.ref_array = ref_array - if nx is None: - nx = self.ref_array.shape[2] - if ny is None: - ny = self.ref_array.shape[1] - if nz is None: - nz = self.ref_array.shape[0] - if nx < 1 or ny < 1 or nz < 1 or x < 1 or y < 1 or z < 1: - raise Exception("Error: invalid dimension, x,y,z nx, ny, nz must be >=1") - self.update_bbox(x, y, z, nx, ny, nz, padding) """ def __repr__(self): return f"{self.__class__.__name__}(x_0:{self.x_0}, x_end:{self.x_end}, y_0:{self.y_0}, y_end:{self.y_end}, " \ @@ -185,11 +173,10 @@

    Module parflow.subset.clipper

    # create a full dimensioned array of no_data_values ret_array = np.full(shape=(self.nz, self.ny + self.padding[0] + self.padding[2], - self.nx + self.padding[1] + self.padding[3]), fill_value=self.no_data, dtype=np.float64) + self.nx + self.padding[1] + self.padding[3]), fill_value=self.no_data, dtype=data_array.dtype) # assign values from the data_array into the return array, mind the padding ret_array[self.z_0:self.z_end, self.padding[2]:self.ny + self.padding[2], - self.padding[3]:self.nx + self.padding[3]] = data_array[self.z_0:self.z_end, self.y_0:self.y_end, - self.x_0:self.x_end] + self.padding[3]:self.nx + self.padding[3]] = data_array[self.z_0:self.z_end, self.y_0:self.y_end,self.x_0:self.x_end] else: ret_array = data_array[self.z_0:self.z_end, self.y_0:self.y_end, self.x_0:self.x_end] return ret_array, None, None, None @@ -293,7 +280,8 @@

    Module parflow.subset.clipper

    BBox object describing the mask bounds """ self.bbox = bbox.get_human_bbox() - self.clipper = BoxClipper(ref_array=None, x=self.bbox[0], y=self.bbox[1], nx=self.bbox[2], ny=self.bbox[3], + padded_extents = bbox.get_padded_extents() + self.clipper = BoxClipper(ref_array=None, x=padded_extents[2]+1, y=padded_extents[0]+1, nx=padded_extents[3]-padded_extents[2], ny=padded_extents[1]-padded_extents[0], nz=1) def clip_latlon(self, lat_lon_file): @@ -424,19 +412,7 @@

    Classes

    (ref_array, x=1, y=1, z=1, nx=None, ny=None, nz=None, padding=(0, 0, 0, 0), no_data=-999)
    -

    Clip a rectangular data region specified by a bounding box -self.padding = padding -self.no_data = no_data -self.ref_array = ref_array -if nx is None: -nx = self.ref_array.shape[2] -if ny is None: -ny = self.ref_array.shape[1] -if nz is None: -nz = self.ref_array.shape[0] -if nx < 1 or ny < 1 or nz < 1 or x < 1 or y < 1 or z < 1: -raise Exception("Error: invalid dimension, x,y,z nx, ny, nz must be >=1") -self.update_bbox(x, y, z, nx, ny, nz, padding)

    +

    Clip a rectangular data region specified by a bounding box

    Parameters

    ref_array : ndarray
    @@ -474,18 +450,6 @@

    Raises

    class BoxClipper(Clipper):
         """Clip a rectangular data region specified by a bounding box
    - self.padding = padding
    -        self.no_data = no_data
    -        self.ref_array = ref_array
    -        if nx is None:
    -            nx = self.ref_array.shape[2]
    -        if ny is None:
    -            ny = self.ref_array.shape[1]
    -        if nz is None:
    -            nz = self.ref_array.shape[0]
    -        if nx < 1 or ny < 1 or nz < 1 or x < 1 or y < 1 or z < 1:
    -            raise Exception("Error: invalid dimension, x,y,z nx, ny, nz must be >=1")
    -        self.update_bbox(x, y, z, nx, ny, nz, padding)
         """
         def __repr__(self):
             return f"{self.__class__.__name__}(x_0:{self.x_0}, x_end:{self.x_end}, y_0:{self.y_0}, y_end:{self.y_end}, " \
    @@ -600,11 +564,10 @@ 

    Raises

    # create a full dimensioned array of no_data_values ret_array = np.full(shape=(self.nz, self.ny + self.padding[0] + self.padding[2], - self.nx + self.padding[1] + self.padding[3]), fill_value=self.no_data, dtype=np.float64) + self.nx + self.padding[1] + self.padding[3]), fill_value=self.no_data, dtype=data_array.dtype) # assign values from the data_array into the return array, mind the padding ret_array[self.z_0:self.z_end, self.padding[2]:self.ny + self.padding[2], - self.padding[3]:self.nx + self.padding[3]] = data_array[self.z_0:self.z_end, self.y_0:self.y_end, - self.x_0:self.x_end] + self.padding[3]:self.nx + self.padding[3]] = data_array[self.z_0:self.z_end, self.y_0:self.y_end,self.x_0:self.x_end] else: ret_array = data_array[self.z_0:self.z_end, self.y_0:self.y_end, self.x_0:self.x_end] return ret_array, None, None, None
    @@ -655,11 +618,10 @@

    Returns

    # create a full dimensioned array of no_data_values ret_array = np.full(shape=(self.nz, self.ny + self.padding[0] + self.padding[2], - self.nx + self.padding[1] + self.padding[3]), fill_value=self.no_data, dtype=np.float64) + self.nx + self.padding[1] + self.padding[3]), fill_value=self.no_data, dtype=data_array.dtype) # assign values from the data_array into the return array, mind the padding ret_array[self.z_0:self.z_end, self.padding[2]:self.ny + self.padding[2], - self.padding[3]:self.nx + self.padding[3]] = data_array[self.z_0:self.z_end, self.y_0:self.y_end, - self.x_0:self.x_end] + self.padding[3]:self.nx + self.padding[3]] = data_array[self.z_0:self.z_end, self.y_0:self.y_end,self.x_0:self.x_end] else: ret_array = data_array[self.z_0:self.z_end, self.y_0:self.y_end, self.x_0:self.x_end] return ret_array, None, None, None @@ -848,7 +810,8 @@

    Parameters

    BBox object describing the mask bounds """ self.bbox = bbox.get_human_bbox() - self.clipper = BoxClipper(ref_array=None, x=self.bbox[0], y=self.bbox[1], nx=self.bbox[2], ny=self.bbox[3], + padded_extents = bbox.get_padded_extents() + self.clipper = BoxClipper(ref_array=None, x=padded_extents[2]+1, y=padded_extents[0]+1, nx=padded_extents[3]-padded_extents[2], ny=padded_extents[1]-padded_extents[0], nz=1) def clip_latlon(self, lat_lon_file): diff --git a/docs/html/parflow/subset/data/index.html b/docs/html/parflow/subset/data/index.html index 00ecae1..41fd608 100644 --- a/docs/html/parflow/subset/data/index.html +++ b/docs/html/parflow/subset/data/index.html @@ -35,6 +35,13 @@

    Module parflow.subset.data

    +

    Sub-modules

    +
    +
    parflow.subset.data.parking_lot_template
    +
    +
    +
    +
    @@ -54,6 +61,11 @@

    Index

  • parflow.subset
  • +
  • Sub-modules

    + +
  • diff --git a/docs/html/parflow/subset/domain.html b/docs/html/parflow/subset/domain.html index 725e1c3..3b88a08 100644 --- a/docs/html/parflow/subset/domain.html +++ b/docs/html/parflow/subset/domain.html @@ -249,10 +249,25 @@

    Module parflow.subset.domain

    if manifest_file is None: manifest_file = data.conus_manifest super().__init__('conus', local_path, manifest_file, version) - # self.mask_array = self.mask_tif.ReadAsArray() # had to do this because conus1 full_dim_mask is all 0's if self.version == 1: self.mask_array = self.get_domain_mask() + 1 + self.mask_array = self.mask_array * 3 + self._patch_map = {1: 'land', 3: 'top', 5: 'sink', 6: 'bottom'} + elif self.version == 2: + self._patch_map = {1: 'ocean', 2: 'land', 3: 'top', 4: 'lakes', 5: 'sink', 6: 'bottom'} + self._border_mask = None + + def get_border_mask(self): + if self._border_mask is None: + tif_filename = os.path.join(self.local_path, self.required_files.get('CELL_TYPES')) + self._border_mask = file_io_tools.read_file(tif_filename) + if self.version == 1: + self._border_mask = self._border_mask + 1 + return self._border_mask + + def get_patch_name(self, patch_id): + return self._patch_map.get(patch_id) def __repr__(self): return f"{self.__class__.__name__}(name:{self.name!r}, version:{self.version!r}, " \ @@ -315,10 +330,25 @@

    Returns

    if manifest_file is None: manifest_file = data.conus_manifest super().__init__('conus', local_path, manifest_file, version) - # self.mask_array = self.mask_tif.ReadAsArray() # had to do this because conus1 full_dim_mask is all 0's if self.version == 1: self.mask_array = self.get_domain_mask() + 1 + self.mask_array = self.mask_array * 3 + self._patch_map = {1: 'land', 3: 'top', 5: 'sink', 6: 'bottom'} + elif self.version == 2: + self._patch_map = {1: 'ocean', 2: 'land', 3: 'top', 4: 'lakes', 5: 'sink', 6: 'bottom'} + self._border_mask = None + + def get_border_mask(self): + if self._border_mask is None: + tif_filename = os.path.join(self.local_path, self.required_files.get('CELL_TYPES')) + self._border_mask = file_io_tools.read_file(tif_filename) + if self.version == 1: + self._border_mask = self._border_mask + 1 + return self._border_mask + + def get_patch_name(self, patch_id): + return self._patch_map.get(patch_id) def __repr__(self): return f"{self.__class__.__name__}(name:{self.name!r}, version:{self.version!r}, " \ @@ -329,6 +359,40 @@

    Ancestors

    +

    Methods

    +
    +
    +def get_border_mask(self) +
    +
    +
    +
    + +Expand source code + +
    def get_border_mask(self):
    +    if self._border_mask is None:
    +        tif_filename = os.path.join(self.local_path, self.required_files.get('CELL_TYPES'))
    +        self._border_mask = file_io_tools.read_file(tif_filename)
    +        if self.version == 1:
    +            self._border_mask = self._border_mask + 1
    +    return self._border_mask
    +
    +
    +
    +def get_patch_name(self, patch_id) +
    +
    +
    +
    + +Expand source code + +
    def get_patch_name(self, patch_id):
    +    return self._patch_map.get(patch_id)
    +
    +
    +

    Inherited members