NCAR / wrf_hydro_gis_preprocessor

MIT License
21 stars 11 forks source link

issue in Build_Routing_Stack.py #8

Open chrisrac opened 1 year ago

chrisrac commented 1 year ago
/home/chris/wrf-hydro/GIS_Training/Build_Routing_Stack.py:28: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
  from distutils.version import LooseVersion
Script initiated at Sun Feb 12 17:45:55 2023
  Parameter values that have not been altered from script default values:
    Using default basin mask setting: False
    Using default reach-based routing setting: False
    Using default regridding factor: 10
    Using default stream initiation threshold: 200
    Using default OVROUGHRTFAC parameter value: 1.0
    Using default RETDEPRTFAC parameter value: 1.0
  Values that will be used in building this routing stack:
    Input WPS Geogrid file: /home/chris/wrf-hydro/GIS_Training/GIS_DATA/geo_em.d01.nc
    Forecast Point CSV file: 
    Mask CHANNELGRID variable to forecast basins?: False
    Create reach-based routing (RouteLink) files?: False
    Lake polygon feature class: 
    Input high-resolution DEM: /home/chris/wrf-hydro/GIS_Training/GIS_DATA/na_dem_3s.tif
    Regridding factor: 10
    Stream initiation threshold: 200
    OVROUGHRTFAC parameter value: 1.0
    RETDEPRTFAC parameter value: 1.0
    Input channel initiation start point feature class: None
    Input groundwater basin polygons: None
    Output ZIP file: /home/chris/wrf-hydro/GIS_Training/Outputs/chris_test.zip
  Running Process GEOGRID function
  Reach-based routing files will not be created.
WPS netCDF projection identification initiated...
    Map Projection: Lambert Conformal Conic
    Using MOAD_CEN_LAT for latitude of origin.
    Using Standard Parallel 2 in Lambert Conformal Conic map projection.
    Geo-referencing step completed without error in  0.03 seconds.
Traceback (most recent call last):
  File "/home/chris/wrf-hydro/GIS_Training/Build_Routing_Stack.py", line 488, in <module>
    GEOGRID_STANDALONE(args.in_Geogrid,
  File "/home/chris/wrf-hydro/GIS_Training/Build_Routing_Stack.py", line 190, in GEOGRID_STANDALONE
    fine_grid = copy.copy(coarse_grid)                                          # Copy the grid object for modification
AttributeError: 'function' object has no attribute 'copy'

any propositions for fixes? (yes, import copy is working, and calling copy.copy(something) outside this script is working normally

also imports of grib, osr, gdal and gdalnumeric are not working, unless changed manually to

from osgeo import osr
from osgeo import gdal
from osgeo.gdalnumeric import *
kmsampson commented 1 year ago

@chrisrac Sorry for the delay. I have been working with one other WRF-Hydro user who encountered similar issues on a Mac. I was able to find a MacOS (11.7.3 Big Sur) to test with. Some very small changes allowed the Build_Routing_Stack.py script to function properly. See commit 02a3171667b9a5b698506d382dae7440b92ab7a2 for specific details. I tried to replicate the copy error, but could not. I did change some of the library syntax, so let us know if that fixes the copy error.

As far as the GDAL imports, this should have been addressed already with some LooseVersion checks against the GDAL library versions. If GDAL > 3.0.0 then it will import with from osgeo import gdal style syntax.

Try pulling the current master and let us know if you continue to encounter the error.