|
26 | 26 |
|
27 | 27 | from .test_utils import setoptions, mk_path_out, ETRS89TestCase
|
28 | 28 |
|
29 |
| -# do_not_run |
30 |
| -# update reference results |
31 |
| -# @pytest.mark.slow |
32 |
| -# class TestCatch(ETRS89TestCase): |
33 |
| -# case_dir = os.path.join(os.path.dirname(__file__), 'data', 'LF_ETRS89_UseCase') |
34 |
| -# mk_path_out(os.path.join(case_dir, 'out')) |
35 |
| -# |
36 |
| -# modules_to_set = ( |
37 |
| -# 'SplitRouting', |
38 |
| -# 'simulateReservoirs', |
39 |
| -# 'simulateLakes', |
40 |
| -# 'drainedIrrigation', |
41 |
| -# 'openwaterevapo', |
42 |
| -# 'riceIrrigation', |
43 |
| -# 'wateruse', |
44 |
| -# 'useWaterDemandAveYear', |
45 |
| -# 'wateruseRegion', |
46 |
| -# 'TransientWaterDemandChange', |
47 |
| -# ) |
48 |
| -# settings_files = { |
49 |
| -# 'base': os.path.join(case_dir, 'settings/base.xml'), |
50 |
| -# 'prerun': os.path.join(case_dir, 'settings/prerun.xml') |
51 |
| -# } |
52 |
| -# |
53 |
| -# def run(self, dt_sec, step_start, step_end): |
54 |
| -# output_dir = mk_path_out(os.path.join(self.case_dir, 'out/test_results{}'.format(dt_sec))) |
55 |
| -# opts_to_unset = ( |
56 |
| -# "repStateSites", "repRateSites", "repStateUpsGauges", "repRateUpsGauges", "repMeteoUpsGauges", |
57 |
| -# "repsimulateLakes", "repStateMaps", |
58 |
| -# "repsimulateReservoirs", "repSnowMaps", "repPFMaps", "repLZMaps", "repUZMaps", |
59 |
| -# "repGwPercUZLZMaps", "repRWS", "repTotalWUse", "repWIndex", |
60 |
| -# "repSurfaceRunoffMaps", "repRainMaps", "repSnowMaps", "repSnowCoverMaps", "repSnowMeltMaps", |
61 |
| -# "repLZMaps", "repUZMaps", |
62 |
| -# "repGwPercUZLZMaps", "repRWS", "repPFMaps", "repPFForestMaps" |
63 |
| -# ) |
64 |
| -# settings = setoptions(self.settings_files['base'], |
65 |
| -# opts_to_set=('repDischargeTs', 'repDischargeMaps', |
66 |
| -# "repThetaMaps", "repThetaForestMaps", |
67 |
| -# "repThetaIrrigationMaps", "repE2O2", |
68 |
| -# "repTotalWaterStorageMaps") + self.modules_to_set, |
69 |
| -# opts_to_unset=opts_to_unset, |
70 |
| -# vars_to_set={'StepStart': step_start, |
71 |
| -# 'StepEnd': step_end, |
72 |
| -# 'DtSec': dt_sec, |
73 |
| -# 'PathOut': output_dir}) |
74 |
| -# mk_path_out(output_dir) |
75 |
| -# lisfloodexe(settings) |
76 |
| -# |
77 |
| -# def test_output_daily(self): |
78 |
| -# self.run('86400', '02/01/2016 06:00', '02/07/2016 06:00') |
79 |
| -# self.compare_reference('dis', check='map', step_length='86400') |
80 |
| -# self.compare_reference('dis', check='tss', step_length='86400') |
81 |
| -# self.compare_reference('chanq', check='tss', step_length='86400') |
82 |
| -# self.compare_reference('thia', check='map', step_length='86400') |
83 |
| -# self.compare_reference('thic', check='map', step_length='86400') |
84 |
| -# self.compare_reference('thfa', check='map', step_length='86400') |
85 |
| -# self.compare_reference('thfc', check='map', step_length='86400') |
86 |
| -# self.compare_reference('tha', check='map', step_length='86400') |
87 |
| -# self.compare_reference('thc', check='map', step_length='86400') |
88 |
| -# self.compare_reference('lz', check='map', step_length='86400') |
89 |
| -# self.compare_reference('tws', check='map', step_length='86400') |
90 |
| -# |
91 |
| -# def test_output_6h(self): |
92 |
| -# self.run('21600', '02/01/2016 06:00', '02/07/2016 06:00') |
93 |
| -# self.compare_reference('dis', check='map', step_length='21600') |
94 |
| -# self.compare_reference('dis', check='tss', step_length='21600') |
95 |
| -# self.compare_reference('chanq', check='tss', step_length='21600') |
96 |
| -# self.compare_reference('thia', check='map', step_length='21600') |
97 |
| -# self.compare_reference('thic', check='map', step_length='21600') |
98 |
| -# self.compare_reference('thfa', check='map', step_length='21600') |
99 |
| -# self.compare_reference('thfc', check='map', step_length='21600') |
100 |
| -# self.compare_reference('tha', check='map', step_length='21600') |
101 |
| -# self.compare_reference('thc', check='map', step_length='21600') |
102 |
| -# self.compare_reference('lz', check='map', step_length='21600') |
103 |
| -# self.compare_reference('tws', check='map', step_length='21600') |
104 |
| -# |
105 |
| -# def test_initvars(self): |
106 |
| -# output_dir = mk_path_out(os.path.join(self.case_dir, 'out/test_results_initvars')) |
107 |
| -# opts_to_unset = ( |
108 |
| -# "repStateSites", "repRateSites", "repStateUpsGauges", "repRateUpsGauges", "repMeteoUpsGauges", |
109 |
| -# "repsimulateLakes", "repStateMaps", |
110 |
| -# "repsimulateReservoirs", "repSnowMaps", "repPFMaps", "repLZMaps", "repUZMaps", |
111 |
| -# "repGwPercUZLZMaps", "repRWS", "repTotalWUse", "repWIndex", |
112 |
| -# "repSurfaceRunoffMaps", "repRainMaps", "repSnowMaps", "repSnowCoverMaps", "repSnowMeltMaps", "repThetaMaps", |
113 |
| -# "repThetaForestMaps", "repLZMaps", "repUZMaps", "repDischargeTs", "repDischargeMaps", |
114 |
| -# "repGwPercUZLZMaps", "repRWS", "repPFMaps", "repPFForestMaps" |
115 |
| -# ) |
116 |
| -# settings = setoptions(self.settings_files['base'], |
117 |
| -# opts_to_set=('repEndMaps',) + self.modules_to_set, |
118 |
| -# opts_to_unset=opts_to_unset, |
119 |
| -# vars_to_set={'StepStart': '02/02/2016 06:00', |
120 |
| -# 'StepEnd': '05/02/2016 06:00', |
121 |
| -# 'PathOut': output_dir}) |
122 |
| -# mk_path_out(output_dir) |
123 |
| -# lisfloodexe(settings) |
124 |
| -# initcond_files = ('ch2cr.end.nc', 'chanq.end.nc', 'chcro.end.nc', |
125 |
| -# 'chside.end.nc', 'cseal.end.nc', 'cum.end.nc', |
126 |
| -# 'cumf.end.nc', 'cumi.end.nc', 'dslf.end.nc', |
127 |
| -# 'dsli.end.nc', 'dslr.end.nc', 'frost.end.nc', |
128 |
| -# 'lakeh.end.nc', 'lakeprevinq.end.nc', |
129 |
| -# 'lakeprevoutq.end.nc', 'lz.end.nc', 'ofdir.end.nc', |
130 |
| -# 'offor.end.nc', 'ofoth.end.nc', 'rsfil.end.nc', |
131 |
| -# 'scova.end.nc', 'scovb.end.nc', 'scovc.end.nc', |
132 |
| -# 'tha.end.nc', 'thb.end.nc', 'thc.end.nc', |
133 |
| -# 'thfa.end.nc', 'thfb.end.nc', 'thfc.end.nc', |
134 |
| -# 'thia.end.nc', 'thib.end.nc', 'thic.end.nc', |
135 |
| -# 'uz.end.nc', 'uzf.end.nc', 'uzi.end.nc') |
136 |
| -# for f in initcond_files: |
137 |
| -# assert os.path.exists(os.path.join(output_dir, f)) |
138 |
| -# |
139 |
| -# def run_init(self, dt_sec, step_start, step_end): |
140 |
| -# path_out_init = mk_path_out(os.path.join(self.case_dir, 'out/test_init_{}'.format(dt_sec))) |
141 |
| -# settings = setoptions(self.settings_files['prerun'], |
142 |
| -# opts_to_set=self.modules_to_set, |
143 |
| -# vars_to_set={'DtSec': dt_sec, |
144 |
| -# 'PathOut': path_out_init, |
145 |
| -# 'StepStart': step_start, |
146 |
| -# 'StepEnd': step_end, |
147 |
| -# }) |
148 |
| -# lisfloodexe(settings) |
149 |
| -# |
150 |
| -# def test_init_daily(self): |
151 |
| -# self.run_init('86400', '31/12/2015 06:00', '06/01/2017 06:00') |
152 |
| -# self.compare_reference('avgdis', check='map', step_length='86400') |
153 |
| -# self.compare_reference('lzavin', check='map', step_length='86400') |
154 |
| -# |
155 |
| -# def test_init_6h(self): |
156 |
| -# self.run_init('21600', '31/12/2015 06:00', '06/01/2017 06:00') |
157 |
| -# self.compare_reference('avgdis', check='map', step_length='21600') |
158 |
| -# self.compare_reference('lzavin', check='map', step_length='21600') |
159 |
| -# |
160 |
| -# def run_waterbalance(self, dt_sec, step_start, step_end): |
161 |
| -# # init files from .../LF_ETRS89_UseCase/maps/safe_init |
162 |
| -# # "AvgDis" value="$(PathRoot)/maps/safe_init/avgdis" |
163 |
| -# # "LZAvInflowMap" value="$(PathRoot)/maps/safe_init/lzavin" |
164 |
| -# output_dir = mk_path_out(os.path.join(self.case_dir, 'out/test_results{}'.format(dt_sec))) |
165 |
| -# opts_to_unset = ( |
166 |
| -# 'wateruse','riceIrrigation','groundwaterSmooth' |
167 |
| -# ) |
168 |
| -# settings = setoptions(self.settings_files['base'], |
169 |
| -# opts_to_set=('SplitRouting','repMBTs','openwaterevapo','drainedIrrigation','simulateLakes','simulateReservoirs'), |
170 |
| -# opts_to_unset=opts_to_unset, |
171 |
| -# vars_to_set={'StepStart': step_start, |
172 |
| -# 'StepEnd': step_end, |
173 |
| -# 'DtSec': dt_sec, |
174 |
| -# 'PathOut': output_dir}) |
175 |
| -# lisfloodexe(settings) |
176 |
| -# |
177 |
| -# def test_waterbalance_daily(self): |
178 |
| -# self.run_waterbalance('86400', '02/01/2016 06:00', '02/07/2016 06:00') |
179 |
| -# self.compare_reference('mbError', check='tss', step_length='86400') |
180 |
| -# self.compare_reference('mbErrorSplitRoutingM3', check='tss', step_length='86400') |
181 |
| -# |
182 |
| -# def test_waterbalance_6h(self): |
183 |
| -# self.run_waterbalance('21600', '02/01/2016 06:00', '02/07/2016 06:00') |
184 |
| -# self.compare_reference('mbError', check='tss', step_length='21600') |
185 |
| -# self.compare_reference('mbErrorSplitRoutingM3', check='tss', step_length='21600') |
| 29 | + |
| 30 | +@pytest.mark.slow |
| 31 | +class TestCatch(ETRS89TestCase): |
| 32 | + case_dir = os.path.join(os.path.dirname(__file__), 'data', 'LF_ETRS89_UseCase') |
| 33 | + mk_path_out(os.path.join(case_dir, 'out')) |
| 34 | + |
| 35 | + modules_to_set = ( |
| 36 | + 'SplitRouting', |
| 37 | + 'simulateReservoirs', |
| 38 | + 'simulateLakes', |
| 39 | + 'drainedIrrigation', |
| 40 | + 'openwaterevapo', |
| 41 | + 'riceIrrigation', |
| 42 | + 'wateruse', |
| 43 | + 'useWaterDemandAveYear', |
| 44 | + 'wateruseRegion', |
| 45 | + 'TransientWaterDemandChange', |
| 46 | + ) |
| 47 | + settings_files = { |
| 48 | + 'base': os.path.join(case_dir, 'settings/base.xml'), |
| 49 | + 'prerun': os.path.join(case_dir, 'settings/prerun.xml') |
| 50 | + } |
| 51 | + |
| 52 | + def run(self, dt_sec, step_start, step_end): |
| 53 | + output_dir = mk_path_out(os.path.join(self.case_dir, 'out/test_results{}'.format(dt_sec))) |
| 54 | + opts_to_unset = ( |
| 55 | + "repStateSites", "repRateSites", "repStateUpsGauges", "repRateUpsGauges", "repMeteoUpsGauges", |
| 56 | + "repsimulateLakes", "repStateMaps", |
| 57 | + "repsimulateReservoirs", "repSnowMaps", "repPFMaps", "repLZMaps", "repUZMaps", |
| 58 | + "repGwPercUZLZMaps", "repRWS", "repTotalWUse", "repWIndex", |
| 59 | + "repSurfaceRunoffMaps", "repRainMaps", "repSnowMaps", "repSnowCoverMaps", "repSnowMeltMaps", |
| 60 | + "repLZMaps", "repUZMaps", |
| 61 | + "repGwPercUZLZMaps", "repRWS", "repPFMaps", "repPFForestMaps" |
| 62 | + ) |
| 63 | + settings = setoptions(self.settings_files['base'], |
| 64 | + opts_to_set=('repDischargeTs', 'repDischargeMaps', |
| 65 | + "repThetaMaps", "repThetaForestMaps", |
| 66 | + "repThetaIrrigationMaps", "repE2O2", |
| 67 | + "repTotalWaterStorageMaps") + self.modules_to_set, |
| 68 | + opts_to_unset=opts_to_unset, |
| 69 | + vars_to_set={'StepStart': step_start, |
| 70 | + 'StepEnd': step_end, |
| 71 | + 'DtSec': dt_sec, |
| 72 | + 'PathOut': output_dir}) |
| 73 | + mk_path_out(output_dir) |
| 74 | + lisfloodexe(settings) |
| 75 | + |
| 76 | + def test_output_daily(self): |
| 77 | + self.run('86400', '02/01/2016 06:00', '02/07/2016 06:00') |
| 78 | + self.compare_reference('dis', check='map', step_length='86400') |
| 79 | + self.compare_reference('dis', check='tss', step_length='86400') |
| 80 | + self.compare_reference('chanq', check='tss', step_length='86400') |
| 81 | + self.compare_reference('thia', check='map', step_length='86400') |
| 82 | + self.compare_reference('thic', check='map', step_length='86400') |
| 83 | + self.compare_reference('thfa', check='map', step_length='86400') |
| 84 | + self.compare_reference('thfc', check='map', step_length='86400') |
| 85 | + self.compare_reference('tha', check='map', step_length='86400') |
| 86 | + self.compare_reference('thc', check='map', step_length='86400') |
| 87 | + self.compare_reference('lz', check='map', step_length='86400') |
| 88 | + self.compare_reference('tws', check='map', step_length='86400') |
| 89 | + |
| 90 | + def test_output_6h(self): |
| 91 | + self.run('21600', '02/01/2016 06:00', '02/07/2016 06:00') |
| 92 | + self.compare_reference('dis', check='map', step_length='21600') |
| 93 | + self.compare_reference('dis', check='tss', step_length='21600') |
| 94 | + self.compare_reference('chanq', check='tss', step_length='21600') |
| 95 | + self.compare_reference('thia', check='map', step_length='21600') |
| 96 | + self.compare_reference('thic', check='map', step_length='21600') |
| 97 | + self.compare_reference('thfa', check='map', step_length='21600') |
| 98 | + self.compare_reference('thfc', check='map', step_length='21600') |
| 99 | + self.compare_reference('tha', check='map', step_length='21600') |
| 100 | + self.compare_reference('thc', check='map', step_length='21600') |
| 101 | + self.compare_reference('lz', check='map', step_length='21600') |
| 102 | + self.compare_reference('tws', check='map', step_length='21600') |
| 103 | + |
| 104 | + def test_initvars(self): |
| 105 | + output_dir = mk_path_out(os.path.join(self.case_dir, 'out/test_results_initvars')) |
| 106 | + opts_to_unset = ( |
| 107 | + "repStateSites", "repRateSites", "repStateUpsGauges", "repRateUpsGauges", "repMeteoUpsGauges", |
| 108 | + "repsimulateLakes", "repStateMaps", |
| 109 | + "repsimulateReservoirs", "repSnowMaps", "repPFMaps", "repLZMaps", "repUZMaps", |
| 110 | + "repGwPercUZLZMaps", "repRWS", "repTotalWUse", "repWIndex", |
| 111 | + "repSurfaceRunoffMaps", "repRainMaps", "repSnowMaps", "repSnowCoverMaps", "repSnowMeltMaps", "repThetaMaps", |
| 112 | + "repThetaForestMaps", "repLZMaps", "repUZMaps", "repDischargeTs", "repDischargeMaps", |
| 113 | + "repGwPercUZLZMaps", "repRWS", "repPFMaps", "repPFForestMaps" |
| 114 | + ) |
| 115 | + settings = setoptions(self.settings_files['base'], |
| 116 | + opts_to_set=('repEndMaps',) + self.modules_to_set, |
| 117 | + opts_to_unset=opts_to_unset, |
| 118 | + vars_to_set={'StepStart': '02/02/2016 06:00', |
| 119 | + 'StepEnd': '05/02/2016 06:00', |
| 120 | + 'PathOut': output_dir}) |
| 121 | + mk_path_out(output_dir) |
| 122 | + lisfloodexe(settings) |
| 123 | + initcond_files = ('ch2cr.end.nc', 'chanq.end.nc', 'chcro.end.nc', |
| 124 | + 'chside.end.nc', 'cseal.end.nc', 'cum.end.nc', |
| 125 | + 'cumf.end.nc', 'cumi.end.nc', 'dslf.end.nc', |
| 126 | + 'dsli.end.nc', 'dslr.end.nc', 'frost.end.nc', |
| 127 | + 'lakeh.end.nc', 'lakeprevinq.end.nc', |
| 128 | + 'lakeprevoutq.end.nc', 'lz.end.nc', 'ofdir.end.nc', |
| 129 | + 'offor.end.nc', 'ofoth.end.nc', 'rsfil.end.nc', |
| 130 | + 'scova.end.nc', 'scovb.end.nc', 'scovc.end.nc', |
| 131 | + 'tha.end.nc', 'thb.end.nc', 'thc.end.nc', |
| 132 | + 'thfa.end.nc', 'thfb.end.nc', 'thfc.end.nc', |
| 133 | + 'thia.end.nc', 'thib.end.nc', 'thic.end.nc', |
| 134 | + 'uz.end.nc', 'uzf.end.nc', 'uzi.end.nc') |
| 135 | + for f in initcond_files: |
| 136 | + assert os.path.exists(os.path.join(output_dir, f)) |
| 137 | + |
| 138 | + def run_init(self, dt_sec, step_start, step_end): |
| 139 | + path_out_init = mk_path_out(os.path.join(self.case_dir, 'out/test_init_{}'.format(dt_sec))) |
| 140 | + settings = setoptions(self.settings_files['prerun'], |
| 141 | + opts_to_set=self.modules_to_set, |
| 142 | + vars_to_set={'DtSec': dt_sec, |
| 143 | + 'PathOut': path_out_init, |
| 144 | + 'StepStart': step_start, |
| 145 | + 'StepEnd': step_end, |
| 146 | + }) |
| 147 | + lisfloodexe(settings) |
| 148 | + |
| 149 | + def test_init_daily(self): |
| 150 | + self.run_init('86400', '31/12/2015 06:00', '06/01/2017 06:00') |
| 151 | + self.compare_reference('avgdis', check='map', step_length='86400') |
| 152 | + self.compare_reference('lzavin', check='map', step_length='86400') |
| 153 | + |
| 154 | + def test_init_6h(self): |
| 155 | + self.run_init('21600', '31/12/2015 06:00', '06/01/2017 06:00') |
| 156 | + self.compare_reference('avgdis', check='map', step_length='21600') |
| 157 | + self.compare_reference('lzavin', check='map', step_length='21600') |
| 158 | + |
| 159 | + def run_waterbalance(self, dt_sec, step_start, step_end): |
| 160 | + # init files from .../LF_ETRS89_UseCase/maps/safe_init |
| 161 | + # "AvgDis" value="$(PathRoot)/maps/safe_init/avgdis" |
| 162 | + # "LZAvInflowMap" value="$(PathRoot)/maps/safe_init/lzavin" |
| 163 | + output_dir = mk_path_out(os.path.join(self.case_dir, 'out/test_results{}'.format(dt_sec))) |
| 164 | + opts_to_unset = ( |
| 165 | + 'wateruse','riceIrrigation','groundwaterSmooth' |
| 166 | + ) |
| 167 | + settings = setoptions(self.settings_files['base'], |
| 168 | + opts_to_set=('SplitRouting','repMBTs','openwaterevapo','drainedIrrigation','simulateLakes','simulateReservoirs'), |
| 169 | + opts_to_unset=opts_to_unset, |
| 170 | + vars_to_set={'StepStart': step_start, |
| 171 | + 'StepEnd': step_end, |
| 172 | + 'DtSec': dt_sec, |
| 173 | + 'PathOut': output_dir}) |
| 174 | + lisfloodexe(settings) |
| 175 | + |
| 176 | + def test_waterbalance_daily(self): |
| 177 | + self.run_waterbalance('86400', '02/01/2016 06:00', '02/07/2016 06:00') |
| 178 | + self.compare_reference('mbError', check='tss', step_length='86400') |
| 179 | + self.compare_reference('mbErrorSplitRoutingM3', check='tss', step_length='86400') |
| 180 | + |
| 181 | + def test_waterbalance_6h(self): |
| 182 | + self.run_waterbalance('21600', '02/01/2016 06:00', '02/07/2016 06:00') |
| 183 | + self.compare_reference('mbError', check='tss', step_length='21600') |
| 184 | + self.compare_reference('mbErrorSplitRoutingM3', check='tss', step_length='21600') |
186 | 185 |
|
0 commit comments