def datetime2mjd_tdb(date, obsvr_long, obsvr_lat, obsvr_hgt, dbg=False): auinkm = 149597870.691 # Compute MJD_UTC from passed datetime mjd_utc = datetime2mjd_utc(date) if mjd_utc == None: return None # Compute MJD_TT mjd_tt = mjd_utc2mjd_tt(mjd_utc, dbg) # Compute TT->TDB # Convert geodetic position to geocentric distance from spin axis (r) and from # equatorial plane (z) (r, z) = S.sla_geoc(obsvr_lat, obsvr_hgt) ut1 = compute_ut1(mjd_utc, dbg) if dbg: print "UT1=", ut1 # Compute relativistic clock correction TDB->TT tdb_tt = S.sla_rcc(mjd_tt, ut1, -obsvr_long, r*auinkm, z*auinkm) if dbg: print "(TDB-TT)=", tdb_tt if dbg: print "(CT-UT)=", S.sla_dtt(mjd_utc)+tdb_tt mjd_tdb = mjd_tt + (tdb_tt/86400.0) return mjd_tdb
def datetime2mjd_tdb(date, obsvr_long, obsvr_lat, obsvr_hgt, dbg=False): auinkm = 149597870.691 # Compute MJD_UTC from passed datetime mjd_utc = datetime2mjd_utc(date) if mjd_utc is None: return None # Compute MJD_TT mjd_tt = mjd_utc2mjd_tt(mjd_utc, dbg) # Compute TT->TDB # Convert geodetic position to geocentric distance from spin axis (r) and from # equatorial plane (z) (r, z) = S.sla_geoc(obsvr_lat, obsvr_hgt) ut1 = compute_ut1(mjd_utc, dbg) if dbg: print("UT1=", ut1) # Compute relativistic clock correction TDB->TT tdb_tt = S.sla_rcc(mjd_tt, ut1, -obsvr_long, r * auinkm, z * auinkm) if dbg: print("(TDB-TT)=", tdb_tt) if dbg: print("(CT-UT)=", S.sla_dtt(mjd_utc) + tdb_tt) mjd_tdb = mjd_tt + (tdb_tt / 86400.0) return mjd_tdb
def mjd_utc_to_mjd_tt(mjd_utc, dbg=False): """Converts a MJD in UTC (MJD_UTC) to a MJD in TT (Terrestial Time) which is needed for any position/ephemeris-based calculations.UTC UTC->TT consists of: UTC->TAI = 10s offset + 24 leapseconds (last one 2009 Jan 1.) TAI->TT = 32.184s fixed offset""" tt_utc = slalib.sla_dtt(mjd_utc) if dbg: print 'TT-UTC(s)=', tt_utc mjd_tt = mjd_utc + (tt_utc/86400.0) if dbg: print 'MJD(TT) = ', mjd_tt return mjd_tt
def mjd_utc2mjd_tt(mjd_utc, dbg=False): '''Converts a MJD in UTC (MJD_UTC) to a MJD in TT (Terrestial Time) which is needed for any position/ephemeris-based calculations. UTC->TT consists of: UTC->TAI = 10s offset + 24 leapseconds (last one 2009 Jan 1.) TAI->TT = 32.184s fixed offset''' # UTC->TT offset tt_utc = S.sla_dtt(mjd_utc) if dbg: print('TT-UTC(s)=', tt_utc) # Correct MJD to MJD(TT) mjd_tt = mjd_utc + (tt_utc / 86400.0) if dbg: print('MJD(TT) = ', mjd_tt) return mjd_tt
def ut_mjd_to_tdb(ut_mjd): tdb = ut_mjd + (sla.sla_dtt(ut_mjd) / 86400) return tdb
def calc_tabular_interval(m, tdb): '''Find n, the tabular interval (Ast.Alg., p.99).''' return m + (sla.sla_dtt(tdb) / 86400)
# ra.append(math.degrees(r1)) # dec.append(math.degrees(d1)) # #with open("slalib_hip_map.txt", "w") as f: # f.write("# Apparent RA DEC for J2000.0 in degrees.\n") # for r, d in zip(ra, dec): # s = "%14.9f %14.9f\n" # f.write(s % (r, d)) # sla_aop # Convert apparent to observed place. tab['pma'] = np.radians(tab['pma'] / 3600.0) / 100.0 tab['pmd'] = np.radians(tab['pmd'] / 3600.0) / 100.0 utc = slalib.sla_caldj(2010, 1, 1)[0] tt = slalib.sla_dtt(utc) / 86400.0 + utc dut = 1.4823561643834426 # from TPM. aob = np.zeros((len(tab['raj2']), ), dtype=np.float64) zob = aob.copy() hob = aob.copy() dob = aob.copy() rob = aob.copy() lon = np.radians(-111.598333) lat = np.radians(31.956389) for j, i in enumerate(tab): r1, d1 = slalib.sla_map(i['raj2'], i['decj2'], i['pma'], i['pmd'], i['px'], 0.0, 2000.0, tt) aob[j], zob[j], hob[j], dob[j], rob[j] = \ slalib.sla_aop(r1, d1, utc, dut, lon, lat, 2093.093, 0.0, 0.0,
def _convert_coordinates(self, lat, long, ra_ref, dec_ref, date, time): """ Accurate conversion from equatorial coordiantes (RA, DEC) to Spherical (TH,PH) coordinates. The code uses the pyslalib library for a number of functions from the SLALIB Fortran library converted to Python. :param lat: latitude (decimal degrees) :param long: longitude (decimal degrees) :param ra_ref: RA(J2000) (decimal hours) :param dec_ref: Dec(J2000) (decimal degrees) :param date: vector date [iyear, imonth, iday] :param time: vector time [ihour imin isec] :return: [theta, pi]: Theta and Phi angles (degrees) """ const_2pi = 2.0 * math.pi d2r = math.pi / 180 r2d = 180 / math.pi # Conversion factor seconds of time to days const_st2day = 1.0/(24 * 3600) # Specify latitude and longitude (radians) lat *= d2r long *= d2r # Specify catalogued position (J2000 coordinates, radians) ra_ref = ra_ref * 15 * d2r dec_ref *= d2r # Specify current time and date % isec = time[2] imin = time[1] ihour = time[0] iday = date[2] imonth = date[1] iyear = date[0] # Convert current UTC to Modified Julian date djm, j1 = slalib.sla_cldj(iyear, imonth, iday) fdutc, j2 = slalib.sla_dtf2d(ihour, imin, isec) djutc = djm + fdutc # Calculate Greenwich Mean Sidereal Time from MJD gmst1 = slalib.sla_gmst(djutc) # Add longitude and Equation of Equinoxes for Local Apparent ST djtt = djutc + slalib.sla_dtt(djutc)*const_st2day last = gmst1 + long + slalib.sla_eqeqx(djtt) if last < 0.0: last += const_2pi # Convert catalogued position to apparent RA, Dec at current date pr = 0.e0 pd = 0.e0 px = 0.e0 rv = 0.e0 eq = 2000.0e0 [raobs, decobs] = slalib.sla_map(ra_ref, dec_ref, pr, pd, px, rv, eq, djutc) # Get Hour Angle and Declination ha = last - raobs if ha < -math.pi: ha += const_2pi if ha > math.pi: ha -= const_2pi dec = decobs # Convert to Azimuth and Elevation azim, elev = slalib.sla_de2h(ha, dec, lat) theta = (90 - elev * r2d).real phi = (azim * r2d).real return [theta, phi]