Skip to content

Commit

Permalink
added try catch for python time function to check out of range values
Browse files Browse the repository at this point in the history
  • Loading branch information
snowman2 committed Jan 22, 2016
1 parent 0fff015 commit 1b0d5a4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion RAPIDpy/helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,11 @@ def write_flows_to_csv(path_to_rapid_qout_file, path_to_output_file,
if 'time' in nc_vars:
if len(data_nc.dimensions['time'])>0:
if not (data_nc.variables['time'][:] == masked).any():
time_var_valid = True
try:
time.gmtime(data_nc.variables['time'][0])
time_var_valid = True
except ValueError:
pass

#analyze and write
if time_var_valid:
Expand Down Expand Up @@ -194,3 +198,4 @@ def write_flows_to_csv(path_to_rapid_qout_file, path_to_output_file,
writer.writerow([index, qout[index]])

data_nc.close()
return time_var_valid

0 comments on commit 1b0d5a4

Please sign in to comment.