Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve setup validation #97

Merged
merged 14 commits into from Sep 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/whats-new.rst
Expand Up @@ -15,6 +15,8 @@ Enhancements
By `Joe Hamman <https://github.com/jhamman>`_.
- Added option a flexible time grouper when chunking MetSim runs (:issue:`93`).
By `Joe Hamman <https://github.com/jhamman>`_.
- Improved configuration validation by checking for correctness of output variables (:issue:`96`)
By `Andrew Bennett <https://github.com/arbennett>`

Bug fixes
~~~~~~~~~
Expand Down
13 changes: 13 additions & 0 deletions metsim/metsim.py
Expand Up @@ -477,6 +477,19 @@ def _validate_setup(self):
if not len(self.params['out_vars']):
errs.append("Output variable list must not be empty")

# Check output variables are valid
daily_out_vars = ['t_min', 't_max', 'prec', 'swe', 'vapor_pressure',
'shortwave', 'tskc', 'pet', 'wind']
out_var_check = ['temp', 'prec', 'shortwave', 'vapor_pressure',
'air_pressure', 'rel_humid', 'spec_humid',
'longwave', 'tsck', 'wind']
if int(self.params['time_step']) == 1440:
out_var_check = daily_out_vars
for var in self.params['out_vars']:
if var not in out_var_check:
errs.append('Cannot output variable {} at timestep {}'.format(
var, self.params['time_step']))

# Check that the parameters specified are available
opts = {'mtclim_swe_corr': [True, False],
'out_precision': ['f4', 'f8'],
Expand Down