@@ -18,73 +18,95 @@ class TestInflow():
18
18
case_dir = os .path .join (os .path .dirname (__file__ ), 'data' , 'LF_ETRS89_UseCase' )
19
19
20
20
def run (self , date_start , date_end , dtsec , type ):
21
- # generate inflow (inflow.tss)
21
+ # generate inflow (inflow.tss) one pixel upstream of inflow point
22
+ out_path_ref = os .path .join (self .case_dir , 'reference_dyn' )
22
23
out_path_run = os .path .join (self .case_dir , 'reference_dyn' , 'inflow_' + type )
23
24
settings_file = os .path .join (self .case_dir , 'settings' , 'inflow.xml' )
24
25
settings = setoptions (settings_file ,
25
- opts_to_unset = ['inflow' , 'SplitRouting' ],
26
+ opts_to_unset = ['inflow' ],
26
27
vars_to_set = {'StepStart' : date_start ,
27
28
'StepEnd' : date_end ,
28
29
'CalendarDayStart' : date_start ,
29
30
'DtSec' : dtsec ,
31
+ # 'DtSecChannel' : dtsec, # single routing step
30
32
'MaskMap' : '$(PathRoot)/maps/mask.map' ,
31
- 'Gauges' : '4317500 2447500' , # one cell upstream of output
33
+ # 'Gauges': '4317500 2447500 4322500 2447500 4322500 2442500',
34
+ 'Gauges' : '4317500 2447500' , # one cell upstream of inflow point
32
35
'ChanqTS' : out_path_run + '/inflow.tss' ,
33
36
'PathOut' : out_path_run })
37
+ mk_path_out (out_path_ref )
34
38
mk_path_out (out_path_run )
35
39
lisfloodexe (settings )
36
40
37
- # generate control run
41
+ # generate control run at inflow point
38
42
out_path_run = os .path .join (self .case_dir , 'reference_dyn' , 'inflow_' + type )
39
43
settings_file = os .path .join (self .case_dir , 'settings' , 'inflow.xml' )
40
44
settings = setoptions (settings_file ,
41
- opts_to_unset = ['inflow' , 'SplitRouting' ],
45
+ opts_to_unset = ['inflow' ],
42
46
vars_to_set = {'StepStart' : date_start ,
43
47
'StepEnd' : date_end ,
44
48
'CalendarDayStart' : date_start ,
45
49
'DtSec' : dtsec ,
50
+ # 'DtSecChannel': dtsec, # single routing step
46
51
'MaskMap' : '$(PathRoot)/maps/mask.map' ,
52
+ # 'Gauges': '4322500 2447500 4322500 2442500',
53
+ # 'Gauges': '4322500 2447500 4447500 2422500', # inflow and outlet
54
+ 'Gauges' : '4322500 2447500' , # inflow point
47
55
'PathOut' : out_path_run })
48
56
# mk_path_out(out_path_run)
49
57
lisfloodexe (settings )
50
58
51
- # run with inflow from dynamic reference
59
+ # run with inflow from dynamic reference and generate outflow at inflow point
52
60
out_path_ref = os .path .join (self .case_dir , 'reference_dyn' , 'inflow_' + type )
53
61
out_path_run = os .path .join (self .case_dir , self .run_type )
54
62
settings_file = os .path .join (self .case_dir , 'settings' , 'inflow.xml' )
55
63
settings = setoptions (settings_file ,
56
64
opts_to_set = ['inflow' ],
57
- opts_to_unset = ['SplitRouting' ],
65
+ # opts_to_unset=['SplitRouting'],
58
66
vars_to_set = {'StepStart' : date_start ,
59
67
'StepEnd' : date_end ,
60
68
'CalendarDayStart' : date_start ,
61
69
'DtSec' : dtsec ,
70
+ # 'DtSecChannel': dtsec, # single routing step
62
71
'MaskMap' : '$(PathRoot)/maps/intercatchment_mask.map' ,
63
72
'InflowPoints' : '$(PathRoot)/maps/inflow_point_1.nc' ,
64
73
'QInTS' : out_path_ref + '/inflow.tss' ,
74
+ # 'Gauges': '4322500 2447500 4322500 2442500',
75
+ # 'Gauges': '4322500 2447500 4447500 2422500', # inflow and outlet
76
+ 'Gauges' : '4322500 2447500' , # inflow point
65
77
'PathOut' : out_path_run })
66
78
mk_path_out (out_path_run )
67
79
lisfloodexe (settings )
68
80
69
- comparator = TSSComparator ()
70
- reference = os .path .join (out_path_ref , 'dis.tss' )
71
- output_tss = os .path .join (out_path_run , 'dis.tss' )
81
+ # set precisioon for the test
82
+ atol = 3.
83
+ rtol = 0.005
84
+ comparator = TSSComparator (atol ,rtol )
85
+
86
+ # test when DtSec = DtSecChannel
87
+ # reference = os.path.join(out_path_ref, 'dis.tss')
88
+ # output_tss = os.path.join(out_path_run, 'dis.tss')
89
+
90
+ # test when DtSec != DtSecChannel
91
+ reference = os .path .join (out_path_ref , 'chanqWin.tss' )
92
+ output_tss = os .path .join (out_path_run , 'chanqWin.tss' )
93
+
72
94
comparator .compare_files (reference , output_tss )
73
95
74
96
def teardown_method (self ):
75
97
print ('Cleaning directories' )
76
- # ref_path = os.path.join(self.case_dir, 'reference_dyn', 'inflow_'+type)
77
- # shutil.rmtree(ref_path, ignore_errors=True)
78
- # out_path = os.path.join(self.case_dir, self.run_type)
79
- # shutil.rmtree(out_path, ignore_errors=True)
98
+ ref_path = os .path .join (self .case_dir , 'reference_dyn' , 'inflow_' + str ( type ) )
99
+ shutil .rmtree (ref_path , ignore_errors = True )
100
+ out_path = os .path .join (self .case_dir , self .run_type )
101
+ shutil .rmtree (out_path , ignore_errors = True )
80
102
81
103
82
104
class TestInflowShort (TestInflow ):
83
105
84
106
run_type = 'short'
85
107
86
- # def test_inflow_6h(self):
87
- # self.run("01/03/2016 06:00", "30/03/2016 06:00", 21600,'6h')
108
+ def test_inflow_6h (self ):
109
+ self .run ("01/03/2016 06:00" , "30/03/2016 06:00" , 21600 ,'6h' )
88
110
89
111
def test_inflow_daily (self ):
90
112
self .run ("02/01/2016 06:00" , "30/01/2016 06:00" , 86400 ,'daily' )
0 commit comments