def draw_planet9(self, **kwargs): from scipy.interpolate import interp1d from scipy.interpolate import UnivariateSpline defaults = dict(color='b', lw=2) setdefaults(kwargs, defaults) ra_lo, dec_lo = np.genfromtxt(fileio.get_datafile('p9_lo.txt'), usecols=(0, 1)).T ra_lo, dec_lo = self.roll(ra_lo, dec_lo) ra_lo += -360 * (ra_lo > 180) ra_lo, dec_lo = ra_lo[::-1], dec_lo[::-1] ra_hi, dec_hi = np.genfromtxt(fileio.get_datafile('p9_hi.txt'), usecols=(0, 1)).T ra_hi, dec_hi = self.roll(ra_hi, dec_hi) ra_hi += -360 * (ra_hi > 180) ra_hi, dec_hi = ra_hi[::-1], dec_hi[::-1] spl_lo = UnivariateSpline(ra_lo, dec_lo) ra_lo_smooth = np.linspace(ra_lo[0], ra_lo[-1], 360) dec_lo_smooth = spl_lo(ra_lo_smooth) spl_hi = UnivariateSpline(ra_hi, dec_hi) ra_hi_smooth = np.linspace(ra_hi[0], ra_hi[-1], 360) dec_hi_smooth = spl_hi(ra_hi_smooth) #self.plot(ra_lo_smooth,dec_lo_smooth,latlon=True,**kwargs) #self.plot(ra_hi_smooth,dec_hi_smooth,latlon=True,**kwargs) orb = fileio.csv2rec(fileio.get_datafile('P9_orbit_Cassini.csv'))[::7] #kwargs = dict(marker='o',s=40,edgecolor='none',cmap='jet_r') #self.scatter(*self.proj(orb['ra'],orb['dec']),c=orb['cassini'],**kwargs) ra, dec = self.roll(orb['ra'], orb['dec']) self.plot(ra, dec, latlon=True, **kwargs)
class DelveScheduler(Scheduler): _defaults = odict(Scheduler._defaults.items() + [ ('tactician','coverage'), ('windows',fileio.get_datafile("delve-windows-v3.csv.gz")), ('targets',fileio.get_datafile("delve-target-fields-v15.csv.gz")), ]) FieldType = DelveFieldArray
class MaglitesScheduler(Scheduler): _defaults = odict(Scheduler._defaults.items() + [ ('tactician','coverage'), ('windows',fileio.get_datafile("maglites-windows.csv")), ('targets',fileio.get_datafile("maglites-target-fields.csv")), ]) FieldType = MaglitesFieldArray
def plot_bliss_coverage(fields, outfile=None, **kwargs): BANDS = ['g', 'r', 'i', 'z'] filename = fileio.get_datafile('bliss-target-fields.csv') target = FieldArray.read(filename) target = target[~np.in1d(target.unique_id, fields.unique_id)] fig, ax = plt.subplots(2, 2, figsize=(16, 9)) plt.subplots_adjust(wspace=0.01, hspace=0.02, left=0.01, right=0.99, bottom=0.01, top=0.99) defaults = dict(edgecolor='none', s=12, alpha=0.2, vmin=-1, vmax=2) setdefaults(kwargs, defaults) for i, b in enumerate(BANDS): plt.sca(ax.flat[i]) f = fields[fields['FILTER'] == b] t = target[target['FILTER'] == b] bmap = DECamMcBride() bmap.draw_des() bmap.draw_galaxy(10) proj = bmap.proj(t['RA'], t['DEC']) bmap.scatter(*proj, c='0.7', **kwargs) proj = bmap.proj(f['RA'], f['DEC']) bmap.scatter(*proj, c=f['TILING'], cmap=CMAPS[b], **kwargs) plt.gca().set_title('BLISS %s-band' % b)
def draw_ligo(self, filename=None, log=True, **kwargs): import healpy as hp from astropy.io import fits as pyfits if not filename: filename = fileio.get_datafile('obsbias_heatmap_semesterA.fits') hpxmap = pyfits.open(filename)[0].data if log: self.draw_hpxmap(np.log10(hpxmap)) else: self.draw_hpxmap(hpxmap)
def draw_des(self, **kwargs): """ Draw the DES footprint on this Basemap instance. """ defaults = dict(color='red', lw=2) setdefaults(kwargs, defaults) filename = fileio.get_datafile('round13-poly.txt') self.draw_polygon(filename, **kwargs)
def draw_smash(self,**kwargs): defaults=dict(facecolor='none',color='k') setdefaults(kwargs,defaults) filename = fileio.get_datafile('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)
def draw_jethwa(self, filename=None, log=True, **kwargs): import healpy as hp if not filename: filename = fileio.get_datafile('jethwa_satellites_n256.fits.gz') hpxmap = hp.read_map(filename) if log: return self.draw_hpxmap(np.log10(hpxmap), **kwargs) else: return self.draw_hpxmap(hpxmap, **kwargs)
def footprintDEEP(ra,dec): """ Selecting exposures around the deep drilling fields """ ra,dec = np.copy(ra), np.copy(dec) sel = np.zeros(len(ra),dtype=bool) filename = fileio.get_datafile('LV_MC_analogs_DECam.txt') targets = np.genfromtxt(filename,names=True,dtype=None) for t in targets: sel |= (angsep(t['RA'],t['Dec'],ra,dec) < t['r_vir']) return sel
def draw_bliss(self, **kwargs): defaults = dict(color='magenta', lw=2) setdefaults(kwargs, defaults) filename = fileio.get_datafile('bliss-poly.txt') data = np.genfromtxt(filename, names=['ra', 'dec', 'poly']) for p in np.unique(data['poly']): poly = data[data['poly'] == p] self.draw_polygon_radec(poly['ra'], poly['dec'], **kwargs)
def draw_sfd(self, **kwargs): import healpy as hp defaults = dict(rasterized=True, cmap=plt.cm.binary) setdefaults(kwargs, defaults) filename = fileio.get_datafile('lambda_sfd_ebv.fits') galhpx = hp.read_map(filename) celhpx = obztak.utils.projector.hpx_gal2cel(galhpx) return self.draw_hpxmap(np.log10(celhpx), **kwargs)
def draw_decals(self, **kwargs): defaults = dict(color='red', lw=2) setdefaults(kwargs, defaults) filename = fileio.get_datafile('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 footprintDES(ra,dec): """ Selecting exposures in the DES footprint Parameters: ----------- ra : Right ascension (deg) dec: Declination (deg) Returns: -------- sel : Selection of fields within the footprint """ filename = fileio.get_datafile('des-round17-poly.txt') return Survey.select_in_path(filename,ra,dec)
def planet9v2(ra, dec): """The other high-probability region for Planet 9""" from matplotlib.path import Path data = np.genfromtxt(fileio.get_datafile('blissII-poly.txt'), names=['RA', 'DEC', 'POLY']) poly = data[data['POLY'] == 1] path = Path(zip(poly['RA'], poly['DEC'])) sel = path.contains_points(np.vstack([ra, dec]).T) poly = data[data['POLY'] == 4] path = Path(zip(poly['RA'], poly['DEC'])) sel |= path.contains_points(np.vstack([ra, dec]).T) return sel
def footprint(ra, dec): import matplotlib.path ra, dec = np.copy(ra), np.copy(dec) filename = fileio.get_datafile('maglitesII-poly.txt') data = np.genfromtxt(filename, names=['ra', 'dec', 'poly']) paths = [] ra -= 360 * (ra > 180) for p in np.unique(data['poly']): poly = data[data['poly'] == p] vertices = np.vstack(np.vstack([poly['ra'], poly['dec']])).T paths.append(matplotlib.path.Path(vertices)) sel = np.sum( [p.contains_points(np.vstack([ra, dec]).T) for p in paths], axis=0) > 0 return sel
def footprintDECALS(ra,dec): """ Selecting exposures in the DESI footprint. Parameters: ----------- ra : Right ascension (deg) dec: Declination (deg) Returns: -------- sel : Selection of fields within the footprint """ import matplotlib.path ra,dec = np.copy(ra), np.copy(dec) filename = fileio.get_datafile('decals-poly.txt') sel = Survey.select_in_path(filename,ra,dec) #sel |= Survey.select_in_path(filename,ra,dec, wrap=360., poly=[3,4]) return sel
def footprintSMASH(ra,dec,angsep=DECAM): """ Selecting exposures in the SMASH island footprint. Parameters: ----------- ra : Right ascension (deg) dec: Declination (deg) angsep : Angular separation (deg) Returns: -------- sel : Selection of fields within the footprint """ import fitsio sel = np.zeros(len(ra),dtype=bool) #filename = fileio.get_datafile('smash_fields_final.txt') filename = fileio.get_datafile('smash_check_calibrated_v6.fits') smash = fitsio.read(filename) smash = smash[smash['NUCALIB'] != 0] idx1,idx2,sep = obztak.utils.projector.match(ra,dec,smash['RA'],smash['DEC']) sel[idx1[sep < angsep]] = True return sel
def weight_gw(self): """ Calculate the field weight for the WIDE survey. """ import healpy as hp airmass = self.airmass moon_angle = self.moon_angle # Reset the exposure time self.fields['EXPTIME'] = 90 if hasattr(self.fields,'hpx'): hpx = self.fields.hpx else: hpx = hp.ang2pix(32,self.fields['RA'],self.fields['DEC'],lonlat=True) setattr(self.fields,'hpx',hpx) gwpix = np.genfromtxt(fileio.get_datafile('GW150914_hpixels_32.tab')) #sel = self.viable_fields sel = np.in1d(hpx,gwpix) sel &= self.fields['FILTER'] == 'g' weight = np.zeros(len(sel)) # Sky brightness selection # Airmass cut airmass_min, airmass_max = self.CONDITIONS['gw'] sel &= ((airmass > airmass_min) & (airmass < airmass_max)) """ # Higher weight for fields close to the moon (when up) # angle = 50 -> weight = 6.4 # Moon angle constraints (viable fields sets moon_angle > 20.) if (self.moon.alt > -0.04) and (self.moon.phase >= 10): #moon_limit = np.min(20 + self.moon.phase/2., 40) moon_limit = 40 sel &= (moon_angle > moon_limit) #weight += 100 * (35./moon_angle)**3 #weight += 10 * (35./moon_angle)**3 weight += 1 * (35./moon_angle)**3 """ # Higher weight for rising fields (higher hour angle) # HA [min,max] = [-53,54] (for airmass 1.4) #weight += 5.0 * self.hour_angle #weight += 1.0 * self.hour_angle #weight += 0.1 * self.hour_angle # Higher weight for larger slews # slew = 10 deg -> weight = 1e2 weight += self.slew**2 #weight += self.slew #weight += 1e3 * self.slew # Higher weight for higher airmass # airmass = 1.4 -> weight = 6.4 weight += 1e3 * (airmass - 1.)**3 #weight += 1e3 * (airmass - 1.)**2 ## Try hard to do high priority fields #weight += 1e3 * (self.fields['PRIORITY'] - 1) #weight += 1e4 * (self.fields['TILING'] > 3) # Set infinite weight to all disallowed fields weight[~sel] = np.inf return weight
def draw_maglites(self, **kwargs): defaults = dict(color='blue', lw=2) setdefaults(kwargs, defaults) filename = fileio.get_datafile('maglites-poly.txt') self.draw_polygon(filename, **kwargs)
def draw_blissII(self, **kwargs): defaults = dict(color='darkorange', lw=2) setdefaults(kwargs, defaults) filename = fileio.get_datafile('blissII-poly.txt') self.draw_polygons(filename, **kwargs)
def prepare_fields(self, infile=None, outfile=None, plot=True, **kwargs): """ Create the list of fields to be targeted by this survey. Parameters: ----------- infile : File containing all possible field locations. outfile: Output file of selected fields plot : Create an output plot of selected fields. Returns: -------- fields : A FieldArray of the selected fields. """ if infile is None: infile = fileio.get_datafile('decam-tiles-bliss-v1.fits.gz') #infile = fileio.get_datafile('decam-tiles-smash-v1.fits.gz') #infile = fileio.get_datafile('decam-tiles-decals-v1.fits.gz') logging.info("Reading tiles from: %s"%os.path.basename(infile)) data = fitsio.read(infile) deep_fields = self.create_deep_fields(data) mc_fields = self.create_mc_fields(data) wide_fields = self.create_wide_fields(data) fields = wide_fields + mc_fields + deep_fields # blacklist blacklist = ['5716-01-g','5716-01-i'] # flame nebula fields['PRIORITY'][np.in1d(fields.unique_id,blacklist)] = DONE if plot: import pylab as plt import skymap.survey plt.ion() sel = [fields['PRIORITY'] > 0] plt.figure() smap = skymap.survey.MaglitesSkymap() smap.draw_fields(fields[sel],alpha=0.3,edgecolor='none') smap.draw_des(c='r') smap.draw_milky_way() smap.draw_smash() plt.figure() smap = skymap.survey.SurveyMcBryde() smap.draw_fields(fields[sel],alpha=0.3,edgecolor='none') smap.draw_des(c='r') smap.draw_milky_way() smap.draw_smash() if outfile: plt.savefig(os.path.splitext(outfile)[0]+'.png',bbox_inches='tight') if not sys.flags.interactive: plt.show(block=True) if outfile: print("Writing %s..."%outfile) fields.write(outfile) return fields
class DECamFocalPlane(object): """Class for storing and manipulating the corners of the DECam CCDs. """ filename = fileio.get_datafile('ccd_corners_xy_fill.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(self.ccd_dict.values()) # Since we don't know the original projection of the DECam # 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 DECam 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 DECam focal plane at a location given by ra,dec. Parameters: ----------- basemap : The DECamBasemap 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
db = Database('db-fnal') db.connect() data = db.query2recarray(QUERY) print("Writing %s..." % filename) fileio.rec2csv(filename, data) else: print("Reading %s..." % filename) data = fileio.csv2rec(filename) good = data[select_good_exposures(data)] guid = np.char.rpartition(good['object'].astype(str), ' ')[:, -1] # Unique fields guid, idx = np.unique(guid, return_index=True) good = good[idx] fields = obztak.delve.DelveFieldArray().load(get_datafile(TARGETS)) fuid = fields.unique_id fields = pd.DataFrame(fields) fields['DONE'] = 0 # Done fields fields.loc[select_done_fields(fields), 'DONE'] |= 1 # Observed by DELVE fields.loc[np.in1d(fuid, guid), 'DONE'] |= 2 uid = pd.DataFrame({ 'uid': fuid }).merge(pd.DataFrame({ 'uid': guid, 'DATE': good['date'] }), how='left')
DECAM2DIMM = 1.0916 DECAMINST = 0.5 # instrumental PSF def dimm2decam(dimm_fwhm, airmass=1.0, band='i', fwhm_inst=0.5): dimm_fwhm = np.atleast_1d(dimm_fwhm) airmass = np.atleast_1d(airmass) const = 1 / WAVETRANS[band] * 1 / DECAM2DIMM if dimm_fwhm.ndim == airmass.ndim: fwhm = const * (dimm_fwhm * (airmass**(0.6))) else: fwhm = const * (dimm_fwhm[:, np.newaxis] * (airmass**(0.6))) return np.hypot(fwhm, fwhm_inst) filename = fileio.get_datafile("delve-windows.csv") windows = pd.read_csv(filename, comment='#', parse_dates=['UTC_START', 'UTC_END']) filename = fileio.get_datafile('delve-target-fields.csv') fields = DelveFieldArray.read(filename) sel = ((fields['PROGRAM'] == 'delve-deep') & (fields['DEC'] > -5)) sel = [38428] sel = (fields['TILING'] == 3) f = fields[sel] # Sex B sexb = f[(f['HEX'] == 15854) & (f['FILTER'] == 'i')] idx = [9409] f = f[idx]
def prepare_fields(self, infile=None, outfile=None, mode='smash_dither', plot=True, smcnod=False): """ Create the list of fields to be targeted by this survey. Parameters: ----------- infile : File containing all possible field locations. outfile: Output file of selected fields mode : Mode for dithering: 'smash_dither', 'smash_rotate', 'decam_dither', 'none' plot : Create an output plot of selected fields. Returns: -------- fields : A FieldArray of the selected fields. """ # Import the dither function here... #def dither(ra,dec,dx,dy): # return ra,dec if mode is None or mode.lower() == 'none': def dither(ra,dec,dx,dy): return ra,dec TILINGS = [(0,0),(0,0),(0,0),(0,0)] elif mode.lower() == 'smash_dither': TILINGS = [(0,0), (1.0,0.0), (-1.0,0.0), (0.0,-0.75)] dither = self.smash_dither elif mode.lower() == 'smash_rotate': TILINGS = [(0,0), (0.75,0.75), (-0.75,0.75), (0.0,-0.75)] dither = self.smash_rotate elif mode.lower() == 'decam_dither': TILINGS = [(0., 0.),(8/3.*CCD_X, -11/3.*CCD_Y), (8/3.*CCD_X, 8/3.*CCD_Y),(-8/3.*CCD_X, 0.)] dither = self.decam_dither if infile is None: infile = fileio.get_datafile('smash_fields_alltiles.txt') data = np.recfromtxt(infile, names=True) # Apply footprint selection after tiling/dither #sel = obztak.utils.projector.footprint(data['RA'],data['DEC']) # This is currently a non-op smash_id = data['ID'] ra = data['RA'] dec = data['DEC'] nhexes = len(data) #ntilings = len(DECAM_DITHERS) ntilings = len(TILINGS) nbands = len(BANDS) nfields = nhexes*nbands*ntilings logging.info("Number of hexes: %d"%nhexes) logging.info("Number of tilings: %d"%ntilings) logging.info("Number of filters: %d"%nbands) fields = FieldArray(nfields) fields['HEX'] = np.tile(np.repeat(smash_id,nbands),ntilings) fields['PRIORITY'].fill(1) fields['TILING'] = np.repeat(np.arange(1,ntilings+1),nhexes*nbands) fields['FILTER'] = np.tile(BANDS,nhexes*ntilings) #for i in range(ntilings): for i,tiling in enumerate(TILINGS): idx0 = i*nhexes*nbands idx1 = idx0+nhexes*nbands ra_dither,dec_dither = dither(ra,dec,tiling[0],tiling[1]) fields['RA'][idx0:idx1] = np.repeat(ra_dither,nbands) fields['DEC'][idx0:idx1] = np.repeat(dec_dither,nbands) # Apply footprint selection after tiling/dither sel = self.footprint(fields['RA'],fields['DEC']) # NORMAL OPERATION if smcnod: # Include SMC northern overdensity fields sel_smcnod = self.footprintSMCNOD(fields) # SMCNOD OPERATION sel = sel | sel_smcnod #sel = sel_smcnod fields['PRIORITY'][sel_smcnod] = 99 #if True: # # Include 'bridge' region between Magellanic Clouds # sel_bridge = self.footprintBridge(fields['RA'],fields['DEC']) # sel = sel | sel_bridge sel = sel & (fields['DEC'] > constants.SOUTHERN_REACH) fields = fields[sel] logging.info("Number of target fields: %d"%len(fields)) if plot: import pylab as plt import obztak.utils.ortho plt.ion() fig, basemap = obztak.utils.ortho.makePlot('2016/2/11 03:00',center=(0,-90),airmass=False,moon=False) proj = obztak.utils.ortho.safeProj(basemap,fields['RA'],fields['DEC']) basemap.scatter(*proj, c=fields['TILING'], edgecolor='none', s=50, cmap='Spectral',vmin=0,vmax=len(TILINGS)) colorbar = plt.colorbar(label='Tiling') if outfile: outfig = os.path.splitext(outfile)[0]+'.png' fig.savefig(outfig,bbox_inches='tight') if not sys.flags.interactive: plt.show(block=True) if outfile: fields.write(outfile) return fields
def prepare_fields(self, infile=None, outfile=None, plot=True, **kwargs): """ Create the list of fields to be targeted by this survey. Parameters: ----------- infile : File containing all possible field locations. outfile: Output file of selected fields plot : Create an output plot of selected fields. Returns: -------- fields : A FieldArray of the selected fields. """ if infile is None: infile = fileio.get_datafile('decam-tiles-bliss.fits.gz') # For decals input file #data['TILEID'] = np.tile(data['TILEID'][data['PASS'] == 1],len(TILINGS)) data = fitsio.read(infile) # Only take tilings of interest data = data[np.in1d(data['PASS'], TILINGS)] # Number of unique tiles nhexes = len(np.unique(data['TILEID'])) ntilings = len(TILINGS) nbands = len(BANDS) nfields = nhexes * nbands * ntilings assert nfields == len(data) * nbands logging.info("Number of hexes: %d" % nhexes) logging.info("Number of tilings: %d" % ntilings) logging.info("Number of filters: %d" % nbands) fields = FieldArray(nfields) fields['HEX'] = np.repeat(data['TILEID'], nbands) fields['TILING'] = np.repeat(data['PASS'], nbands) fields['FILTER'] = np.tile(BANDS, nhexes * ntilings) fields['RA'] = np.repeat(data['RA'], nbands) fields['DEC'] = np.repeat(data['DEC'], nbands) # Apply footprint selection after tiling/dither sel = self.footprint(fields['RA'], fields['DEC']) # NORMAL OPERATION sel = sel & (fields['DEC'] > constants.SOUTHERN_REACH) fields = fields[sel] # Prioritize fields at high declination fields['PRIORITY'][fields['TILING'] == 2] = 2 fields['PRIORITY'][fields['TILING'] == 3] = 3 fields['PRIORITY'][fields['TILING'] == 1] = 4 fields['PRIORITY'][fields['TILING'] == 4] = 5 #fields['PRIORITY'] = fields['TILING'] + 1 fields['PRIORITY'][(fields['DEC'] < -70) & np.in1d(fields['TILING'], [2, 3])] -= 1 logging.info("Number of target fields: %d" % len(fields)) if plot: import pylab as plt import obztak.utils.ortho plt.ion() fig, basemap = obztak.utils.ortho.makePlot('2016/2/11 03:00', center=(0, -90), airmass=False, moon=False) proj = basemap.proj(fields['RA'], fields['DEC']) basemap.scatter(*proj, c=fields['TILING'], edgecolor='none', s=50, cmap='Spectral', vmin=0, vmax=ntilings) colorbar = plt.colorbar(label='Tiling') if outfile: outfig = os.path.splitext(outfile)[0] + '.png' fig.savefig(outfig, bbox_inches='tight') if not sys.flags.interactive: plt.show(block=True) if outfile: logging.info("Writing %s..." % outfile) fields.write(outfile) return fields
# Create the array of possible dates data['date'] = np.array([begin + dt.timedelta(days=i) for i in xrange(size)]) data['half'] = 'full ' tac = obztak.tactician.Tactician() print("Calculating moon phase and altitude...") for i,d in enumerate(data): tac.set_date(str(d['date']).replace('T',' ')+'UTC') data[i]['moon'] = tac.moon.phase data[i]['zenith'] = tac.zenith_angle[0] data[i]['semester'] = get_semester(d['date']) #data = recfns.rec_append_fields(data,['moonphase','moonalt'],[phase,alt]) fields = obztak.delve.DelveFieldArray.read(fileio.get_datafile('delve-target-fields.csv')) sel = fields['PRIORITY'] > 0 sel &= ~((fields['TILING'] > 3) & (fields['PROGRAM'] == 'delve-wide')) sel &= ~((fields['TILING'] > 3) & (fields['PROGRAM'] == 'delve-mc')) fields = fields[sel] print("Calculating KDE...") pts = np.repeat(fields['RA'],np.round(fields['EXPTIME']/90.).astype(int)) pts = np.concatenate([pts, pts[pts < 5.]+360, pts[pts > 355.] - 360]) kde = scipy.stats.gaussian_kde(pts,bw_method=7.0/360.) #kde = scipy.stats.gaussian_kde(pts) data['weight'] = kde(data['zenith']) # Remove exposure close to full moon data['weight'][data['moon'] > 80.] = 0 print("Making choices...")
""" Create various tiling schemes. """ __author__ = "Alex Drlica-Wagner" import fitsio import numpy as np from obztak.utils import fileio from obztak.survey import Survey from obztak.utils.constants import BANDS, SMASH_POLE, CCD_X, CCD_Y, STANDARDS, COLORS, DECAM from obztak.delve import DelveSurvey from obztak.maglites import MaglitesSurvey from obztak.maglites2 import Maglites2Survey DECALS = fitsio.read(fileio.get_datafile('decam-tiles_obstatus.fits')) SMASH = np.genfromtxt(fileio.get_datafile('smash_fields_alltiles.txt'), dtype=[('TILEID', '>i4'), ('RA', '>f8'), ('DEC', '>f8')]) N = len(DECALS) / 3 DTYPE = [ ('TILEID', '>i4'), ('PASS', '>i2'), ('RA', '>f8'), ('DEC', '>f8'), ('IN_DES', bool), ('IN_DECALS', bool), ('IN_SMASH', bool), ('IN_MAGLITES', bool), ]