UW-Hydro / tonic

A pre/post processing toolbox for hydrologic models
MIT License
20 stars 33 forks source link

module 'tonic.models.vic.grid_params' has no attribute 'cols' or 'format' #77

Open danhamill opened 2 years ago

danhamill commented 2 years ago

I am trying to convert a netcdf file representing the livenh dataset back to ascii to ensure the conversion from #76 worked.

My Script is:

from tonic.models.vic.ncparam2ascii import subset

param_file =   r'livenh\livenh.params.vic5.nc'
veg_export  =  r"livenh\output\veg.txt"
snow_export =  r"livenh\output\snow.txt"
soil_export =  r"livenh\output\soil.txt"

subset(param_file, soil_file = soil_export,
       snow_file = snow_export, veg_file = veg_export,
       )

It appeared to complete the veg file export, but failed on the snow export.

Exception has occurred: AttributeError
module 'tonic.models.vic.grid_params' has no attribute 'cols'
  File "C:\workspace\git_clones\tonic\tonic\models\vic\ncparam2ascii.py", line 328, in snow
    c = grid_params.cols(snow_bands=snow_bands)
  File "C:\workspace\git_clones\tonic\tonic\models\vic\ncparam2ascii.py", line 59, in subset
    snow(data, xinds, yinds, snow_file)
  File "C:\workspace\git_clones\tonic\tests\levenh_to_ascii.py", line 9, in <module>
    subset(param_file, soil_file = soil_export,

https://github.com/UW-Hydro/tonic/blob/67cc1a1efa481a65e304917bc8af36c2a30af055/tonic/models/vic/ncparam2ascii.py#L321-L350

grid_params appears to have the attribute Cols as apposed to cols.

After inspecting the output veg file, I see this in the output:

450000 2
6 0.828125 0.1 0.1 1.0 0.65 1.0 0.25 
1.68 1.52 1.68 2.9 4.9 5.0 5.0 4.6 3.44 3.04 2.16 2.0 
7 0.171875 0.1 0.1 1.0 0.65 1.0 0.25 
2.0 2.25 2.95 3.85 3.75 3.5 3.55 3.2 3.3 2.85 2.6 2.2 

And this is from the Livenh input file I started with:

450000 2
6 0.828125 0.10 0.10 1.00 0.65 1.00 0.25 
0.175 0.238 0.275 0.275 0.425 0.825 1.175 1.300 0.837 0.350 0.200 0.175 
7 0.171875 0.10 0.10 1.00 0.65 1.00 0.25 
0.487 0.500 0.213 0.213 0.400 0.875 1.525 1.562 0.775 0.363 0.225 0.350 

I believe the mistaken lines represent monthly LAI numbers. Why are they different?

danhamill commented 2 years ago

Similarly, grid_params has the attribute Format as apposed to format

Exception has occurred: AttributeError
module 'tonic.models.vic.grid_params' has no attribute 'format'
  File "C:\workspace\git_clones\tonic\tonic\models\vic\ncparam2ascii.py", line 329, in snow
    f = grid_params.format(snow_bands=snow_bands)
  File "C:\workspace\git_clones\tonic\tonic\models\vic\ncparam2ascii.py", line 59, in subset
    snow(data, xinds, yinds, snow_file)
  File "C:\workspace\git_clones\tonic\tests\levenh_to_ascii.py", line 9, in <module>
    subset(param_file, soil_file = soil_export,

https://github.com/UW-Hydro/tonic/blob/67cc1a1efa481a65e304917bc8af36c2a30af055/tonic/models/vic/ncparam2ascii.py#L321-L350