@@ -355,6 +355,46 @@ def test_invalid_compound_name_raises_error(self):
355355 with pytest .raises (ValueError ):
356356 validate_and_resample_if_needed (ds , "Unknown.tas" , "tas" )
357357
358+ def test_static_target_without_time_coord_no_resampling (self ):
359+ """Static targets (fx) should skip time validation when no time coord exists."""
360+ ds = xr .Dataset (
361+ {"mrsofc" : (["lat" , "lon" ], np .ones ((2 , 3 ), dtype = "f4" ))},
362+ coords = {"lat" : [0.0 , 1.0 ], "lon" : [10.0 , 20.0 , 30.0 ]},
363+ )
364+
365+ ds_result , was_resampled = validate_and_resample_if_needed (
366+ ds , "Efx.mrsofc" , "mrsofc"
367+ )
368+
369+ assert not was_resampled
370+ assert ds_result is ds
371+
372+ def test_static_target_singleton_time_coord_no_resampling (self ):
373+ """Static targets tolerate a singleton source time axis (common UM fx inputs)."""
374+ time = pd .date_range ("2000-01-01" , periods = 1 , freq = "D" )
375+ ds = xr .Dataset (
376+ {"mrsofc" : (["time" , "lat" , "lon" ], np .ones ((1 , 2 , 3 ), dtype = "f4" ))},
377+ coords = {"time" : time , "lat" : [0.0 , 1.0 ], "lon" : [10.0 , 20.0 , 30.0 ]},
378+ )
379+
380+ ds_result , was_resampled = validate_and_resample_if_needed (
381+ ds , "Efx.mrsofc" , "mrsofc"
382+ )
383+
384+ assert not was_resampled
385+ assert ds_result is ds
386+
387+ def test_static_target_rejects_time_varying_input (self ):
388+ """Static targets should reject inputs with multiple time steps."""
389+ time = pd .date_range ("2000-01-01" , periods = 2 , freq = "D" )
390+ ds = xr .Dataset (
391+ {"mrsofc" : (["time" , "lat" , "lon" ], np .ones ((2 , 2 , 3 ), dtype = "f4" ))},
392+ coords = {"time" : time , "lat" : [0.0 , 1.0 ], "lon" : [10.0 , 20.0 , 30.0 ]},
393+ )
394+
395+ with pytest .raises (IncompatibleFrequencyError , match = r"fixed \(fx\)" ):
396+ validate_and_resample_if_needed (ds , "Efx.mrsofc" , "mrsofc" )
397+
358398
359399class TestErrorHandling :
360400 """Tests for error handling in resampling operations."""
0 commit comments