def hipecleq(): """Print summary of ECL-EQ comparison with SLALIB ecleq (HIP).""" hip_tab = get_hipdata() sla_tab = get_sla("slalib_hip_ecleq.txt") dummy = np.zeros((len(hip_tab['px']), )) v6l = convert.cat2v6(hip_tab['elon2'], hip_tab['elat2'], dummy, dummy, dummy, dummy, tpm.CJ) v6o = convert.convertv6(v6l, s1=3, s2=6) cat = convert.v62cat(v6o, tpm.CJ) cat = cat2array(cat) ra_diff = np.degrees(cat['alpha']) - sla_tab[:, 0] ra_diff = np.abs(ra_diff * 3600.0) dec_diff = np.degrees(cat['delta']) - sla_tab[:, 1] dec_diff = np.abs(dec_diff * 3600.0) print("Comparison with SLALIB ecleq using HIPPARCOS data.") fs = "{0} {1}\n" + \ "Min: {2:.4f} Max: {3:.4f} \nMean: {4:.4f} Std: {5:.4f}\n" x = stats.describe(ra_diff) print(fs.format("ra_diff", "arcsec", x[1][0], x[1][1], x[2], x[3]**0.5)) x = stats.describe(dec_diff) print(fs.format("dec_diff", "arcsec", x[1][0], x[1][1], x[2], x[3]**0.5))
def hipeqgal(): """Print summary of EQ-GAL comparison with SLALIB eqgal (HIP).""" hip_tab = get_hipdata() sla_tab = get_sla("slalib_hip_eqgal.txt") dummy = np.zeros((len(hip_tab['px']), )) v6l = convert.cat2v6(hip_tab['raj2'], hip_tab['decj2'], dummy, dummy, dummy, dummy, tpm.CJ) v6o = convert.convertv6(v6l, s1=6, s2=4) # The galactic coordinates are at epoch J2000. But SLALIB # results are for B1950. So apply proper motion here. v6o = convert.proper_motion(v6o, tpm.B1950, tpm.J2000) cat = convert.v62cat(v6o, tpm.CJ) cat = cat2array(cat) ra_diff = np.degrees(cat['alpha']) - sla_tab[:, 0] ra_diff = np.abs(ra_diff * 3600.0) dec_diff = np.degrees(cat['delta']) - sla_tab[:, 1] dec_diff = np.abs(dec_diff * 3600.0) print("Comparison with SLALIB eqgal using HIPPARCOS data.") fs = "{0} {1}\n" + \ "Min: {2:.4f} Max: {3:.4f} \nMean: {4:.4f} Std: {5:.4f}\n" x = stats.describe(ra_diff) print(fs.format("ra_diff", "arcsec", x[1][0], x[1][1], x[2], x[3]**0.5)) x = stats.describe(dec_diff) print(fs.format("dec_diff", "arcsec", x[1][0], x[1][1], x[2], x[3]**0.5))
def hipecleq(): """Print summary of ECL-EQ comparison with SLALIB ecleq (HIP).""" hip_tab = get_hipdata() sla_tab = get_sla("slalib_hip_ecleq.txt") dummy = np.zeros((len(hip_tab['px']),)) v6l = convert.cat2v6(hip_tab['elon2'], hip_tab['elat2'], dummy, dummy, dummy, dummy, tpm.CJ) v6o = convert.convertv6(v6l, s1=3, s2=6) cat = convert.v62cat(v6o, tpm.CJ) cat = cat2array(cat) ra_diff = np.degrees(cat['alpha']) - sla_tab[:, 0] ra_diff = np.abs(ra_diff * 3600.0) dec_diff = np.degrees(cat['delta']) - sla_tab[:, 1] dec_diff = np.abs(dec_diff * 3600.0) print("Comparison with SLALIB ecleq using HIPPARCOS data.") fs = "{0} {1}\n" + \ "Min: {2:.4f} Max: {3:.4f} \nMean: {4:.4f} Std: {5:.4f}\n" x = stats.describe(ra_diff) print(fs.format("ra_diff", "arcsec", x[1][0], x[1][1], x[2], x[3] ** 0.5)) x = stats.describe(dec_diff) print(fs.format("dec_diff", "arcsec", x[1][0], x[1][1], x[2], x[3] ** 0.5))
def hipgaleq(): """Print summary of GAL-EQ comparison with SLALIB galeq (HIP).""" hip_tab = get_hipdata() sla_tab = get_sla("slalib_hip_galeq.txt") dummy = np.zeros((len(hip_tab['px']),)) v6l = convert.cat2v6(hip_tab['glon'], hip_tab['glat'], dummy, dummy, dummy, dummy, tpm.CJ) # The actual epoch of galactic data is J2000. But in SLALIB # the input is taken to be B1950.0. So use tpm.B1950 as epoch # in the conversion. v6o = convert.convertv6(v6l, s1=4, s2=6, epoch=tpm.B1950) cat = convert.v62cat(v6o, tpm.CJ) cat = cat2array(cat) ra_diff = np.degrees(cat['alpha']) - sla_tab[:, 0] ra_diff = np.abs(ra_diff * 3600.0) dec_diff = np.degrees(cat['delta']) - sla_tab[:, 1] dec_diff = np.abs(dec_diff * 3600.0) print("Comparison with SLALIB galeq using HIPPARCOS data.") fs = "{0} {1}\n" + \ "Min: {2:.4f} Max: {3:.4f} \nMean: {4:.4f} Std: {5:.4f}\n" x = stats.describe(ra_diff) print(fs.format("ra_diff", "arcsec", x[1][0], x[1][1], x[2], x[3] ** 0.5)) x = stats.describe(dec_diff) print(fs.format("dec_diff", "arcsec", x[1][0], x[1][1], x[2], x[3] ** 0.5))
def hipeqgal(): """Print summary of EQ-GAL comparison with SLALIB eqgal (HIP).""" hip_tab = get_hipdata() sla_tab = get_sla("slalib_hip_eqgal.txt") dummy = np.zeros((len(hip_tab['px']),)) v6l = convert.cat2v6(hip_tab['raj2'], hip_tab['decj2'], dummy, dummy, dummy, dummy, tpm.CJ) v6o = convert.convertv6(v6l, s1=6, s2=4) # The galactic coordinates are at epoch J2000. But SLALIB # results are for B1950. So apply proper motion here. v6o = convert.proper_motion(v6o, tpm.B1950, tpm.J2000) cat = convert.v62cat(v6o, tpm.CJ) cat = cat2array(cat) ra_diff = np.degrees(cat['alpha']) - sla_tab[:, 0] ra_diff = np.abs(ra_diff * 3600.0) dec_diff = np.degrees(cat['delta']) - sla_tab[:, 1] dec_diff = np.abs(dec_diff * 3600.0) print("Comparison with SLALIB eqgal using HIPPARCOS data.") fs = "{0} {1}\n" + \ "Min: {2:.4f} Max: {3:.4f} \nMean: {4:.4f} Std: {5:.4f}\n" x = stats.describe(ra_diff) print(fs.format("ra_diff", "arcsec", x[1][0], x[1][1], x[2], x[3] ** 0.5)) x = stats.describe(dec_diff) print(fs.format("dec_diff", "arcsec", x[1][0], x[1][1], x[2], x[3] ** 0.5))
def hipgaleq(): """Print summary of GAL-EQ comparison with SLALIB galeq (HIP).""" hip_tab = get_hipdata() sla_tab = get_sla("slalib_hip_galeq.txt") dummy = np.zeros((len(hip_tab['px']), )) v6l = convert.cat2v6(hip_tab['glon'], hip_tab['glat'], dummy, dummy, dummy, dummy, tpm.CJ) # The actual epoch of galactic data is J2000. But in SLALIB # the input is taken to be B1950.0. So use tpm.B1950 as epoch # in the conversion. v6o = convert.convertv6(v6l, s1=4, s2=6, epoch=tpm.B1950) cat = convert.v62cat(v6o, tpm.CJ) cat = cat2array(cat) ra_diff = np.degrees(cat['alpha']) - sla_tab[:, 0] ra_diff = np.abs(ra_diff * 3600.0) dec_diff = np.degrees(cat['delta']) - sla_tab[:, 1] dec_diff = np.abs(dec_diff * 3600.0) print("Comparison with SLALIB galeq using HIPPARCOS data.") fs = "{0} {1}\n" + \ "Min: {2:.4f} Max: {3:.4f} \nMean: {4:.4f} Std: {5:.4f}\n" x = stats.describe(ra_diff) print(fs.format("ra_diff", "arcsec", x[1][0], x[1][1], x[2], x[3]**0.5)) x = stats.describe(dec_diff) print(fs.format("dec_diff", "arcsec", x[1][0], x[1][1], x[2], x[3]**0.5))
def fk5ecl(): # FK5 equinox and epoch J2000.0, to IAU 1980 ecliptic J2000.0 v6o = convert.convertv6(v6, s1=6, s2=3) # Convert V6C vectors into a list of dictionaries, each of which # contain the 6-D Fk4 B1950.0 coordinates. cat = convert.v62cat(v6o, tpm.CJ) return cat
def hipfk425(): """Print summary of FK4-FK5 comparison with SLALIB fk425 (HIP). The input FK4 data is the same generated for the the FK5-FK4 conversion test. I read that data into slalib and perform the reverse conversion. The result is then compared with that from PyTPM. """ sla_tabb = get_sla("slalib_hip_fk524.txt") sla_tab = get_sla("slalib_hip_fk524_fk425.txt") r = np.radians(sla_tabb[:, 0]) d = np.radians(sla_tabb[:, 1]) px = sla_tabb[:, 2] / 1000.0 pma = sla_tabb[:, 3] / 1000.0 * 100.0 pmd = sla_tabb[:, 4] / 1000.0 * 100.0 rv = sla_tabb[:, 5] v6l = convert.cat2v6(r, d, pma, pmd, px, rv, tpm.CB) v6o = convert.convertv6(v6l, s1=5, s2=6, epoch=tpm.B1950) v6o = convert.proper_motion(v6o, tpm.J2000, tpm.B1950) cat = convert.v62cat(v6o, tpm.CJ) cat = cat2array(cat) r = np.degrees(cat['alpha']) d = np.degrees(cat['delta']) # arc-sec/cent. to milli-arcsec/Jul. year. pma = cat['pma'] * 1000.0 / 100.0 pmd = cat['pmd'] * 1000.0 / 100.0 # arc-sec to milli-arcsec px = cat['px'] * 1000.0 ra_diff = np.abs(r - sla_tab[:, 0]) * 3600.0 dec_diff = np.abs(d - sla_tab[:, 1]) * 3600.0 px_diff = np.abs(px - sla_tab[:, 2]) pma_diff = np.abs(pma - sla_tab[:, 3]) pmd_diff = np.abs(pmd - sla_tab[:, 4]) rv_diff = np.abs(rv - sla_tab[:, 5]) fs = "{0} {1}\n" + \ "Min: {2:.4f} Max: {3:.4f} \nMean: {4:.4f} Std: {5:.4f}\n" x = [ stats.describe(np.abs(i)) for i in [ra_diff, dec_diff, px_diff, pma_diff, pmd_diff, rv_diff] ] print("Comparison with SLALIB fk425 using HIPPARCOS data.") for name, unit, s in zip( ["ra_diff", "dec_diff", "px_diff", "pma_diff", "pmd_diff", "rv_diff"], [ "arsec", "arcsec", "milliarcsec", "milli-arsec/trop. yr", "milli-arcsec/trop. yr", "km/s" ], x): print(fs.format(name, unit, s[1][0], s[1][1], s[2], s[3]**0.5))
def hipfk425(): """Print summary of FK4-FK5 comparison with SLALIB fk425 (HIP). The input FK4 data is the same generated for the the FK5-FK4 conversion test. I read that data into slalib and perform the reverse conversion. The result is then compared with that from PyTPM. """ sla_tabb = get_sla("slalib_hip_fk524.txt") sla_tab = get_sla("slalib_hip_fk524_fk425.txt") r = np.radians(sla_tabb[:, 0]) d = np.radians(sla_tabb[:, 1]) px = sla_tabb[:, 2] / 1000.0 pma = sla_tabb[:, 3] / 1000.0 * 100.0 pmd = sla_tabb[:, 4] / 1000.0 * 100.0 rv = sla_tabb[:, 5] v6l = convert.cat2v6(r, d, pma, pmd, px, rv, tpm.CB) v6o = convert.convertv6(v6l, s1=5, s2=6, epoch=tpm.B1950) v6o = convert.proper_motion(v6o, tpm.J2000, tpm.B1950) cat = convert.v62cat(v6o, tpm.CJ) cat = cat2array(cat) r = np.degrees(cat['alpha']) d = np.degrees(cat['delta']) # arc-sec/cent. to milli-arcsec/Jul. year. pma = cat['pma'] * 1000.0 / 100.0 pmd = cat['pmd'] * 1000.0 / 100.0 # arc-sec to milli-arcsec px = cat['px'] * 1000.0 ra_diff = np.abs(r - sla_tab[:, 0]) * 3600.0 dec_diff = np.abs(d - sla_tab[:, 1]) * 3600.0 px_diff = np.abs(px - sla_tab[:, 2]) pma_diff = np.abs(pma - sla_tab[:, 3]) pmd_diff = np.abs(pmd - sla_tab[:, 4]) rv_diff = np.abs(rv - sla_tab[:, 5]) fs = "{0} {1}\n" + \ "Min: {2:.4f} Max: {3:.4f} \nMean: {4:.4f} Std: {5:.4f}\n" x = [stats.describe(np.abs(i)) for i in [ra_diff, dec_diff, px_diff, pma_diff, pmd_diff, rv_diff]] print("Comparison with SLALIB fk425 using HIPPARCOS data.") for name, unit, s in zip( ["ra_diff", "dec_diff", "px_diff", "pma_diff", "pmd_diff", "rv_diff"], ["arsec", "arcsec", "milliarcsec", "milli-arsec/trop. yr", "milli-arcsec/trop. yr", "km/s"], x): print(fs.format(name, unit, s[1][0], s[1][1], s[2], s[3] ** 0.5))
def fk54(): # Convert from FK5 equinox and epoch J2000.0 to FK4 equinox B1950, but # at the given epoch i.e., J2000.0. v6o = convert.convertv6(v6, s1=6, s2=5, epoch=tpm.J2000) # Apply proper motion from J2000.0 to B1950.0. Objects with zero # velocity in FK5 will have a fictitious proper motion in FK4. v6o = convert.proper_motion(v6o, tpm.B1950, tpm.J2000) # Convert V6C vectors into a list of dictionaries, each of which # contain the 6-D Fk4 B1950.0 coordinates. cat = convert.v62cat(v6o, tpm.CB) return cat
def fB1950toJ2000_main(ra_J2000, dec_J2000): ''' Precess Right Ascension and Declination coordinates from the sexagismal positions in the B1959 system to decimal degrees in the J2000 system. Input ra_J2000: single Right Ascension position in sexagismal J2000 dec_J2000: single Declination position in sexagismal J2000 Output ra_deg: single Right Ascension position in decimal degree dec_deg: single Declination position in decimal degrees ''' # convert decimal degrees to sexagismal format ra_sexa, dec_sexa = degtosexa(ra_J2000, dec_J2000) # extract RA hh:mm:ss and Dec dd:mm:ss components ra_hh = float(ra_sexa.split(" ")[0]) ra_mm = float(ra_sexa.split(" ")[1]) ra_ss = float(ra_sexa.split(" ")[2]) dec_dd = float(dec_sexa.split(" ")[0][1:]) dec_mm = float(dec_sexa.split(" ")[1]) dec_ss = float(dec_sexa.split(" ")[2]) # create RA and Dec objects ra_J2000 = tpm.HMS(hh=ra_hh, mm=ra_mm, ss=ra_ss).to_radians() dec_J2000 = tpm.DMS(dd=dec_dd, mm=dec_mm, ss=dec_ss).to_radians() # velocity vector v5 = convert.cat2v6(ra_J2000, dec_J2000) v5_fk6 = convert.convertv6(v5, s1=5, s2=6, epoch=tpm.B1950, equinox=tpm.B1950) v5_fk6_ep2000 = convert.proper_motion(v5_fk6, tpm.J2000, tpm.B1950) d = convert.v62cat(v5_fk6_ep2000, C=tpm.CJ) ra_new_rad = d["alpha"] ra_deg = ra_new_rad * 180. / np.pi dec_new_rad = d["delta"] dec_deg = dec_new_rad * 180. / np.pi return ra_deg, dec_deg
# Create V6C array from catalog data. v6l = convert.cat2v6(hip_tab['raj2'], hip_tab['decj2'], hip_tab['pma'], hip_tab['pmd'], hip_tab['px'], rv, tpm.CJ) # UTC and TDB for mid-night of 2010/1/1. utc = tpm.gcal2j(2010, 1, 1) - 0.5 # midnight tt = tpm.utc2tdb(utc) # Apply proper motion from J2000 to date. v6o = convert.proper_motion(v6l, tt, tpm.J2000) # Convert from mean equinox J2000 to true equinox and epoch of date. v6o = convert.convertv6(v6o, s1=6, s2=11, utc=utc) # Convert to Numpy rec-array. cat = convert.v62cat(v6o, tpm.CJ) cat = cat2array(cat) ra_diff = np.degrees(cat['alpha']) - tab[:, 0] ra_diff = np.abs(ra_diff) * 3600.0 dec_diff = np.degrees(cat['delta']) - tab[:, 1] dec_diff = np.abs(dec_diff) * 3600.0 print("Comparison with SLALIB map using HIPPARCOS data.") fs = "{0} {1}\n" + \ "Min: {2:.4f} Max: {3:.4f} \nMean: {4:.4f} Std: {5:.4f}\n" x = stats.describe(ra_diff) print(fs.format("ra_diff", "arcsec", x[1][0], x[1][1], x[2], x[3]**0.5)) x = stats.describe(dec_diff) print(fs.format("dec_diff", "arcsec", x[1][0], x[1][1], x[2], x[3]**0.5))
alt = 35800.26 #m ut = 2455822.20000367 #julian date for i in range(0, 1): v6 = convert.cat2v6(alpha=az, delta=el, pma=0.0, pmd=0.0, px=0.0, rv=0, C=tpm.CJ) start_clock = time.clock() v6c = convert.convertv6(v6=v6, utc=ut, s1=tpm.TPM_S19, s2=tpm.TPM_S07, epoch=tpm.J2000, equinox=tpm.J2000, lon=lon, lat=lat, alt=alt, xpole=0.0, ypole=0.0, T=273.15, P=1013.25, H=0.0, wavelength=19986.16386) print("TIME[%d]:%.2g s" % (i, time.clock() - start_clock)) cat = convert.v62cat(v6c) print(np.degrees([cat['alpha'], cat['delta']]))
import datetime import time import numpy as np from pytpm import convert, tpm az = 3.30084818 #rad el = 0.94610742 #rad lat = 34.64 #deg lon = -103.7 #deg alt = 35800.26 #m ut = 2455822.20000367 #julian date for i in range(0, 1): v6 = convert.cat2v6(alpha = az, delta = el, pma=0.0, pmd=0.0, px=0.0, rv=0, C=tpm.CJ) start_clock = time.clock() v6c = convert.convertv6(v6=v6, utc=ut, s1=tpm.TPM_S19, s2=tpm.TPM_S07, epoch=tpm.J2000, equinox=tpm.J2000, lon=lon, lat=lat, alt=alt, xpole=0.0, ypole=0.0, T=273.15, P=1013.25, H=0.0, wavelength=19986.16386) print("TIME[%d]:%.2g s" % (i, time.clock() - start_clock)) cat = convert.v62cat(v6c) print(np.degrees([cat['alpha'], cat['delta']]))
# Create V6C array from catalog data. v6l = convert.cat2v6(hip_tab['raj2'], hip_tab['decj2'], hip_tab['pma'], hip_tab['pmd'], hip_tab['px'], rv, tpm.CJ) # UTC and TDB for mid-night of 2010/1/1. utc = tpm.gcal2j(2010, 1, 1) - 0.5 # midnight tt = tpm.utc2tdb(utc) # Apply proper motion from J2000 to date. v6o = convert.proper_motion(v6l, tt, tpm.J2000) # Convert from mean equinox J2000 to true equinox and epoch of date. v6o = convert.convertv6(v6o, s1=6, s2=11, utc=utc) # Convert to Numpy rec-array. cat = convert.v62cat(v6o, tpm.CJ) cat = cat2array(cat) ra_diff = np.degrees(cat['alpha']) - tab[:, 0] ra_diff = np.abs(ra_diff) * 3600.0 dec_diff = np.degrees(cat['delta']) - tab[:, 1] dec_diff = np.abs(dec_diff) * 3600.0 print("Comparison with SLALIB map using HIPPARCOS data.") fs = "{0} {1}\n" + \ "Min: {2:.4f} Max: {3:.4f} \nMean: {4:.4f} Std: {5:.4f}\n" x = stats.describe(ra_diff) print(fs.format("ra_diff", "arcsec", x[1][0], x[1][1], x[2], x[3] ** 0.5)) x = stats.describe(dec_diff) print(fs.format("dec_diff", "arcsec", x[1][0], x[1][1], x[2], x[3] ** 0.5))
# Dummy radial velocity. rv = np.zeros_like(hip_tab['px']) # Create array of TPM V6C vectors. v6l = convert.cat2v6(hip_tab['raj2'], hip_tab['decj2'], hip_tab['pma'], hip_tab['pmd'], hip_tab['px'], rv, tpm.CJ) # Time for the observations. utc = tpm.gcal2j(2010, 1, 1) - 0.5 # midnight tt = tpm.utc2tdb(utc) # Convert J2000 RA, DEC to Az, EL and ZD at given UTC. v6o = convert.proper_motion(v6l, tt, tpm.J2000) v619 = convert.convertv6(v6o, s1=6, s2=19, utc=utc) cat19 = convert.v62cat(v619, tpm.CJ) cat19 = cat2array(cat19) az = np.degrees(cat19['alpha']) el = np.degrees(cat19['delta']) zd = 90.0 - el # Keep only those objects with ZD < 75.0 degrees. indx = np.where(zd < 75.0) # Difference in AZ and ZD, using TPM and SLALIB. az_diff = np.abs(az[indx] - az_sla[indx]) * 3600.0 zd_diff = np.abs(zd[indx] - zd_sla[indx]) * 3600.0 # Az, El to HA and Dec. v620 = convert.convertv6(v619, s1=19, s2=20, utc=utc) cat20 = convert.v62cat(v620, tpm.CJ)