@@ -159,20 +159,22 @@ def test_climate_gmsl_anomalies(tmp_path):
159159 d .mkdir ()
160160 infile_path = d / "gmsl_fair.zarr"
161161 gases = ["CO2_Fossil" , "CH4" , "N2O" ]
162- # This struction might appear weird, but matches that used for initial EPA runs.
162+
163163 ds_in = xr .Dataset (
164164 {
165- "gmsl" : (
166- ["runtype" , "pulse_year" , "simulation" , "runid" , "year" , "gas" ],
167- np .ones ((2 , 1 , 1 , 2 , 1 , 3 )),
165+ "pulse_gmsl" : (
166+ ["pulse_year" , "runid" , "year" , "gas" ],
167+ np .ones ((1 , 2 , 1 , 3 )),
168+ ),
169+ "control_gmsl" : (
170+ ["runid" , "year" ],
171+ np .ones ((2 , 1 )),
168172 ),
169173 },
170174 coords = {
171175 "gas" : (["gas" ], gases ),
172176 "pulse_year" : (["pulse_year" ], [2020 ]),
173177 "runid" : (["runid" ], [1 , 2 ]),
174- "runtype" : (["runtype" ], ["control" , "pulse" ]),
175- "simulation" : (["simulation" ], [1 ]),
176178 "year" : (["year" ], [2020 ]),
177179 },
178180 )
@@ -181,19 +183,18 @@ def test_climate_gmsl_anomalies(tmp_path):
181183 expected = xr .Dataset (
182184 {
183185 "pulse_gmsl" : (
184- ["pulse_year" , "simulation" , " runid" , "year" , "gas" ],
185- np .ones ((1 , 1 , 2 , 1 , 3 )),
186+ ["pulse_year" , "runid" , "year" , "gas" ],
187+ np .ones ((1 , 2 , 1 , 3 )),
186188 ),
187189 "control_gmsl" : (
188- ["pulse_year" , "simulation" , " runid" , "year" , "gas " ],
189- np .ones ((1 , 1 , 2 , 1 , 3 )),
190+ ["runid" , "year" ],
191+ np .ones ((2 , 1 )),
190192 ),
191193 },
192194 coords = {
193195 "gas" : (["gas" ], gases ),
194196 "pulse_year" : (["pulse_year" ], [2020 ]),
195197 "runid" : (["runid" ], [1 , 2 ]),
196- "simulation" : (["simulation" ], [1 ]),
197198 "year" : (["year" ], [2020 ]),
198199 },
199200 )
@@ -214,66 +215,6 @@ def test_climate_gmsl_anomalies(tmp_path):
214215 xr .testing .assert_equal (actual , expected )
215216
216217
217- @pytest .mark .parametrize (
218- "unnecesary_coord" , ["confidence" , "kind" , "locations" , "workflow_src" ]
219- )
220- def test_climate_gmsl_anomalies_dropcoords (tmp_path , unnecesary_coord ):
221- """
222- Test that Climate instances give "gmsl_anomalies" with "unnecessary coords" dropped
223- """
224- # Set up input data in temporary directory because Climate needs to read
225- # from a magical Zarr Store.
226- d = tmp_path / "climate"
227- d .mkdir ()
228- infile_path = d / "gmsl_fair.zarr"
229- gases = ["CO2_Fossil" , "CH4" , "N2O" ]
230- # This struction might appear weird, but matches that used for initial EPA runs.
231- ds_in = xr .Dataset (
232- {
233- "gmsl" : (
234- [
235- unnecesary_coord ,
236- "runtype" ,
237- "pulse_year" ,
238- "simulation" ,
239- "runid" ,
240- "year" ,
241- "gas" ,
242- ],
243- np .ones ((1 , 2 , 1 , 1 , 2 , 1 , 3 )),
244- ),
245- },
246- coords = {
247- "gas" : (["gas" ], gases ),
248- "pulse_year" : (["pulse_year" ], [2020 ]),
249- "runid" : (["runid" ], [1 , 2 ]),
250- "runtype" : (["runtype" ], ["control" , "pulse" ]),
251- "simulation" : (["simulation" ], [1 ]),
252- "year" : (["year" ], [2020 ]),
253- unnecesary_coord : (
254- [unnecesary_coord ],
255- ["foobar" ],
256- ), # This one is unnecessary.
257- },
258- )
259- ds_in .to_zarr (infile_path )
260-
261- clim = Climate (
262- gmst_path = "" ,
263- gmsl_path = "" ,
264- gmst_fair_path = "bacon" ,
265- gmsl_fair_path = str (infile_path ),
266- pulse_year = 2020 ,
267- damages_pulse_conversion_path = "bacon" ,
268- ecs_mask_path = None ,
269- emission_scenarios = None ,
270- gases = gases ,
271- )
272- actual = clim .gmsl_anomalies
273-
274- assert unnecesary_coord not in actual .coords
275-
276-
277218def test_climate_gmst_anomalies (tmp_path ):
278219 """
279220 Test that Climate instances give "gmst_anomalies" from a GMST FAIR NetCDF file path
@@ -418,20 +359,22 @@ def test_climate_anomalies(tmp_path):
418359 gmsl_infile_path = d / "gmsl_fair.zarr"
419360 gases_gmsl = ["CO2_Fossil" , "CH4" , "N2O" ]
420361 gmsl_infile_path = d / "gmsl_fair2.zarr"
421- # As usual, this struction might appear weird, but matches that used for initial EPA runs.
362+
422363 gmsl_in = xr .Dataset (
423364 {
424- "gmsl" : (
425- ["runtype" , "pulse_year" , "simulation" , "runid" , "year" , "gas" ],
426- np .ones ((2 , 1 , 1 , 2 , 3 , 3 )),
365+ "pulse_gmsl" : (
366+ ["pulse_year" , "runid" , "year" , "gas" ],
367+ np .ones ((1 , 2 , 3 , 3 )),
368+ ),
369+ "control_gmsl" : (
370+ ["runid" , "year" ],
371+ np .ones ((2 , 3 )),
427372 ),
428373 },
429374 coords = {
430375 "gas" : (["gas" ], gases_gmsl ),
431376 "pulse_year" : (["pulse_year" ], [2002 ]),
432377 "runid" : (["runid" ], [1 , 2 ]),
433- "runtype" : (["runtype" ], ["control" , "pulse" ]),
434- "simulation" : (["simulation" ], [1 ]),
435378 "year" : (["year" ], [2000 , 2001 , 2002 ]),
436379 },
437380 )
@@ -442,18 +385,20 @@ def test_climate_anomalies(tmp_path):
442385 "control_temperature" : (["gas" , "runid" , "year" ], np .zeros ((3 , 2 , 1 ))),
443386 "pulse_temperature" : (["gas" , "runid" , "year" ], np .zeros ((3 , 2 , 1 ))),
444387 "control_gmsl" : (
445- ["simulation" , "runid" , "year" , "gas" ],
446- np .ones ((1 , 2 , 1 , 3 )),
388+ [
389+ "runid" ,
390+ "year" ,
391+ ],
392+ np .ones ((2 , 1 )),
447393 ),
448394 "pulse_gmsl" : (
449- ["simulation" , " runid" , "year" , "gas" ],
450- np .ones ((1 , 2 , 1 , 3 )),
395+ ["runid" , "year" , "gas" ],
396+ np .ones ((2 , 1 , 3 )),
451397 ),
452398 },
453399 coords = {
454400 "year" : (["year" ], [2002 ]),
455401 "gas" : (["gas" ], gases_gmst ),
456- "simulation" : (["simulation" ], [1 ]),
457402 "runid" : (["runid" ], [1 , 2 ]),
458403 },
459404 ).chunk ({"year" : 11 })
0 commit comments