def test_detector_angles(): # set a test date date = parse_time('2012-02-15') file = fermi.download_weekly_pointing_file(date) det = fermi.get_detector_sun_angles_for_date(date, file) assert len(det) == 13 assert_almost_equal(det['n0'][0].value, 20.30309, decimal=1) assert_almost_equal(det['n1'][0].value, 30.30430, decimal=1) assert_almost_equal(det['n2'][0].value, 74.86032, decimal=1) assert_almost_equal(det['n3'][0].value, 31.24400, decimal=1) assert_almost_equal(det['n4'][0].value, 75.10403, decimal=1) assert_almost_equal(det['n5'][0].value, 60.40967, decimal=1) assert_almost_equal(det['n6'][0].value, 46.14087, decimal=1) assert_almost_equal(det['n7'][0].value, 69.71780, decimal=1) assert_almost_equal(det['n8'][0].value, 106.08064, decimal=1) assert_almost_equal(det['n9'][0].value, 68.543067, decimal=1) assert_almost_equal(det['n10'][0].value, 105.76825, decimal=1) assert_almost_equal(det['n11'][0].value, 119.69057, decimal=1) det2 = fermi.get_detector_sun_angles_for_time( parse_time('2012-02-15 02:00'), file) assert len(det2) == 13 assert type(det2) == dict assert_almost_equal(det2['n0'].value, 87.24744, decimal=1) assert_almost_equal(det2['n1'].value, 69.90883, decimal=1) assert_almost_equal(det2['n10'].value, 123.56429, decimal=1) assert_almost_equal(det2['n11'].value, 167.26615, decimal=1) assert_almost_equal(det2['n2'].value, 59.82642, decimal=1) assert_almost_equal(det2['n3'].value, 69.18959, decimal=1) assert_almost_equal(det2['n4'].value, 56.83158, decimal=1) assert_almost_equal(det2['n5'].value, 12.49959, decimal=1) assert_almost_equal(det2['n6'].value, 115.31259, decimal=1) assert_almost_equal(det2['n7'].value, 129.49283, decimal=1) assert_almost_equal(det2['n8'].value, 121.91083, decimal=1) assert_almost_equal(det2['n9'].value, 130.04144, decimal=1)
def test_detector_angles(): # set a test date date = parse_time('2012-02-15') file = fermi.download_weekly_pointing_file(date) det = fermi.get_detector_sun_angles_for_date(date, file) assert len(det) == 13 assert_almost_equal(det['n0'][0].value, 21.73944, decimal=1) assert_almost_equal(det['n1'][0].value, 30.62983, decimal=1) assert_almost_equal(det['n2'][0].value, 74.67486, decimal=1) assert_almost_equal(det['n3'][0].value, 30.46062, decimal=1) assert_almost_equal(det['n4'][0].value, 73.89734, decimal=1) assert_almost_equal(det['n5'][0].value, 58.99893, decimal=1) assert_almost_equal(det['n6'][0].value, 47.31091, decimal=1) assert_almost_equal(det['n7'][0].value, 70.63391, decimal=1) assert_almost_equal(det['n8'][0].value, 106.30992, decimal=1) assert_almost_equal(det['n9'][0].value, 70.07033, decimal=1) assert_almost_equal(det['n10'][0].value, 106.97884, decimal=1) assert_almost_equal(det['n11'][0].value, 121.09603, decimal=1) det2 = fermi.get_detector_sun_angles_for_time( parse_time('2012-02-15 02:00'), file) assert len(det2) == 13 assert type(det2) == dict assert_almost_equal(det2['n0'].value, 83.76092, decimal=1) assert_almost_equal(det2['n1'].value, 66.65847, decimal=1) assert_almost_equal(det2['n10'].value, 123.28952, decimal=1) assert_almost_equal(det2['n11'].value, 170.69869, decimal=1) assert_almost_equal(det2['n2'].value, 58.78532, decimal=1) assert_almost_equal(det2['n3'].value, 66.69068, decimal=1) assert_almost_equal(det2['n4'].value, 57.16402, decimal=1) assert_almost_equal(det2['n5'].value, 9.04924, decimal=1) assert_almost_equal(det2['n6'].value, 112.21230, decimal=1) assert_almost_equal(det2['n7'].value, 127.35783, decimal=1) assert_almost_equal(det2['n8'].value, 122.98894, decimal=1) assert_almost_equal(det2['n9'].value, 126.95987, decimal=1)
def test_detector_angles(): #set a test date date = parse_time('2012-02-15') file = fermi.download_weekly_pointing_file(date) det=fermi.get_detector_sun_angles_for_date(date,file) assert len(det) == 13 #assert type(det) == collections.OrderedDict assert_almost_equal(det['n0'][0].value, 20.30309,decimal=1) assert_almost_equal(det['n1'][0].value, 30.30430, decimal=1) assert_almost_equal(det['n2'][0].value, 74.86032, decimal=1) assert_almost_equal(det['n3'][0].value, 31.24400, decimal=1) assert_almost_equal(det['n4'][0].value, 75.10403, decimal=1) assert_almost_equal(det['n5'][0].value, 60.40967, decimal=1) assert_almost_equal(det['n6'][0].value, 46.14087, decimal=1) assert_almost_equal(det['n7'][0].value, 69.71780, decimal=1) assert_almost_equal(det['n8'][0].value, 106.08064, decimal=1) assert_almost_equal(det['n9'][0].value, 68.543067, decimal=1) assert_almost_equal(det['n10'][0].value, 105.76825, decimal=1) assert_almost_equal(det['n11'][0].value, 119.69057, decimal=1) det2=fermi.get_detector_sun_angles_for_time(parse_time('2012-02-15 02:00'),file) assert len(det2) == 13 assert type(det2) == dict assert_almost_equal(det2['n0'].value, 87.24744,decimal=1) assert_almost_equal(det2['n1'].value, 69.90883,decimal=1) assert_almost_equal(det2['n10'].value, 123.56429,decimal=1) assert_almost_equal(det2['n11'].value, 167.26615,decimal=1) assert_almost_equal(det2['n2'].value, 59.82642,decimal=1) assert_almost_equal(det2['n3'].value, 69.18959,decimal=1) assert_almost_equal(det2['n4'].value, 56.83158,decimal=1) assert_almost_equal(det2['n5'].value, 12.49959,decimal=1) assert_almost_equal(det2['n6'].value, 115.31259,decimal=1) assert_almost_equal(det2['n7'].value, 129.49283,decimal=1) assert_almost_equal(det2['n8'].value, 121.91083,decimal=1) assert_almost_equal(det2['n9'].value, 130.04144,decimal=1)
def test_detector_angles(): # set a test date date = parse_time('2012-02-15') file = fermi.download_weekly_pointing_file(date) det = fermi.get_detector_sun_angles_for_date(date, file) assert len(det) == 13 assert_almost_equal(det['n0'][0].value, 21.79, decimal=1) assert_almost_equal(det['n1'][0].value, 30.45, decimal=1) assert_almost_equal(det['n2'][0].value, 74.44, decimal=1) assert_almost_equal(det['n3'][0].value, 30.58, decimal=1) assert_almost_equal(det['n4'][0].value, 73.93, decimal=1) assert_almost_equal(det['n5'][0].value, 58.78, decimal=1) assert_almost_equal(det['n6'][0].value, 47.56, decimal=1) assert_almost_equal(det['n7'][0].value, 70.89, decimal=1) assert_almost_equal(det['n8'][0].value, 106.54, decimal=1) assert_almost_equal(det['n9'][0].value, 70.17, decimal=1) assert_almost_equal(det['n10'][0].value, 106.95, decimal=1) assert_almost_equal(det['n11'][0].value, 121.32, decimal=1) det2 = fermi.get_detector_sun_angles_for_time( parse_time('2012-02-15 02:00'), file) assert len(det2) == 13 assert type(det2) == dict assert_almost_equal(det2['n0'].value, 83.54, decimal=1) assert_almost_equal(det2['n1'].value, 66.50, decimal=1) assert_almost_equal(det2['n10'].value, 123.39, decimal=1) assert_almost_equal(det2['n11'].value, 170.89, decimal=1) assert_almost_equal(det2['n2'].value, 58.84, decimal=1) assert_almost_equal(det2['n3'].value, 66.44, decimal=1) assert_almost_equal(det2['n4'].value, 57.06, decimal=1) assert_almost_equal(det2['n5'].value, 8.85, decimal=1) assert_almost_equal(det2['n6'].value, 111.95, decimal=1) assert_almost_equal(det2['n7'].value, 127.12, decimal=1) assert_almost_equal(det2['n8'].value, 122.93, decimal=1) assert_almost_equal(det2['n9'].value, 126.82, decimal=1)
def _get_closest_detector_for_date(cls, date, **kwargs): """Returns the GBM detector with the smallest mean angle to the Sun for the given date""" pointing_file = fermi.download_weekly_pointing_file(date) det_angles = fermi.get_detector_sun_angles_for_date(date, pointing_file) det_angle_means = [] for n in det_angles.keys(): if not n == 'time': det_angle_values = [] for angle in det_angles[n]: det_angle_values.append(angle.value) det_angle_means.append(np.mean(det_angle_values)) best_det = 'n' +str(np.argmin(det_angle_means)) return best_det
def test_download_weekly_pointing_file(): # set a test date date = parse_time('2011-10-01') afile = fermi.download_weekly_pointing_file(date) assert isinstance(afile, six.string_types) assert afile.endswith('.fits')
def test_download_weekly_pointing_file(): #set a test date date = parse_time('2011-10-01') file = fermi.download_weekly_pointing_file(date) assert file.endswith('FERMI_POINTING_FINAL_174_2011272_2011279_02.fits')