UW-Hydro / tonic

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

Problem in `regular_grid` and `DOMAIN` logic #26

Open orianac opened 8 years ago

orianac commented 8 years ago

The VIC2nc converter doesn't behave in a very friendly way if we don't have the regular_grid and DOMAIN sections of the config file set up properly.

The two pertinent sections of the config file are below:

# input grid type (if False, Read from domain section below)
# valid values: True, False
regular_grid: True

and

# Grid File (domain file): uncomment if grid is irregular or you want to use a domain file
[DOMAIN]
filename: /Users/jhamman/Dropbox/RASM_Joe/routing_inputs/pour_points/domain.lnd.wr50a_ar9v4.100920.nc
longitude_var: xc
latitude_var: yc
y_x_dims: nj, ni
# Non-coordinate variables to include in each netcdf
copy_vars: frac, mask, area, xv, yv

If you set regular_grid: True and comment out the DOMAIN section the script runs fine. If you set regular_grid: False and leave in the DOMAIN section the script also runs fine. But if you set regular_grid: True and leave in the DOMAIN section the script spits out this error:

Traceback (most recent call last):
 File "/home/mbapt/anaconda/envs/tonic/bin/vic_utils", line 4, in <module>
   __import__('pkg_resources').run_script('tonic===0.0.0.dev-c3c957e', 'vic_utils')
 File "/home/mbapt/anaconda/envs/tonic/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/pkg_resources/__init__.py", line 745, in run_script
 File "/home/mbapt/anaconda/envs/tonic/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/pkg_resources/__init__.py", line 1677, in run_script
 File "/home/mbapt/anaconda/envs/tonic/lib/python2.7/site-packages/tonic-0.0.0.dev_c3c957e-py2.7.egg/EGG-INFO/scripts/vic_utils", line 221, in <module>

 File "/home/mbapt/anaconda/envs/tonic/lib/python2.7/site-packages/tonic-0.0.0.dev_c3c957e-py2.7.egg/EGG-INFO/scripts/vic_utils", line 197, in main

 File "build/bdist.linux-x86_64/egg/tonic/models/vic/vic2netcdf.py", line 505, in _run
 File "build/bdist.linux-x86_64/egg/tonic/models/vic/vic2netcdf.py", line 722, in vic2nc
 File "build/bdist.linux-x86_64/egg/tonic/models/vic/vic2netcdf.py", line 428, in nc_fields
ValueError: Field DOMAIN missing units                                      attribute

Can we include logic in the code to accommodate the instance in which regular_grid: True and the DOMAIN section is present? Or at least have a more informative error message?