@@ -59,6 +59,12 @@ def config(base_config):
59
59
chemistry:
60
60
reshapr config: month-average_202111_chemistry.yaml
61
61
file pattern: "SalishSeaCast_1m_chem_T_{yyyymmdd}_{yyyymmdd}.nc"
62
+ grazing:
63
+ reshapr config: month-average_202111_grazing_mortality.yaml
64
+ file pattern: "SalishSeaCast_1m_graz_T_{yyyymmdd}_{yyyymmdd}.nc"
65
+ growth:
66
+ reshapr config: month-average_202111_bio_growth_rates.yaml
67
+ file pattern: "SalishSeaCast_1m_prod_T_{yyyymmdd}_{yyyymmdd}.nc"
62
68
physics:
63
69
reshapr config: month-average_202111_physics.yaml
64
70
file pattern: "SalishSeaCast_1m_grid_T_{yyyymmdd}_{yyyymmdd}.nc"
@@ -100,6 +106,8 @@ def test_add_reshapr_var_group_arg(self, mock_worker):
100
106
assert worker .cli .parser ._actions [4 ].choices == {
101
107
"biology" ,
102
108
"chemistry" ,
109
+ "grazing" ,
110
+ "growth" ,
103
111
"physics" ,
104
112
}
105
113
assert worker .cli .parser ._actions [4 ].help
@@ -142,12 +150,16 @@ def test_message_registry_keys(self, prod_config):
142
150
"failure month biology" ,
143
151
"success month chemistry" ,
144
152
"failure month chemistry" ,
153
+ "success month grazing" ,
154
+ "failure month grazing" ,
155
+ "success month growth" ,
156
+ "failure month growth" ,
145
157
"success month physics" ,
146
158
"failure month physics" ,
147
159
"crash" ,
148
160
]
149
161
150
- def test_averaged_datasets (self , prod_config ):
162
+ def test_reshapr_configs (self , prod_config ):
151
163
averaged_datasets = prod_config ["averaged datasets" ]
152
164
expected = "/SalishSeaCast/SalishSeaNowcast/config/reshapr/"
153
165
@@ -196,6 +208,16 @@ def test_day_averaged_datasets(
196
208
"month-average_202111_chemistry.yaml" ,
197
209
"SalishSeaCast_1m_chem_T_{yyyymmdd}_{yyyymmdd}.nc" ,
198
210
),
211
+ (
212
+ "grazing" ,
213
+ "month-average_202111_grazing_mortality.yaml" ,
214
+ "SalishSeaCast_1m_graz_T_{yyyymmdd}_{yyyymmdd}.nc" ,
215
+ ),
216
+ (
217
+ "growth" ,
218
+ "month-average_202111_bio_growth_rates.yaml" ,
219
+ "SalishSeaCast_1m_prod_T_{yyyymmdd}_{yyyymmdd}.nc" ,
220
+ ),
199
221
(
200
222
"physics" ,
201
223
"month-average_202111_physics.yaml" ,
@@ -247,6 +269,8 @@ def test_day_average_success(self, avg_time_interval, reshapr_var_group, caplog)
247
269
(
248
270
("month" , "biology" ),
249
271
("month" , "chemistry" ),
272
+ ("month" , "grazing" ),
273
+ ("month" , "growth" ),
250
274
("month" , "physics" ),
251
275
),
252
276
)
@@ -301,6 +325,8 @@ def test_day_average_failure(self, avg_time_interval, reshapr_var_group, caplog)
301
325
(
302
326
("month" , "biology" ),
303
327
("month" , "chemistry" ),
328
+ ("month" , "grazing" ),
329
+ ("month" , "growth" ),
304
330
("month" , "physics" ),
305
331
),
306
332
)
@@ -385,6 +411,8 @@ def mock_extract_netcdf(reshapr_config, reshapr_config_yaml):
385
411
(
386
412
("month" , "biology" ),
387
413
("month" , "chemistry" ),
414
+ ("month" , "grazing" ),
415
+ ("month" , "growth" ),
388
416
("month" , "physics" ),
389
417
),
390
418
)
@@ -446,3 +474,22 @@ def test_bad_month_avg_run_date(self, caplog, config):
446
474
assert caplog .records [0 ].levelname == "ERROR"
447
475
expected = f"Month-averaging must start on the first day of a month but run_date = 2022-11-10"
448
476
assert caplog .messages [0 ] == expected
477
+
478
+ @pytest .mark .parametrize ("reshapr_var_group" , ("grazing" , "growth" ))
479
+ def test_month_avg_only_var_groups (self , reshapr_var_group , caplog , config ):
480
+ parsed_args = SimpleNamespace (
481
+ avg_time_interval = "day" ,
482
+ run_date = arrow .get ("2024-09-24" ),
483
+ reshapr_var_group = reshapr_var_group ,
484
+ )
485
+ caplog .set_level (logging .DEBUG )
486
+
487
+ with pytest .raises (WorkerError ):
488
+ make_averaged_dataset .make_averaged_dataset (parsed_args , config )
489
+
490
+ assert caplog .records [0 ].levelname == "ERROR"
491
+ expected = (
492
+ f"Day-average { reshapr_var_group } datasets are calculated by NEMO; "
493
+ f"use this worker for month-averaging"
494
+ )
495
+ assert caplog .messages [0 ] == expected
0 commit comments