Skip to content

Commit 4d7ae7a

Browse files
committed
fixed some bugs related to first optr.srad
1 parent a37824f commit 4d7ae7a

4 files changed

Lines changed: 1568 additions & 1559 deletions

File tree

prms_python/data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Data(object):
1717
"""
1818
Object that reads the PRMS data file and loads it into a date-time indexed
1919
DataFrame for data management, analysis and visualization. The ``modify``
20-
method allow for inplace modification of one or more time series inputs in the
20+
method allows for inplace modification of one or more time series inputs in the
2121
data file based on a user defined function. The ``write`` method reformats the
2222
Dataframe to PRMS text format and writes a new data file to disk. Here is an
2323
example of loading a data file, modifying the temperature inputs ('tmin' and
@@ -30,7 +30,7 @@ class Data(object):
3030
>>> d.modify(f,['tmax','tmin'])
3131
>>> d.write('example_modified_data_file')
3232
33-
d is a Data instance of the example data file, calling
33+
d is a Data instance of example_data_file, calling
3434
3535
>>> d.DataFrame
3636

prms_python/optimizer.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ class Optimizer:
3535
>>> optr.srad('path/to/reference_data/measured_srad.csv', srad_hru)
3636
3737
'''
38+
39+
## constant attributes for allowable range of solrad parameters
40+
dday_int = (-60.0, 10.0)
41+
dday_slope = (0.2, 0.9)
3842

3943
def __init__(self, parameters, data, control_file, working_dir,
4044
title=None, description=None):
@@ -50,12 +54,15 @@ def __init__(self, parameters, data, control_file, working_dir,
5054
else:
5155
raise TypeError('data must be instance of Data')
5256

57+
if not os.path.isdir(working_dir):
58+
os.mkdir(working_dir)
59+
5360
self.control_file = control_file
5461
self.working_dir = working_dir
5562
self.title = title
5663
self.description = description
5764

58-
def srad(self, reference_srad_path, station_nhru, method='',
65+
def srad(self, reference_srad_path, station_nhru, method='',
5966
dday_intcp_range=None, dday_slope_range=None,
6067
intcp_delta=None, slope_delta=None, nproc=None):
6168
'''
@@ -134,7 +141,7 @@ def _error(x, y):
134141
(
135142
output['simulation_dir'],
136143
_error(measured_srad,
137-
output['statvar']['swrad ' + str(station_nhru)])
144+
output['statvar']['swrad_' + str(station_nhru)])
138145
)
139146

140147
for output in outputs

prms_python/util.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,10 @@ def load_statvar(statvar_file):
7070
def load_data_file(data_file):
7171
"""
7272
Read the data file and load into a datetime indexed Pandas dataframe object
73-
INPUT: data_file = data file path (string)
74-
OUTPUT: df = Pandas dataframe of input time series data from data file with datetime index
73+
Arguments:
74+
data_file (string): data file path
75+
Returns:
76+
df (pandas.DataFrame): Pandas dataframe of input time series data from data file with datetime index
7577
"""
7678
# valid input time series that can be put into a data file
7779
valid_input_variables = ('gate_ht',

0 commit comments

Comments
 (0)