def convert_voe_coords_to_eqposn(c): """Unit-checked conversion from voeventparse.Position2D -> astropysics FK5""" acceptable_coord_sys = ( voeventparse.definitions.sky_coord_system.utc_fk5_geo, voeventparse.definitions.sky_coord_system.utc_icrs_geo ) if (c.system not in acceptable_coord_sys or c.units != 'deg'): raise ValueError( "Unrecognised Coords type: %s, %s" % (c.system, c.units)) return Equatorial(c.ra / DEG_PER_RADIAN, c.dec / DEG_PER_RADIAN, epoch=J2000)
def _get_radec_from_ecliptic(self, elong, elat): # convert via pyephem try: ec = Ecliptic(elong, elat) # check for B name if "B" in self.name: epoch = "1950" else: epoch = "2000" eq = Equatorial(ec, epoch=str(epoch)) raj = np.double(eq.ra) decj = np.double(eq.dec) except TypeError: msg = "WARNING: Cannot fine sky location coordinates " msg += "for PSR {0}. ".format(self.name) msg += "Setting values to 0.0" logger.warning(msg) raj = 0.0 decj = 0.0 return raj, decj
def _get_radec_from_ecliptic(self, elong, elat): # convert via pyephem try: ec = Ecliptic(elong, elat) # check for B name if 'B' in self.name: epoch = '1950' else: epoch = '2000' eq = Equatorial(ec, epoch=str(epoch)) raj = np.double(eq.ra) decj = np.double(eq.dec) # TODO: should use logging here except TypeError: msg = 'WARNING: Cannot fine sky location coordinates ' msg += 'for PSR {0}. '.format(self.name) msg += 'Setting values to 0.0' print(msg) raj = 0.0 decj = 0.0 return raj, decj
dates = strnow.split('T') datestr = dates[0] + ' ' + dates[1] me.date = datestr timestrfull = str(dates[1]) times = timestrfull.split('.') outname = dates[0] + '_' + times[0] + '.txt' #print(outname) # check the LST as a test #print('UTC = ' + datestr + ' -> ' + str(me.sidereal_time()) + ' LST ') #now compute the ra,dec from the azimuth,elevation, time and location ra_a, dec_a = me.radec_of(az, str(el)) print('Horn Ra,Dec = %s,%s for Az,El %s,%s of %s' % (ra_a, dec_a, az, str(el), datestr)) #radec_a = Equatorial( ra_a, dec_a, me.date) radec = Equatorial(ra_a, dec_a, epoch=datestr) print(radec.ra, radec.dec) #finally calculate the galactic coordiates for the ra, dec coordinates gal = Galactic(radec) print(gal.lon, gal.lat) #now write a file with the coordinate sets outfile = open(outname, 'w') outline = ' Az Ra Dec G-Lon G-Lat \n' outfile.write(outline) #for all azimuths, assuming a fixed elevation for azimuth in range(0, 360, 10): az = str(azimuth) ra_a, dec_a = me.radec_of(az, str(el)) radec = Equatorial(ra_a, dec_a, epoch=datestr)