@@ -96,13 +96,13 @@ def l1b_histrates():
9696 )
9797 l1b_histrates = xr .Dataset (
9898 {
99- "h_counts" : (("epoch" , "azimuth_6 " , "esa_step " ), np .zeros ((2 , 60 , 7 ))),
100- "o_counts" : (("epoch" , "azimuth_6 " , "esa_step " ), np .zeros ((2 , 60 , 7 ))),
99+ "h_counts" : (("epoch" , "esa_step " , "azimuth_6 " ), np .zeros ((2 , 7 , 60 ))),
100+ "o_counts" : (("epoch" , "esa_step " , "azimuth_6 " ), np .zeros ((2 , 7 , 60 ))),
101101 },
102102 coords = {
103103 "epoch" : epoch_date ,
104- "azimuth_6" : np .arange (60 ),
105104 "esa_step" : np .arange (1 , 8 ),
105+ "azimuth_6" : np .arange (60 ),
106106 },
107107 )
108108
@@ -114,13 +114,13 @@ def l1a_hist():
114114 epoch_date = et_to_ttj2000ns (str_to_et (["2025-04-15T02:00:00" ]))
115115 l1a_hist = xr .Dataset (
116116 {
117- "hydrogen" : (("epoch" , "azimuth_6 " , "esa_step " ), np .zeros ((1 , 60 , 7 ))),
118- "oxygen" : (("epoch" , "azimuth_6 " , "esa_step " ), np .zeros ((1 , 60 , 7 ))),
117+ "hydrogen" : (("epoch" , "esa_step " , "azimuth_6 " ), np .zeros ((1 , 7 , 60 ))),
118+ "oxygen" : (("epoch" , "esa_step " , "azimuth_6 " ), np .zeros ((1 , 7 , 60 ))),
119119 },
120120 coords = {
121121 "epoch" : epoch_date ,
122- "azimuth_6" : np .arange (60 ),
123122 "esa_step" : np .arange (1 , 8 ),
123+ "azimuth_6" : np .arange (60 ),
124124 },
125125 )
126126 return l1a_hist
@@ -787,37 +787,39 @@ def test_resweep_histogram_success(anc_dependencies):
787787 epoch_date = et_to_ttj2000ns (
788788 str_to_et (["2025-04-15T02:00:00" , "2025-04-15T03:00:00" ])
789789 )
790- l1b_de = xr .Dataset (
790+ l1b_histrate = xr .Dataset (
791791 {
792- "h_counts" : (("epoch" , "azimuth_6 " , "esa_step " ), np .zeros ((2 , 60 , 7 ))),
793- "o_counts" : (("epoch" , "azimuth_6 " , "esa_step " ), np .zeros ((2 , 60 , 7 ))),
792+ "h_counts" : (("epoch" , "esa_step " , "azimuth_6 " ), np .zeros ((2 , 7 , 60 ))),
793+ "o_counts" : (("epoch" , "esa_step " , "azimuth_6 " ), np .zeros ((2 , 7 , 60 ))),
794794 },
795795 coords = {
796796 "epoch" : epoch_date ,
797- "azimuth_6" : np .arange (60 ),
798797 "esa_step" : np .arange (1 , 8 ),
798+ "spin_bin_6" : np .arange (60 ),
799799 },
800800 )
801- exposure_factor_expected = np .zeros ((2 , 60 , 7 ) )
802- exposure_factor_expected [:, :, 0 ] = 1
801+ exposure_factor_expected = np .full ((2 , 7 , 60 ), 1 )
802+ exposure_factor_expected [:, 0 , : ] = 2
803803
804- l1b_de .h_counts [0 , 0 , 0 ] = 5
805- l1b_de .h_counts [0 , 0 , 1 ] = 10
806- l1b_de .h_counts [0 , 0 , 2 ] = 2
804+ l1b_histrate .h_counts [0 , 0 , 0 ] = 5
805+ l1b_histrate .h_counts [0 , 1 , 0 ] = 10
806+ l1b_histrate .h_counts [0 , 2 , 0 ] = 2
807807
808- l1b_de .o_counts [1 , 0 , 0 ] = 2
809- l1b_de .o_counts [1 , 0 , 1 ] = 3
810- l1b_de .o_counts [1 , 0 , 2 ] = 4
808+ l1b_histrate .o_counts [1 , 0 , 0 ] = 2
809+ l1b_histrate .o_counts [1 , 1 , 0 ] = 3
810+ l1b_histrate .o_counts [1 , 2 , 0 ] = 4
811811
812- l1b_histrates , exposure_factor = resweep_histogram_data (l1b_de , anc_dependencies )
812+ l1b_histrates , exposure_factor = resweep_histogram_data (
813+ l1b_histrate , anc_dependencies
814+ )
813815
814816 assert l1b_histrates .h_counts [0 , 0 , 0 ] == 15
815- assert l1b_histrates .h_counts [0 , 0 , 1 ] == 0
816- assert l1b_histrates .h_counts [0 , 0 , 2 ] == 2
817+ assert l1b_histrates .h_counts [0 , 1 , 0 ] == 0
818+ assert l1b_histrates .h_counts [0 , 2 , 0 ] == 2
817819
818820 assert l1b_histrates .o_counts [1 , 0 , 0 ] == 5
819- assert l1b_histrates .o_counts [1 , 0 , 1 ] == 0
820- assert l1b_histrates .o_counts [1 , 0 , 2 ] == 4
821+ assert l1b_histrates .o_counts [1 , 1 , 0 ] == 0
822+ assert l1b_histrates .o_counts [1 , 2 , 0 ] == 4
821823
822824 assert np .array_equal (exposure_factor , exposure_factor_expected )
823825
@@ -827,43 +829,43 @@ def test_resweep_histogram_no_date(anc_dependencies):
827829 epoch_date = et_to_ttj2000ns (
828830 str_to_et (["2025-04-25T02:00:00" , "2025-04-25T03:00:00" ])
829831 )
830- l1b_de = xr .Dataset (
832+ l1b_histrate = xr .Dataset (
831833 {
832- "h_counts" : (("epoch" , "azimuth_6 " , "esa_step " ), np .zeros ((2 , 60 , 7 ))),
833- "o_counts" : (("epoch" , "azimuth_6 " , "esa_step " ), np .zeros ((2 , 60 , 7 ))),
834+ "h_counts" : (("epoch" , "esa_step " , "azimuth_6 " ), np .zeros ((2 , 7 , 60 ))),
835+ "o_counts" : (("epoch" , "esa_step " , "azimuth_6 " ), np .zeros ((2 , 7 , 60 ))),
834836 },
835837 coords = {
836838 "epoch" : epoch_date ,
837- "azimuth_6" : np .arange (60 ),
838839 "esa_step" : np .arange (1 , 8 ),
840+ "spin_bin_6" : np .arange (60 ),
839841 },
840842 )
841843
842- l1b_de .h_counts [0 , 0 , 0 ] = 5
843- l1b_de .h_counts [0 , 0 , 1 ] = 10
844- l1b_de .h_counts [0 , 0 , 2 ] = 2
844+ l1b_histrate .h_counts [0 , 0 , 0 ] = 5
845+ l1b_histrate .h_counts [0 , 1 , 0 ] = 10
846+ l1b_histrate .h_counts [0 , 2 , 0 ] = 2
845847
846848 with pytest .raises (
847849 ValueError ,
848850 match = "No sweep table entry found for date "
849851 "2025-04-25T02:00:00.000 at epoch idx 0" ,
850852 ):
851- resweep_histogram_data (l1b_de , anc_dependencies )
853+ resweep_histogram_data (l1b_histrate , anc_dependencies )
852854
853855
854856def test_resweep_histogram_multiple_lut (anc_dependencies ):
855857 epoch_date = et_to_ttj2000ns (
856858 str_to_et (["2025-04-16T02:00:00" , "2025-04-16T03:00:00" ])
857859 )
858- l1b_de = xr .Dataset (
860+ l1b_histrate = xr .Dataset (
859861 {
860- "h_counts" : (("epoch" , "azimuth_6 " , "esa_step " ), np .zeros ((2 , 60 , 7 ))),
861- "o_counts" : (("epoch" , "azimuth_6 " , "esa_step " ), np .zeros ((2 , 60 , 7 ))),
862+ "h_counts" : (("epoch" , "esa_step " , "azimuth_6 " ), np .zeros ((2 , 7 , 60 ))),
863+ "o_counts" : (("epoch" , "esa_step " , "azimuth_6 " ), np .zeros ((2 , 7 , 60 ))),
862864 },
863865 coords = {
864866 "epoch" : epoch_date ,
865- "azimuth_6" : np .arange (60 ),
866867 "esa_step" : np .arange (1 , 8 ),
868+ "spin_bin_6" : np .arange (60 ),
867869 },
868870 )
869871
@@ -872,7 +874,7 @@ def test_resweep_histogram_multiple_lut(anc_dependencies):
872874 match = f"Expected exactly 1 unique LUT_table "
873875 f"value for date 2025-04-16, but found 2:{ [1 , 2 ]} " ,
874876 ):
875- resweep_histogram_data (l1b_de , anc_dependencies )
877+ resweep_histogram_data (l1b_histrate , anc_dependencies )
876878
877879
878880def test_calculate_histogram_rates (l1b_histrates ):
@@ -889,32 +891,32 @@ def test_calculate_histogram_rates(l1b_histrates):
889891 ]
890892 )
891893 avg_spin_durations_per_cycle = xr .DataArray ([30 , 15 ])
892- exposure_factor = np .zeros ((2 , 60 , 7 ))
894+ exposure_factor = np .zeros ((2 , 7 , 60 ))
893895 exposure_factor [0 , 0 , 0 ] = 1
894896 l1b_histrates .h_counts [0 , 0 , 0 ] = 30
895- l1b_histrates .h_counts [0 , 0 , 1 ] = 10
896- l1b_histrates .h_counts [0 , 0 , 2 ] = 2
897+ l1b_histrates .h_counts [0 , 1 , 0 ] = 10
898+ l1b_histrates .h_counts [0 , 2 , 0 ] = 2
897899 l1b_histrates .h_counts [1 , 0 , 0 ] = 15
898- l1b_histrates .h_counts [1 , 0 , 1 ] = 30
899- l1b_histrates .h_counts [1 , 0 , 2 ] = 45
900+ l1b_histrates .h_counts [1 , 1 , 0 ] = 30
901+ l1b_histrates .h_counts [1 , 2 , 0 ] = 45
900902
901903 l1b_histrates .o_counts [0 , 0 , 0 ] = 100
902- l1b_histrates .o_counts [0 , 0 , 1 ] = 50
903- l1b_histrates .o_counts [0 , 0 , 2 ] = 25
904+ l1b_histrates .o_counts [0 , 1 , 0 ] = 50
905+ l1b_histrates .o_counts [0 , 2 , 0 ] = 25
904906 l1b_histrates .o_counts [1 , 0 , 0 ] = 2
905- l1b_histrates .o_counts [1 , 0 , 1 ] = 3
906- l1b_histrates .o_counts [1 , 0 , 2 ] = 4
907+ l1b_histrates .o_counts [1 , 1 , 0 ] = 3
908+ l1b_histrates .o_counts [1 , 2 , 0 ] = 4
907909
908910 l1b_histrate = calculate_histogram_rates (
909911 l1b_histrates , acq_start , acq_end , avg_spin_durations_per_cycle , exposure_factor
910912 )
911913
912914 hist_rates_h_epoch_0 = l1b_histrate ["h_rates" ]
913915 hist_rates_h_epoch_0 [0 , :, :] = hist_rates_h_epoch_0 [0 , :, :] / 2
914- hist_rates_h_epoch_0 [0 , 0 , : ] = hist_rates_h_epoch_0 [0 , 0 , : ] / 2
916+ hist_rates_h_epoch_0 [0 , :, 0 ] = hist_rates_h_epoch_0 [0 , :, 0 ] / 2
915917 hist_rates_o_epoch_0 = l1b_histrate ["o_rates" ]
916918 hist_rates_o_epoch_0 [0 , :, :] = hist_rates_o_epoch_0 [0 , :, :] / 2
917- hist_rates_o_epoch_0 [0 , 0 , : ] = hist_rates_o_epoch_0 [0 , 0 , : ] / 2
919+ hist_rates_o_epoch_0 [0 , :, 0 ] = hist_rates_o_epoch_0 [0 , :, 0 ] / 2
918920
919921 np .testing .assert_array_equal (
920922 l1b_histrate ["h_rates" ][0 , :, :], hist_rates_h_epoch_0 [0 , :, :]
@@ -944,13 +946,13 @@ def test_calculate_histogram_rates_no_interval_found(l1b_histrates):
944946 ]
945947 )
946948 avg_spin_durations_per_cycle = xr .DataArray ([30 , 15 ])
947- exposure_factor = np .zeros ((2 , 60 , 7 ))
949+ exposure_factor = np .zeros ((2 , 7 , 60 ))
948950 l1b_histrate = calculate_histogram_rates (
949951 l1b_histrates , acq_start , acq_end , avg_spin_durations_per_cycle , exposure_factor
950952 )
951953
952- np .testing .assert_array_equal (l1b_histrate ["h_rates" ], np .full ((2 , 60 , 7 ), np .nan ))
953- np .testing .assert_array_equal (l1b_histrate ["o_rates" ], np .full ((2 , 60 , 7 ), np .nan ))
954+ np .testing .assert_array_equal (l1b_histrate ["h_rates" ], np .full ((2 , 7 , 60 ), np .nan ))
955+ np .testing .assert_array_equal (l1b_histrate ["o_rates" ], np .full ((2 , 7 , 60 ), np .nan ))
954956
955957
956958def test_calculate_histogram_rates_zero_exposure_time (l1b_histrates ):
@@ -967,10 +969,10 @@ def test_calculate_histogram_rates_zero_exposure_time(l1b_histrates):
967969 ]
968970 )
969971 avg_spin_durations_per_cycle = xr .DataArray ([0 , 15 ])
970- exposure_factor = np .zeros ((2 , 60 , 7 ))
972+ exposure_factor = np .zeros ((2 , 7 , 60 ))
971973 l1b_histrate = calculate_histogram_rates (
972974 l1b_histrates , acq_start , acq_end , avg_spin_durations_per_cycle , exposure_factor
973975 )
974976
975- np .testing .assert_array_equal (l1b_histrate ["h_rates" ], np .full ((2 , 60 , 7 ), np .nan ))
976- np .testing .assert_array_equal (l1b_histrate ["o_rates" ], np .full ((2 , 60 , 7 ), np .nan ))
977+ np .testing .assert_array_equal (l1b_histrate ["h_rates" ], np .full ((2 , 7 , 60 ), np .nan ))
978+ np .testing .assert_array_equal (l1b_histrate ["o_rates" ], np .full ((2 , 7 , 60 ), np .nan ))
0 commit comments