def eq_to_gal(a, d): M = celestial.sky2sky((celestial.eq, celestial.fk5), celestial.gal, a, d) try: len(a) l, b = ravel(M[:,0]), ravel(M[:,1]) except: l = M[0,0] b = M[0,1] return l, b
def convert(coords, systems): """Convert an array of in_coords from in_system to out_system""" if not set(systems.values()).issubset(SUPPORTED_SYSTEMS): return None # Use kapteyn package specific specifiers for in- and out-systems skyin, skyout = system_spec(systems['in']), system_spec(systems['out']) coords = celestial.sky2sky(skyin, skyout, coords['lon'], coords['lat']) coords = np.array(coords) return dict(lon=coords[:,0], lat=coords[:,1])
def transform_celestial(coords, systems): """Convert an array of in_coords from in_system to out_system""" # Use kapteyn package specific specifiers for in- and out-systems skyin, skyout = system_spec(systems['in']), system_spec(systems['out']) coords = celestial.sky2sky(skyin, skyout, coords['lon'], coords['lat']) coords = np.array(coords) out = Table() out['lon'] = coords[:, 0] out['lat'] = coords[:, 1] return out
def transform_celestial(coords, systems): """Convert an array of in_coords from in_system to out_system""" # Use kapteyn package specific specifiers for in- and out-systems skyin, skyout = system_spec(systems['in']), system_spec(systems['out']) coords = celestial.sky2sky(skyin, skyout, coords['lon'], coords['lat']) coords = np.array(coords) out = Table() out['lon'] = coords[:, 0] out['lat'] = coords[:, 1] return out
def gal_to_eq(l, b): M = celestial.sky2sky(celestial.gal, (celestial.eq, celestial.fk5), l, b) a, d = ravel(M[:,0]), ravel(M[:,1]) return a, d
def transform_to(skyout, tag): """Convert the test input coordinates to a given output system and save to text file""" skyin = 'fk5' output = celestial.sky2sky(skyin, skyout, initial_coords[:, 0], initial_coords[:, 1]) np.savetxt('coords_{tag}.txt'.format(tag=tag), output, fmt="%20.15f")
def radec2glon(ra, dec): lonlat = celestial.sky2sky( (celestial.eq, celestial.fk5), celestial.gal, ra.flat, dec.flat).A return lonlat[:, 1].ravel()
def lonlat2dec(lon, lat): radec = celestial.sky2sky( (celestial.eq, celestial.fk5), celestial.gal, ra.flat, dec.flat).A return radec[:, 1].ravel()
def lonlat2ra(lon, lat): radec = celestial.sky2sky( (celestial.eq, celestial.fk5), celestial.gal, lon.flat, lat.flat).A return radec[:, 0].ravel()
def radec2glon(ra, dec): lonlat = celestial.sky2sky((celestial.eq, celestial.fk5), celestial.gal, ra.flat, dec.flat).A return lonlat[:, 1].ravel()
def lonlat2dec(lon, lat): radec = celestial.sky2sky((celestial.eq, celestial.fk5), celestial.gal, ra.flat, dec.flat).A return radec[:, 1].ravel()
def lonlat2ra(lon, lat): radec = celestial.sky2sky((celestial.eq, celestial.fk5), celestial.gal, lon.flat, lat.flat).A return radec[:, 0].ravel()