def test_sky_position(t1, t2): pos1 = sun.sky_position(t1) ra1 = sun.apparent_rightascension(t1) dec1 = sun.apparent_declination(t1) assert_quantity_allclose(pos1, (ra1, dec1)) pos2 = sun.sky_position(t2, equinox_of_date=False) ra2 = sun.apparent_rightascension(t2, equinox_of_date=False) dec2 = sun.apparent_declination(t2, equinox_of_date=False) assert_quantity_allclose(pos2, (ra2, dec2))
def test_apparent_declination(t1, t2): # Validate against a published value from the Astronomical Almanac (1992, C16) assert_quantity_allclose(sun.apparent_declination(t1), Angle('-7d47m01.7s'), atol=0.05 * u.arcsec) # Validate against a published value from the Astronomical Almanac (2013, C12) assert_quantity_allclose(sun.apparent_declination(t2), Angle('23d22m27.8s'), atol=0.05 * u.arcsec)
def get_detector_sun_angles_for_date(date, file): """ get the GBM detector angles vs the sun as a function of time for a given date Parameters ---------- date : `astropy.time.Time` A `~astropy.time.Time` object or other date format understood by the parse_time function. file : `str` A filepath to a Fermi/LAT weekly pointing file (e.g. as obtained by the download_weekly_pointing_file function). """ date = parse_time(date) tran = TimeRange(date, date + TimeDelta(1 * u.day)) scx, scz, times = get_scx_scz_in_timerange(tran, file) # retrieve the detector angle information in spacecraft coordinates detectors = nai_detector_angles() detector_to_sun_angles = [] # get the detector vs Sun angles for each t and store in a list of # dictionaries. for i in range(len(scx)): detector_radecs = nai_detector_radecs(detectors, scx[i], scz[i], times[i]) # this gets the sun position with RA in hours in decimal format # (e.g. 4.3). DEC is already in degrees sunpos_ra_not_in_deg = [ sun.apparent_rightascension(times[i]), sun.apparent_declination(times[i]) ] # now Sun position with RA in degrees sun_pos = [sunpos_ra_not_in_deg[0].to('deg'), sunpos_ra_not_in_deg[1]] # now get the angle between each detector and the Sun detector_to_sun_angles.append( get_detector_separation_angles(detector_radecs, sun_pos)) # slice the list of dictionaries to get the angles for each detector in a # list form angles = OrderedDict() key_list = [ 'n0', 'n1', 'n2', 'n3', 'n4', 'n5', 'n6', 'n7', 'n8', 'n9', 'n10', 'n11', 'time' ] for i in range(13): if not key_list[i] == 'time': angles[key_list[i]] = [ item[key_list[i]].value for item in detector_to_sun_angles ] * u.deg else: angles[key_list[i]] = [ item[key_list[i]] for item in detector_to_sun_angles ] return angles
def get_detector_sun_angles_for_time(time, file): """ Get the GBM detector angles vs the Sun for a single time. Parameters ---------- time : {parse_time_types} A time specified as a parse_time-compatible time string, number, or a datetime object. file : `str` A filepath to a Fermi/LAT weekly pointing file (e.g. as obtained by the download_weekly_pointing_file function). Returns ------- `tuple`: A tuple of all the detector angles. """ time = parse_time(time) scx, scz, tt = get_scx_scz_at_time(time, file) # retrieve the detector angle information in spacecraft coordinates detectors = nai_detector_angles() # get the detector pointings in RA/DEC given the input spacecraft x and z # axes detector_radecs = nai_detector_radecs(detectors, scx, scz, tt) # this gets the sun position with RA in hours in decimal format (e.g. 4.3). # DEC is already in degrees sunpos_ra_not_in_deg = [ sun.apparent_rightascension(time), sun.apparent_declination(time) ] # now Sun position with RA in degrees sun_pos = [sunpos_ra_not_in_deg[0].to('deg'), sunpos_ra_not_in_deg[1]] # sun_pos = [(sunpos_ra_not_in_deg[0] / 24) * 360., sunpos_ra_not_in_deg[1]] # now get the angle between each detector and the Sun detector_to_sun_angles = (get_detector_separation_angles( detector_radecs, sun_pos)) return detector_to_sun_angles
def test_apparent_declination_J2000(t1): # Regression-only test assert_quantity_allclose(sun.apparent_declination(t1, equinox_of_date=False), Angle('-7d49m13.1s'), atol=0.05 * u.arcsec)
def get_detector_sun_angles_for_date(date, file): """ Get the GBM detector angles vs the Sun as a function of time for a given date. Parameters ---------- date : {parse_time_types} A date specified as a parse_time-compatible time string, number, or a datetime object. file : `str` A filepath to a Fermi/LAT weekly pointing file (e.g. as obtained by the download_weekly_pointing_file function). Returns ------- `tuple`: A tuple of all the detector angles. """ date = parse_time(date) tran = TimeRange(date, date + TimeDelta(1 * u.day)) scx, scz, times = get_scx_scz_in_timerange(tran, file) # retrieve the detector angle information in spacecraft coordinates detectors = nai_detector_angles() detector_to_sun_angles = [] # get the detector vs Sun angles for each t and store in a list of # dictionaries. for i in range(len(scx)): detector_radecs = nai_detector_radecs(detectors, scx[i], scz[i], times[i]) # this gets the sun position with RA in hours in decimal format # (e.g. 4.3). DEC is already in degrees sunpos_ra_not_in_deg = [ sun.apparent_rightascension(times[i]), sun.apparent_declination(times[i]), ] # now Sun position with RA in degrees sun_pos = [sunpos_ra_not_in_deg[0].to("deg"), sunpos_ra_not_in_deg[1]] # now get the angle between each detector and the Sun detector_to_sun_angles.append( get_detector_separation_angles(detector_radecs, sun_pos)) # slice the list of dictionaries to get the angles for each detector in a # list form angles = OrderedDict() key_list = [ "n0", "n1", "n2", "n3", "n4", "n5", "n6", "n7", "n8", "n9", "n10", "n11", "time", ] for i in range(13): if not key_list[i] == "time": angles[key_list[i]] = [ item[key_list[i]].value for item in detector_to_sun_angles ] * u.deg else: angles[key_list[i]] = [ item[key_list[i]] for item in detector_to_sun_angles ] return angles