def main(flg_fig): # Init if flg_fig == 'all': flg_fig = np.sum( np.array( [2**ii for ii in range(1)] )) # Skipping fig_chk_nhi else: flg_fig = int(flg_fig) # COS-Dwarf Images if (flg_fig % 2**1) >= 2**0: fig_cos_dwarfs_images() # LRG finder if (flg_fig % 2**2) >= 2**1: # LRG Finder (out of order to avoid PDF issues) coord = xra.to_coord( (176.1888,7.24901) ) finder.main(['LRG', coord], imsize=1.*u.arcmin, show_circ=False) # z~1 QPQ finder if (flg_fig % 2**3) >= 2**2: # LRG Finder (out of order to avoid PDF issues) coord = xra.to_coord( (26.62542, 0.25583)) finder.main(['z1QPQ', coord], imsize=1.*u.arcmin, show_circ=False) # All Halos if (flg_fig % 2**4) >= 2**3: fig_all_halo_images()
def __init__(self, gal_ra, gal_dec, gal_z, bg_ra, bg_dec, bg_z, cosmo=None, verbose=False): # Galaxy self.galaxy = Galaxy(gal_ra, gal_dec, z=gal_z) # Name self.name = ( 'CGM' + self.galaxy.coord.ra.to_string(unit=u.hour, sep='', pad=True) + self.galaxy.coord.dec.to_string(sep='', pad=True, alwayssign=True)) # Absorption system self.abs_sys = CGMAbs() self.abs_sys.coord = xra.to_coord((bg_ra, bg_dec)) # Background source self.abs_sys.zem = bg_z # Calcualte rho if cosmo is None: from astropy.cosmology import WMAP9 as cosmo if verbose is True: print('cgm.core: Using WMAP9 cosmology') ang_sep = self.abs_sys.coord.separation(self.galaxy.coord).to('arcmin') kpc_amin = cosmo.kpc_comoving_per_arcmin( self.galaxy.z) # kpc per arcmin self.rho = ang_sep * kpc_amin / (1 + self.galaxy.z) # Physical
def __init__(self, ra, dec, z=None): self.z = z # Coord self.coord = xra.to_coord( (ra,dec) ) # Name self.name = ('J'+ self.coord.ra.to_string(unit=u.hour,sep='',pad=True)+ self.coord.dec.to_string(sep='',pad=True,alwayssign=True))
def __getitem__(self,k): ''' Passback a SdssQso object k: Input to get_qso ''' from xastropy.sdss.qso import SdssQso row = self.get_qso(k) if row is None: return None # Generate SdssQso qso = SdssQso(z=row['Z'][0],database=self) qso.coord = xor.to_coord((row['RAOBJ'][0]*u.deg,row['DECOBJ'][0]*u.deg)) # Return return qso
def __init__(self, name, radec, cosmo=None, verbose=False): # Field self.name = name self.coord = xra.to_coord(radec) # Cosmology if cosmo is None: from astropy.cosmology import WMAP9 as cosmo if verbose is True: print('IgmGalxyField: Using WMAP9 cosmology') self.cosmo = cosmo # Init self.igm = None self.targets = None self.galaxies = None self.observing = None
def __init__(self, gal_ra, gal_dec, gal_z, bg_ra, bg_dec, bg_z, cosmo=None, verbose=False): # Galaxy self.galaxy = Galaxy(gal_ra, gal_dec, z=gal_z) # Name self.name = ('CGM'+ self.galaxy.coord.ra.to_string(unit=u.hour,sep='',pad=True)+ self.galaxy.coord.dec.to_string(sep='',pad=True,alwayssign=True)) # Absorption system self.abs_sys = CGMAbs() self.abs_sys.coord = xra.to_coord( (bg_ra,bg_dec) ) # Background source self.abs_sys.zem = bg_z # Calcualte rho if cosmo is None: from astropy.cosmology import WMAP9 as cosmo if verbose is True: print('cgm.core: Using WMAP9 cosmology') ang_sep = self.abs_sys.coord.separation(self.galaxy.coord).to('arcmin') kpc_amin = cosmo.kpc_comoving_per_arcmin( self.galaxy.z ) # kpc per arcmin self.rho = ang_sep * kpc_amin / (1+self.galaxy.z) # Physical
def deimos_targets(field, path=None): '''Generate files related to DEIMOS deimos_targets Parameters: ----------- field: tuple (Name, ra, dec) Returns: ---------- ''' if path is None: path = '/Galx_Spectra/DEIMOS/' # Loop on Fields mask_path = field[0] + path + '/Masks/' # SExtractor targeting targetting_file = glob.glob(mask_path + '*targ.yaml') if len(targetting_file) == 1: sex_targ = parse_sex_file(field, targetting_file[0]) sex_targ.add_column(Column(['DEIMOS'] * len(sex_targ), name='INSTR')) # Setup for mask matching sex_coord = SkyCoord(ra=sex_targ['TARG_RA'] * u.deg, dec=sex_targ['TARG_DEC'] * u.deg) sex_msk_clms = {} cnames = ['MASK_NAME', 'MASK_ID'] smsk = '--' msk_val = [smsk] * len(cnames) for kk, cname in enumerate(cnames): sex_msk_clms[cname] = [msk_val[kk]] * len(sex_targ) elif len(targetting_file) == 0: print( 'WARNING: No SExtractor info for mask path {:s}'.format(mask_path)) xdb.set_trace() sex_targ = None else: raise ValueError('Found multiple targ.yaml files!!') # Mask info all_masks = [] all_masktarg = [] all_obs = [] files = glob.glob(mask_path + '*.out') for msk_file in files: print('Reading DEIMOS mask file: {:s}'.format(msk_file)) # Parse mask_dict, targ_tab, obs_tab = parse_deimos_mask_file(msk_file) # Fill up SEx file if sex_targ is not None: for targ in targ_tab: targ_coord = xra.to_coord((targ['RAS'], targ['DECS'])) sep = targ_coord.separation(sex_coord) isep = np.argmin(sep) if sep[isep] > 0.5 * u.arcsec: raise ValueError('No match in SExtractor?!') else: # Fill if sex_msk_clms['MASK_NAME'][isep] == smsk: sex_msk_clms['MASK_NAME'][isep] = mask_dict[ 'MASK_NAME'] else: # Already full sex_targ.add_row(sex_targ[isep]) sex_msk_clms['MASK_NAME'].append( mask_dict['MASK_NAME']) # Append all_masks.append(mask_dict) all_masktarg.append(targ_tab) all_obs.append(obs_tab) # Add columns to sex_targ for tt, cname in enumerate(cnames): # Mask mask = np.array([False] * len(sex_targ)) bad = np.where(np.array(sex_msk_clms[cname]) == msk_val[tt])[0] if len(bad) > 0: mask[bad] = True # clm = MaskedColumn(sex_msk_clms[cname], name=cname, mask=mask) sex_targ.add_column(clm) # Return return sex_targ, all_masks, all_obs, all_masktarg
def test_tocoord(): from astropy.coordinates import SkyCoord radec = x_r.stod1('J103138.87+255902.3') coord = x_r.to_coord(radec) # assert isinstance(coord,SkyCoord)
def test_tocoord(): from astropy.coordinates import SkyCoord radec = x_r.stod1('J103138.87+255902.3') coord = x_r.to_coord(radec) # assert isinstance(coord, SkyCoord)
def deimos_targets(field, obs_path, deimos_path=None): """Generate files related to DEIMOS deimos_targets Parameters: ----------- field : tuple (Name, ra, dec) Returns: ---------- sex_targ, all_masks, all_obs, all_masktarg """ if deimos_path is None: deimos_path = '/Galx_Spectra/DEIMOS/' # Loop on Fields mask_path = obs_path+field[0]+deimos_path+'/Masks/' # SExtractor targeting targetting_file = glob.glob(mask_path+'*targ.yaml') if len(targetting_file) == 1: sex_targ = parse_sex_file(field, targetting_file[0]) sex_targ.add_column(Column(['DEIMOS']*len(sex_targ),name='INSTR')) # Setup for mask matching sex_coord = SkyCoord(ra=sex_targ['TARG_RA']*u.deg, dec=sex_targ['TARG_DEC']*u.deg) sex_msk_clms = {} cnames = ['MASK_NAME', 'MASK_ID'] smsk = '--' msk_val = [smsk]*len(cnames) for kk,cname in enumerate(cnames): sex_msk_clms[cname] = [msk_val[kk]]*len(sex_targ) elif len(targetting_file) == 0: print('WARNING: No SExtractor info for mask path {:s}'.format(mask_path)) print('Assuming no DEIMOS files') return [None]*4 #sex_targ = None else: raise ValueError('Found multiple targ.yaml files!!') # Mask info all_masks = [] all_masktarg = [] all_obs = [] files = glob.glob(mask_path+'*.out') for msk_file in files: print('Reading DEIMOS mask file: {:s}'.format(msk_file)) # Parse mask_dict, targ_tab, obs_tab = parse_deimos_mask_file(msk_file) # Fill up SEx file if sex_targ is not None: for targ in targ_tab: targ_coord = xra.to_coord((targ['RAS'], targ['DECS'])) sep = targ_coord.separation(sex_coord) isep = np.argmin(sep) if sep[isep] > 0.5*u.arcsec: raise ValueError('No match in SExtractor?!') else: # Fill if sex_msk_clms['MASK_NAME'][isep] == smsk: sex_msk_clms['MASK_NAME'][isep] = mask_dict['MASK_NAME'] else: # Already full sex_targ.add_row(sex_targ[isep]) sex_msk_clms['MASK_NAME'].append(mask_dict['MASK_NAME']) # Append all_masks.append(mask_dict) all_masktarg.append(targ_tab) all_obs.append(obs_tab) # Add columns to sex_targ for tt, cname in enumerate(cnames): # Mask mask = np.array([False]*len(sex_targ)) bad = np.where(np.array(sex_msk_clms[cname])==msk_val[tt])[0] if len(bad)>0: mask[bad]=True # clm = MaskedColumn(sex_msk_clms[cname],name=cname,mask=mask) sex_targ.add_column(clm) # Return return sex_targ, all_masks, all_obs, all_masktarg
def main(inp, survey='2r', radec=None, deci=None, fpath=None, show_circ=True, EPOCH=0., DSS=None, BW=False, imsize=5. * astrou.arcmin, show_spec=False, OUT_TYPE='PDF', show_another=None): ''' Parameters: --------- inp: Input string or List of strings or List of several items 'ra_dec_list.txt' -- ASCII file with columns of Name,RA,DEC and RA,DEC are string or float (deg) ['NAME_OF_TARG', '10:31:38.87', '+25:59:02.3'] ['NAME_OF_TARG', 124.24*u.deg, -23.244*u.deg] ['NAME_OF_TARG', SkyCoord] radec: integer (0) [DEPRECATED!] Flag indicating type of input 0 = ASCII file with columns of Name,RA,DEC and RA,DEC are string or float (deg) 1 = List of string ['Name', 'RA', 'DEC'] 2 = ['Name', ra_deg, dec_deg] BW: bool (False) B&W image? show_circ: bool (True) Show a yellow circle on the target show_another : tuple, optional RA,DEC for another target to circle (e.g. offset star) show_spec: bool (False) Try to grab and show an SDSS spectrum imsize: Quantity, optional Image size OUT_TYPE: str, optional File type -- 'PDF', 'PNG' ''' reload(x_r) reload(xgs) import matplotlib.pyplot as plt import matplotlib.cm as cm # Init if fpath is None: fpath = './' try: imsize = imsize.to('arcmin').value except AttributeError: raise AttributeError('finder: Input imsize needs to be an Angle') cradius = imsize / 50. # Read in the Target list if isinstance(inp, basestring): raise NotImplementedError("No longer implemented") #ra_tab = get_coord(targ_file, radec=radec) else: ira_tab = {} ira_tab['Name'] = inp[0] if isinstance(inp[1], basestring): ra, dec = x_r.stod1((inp[1], inp[2])) ira_tab['RA'] = ra ira_tab['DEC'] = dec elif isinstance(inp[1], float): ira_tab['RA'] = inp[1] * astrou.deg ira_tab['DEC'] = inp[2] * astrou.deg elif isinstance(inp[1], SkyCoord): ira_tab['RA'] = inp[1].ra.deg ira_tab['DEC'] = inp[1].dec.deg else: # Should check it is a Quantity ira_tab['RA'] = inp[1] ira_tab['DEC'] = inp[2] # Strings ras, decs = x_r.dtos1((ira_tab['RA'], ira_tab['DEC'])) ira_tab['RAS'] = ras ira_tab['DECS'] = decs # Make a list ra_tab = [ira_tab] # Grab ra, dec in decimal degrees if deci is not None: return #xdb.set_trace() #x_r.stod(ra_tab) #ra_tab['RA'][q], ra_tab['DEC'][q], TABL) # Precess (as necessary) if EPOCH > 1000.: from astropy import units as u from astropy.coordinates import FK5 from astropy.time import Time # Precess to 2000. tEPOCH = Time(EPOCH, format='jyear', scale='utc') # Load into astropy fk5c = FK5(ra=ra_tab['RA'], dec=ra_tab['DEC'], equinox=tEPOCH, unit=(u.degree, u.degree)) # Precess newEPOCH = Time(2000., format='jyear', scale='utc') newfk5 = fk5c.precess_to(newEPOCH) # Save ra_tab['RA'] = newfk5.ra.degree ra_tab['DEC'] = newfk5.dec.degree # Strings too? ra_tab['RAS'] = str(newfk5.ra.to_string(unit=u.hour, sep=':')) ra_tab['DECS'] = str(newfk5.dec.to_string(unit=u.hour, sep=':')) ## # Main Loop for obj in ra_tab: # Outfil nm = "".join(obj['Name'].split()) if OUT_TYPE == 'PNG': outfil = fpath + nm + '.png' else: outfil = fpath + nm + '.pdf' print(outfil) # Grab the Image reload(xgs) img, oBW = xgs.getimg(obj['RA'], obj['DEC'], imsize, BW=BW, DSS=DSS) # Generate the plot plt.clf() fig = plt.figure(dpi=1200) fig.set_size_inches(8.0, 10.5) # Font plt.rcParams['font.family'] = 'times new roman' ticks_font = matplotlib.font_manager.FontProperties( family='times new roman', style='normal', size=16, weight='normal', stretch='normal') ax = plt.gca() for label in ax.get_yticklabels(): label.set_fontproperties(ticks_font) for label in ax.get_xticklabels(): label.set_fontproperties(ticks_font) # Image if oBW == 1: cmm = cm.Greys_r else: cmm = None plt.imshow(img, cmap=cmm, aspect='equal', extent=(-imsize / 2., imsize / 2, -imsize / 2., imsize / 2)) # Axes plt.xlim(-imsize / 2., imsize / 2.) plt.ylim(-imsize / 2., imsize / 2.) # Label plt.xlabel('Relative ArcMin', fontsize=20) xpos = 0.12 * imsize ypos = 0.02 * imsize plt.text(-imsize / 2. - xpos, 0., 'EAST', rotation=90., fontsize=20) plt.text(0., imsize / 2. + ypos, 'NORTH', fontsize=20, horizontalalignment='center') #import pdb; pdb.set_trace() # Circle if show_circ: circle = plt.Circle((0, 0), cradius, color='y', fill=False) plt.gca().add_artist(circle) # Second Circle if show_another is not None: # Coordinates cobj = x_r.to_coord((obj['RA'], obj['DEC'])) canother = x_r.to_coord(show_another) # Offsets off, PA = x_r.offsets(cobj, canother) xanother = -1 * off[0].to('arcmin').value yanother = off[1].to('arcmin').value square = matplotlib.patches.Rectangle( (xanother - cradius, yanother - cradius), cradius * 2, cradius * 2, color='cyan', fill=False) plt.gca().add_artist(square) plt.text(0.5, 1.24, str(nm), fontsize=32, horizontalalignment='center', transform=ax.transAxes) plt.text(0.5, 1.18, 'RA (J2000) = ' + str(obj['RAS']) + ' DEC (J2000) = ' + str(obj['DECS']), fontsize=22, horizontalalignment='center', transform=ax.transAxes) plt.text(0.5, 1.12, 'RA(offset) = {:s} DEC(offset) = {:s}'.format( canother.ra.to_string(unit=astrou.hour, pad=True, sep=':', precision=2), canother.dec.to_string(pad=True, alwayssign=True, sep=':', precision=1)), fontsize=22, horizontalalignment='center', transform=ax.transAxes, color='blue') plt.text( 0.5, 1.06, 'RA(offset to obj) = {:g} DEC(offset to obj) = {:g}'.format( -1 * off[0].to('arcsec'), -1 * off[1].to('arcsec')), fontsize=18, horizontalalignment='center', transform=ax.transAxes) else: # Title plt.text(0.5, 1.24, str(nm), fontsize=32, horizontalalignment='center', transform=ax.transAxes) plt.text(0.5, 1.16, 'RA (J2000) = ' + str(obj['RAS']), fontsize=28, horizontalalignment='center', transform=ax.transAxes) plt.text(0.5, 1.10, 'DEC (J2000) = ' + str(obj['DECS']), fontsize=28, horizontalalignment='center', transform=ax.transAxes) # Spectrum?? if show_spec: spec_img = xgs.get_spec_img(obj['RA'], obj['DEC']) plt.imshow(spec_img, extent=(-imsize / 2.1, imsize * (-0.1), -imsize / 2.1, imsize * (-0.2))) # Write if show_spec: plt.savefig(outfil, dpi=300) else: plt.savefig(outfil) print 'finder: Wrote ' + outfil plt.close() #xdb.set_trace() print 'finder: All done.' return oBW
def deimos_targets(field, path=None): """Generate files related to DEIMOS deimos_targets Parameters: ----------- field: tuple (Name, ra, dec) Returns: ---------- """ if path is None: path = "/Galx_Spectra/DEIMOS/" # Loop on Fields mask_path = field[0] + path + "/Masks/" # SExtractor targeting targetting_file = glob.glob(mask_path + "*targ.yaml") if len(targetting_file) == 1: sex_targ = parse_sex_file(field, targetting_file[0]) sex_targ.add_column(Column(["DEIMOS"] * len(sex_targ), name="INSTR")) # Setup for mask matching sex_coord = SkyCoord(ra=sex_targ["TARG_RA"] * u.deg, dec=sex_targ["TARG_DEC"] * u.deg) sex_msk_clms = {} cnames = ["MASK_NAME", "MASK_ID"] smsk = "--" msk_val = [smsk] * len(cnames) for kk, cname in enumerate(cnames): sex_msk_clms[cname] = [msk_val[kk]] * len(sex_targ) elif len(targetting_file) == 0: print("WARNING: No SExtractor info for mask path {:s}".format(mask_path)) xdb.set_trace() sex_targ = None else: raise ValueError("Found multiple targ.yaml files!!") # Mask info all_masks = [] all_masktarg = [] all_obs = [] files = glob.glob(mask_path + "*.out") for msk_file in files: print("Reading DEIMOS mask file: {:s}".format(msk_file)) # Parse mask_dict, targ_tab, obs_tab = parse_deimos_mask_file(msk_file) # Fill up SEx file if sex_targ is not None: for targ in targ_tab: targ_coord = xra.to_coord((targ["RAS"], targ["DECS"])) sep = targ_coord.separation(sex_coord) isep = np.argmin(sep) if sep[isep] > 0.5 * u.arcsec: raise ValueError("No match in SExtractor?!") else: # Fill if sex_msk_clms["MASK_NAME"][isep] == smsk: sex_msk_clms["MASK_NAME"][isep] = mask_dict["MASK_NAME"] else: # Already full sex_targ.add_row(sex_targ[isep]) sex_msk_clms["MASK_NAME"].append(mask_dict["MASK_NAME"]) # Append all_masks.append(mask_dict) all_masktarg.append(targ_tab) all_obs.append(obs_tab) # Add columns to sex_targ for tt, cname in enumerate(cnames): # Mask mask = np.array([False] * len(sex_targ)) bad = np.where(np.array(sex_msk_clms[cname]) == msk_val[tt])[0] if len(bad) > 0: mask[bad] = True # clm = MaskedColumn(sex_msk_clms[cname], name=cname, mask=mask) sex_targ.add_column(clm) # Return return sex_targ, all_masks, all_obs, all_masktarg
def main(inp, survey='2r', radec=None, deci=None, fpath=None, show_circ=True, EPOCH=0., DSS=None, BW=False, imsize=5.*astrou.arcmin, show_spec=False, OUT_TYPE='PDF', show_another=None): ''' Parameters: --------- inp: Input string or List of strings or List of several items 'ra_dec_list.txt' -- ASCII file with columns of Name,RA,DEC and RA,DEC are string or float (deg) ['NAME_OF_TARG', '10:31:38.87', '+25:59:02.3'] ['NAME_OF_TARG', 124.24*u.deg, -23.244*u.deg] ['NAME_OF_TARG', SkyCoord] radec: integer (0) [DEPRECATED!] Flag indicating type of input 0 = ASCII file with columns of Name,RA,DEC and RA,DEC are string or float (deg) 1 = List of string ['Name', 'RA', 'DEC'] 2 = ['Name', ra_deg, dec_deg] BW: bool (False) B&W image? show_circ: bool (True) Show a yellow circle on the target show_another : tuple, optional RA,DEC for another target to circle (e.g. offset star) show_spec: bool (False) Try to grab and show an SDSS spectrum imsize: Quantity, optional Image size OUT_TYPE: str, optional File type -- 'PDF', 'PNG' ''' reload(x_r) reload(xgs) import matplotlib.pyplot as plt import matplotlib.cm as cm # Init if fpath is None: fpath = './' try: imsize=imsize.to('arcmin').value except AttributeError: raise AttributeError('finder: Input imsize needs to be an Angle') cradius = imsize / 50. # Read in the Target list if isinstance(inp,basestring): raise NotImplementedError("No longer implemented") #ra_tab = get_coord(targ_file, radec=radec) else: ira_tab = {} ira_tab['Name'] = inp[0] if isinstance(inp[1],basestring): ra, dec = x_r.stod1((inp[1],inp[2])) ira_tab['RA'] = ra ira_tab['DEC'] = dec elif isinstance(inp[1],float): ira_tab['RA'] = inp[1] * astrou.deg ira_tab['DEC'] = inp[2]* astrou.deg elif isinstance(inp[1],SkyCoord): ira_tab['RA'] = inp[1].ra.deg ira_tab['DEC'] = inp[1].dec.deg else: # Should check it is a Quantity ira_tab['RA'] = inp[1] ira_tab['DEC'] = inp[2] # Strings ras,decs = x_r.dtos1((ira_tab['RA'],ira_tab['DEC'])) ira_tab['RAS'] = ras ira_tab['DECS'] = decs # Make a list ra_tab = [ira_tab] # Grab ra, dec in decimal degrees if deci is not None: return #xdb.set_trace() #x_r.stod(ra_tab) #ra_tab['RA'][q], ra_tab['DEC'][q], TABL) # Precess (as necessary) if EPOCH > 1000.: from astropy import units as u from astropy.coordinates import FK5 from astropy.time import Time # Precess to 2000. tEPOCH = Time(EPOCH, format='jyear', scale='utc') # Load into astropy fk5c = FK5(ra=ra_tab['RA'], dec=ra_tab['DEC'], equinox=tEPOCH, unit=(u.degree,u.degree)) # Precess newEPOCH = Time(2000., format='jyear', scale='utc') newfk5 = fk5c.precess_to(newEPOCH) # Save ra_tab['RA'] = newfk5.ra.degree ra_tab['DEC'] = newfk5.dec.degree # Strings too? ra_tab['RAS'] = str(newfk5.ra.to_string(unit=u.hour,sep=':')) ra_tab['DECS'] = str(newfk5.dec.to_string(unit=u.hour,sep=':')) ## # Main Loop for obj in ra_tab: # Outfil nm = "".join(obj['Name'].split()) if OUT_TYPE=='PNG': outfil = fpath+ nm + '.png' else: outfil = fpath+ nm + '.pdf' print(outfil) # Grab the Image reload(xgs) img, oBW = xgs.getimg(obj['RA'], obj['DEC'], imsize, BW=BW,DSS=DSS) # Generate the plot plt.clf() fig = plt.figure(dpi=1200) fig.set_size_inches(8.0,10.5) # Font plt.rcParams['font.family']= 'times new roman' ticks_font = matplotlib.font_manager.FontProperties(family='times new roman', style='normal', size=16, weight='normal', stretch='normal') ax = plt.gca() for label in ax.get_yticklabels() : label.set_fontproperties(ticks_font) for label in ax.get_xticklabels() : label.set_fontproperties(ticks_font) # Image if oBW == 1: cmm = cm.Greys_r else: cmm = None plt.imshow(img,cmap=cmm,aspect='equal',extent=(-imsize/2., imsize/2, -imsize/2.,imsize/2)) # Axes plt.xlim(-imsize/2., imsize/2.) plt.ylim(-imsize/2., imsize/2.) # Label plt.xlabel('Relative ArcMin', fontsize=20) xpos = 0.12*imsize ypos = 0.02*imsize plt.text(-imsize/2.-xpos, 0., 'EAST', rotation=90.,fontsize=20) plt.text(0.,imsize/2.+ypos, 'NORTH', fontsize=20, horizontalalignment='center') #import pdb; pdb.set_trace() # Circle if show_circ: circle=plt.Circle((0,0),cradius,color='y', fill=False) plt.gca().add_artist(circle) # Second Circle if show_another is not None: # Coordinates cobj = x_r.to_coord((obj['RA'],obj['DEC'])) canother = x_r.to_coord(show_another) # Offsets off, PA = x_r.offsets(cobj, canother) xanother = -1*off[0].to('arcmin').value yanother = off[1].to('arcmin').value square=matplotlib.patches.Rectangle((xanother-cradius, yanother-cradius), cradius*2,cradius*2,color='cyan', fill=False) plt.gca().add_artist(square) plt.text(0.5, 1.24, str(nm), fontsize=32, horizontalalignment='center',transform=ax.transAxes) plt.text(0.5, 1.18, 'RA (J2000) = '+str(obj['RAS'])+ ' DEC (J2000) = '+str(obj['DECS']), fontsize=22, horizontalalignment='center',transform=ax.transAxes) plt.text(0.5, 1.12, 'RA(offset) = {:s} DEC(offset) = {:s}'.format( canother.ra.to_string(unit=astrou.hour,pad=True,sep=':', precision=2), canother.dec.to_string(pad=True, alwayssign=True, sep=':', precision=1)), fontsize=22, horizontalalignment='center',transform=ax.transAxes, color='blue') plt.text(0.5, 1.06, 'RA(offset to obj) = {:g} DEC(offset to obj) = {:g}'.format( -1*off[0].to('arcsec'), -1*off[1].to('arcsec')), fontsize=18, horizontalalignment='center',transform=ax.transAxes) else: # Title plt.text(0.5,1.24, str(nm), fontsize=32, horizontalalignment='center',transform=ax.transAxes) plt.text(0.5,1.16, 'RA (J2000) = '+str(obj['RAS']), fontsize=28, horizontalalignment='center',transform=ax.transAxes) plt.text(0.5,1.10, 'DEC (J2000) = '+str(obj['DECS']), fontsize=28, horizontalalignment='center',transform=ax.transAxes) # Spectrum?? if show_spec: spec_img = xgs.get_spec_img(obj['RA'], obj['DEC']) plt.imshow(spec_img,extent=(-imsize/2.1, imsize*(-0.1), -imsize/2.1, imsize*(-0.2))) # Write if show_spec: plt.savefig(outfil, dpi=300) else: plt.savefig(outfil) print 'finder: Wrote '+outfil plt.close() #xdb.set_trace() print 'finder: All done.' return oBW