def radec2azel(self, mjd, ra, dec): """ Given RA/Dec and time returns Az/El. Parameters ---------- mjd : float Date in MJD. ra : float Right ascension in radian. dec : float Declination in radian. Returns ---------- az : float Azimuth in radian. el : float Elevation in radian. """ amprms = slalib.sla_mappa(self.epequi, mjd) self.aoprms = slalib.sla_aoppat(mjd, self.aoprms) ra_app, dec_app = slalib.sla_mapqkz(ra, dec, amprms) az, zd, a, b, c = slalib.sla_aopqk(ra_app, dec_app, self.aoprms) el = np.pi / 2 - zd return az, el
def azel2radecpa(self, mjd, az, el): """ Given Az/El and time returns RA/Dec and parallactic angle. This routine does not return a precisely correct parallactic angle. Parameters ---------- mjd : float Date in MJD. az : float Azimuth in radian. el : float Elevation in radian. Returns ---------- ra : float Right ascension in radian. dec : float Declination in radian. pa : float Parallactic angle in radian. """ zd = np.pi / 2 - el amprms = slalib.sla_mappa(self.epequi, mjd) self.aoprms = slalib.sla_aoppat(mjd, self.aoprms) ra_app1, dec_app1 = slalib.sla_oapqk('a', az, zd + 1e-8, self.aoprms) ra1, dec1 = slalib.sla_ampqk(ra_app1, dec_app1, amprms) ra_app2, dec_app2 = slalib.sla_oapqk('a', az, zd - 1e-8, self.aoprms) ra2, dec2 = slalib.sla_ampqk(ra_app2, dec_app2, amprms) pa = slalib.sla_dbear(ra1, dec1, ra2, dec2) ra = 0.5 * (ra1 + ra2) dec = 0.5 * (dec1 + dec2) return ra, dec, pa
def calculate_airmass_at_times(times, target, obs_latitude, obs_longitude, obs_height): """ Returns the airmass values at each of the times passed in for the given target Returns the airmass values for a target and observer specified at each time value in the input times list. This uses the speedier slalib aop quick function which caches the object lat/lon/height and refraction parameters. Args: times (list): A list of datetimes during which to calculate the airmass of the target target (dict): A dictionary of target details in the rise-set library format obs_latitude (Angle): The site/observer latitude within a rise-set Angle obs_longitude (Angle): The site/observer longitude within a rise-set Angle obs_height (float): The site/observer altitude in meters Returns: list: A list of airmass values that correspond to the input list of datetimes """ airmasses = [] aop_params = None # Assume standard atmosphere temp_k = 273.15 # local ambient temperature (K; std=273.15) pres_mb = 1013.25 # local atmospheric pressure (mb; std=1013.25D0) rel_humid = 0.3 # local relative humidity (in the range 0D0-1D0) wavelen = 0.55 # effective wavelength (in microns e.g. 0.55D0 (approx V band)) tlr = 0.0065 # tropospheric lapse rate (K per metre, e.g. 0.0065D0) # Assume no polar motion xp = yp = 0.0 # Assume UT1-UTC dut = 0.0 site = { 'longitude': obs_longitude, 'latitude': obs_latitude, 'altitude': obs_height } for time in times: mjd_utc = gregorian_to_ut_mjd(time) if aop_params is None: aop_params = sla.sla_aoppa(mjd_utc, dut, obs_longitude.in_radians(), obs_latitude.in_radians(), obs_height, xp, yp, temp_k, pres_mb, rel_humid, wavelen, tlr) else: aop_params = sla.sla_aoppat(mjd_utc, aop_params) # Convert datetime to MJD_TDB tdb = ut_mjd_to_tdb(mjd_utc) #not TDB but good enough # Convert catalog mean RA, Dec at J2000 to apparent of date if is_moving_object(target): ra_apparent, dec_apparent = elem_to_topocentric_apparent( time, target, site, target_to_jform(target)) else: ra_apparent, dec_apparent = mean_to_apparent(target, tdb) airmass = apparent_to_airmass(ra_apparent, dec_apparent, aop_params) airmasses.append(airmass) return airmasses