def draw_des19(self,**kwargs): """ Draw the DES footprint. """ defaults=dict(color='blue', lw=2) setdefaults(kwargs,defaults) filename = os.path.join(get_datadir(),'des-round19-poly.txt') return self.draw_polygon(filename,**kwargs)
def read_constellations(cls): import json dirname = get_datadir() filename = 'constellationsANDstars.json' with open(os.path.join(dirname, filename), 'r') as f: data = json.load(f) # Constellation shapes shapes = [] for const in data['constellations'].values(): for shape in const: shapes.append(np.degrees(shape)) shapes = np.array(shapes) # Stars stars = np.array(data['stars']) stars[:, :2] = np.degrees(stars[:, :2]) # Boundaries boundaries = [np.degrees(e) for e in data['boundaries']] # Centers centers = data['centers'] for k, v in centers.items(): centers[k] = np.degrees(v) return shapes, stars, boundaries, centers
def draw_maglites(self,**kwargs): """Draw the MagLiteS footprint""" defaults=dict(color='blue', lw=2) setdefaults(kwargs,defaults) filename = os.path.join(get_datadir(),'maglites-poly.txt') self.draw_polygon(filename,**kwargs)
def draw_bliss(self,**kwargs): """Draw the BLISS footprint""" defaults=dict(color='magenta', lw=2) setdefaults(kwargs,defaults) filename = os.path.join(get_datadir(),'bliss-poly.txt') self.draw_polygons(filename,**kwargs)
def draw_sfd(self, **kwargs): defaults = dict(rasterized=True, cmap=plt.cm.binary) setdefaults(kwargs, defaults) dirname = get_datadir() filename = 'lambda_sfd_ebv.fits' galhpx = hp.read_map(os.path.join(dirname, filename)) celhpx = obztak.utils.projector.hpx_gal2cel(galhpx) return self.draw_hpxmap(np.log10(celhpx), **kwargs)
def draw_smash(self,**kwargs): """ Draw the SMASH fields. """ defaults=dict(facecolor='none',color='k') setdefaults(kwargs,defaults) filename = os.path.join(get_datadir(),'smash_fields_final.txt') smash=np.genfromtxt(filename,dtype=[('ra',float),('dec',float)],usecols=[4,5]) xy = self.proj(smash['ra'],smash['dec']) self.scatter(*xy,**kwargs)
class MachoFocalPlane(FocalPlane): """Class for storing and manipulating the corners of the DECam CCDs. """ filename = os.path.join(get_datadir(),'macho_corners_xy.dat') def __init__(self): # This is not safe. Use yaml instead (extra dependency) self.ccd_dict = eval(''.join(open(self.filename).readlines())) # These are x,y coordinates self.corners = np.array(list(self.ccd_dict.values()))
def draw_decals(self, **kwargs): defaults = dict(color='red', lw=2) setdefaults(kwargs, defaults) filename = os.path.join(get_datadir(), 'decals-perimeter.txt') decals = np.genfromtxt(filename, names=['poly', 'ra', 'dec']) poly1 = decals[decals['poly'] == 1] poly2 = decals[decals['poly'] == 2] #self.draw_polygon_radec(poly1['ra'],poly1['dec'],**kwargs) #self.draw_polygon_radec(poly2['ra'],poly2['dec'],**kwargs) self.scatter(*self.proj(poly1['ra'], poly1['dec'])) self.scatter(*self.proj(poly2['ra'], poly2['dec']))
def draw_magellanic_stream(self, **kwargs): import fitsio defaults = dict(xsize=800, vmin=17., vmax=25.0, rasterized=True, cmap=plt.cm.binary) setdefaults(kwargs, defaults) dirname = get_datadir() filename = 'allms_coldens_gal_nside_1024.fits' galhpx = fitsio.read(os.path.join(dirname, filename))['coldens'] celhpx = obztak.utils.projector.hpx_gal2cel(galhpx) return self.draw_hpxmap(celhpx, **kwargs)
def draw_decals(self,**kwargs): defaults=dict(color='red', lw=2) setdefaults(kwargs,defaults) filename = os.path.join(get_datadir(),'decals-poly.txt') return self.draw_polygon(filename,**kwargs)
class HSCFocalPlane(object): """Class for storing and manipulating the corners of the HSC CCDs. """ filename = os.path.join(get_datadir(), 'subaru_hsc_ccds.dat') def __init__(self): # This is not safe. Use yaml instead (extra dependency) self.ccd_dict = eval(''.join(open(self.filename).readlines())) # These are x,y coordinates self.corners = np.array(list(self.ccd_dict.values())) # Since we don't know the original projection of the HSC # focal plane into x,y it is probably not worth trying to # deproject it right now... #x,y = self.ccd_array[:,:,0],self.ccd_array[:,:,1] #ra,dec = Projector(0,0).image2sphere(x.flat,y.flat) #self.corners[:,:,0] = ra.reshape(x.shape) #self.corners[:,:,1] = dec.reshape(y.shape) def rotate(self, ra, dec): """Rotate the corners of the HSC CCDs to a given sky location. Parameters: ----------- ra : The right ascension (deg) of the focal plane center dec : The declination (deg) of the focal plane center Returns: -------- corners : The rotated corner locations of the CCDs """ corners = np.copy(self.corners) R = SphericalRotator(ra, dec) _ra, _dec = R.rotate(corners[:, :, 0].flat, corners[:, :, 1].flat, invert=True) corners[:, :, 0] = _ra.reshape(corners.shape[:2]) corners[:, :, 1] = _dec.reshape(corners.shape[:2]) return corners def project(self, basemap, ra, dec): """Apply the given basemap projection to the HSC focal plane at a location given by ra,dec. Parameters: ----------- basemap : The Basemap to project to. ra : The right ascension (deg) of the focal plane center dec : The declination (deg) of the focal plane center Returns: -------- corners : Projected corner locations of the CCDs """ corners = self.rotate(ra, dec) x, y = basemap.proj(corners[:, :, 0], corners[:, :, 1]) # Remove CCDs that cross the map boundary x[(np.ptp(x, axis=1) > np.pi)] = np.nan corners[:, :, 0] = x corners[:, :, 1] = y return corners