-
Notifications
You must be signed in to change notification settings - Fork 383
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Streamflow Diagnostics seasonality plots
- Loading branch information
Showing
16 changed files
with
891 additions
and
9 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
acme_diags/driver/default_diags/streamflow_model_vs_model.cfg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[#] | ||
sets = ["streamflow"] | ||
case_id = "seasonality" | ||
variables = ["RIVER_DISCHARGE_OVER_LAND_LIQ"] | ||
regions = ["global"] | ||
seasons = ["ANN"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[#] | ||
sets = ["streamflow"] | ||
case_id = "seasonality" | ||
variables = ["RIVER_DISCHARGE_OVER_LAND_LIQ"] | ||
ref_name = "GSIM" | ||
reference_name = "GSIM monthly streamflow (1986-1995)" | ||
regions = ["global"] | ||
seasons = ["ANN"] |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
from .core_parameter import CoreParameter | ||
|
||
|
||
class StreamflowParameter(CoreParameter): | ||
def __init__(self): | ||
super(StreamflowParameter, self).__init__() | ||
self.max_num_gauges = None | ||
self.test_mat_file = None | ||
self.ref_mat_file = None | ||
self.plot_type = 'seasonality' | ||
self.print_statements = False | ||
self.ref_timeseries_input = True | ||
self.test_timeseries_input = True | ||
self.granulate.remove('seasons') | ||
|
||
def check_values(self): | ||
if not hasattr(self, 'gauges_path'): | ||
msg = 'gauges_path must be specified' | ||
raise RuntimeError(msg) | ||
|
||
# TODO: In future pull requests add 'scatter', 'bias' | ||
valid_plot_types = ['seasonality'] | ||
if self.plot_type not in valid_plot_types: | ||
msg = 'plot_type={} not in {}'.format( | ||
self.plot_type, valid_plot_types) | ||
raise RuntimeError(msg) | ||
|
||
test_ref_start_yr_both_set = hasattr(self, 'test_start_yr') and hasattr(self, 'ref_start_yr') | ||
if hasattr(self, 'start_yr'): | ||
# Use `start_yr` as a default value for other parameters. | ||
if not hasattr(self, 'test_start_yr'): | ||
self.test_start_yr = self.start_yr | ||
if not hasattr(self, 'ref_start_yr'): | ||
self.ref_start_yr = self.start_yr | ||
elif test_ref_start_yr_both_set and self.test_start_yr == self.ref_start_yr: | ||
# Derive the value of self.start_yr | ||
self.start_yr = self.test_start_yr | ||
|
||
test_ref_end_yr_both_set = hasattr(self, 'test_end_yr') and hasattr(self, 'ref_end_yr') | ||
if hasattr(self, 'end_yr'): | ||
# Use `end_yr` as a default value for other parameters. | ||
if not hasattr(self, 'test_end_yr'): | ||
self.test_end_yr = self.end_yr | ||
if not hasattr(self, 'ref_end_yr'): | ||
self.ref_end_yr = self.end_yr | ||
elif test_ref_end_yr_both_set and self.test_end_yr == self.ref_end_yr: | ||
# Derive the value of self.end_yr | ||
self.end_yr = self.test_end_yr | ||
|
||
if hasattr(self, 'start_yr'): | ||
# We need to re-evaluate this variable, since these attributes could have been set. | ||
test_ref_end_yr_both_set = hasattr(self, 'test_end_yr') and hasattr(self, 'ref_end_yr') | ||
if not (hasattr(self, 'end_yr') or test_ref_end_yr_both_set): | ||
msg = "To use 'start_yr' you need to also define 'end_yr' or both 'test_end_yr' and 'ref_end_yr'." | ||
raise RuntimeError(msg) | ||
|
||
if hasattr(self, 'end_yr'): | ||
# We need to re-evaluate this variable, since these attributes could have been set. | ||
test_ref_start_yr_both_set = hasattr(self, 'test_start_yr') and hasattr(self, 'ref_start_yr') | ||
if not (hasattr(self, 'start_yr') or test_ref_start_yr_both_set): | ||
msg = "To use 'end_yr' you need to also define 'start_yr' or both 'test_start_yr' and 'ref_start_yr'." | ||
raise RuntimeError(msg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
from .core_parser import CoreParser | ||
from acme_diags.parameter.streamflow_parameter import StreamflowParameter | ||
|
||
|
||
class StreamflowParser(CoreParser): | ||
def __init__(self, *args, **kwargs): | ||
if 'parameter_cls' in kwargs: | ||
super().__init__(*args, **kwargs) | ||
else: | ||
super().__init__(parameter_cls=StreamflowParameter, *args, **kwargs) | ||
|
||
|
||
def load_default_args(self, files=[]): | ||
# This has '-p' and '--parameter' reserved. | ||
super().load_default_args(files) | ||
|
||
self.add_argument( | ||
'--gauges_path', | ||
dest='gauges_path', | ||
help='The file containing the gauge data.', | ||
action='store_const', | ||
const=True, | ||
required=False) | ||
|
||
self.add_argument( | ||
'--max_num_gauges', | ||
dest='max_num_gauges', | ||
help='The maximum number of gauges that should be processed.', | ||
action='store_const', | ||
const=True, | ||
required=False) | ||
|
||
self.add_argument( | ||
'--print_statements', | ||
dest='print_statements', | ||
help='Print information useful for debugging.', | ||
action='store_const', | ||
const=True, | ||
required=False) | ||
|
||
self.add_argument( | ||
'--ref_timeseries_input', | ||
dest='ref_timeseries_input', | ||
help='The input reference data are timeseries files.', | ||
action='store_const', | ||
const=True, | ||
required=False) | ||
|
||
self.add_argument( | ||
'--test_timeseries_input', | ||
dest='test_timeseries_input', | ||
help='The input test data are timeseries files.', | ||
action='store_const', | ||
const=True, | ||
required=False) | ||
|
||
self.add_argument( | ||
'--start_yr', | ||
dest='start_yr', | ||
help="Start year for the timeseries files.", | ||
required=False) | ||
|
||
self.add_argument( | ||
'--end_yr', | ||
dest='end_yr', | ||
help="End year for the timeseries files.", | ||
required=False) |
Oops, something went wrong.