2222from RAiDER .aria .prepFromGUNW import (
2323 check_hrrr_dataset_availablity_for_s1_azimuth_time_interpolation ,
2424 check_weather_model_availability ,_get_acq_time_from_gunw_id ,
25- get_slc_ids_from_gunw ,get_acq_time_from_slc_id
25+ get_slc_ids_from_gunw ,get_acq_time_from_slc_id , identify_which_hrrr
2626)
2727from RAiDER .cli .raider import calcDelaysGUNW
28+ from RAiDER .models .hrrr import HRRR , HRRRAK
2829from RAiDER .models .customExceptions import (
2930 NoWeatherModelData , WrongNumberOfFiles ,
3031)
@@ -260,16 +261,6 @@ def test_azimuth_timing_interp_against_center_time_interp(weather_model_name: st
260261 # https://github.com/dbekaert/RAiDER/blob/
261262 # f77af9ce2d3875b00730603305c0e92d6c83adc2/tools/RAiDER/aria/prepFromGUNW.py#L151-L200
262263
263- # For prepGUNW
264- side_effect = [
265- # center-time
266- [Path (orbit_dict_for_azimuth_time_test ['reference' ])],
267- # azimuth-time
268- [Path (orbit_dict_for_azimuth_time_test ['reference' ])],
269- ]
270- mocker .patch ('eof.download.download_eofs' ,
271- side_effect = side_effect )
272-
273264 # These outputs are not needed since the orbits are specified above
274265 mocker .patch ('RAiDER.s1_azimuth_timing.get_slc_id_from_point_and_time' ,
275266 side_effect = [
@@ -281,11 +272,11 @@ def test_azimuth_timing_interp_against_center_time_interp(weather_model_name: st
281272 ])
282273
283274 mocker .patch (
284- 'RAiDER.s1_azimuth_timing.get_orbits_from_slc_ids_hyp3lib ' ,
275+ 'RAiDER.s1_azimuth_timing.get_orbits_from_slc_ids ' ,
285276 side_effect = [
286277 # For azimuth time
287- [Path (orbit_dict_for_azimuth_time_test ['reference' ])],
288- [Path (orbit_dict_for_azimuth_time_test ['secondary' ]), Path (orbit_dict_for_azimuth_time_test ['secondary' ])],
278+ [str (orbit_dict_for_azimuth_time_test ['reference' ])],
279+ [str (orbit_dict_for_azimuth_time_test ['secondary' ]), str (orbit_dict_for_azimuth_time_test ['secondary' ])],
289280 ]
290281 )
291282
@@ -312,12 +303,9 @@ def test_azimuth_timing_interp_against_center_time_interp(weather_model_name: st
312303 # Calls 4 times for azimuth time and 4 times for center time
313304 assert RAiDER .processWM .prepareWeatherModel .call_count == 8
314305 # Only calls once each ref and sec list of slcs
315- assert RAiDER .s1_azimuth_timing .get_orbits_from_slc_ids_hyp3lib .call_count == 2
306+ assert RAiDER .s1_azimuth_timing .get_orbits_from_slc_ids .call_count == 2
316307 # Only calls for azimuth timing: once for ref and sec
317308 assert RAiDER .s1_azimuth_timing .get_slc_id_from_point_and_time .call_count == 2
318- ## When we return to sentineleof
319- # Once for center-time and azimuth-time each
320- # assert eof.download.download_eofs.call_count == 2
321309
322310 for ifg_type in ['reference' , 'secondary' ]:
323311 for var in ['troposphereHydrostatic' , 'troposphereWet' ]:
@@ -441,16 +429,6 @@ def test_provenance_metadata_for_tropo_group(weather_model_name: str,
441429 out_path = shutil .copy (gunw_azimuth_test , tmp_path / out )
442430
443431 if interp_method == 'azimuth_time_grid' :
444- # For prepGUNW
445- side_effect = [
446- # center-time
447- [Path (orbit_dict_for_azimuth_time_test ['reference' ])],
448- # azimuth-time
449- [Path (orbit_dict_for_azimuth_time_test ['reference' ])],
450- ]
451- mocker .patch ('RAiDER.s1_azimuth_timing.get_orbits_from_slc_ids_hyp3lib' ,
452- side_effect = side_effect )
453-
454432 # These outputs are not needed since the orbits are specified above
455433 mocker .patch ('RAiDER.s1_azimuth_timing.get_slc_id_from_point_and_time' ,
456434 side_effect = [
@@ -462,11 +440,11 @@ def test_provenance_metadata_for_tropo_group(weather_model_name: str,
462440 ])
463441
464442 mocker .patch (
465- 'RAiDER.s1_azimuth_timing.get_orbits_from_slc_ids_hyp3lib ' ,
443+ 'RAiDER.s1_azimuth_timing.get_orbits_from_slc_ids ' ,
466444 side_effect = [
467445 # For azimuth time
468- [Path (orbit_dict_for_azimuth_time_test ['reference' ])],
469- [Path (orbit_dict_for_azimuth_time_test ['secondary' ]), Path (orbit_dict_for_azimuth_time_test ['secondary' ])],
446+ [str (orbit_dict_for_azimuth_time_test ['reference' ])],
447+ [str (orbit_dict_for_azimuth_time_test ['secondary' ]), str (orbit_dict_for_azimuth_time_test ['secondary' ])],
470448 ]
471449 )
472450 weather_model_path_dict = (weather_model_dict_for_center_time_test
@@ -543,16 +521,6 @@ def test_GUNW_workflow_fails_if_a_download_fails(gunw_azimuth_test, orbit_dict_f
543521 # Maybe better mocks could be done - but this is sufficient or simply a factory for this test given
544522 # This is reused so many times.
545523
546- # For prepGUNW
547- side_effect = [
548- # center-time
549- [Path (orbit_dict_for_azimuth_time_test ['reference' ])],
550- # azimuth-time
551- [Path (orbit_dict_for_azimuth_time_test ['reference' ])],
552- ]
553- mocker .patch ('eof.download.download_eofs' ,
554- side_effect = side_effect )
555-
556524 # These outputs are not needed since the orbits are specified above
557525 mocker .patch ('RAiDER.s1_azimuth_timing.get_slc_id_from_point_and_time' ,
558526 side_effect = [
@@ -564,11 +532,11 @@ def test_GUNW_workflow_fails_if_a_download_fails(gunw_azimuth_test, orbit_dict_f
564532 ])
565533
566534 mocker .patch (
567- 'RAiDER.s1_azimuth_timing.get_orbits_from_slc_ids_hyp3lib ' ,
535+ 'RAiDER.s1_azimuth_timing.get_orbits_from_slc_ids ' ,
568536 side_effect = [
569537 # For azimuth time
570- [Path (orbit_dict_for_azimuth_time_test ['reference' ])],
571- [Path (orbit_dict_for_azimuth_time_test ['secondary' ]), Path (orbit_dict_for_azimuth_time_test ['secondary' ])],
538+ [str (orbit_dict_for_azimuth_time_test ['reference' ])],
539+ [str (orbit_dict_for_azimuth_time_test ['secondary' ]), str (orbit_dict_for_azimuth_time_test ['secondary' ])],
572540 ]
573541 )
574542
@@ -665,3 +633,72 @@ def test_get_acq_time_invalid_slc_id():
665633 invalid_slc_id = "test/gunw_azimuth_test_data/S1B_OPER_AUX_POEORB_OPOD_20210731T111940_V20210710T225942_20210712T005942.EOF"
666634 with pytest .raises (ValueError ):
667635 get_acq_time_from_slc_id (invalid_slc_id )
636+
637+
638+ def test_identify_which_hrrr_1 ():
639+ """Tests if function identifies the correct HRRR file"""
640+ gunw_id = Path ("test/gunw_azimuth_test_data/S1-GUNW-A-R-064-tops-20210723_20210711-015000-00119W_00033N-PP-6267-v2_0_6.nc" )
641+ result = identify_which_hrrr (gunw_id )
642+ assert result == "HRRR"
643+
644+
645+ def test_identify_which_hrrr_2 ():
646+ """Tests if function identifies the correct HRRR file"""
647+ gunw_id = Path ("test/gunw_test_data/S1-GUNW-D-R-059-tops-20230320_20220418-180300-00179W_00051N-PP-c92e-v2_0_6.nc" )
648+ result = identify_which_hrrr (gunw_id )
649+ assert result == "HRRRAK"
650+
651+
652+ def test_cast_to_hrrrak_1 ():
653+ """Tests if function casts the HRRR file to HRRRAK"""
654+ ak_bounds = [51.0 , 71.0 , - 175. , - 130.0 ]
655+ conus_bounds = [34.0 ,35.0 , - 91 , - 90.0 ]
656+ model = HRRR ()
657+ model .checkValidBounds (conus_bounds )
658+ model .checkValidBounds (ak_bounds )
659+ assert model ._Name == "HRRR-AK"
660+
661+
662+ def test_cast_to_hrrrak_2 ():
663+ """Tests if function casts the HRRR file to HRRRAK"""
664+ ak_bounds = [51.0 , 71.0 , - 175. , - 130.0 ]
665+ model = HRRRAK ()
666+ model .checkValidBounds (ak_bounds )
667+ assert model ._Name == "HRRR-AK"
668+
669+
670+ def test_cast_to_hrrrak_2b ():
671+ """Tests if function casts the HRRR file to HRRRAK"""
672+ ak_bounds = [60.0 , 65.0 , - 150. , - 120.0 ]
673+ model = HRRRAK ()
674+ model .checkValidBounds (ak_bounds )
675+ assert model ._Name == "HRRR-AK"
676+
677+
678+ def test_cast_to_hrrrak_3 ():
679+ """Tests if function casts the HRRR file to HRRRAK"""
680+ conus_bounds = [34.0 ,35.0 , - 91 , - 90.0 ]
681+ model = HRRR ()
682+ model .checkValidBounds (conus_bounds )
683+ assert model ._Name == "HRRR"
684+
685+
686+ def test_cast_to_hrrrak_4 ():
687+ """Tests if function casts the HRRR file to HRRRAK"""
688+ europe_bounds = [- 1 , 1 , - 1 , 1 ]
689+ model = HRRR ()
690+ with pytest .raises (ValueError ):
691+ model .checkValidBounds (europe_bounds )
692+
693+
694+ def test_identify_which_hrrr_invalid ():
695+ """Tests if function raises error for an invalid gunw_id format"""
696+ invalid_gunw_id = "dummy.nc"
697+ with pytest .raises (NoWeatherModelData ):
698+ identify_which_hrrr (invalid_gunw_id )
699+
700+
701+ def test_check_hrrr_dataset_availablity_for_s1_azimuth_time_interpolation_again ():
702+ """Tests if function raises error for an invalid gunw_id format"""
703+ gunw_id = "S1-GUNW-D-R-044-tops-20240418_20240406-171649-00163W_00069N-PP-af6b-v3_0_1.nc"
704+ assert check_hrrr_dataset_availablity_for_s1_azimuth_time_interpolation (gunw_id , 'hrrrak' ) is True
0 commit comments