Open danhamill opened 2 years ago
Additionally, the VIC user manual page for tonic seems to be assuming people are using the develop branch (which appears to be more than 5-years old).
To get the tonic example from the user manual to work I had to add a few imports and change the argument 'version' in develop (which I assume means which version you want to write to) to 'version_in' in master (which seems to mean what version of the VIC the ascii files were originally from)
I am working under the assumption I should be using the master branch. Is that correct?
Apparently the issue was related to veg_class
returing two items. That made veg_lib
a tuple and failed in grid_param
.
Full working script:
from tonic.models.vic.grid_params import soil, snow, veg, veg_class, Cols, Desc, write_netcdf, grid_params, calc_grid
# Read the soil parameters
soil_dict = soil(r'livenh\vic.nldas.mexico.soil.txt', c=Cols(nlayers=3))
# Read the snow parameters
snow_dict = snow(r'livenh\vic.nldas.mexico.snow.txt.L13',
soil_dict, c=Cols(snow_bands=5))
# Read the veg parameter file
veg_dict = veg(r'livenh\vic.nldas.mexico.veg.txt',
soil_dict,
vegparam_lai=True,
veg_classes=11)
# Read the veg library file
veg_lib, lib_bare_idx= veg_class(r'livenh\LDAS_veg_lib')
# Determine the grid shape
target_grid, target_attrs = calc_grid(soil_dict['lats'], soil_dict['lons'])
# Grid all the parameters
grid_dict = grid_params(soil_dict, target_grid, version_in = '4.1.2',
veg_dict=veg_dict, veglib_dict=veg_lib, snow_dict=snow_dict,
)
# Write a netCDF file with all the parameters
write_netcdf(r'livenh\livenh.params.vic5.nc', target_attrs,
target_grid=target_grid,
soil_grid=grid_dict['soil_dict'],
snow_grid=grid_dict['snow_dict'],
veg_grid=grid_dict['veg_dict'],
version_in='4.1.2')
Posing here in case somebody else runs into this issue.
I am trying to convert the livenh VIC parameter files to netcdf format.
I have installed tonic to a python 3.9 environment with these packages:
I am getting the following trace back from
grid_params
Which points to Line 1013 of grid_params.py and read as:
Here is my script:
Could I be missing something in
veg
?