From f313176633f6957f25cb500e8a2b947ab2b266b1 Mon Sep 17 00:00:00 2001 From: Alex Drlica-Wagner Date: Fri, 14 Jul 2023 17:29:50 -0500 Subject: [PATCH 1/6] initial magic code --- bin/schedule_night | 2 + obztak/factory.py | 14 +- obztak/magic.py | 409 ++++++++++++++++++++++++++++++++++++++ obztak/survey.py | 13 +- obztak/utils/constants.py | 5 + obztak/utils/ortho.py | 3 +- 6 files changed, 438 insertions(+), 8 deletions(-) create mode 100644 obztak/magic.py diff --git a/bin/schedule_night b/bin/schedule_night index a9b2508..c424220 100755 --- a/bin/schedule_night +++ b/bin/schedule_night @@ -40,6 +40,8 @@ def main(): logging.info("Scheduling nite: %s"%(nitestr)) logging.info("Start Time (UTC): %s"%(datestr)) + print(args.fields) + print(args.windows) scheduler = scheduler_factory(target_fields=args.fields, windows=args.windows, completed_fields=args.complete) diff --git a/obztak/factory.py b/obztak/factory.py index 9dad0ec..6f7764f 100644 --- a/obztak/factory.py +++ b/obztak/factory.py @@ -11,7 +11,8 @@ from obztak import get_survey from obztak.utils.date import isstring -MODULES = ['obztak.maglites','obztak.bliss','obztak.maglites2','obztak.delve'] +MODULES = ['obztak.maglites','obztak.bliss','obztak.maglites2','obztak.delve', + 'obztak.magic'] SURVEYS = odict([ (None,'Survey'), @@ -20,6 +21,7 @@ ('bliss','BlissSurvey'), ('maglites2','Maglites2Survey'), ('delve','DelveSurvey'), + ('magic','MagicSurvey'), ]) SCHEDULERS = odict([ @@ -29,6 +31,7 @@ ('bliss','BlissScheduler'), ('maglites2','Maglites2Scheduler'), ('delve','DelveScheduler'), + ('magic','MagicScheduler'), ]) FIELDS = odict([ @@ -37,7 +40,7 @@ ('maglites','MaglitesFieldArray'), ('bliss','BlissFieldArray'), ('maglites2','Maglites2FieldArray'), - ('delve','DelveFieldArray'), + ('magic','MagicFieldArray'), ]) TACTICIANS = odict([ @@ -55,6 +58,7 @@ ('bliss','BlissTactician'), ('maglites2','Maglites2Tactician'), ('delve','DelveTactician'), + ('magic','MagicTactician'), ]) def factory(cls, modules=None, **kwargs): @@ -92,14 +96,14 @@ def fn(member): return members[lower](**kwargs) def scheduler_factory(cls=None, **kwargs): - #modules = ['obztak.scheduler','obztak.maglites','obztak.bliss','obztak.maglites2'] + print("scheduler_factory") modules = ['obztak.scheduler']+MODULES if cls is None: cls = get_survey() cls = SCHEDULERS.get(cls,cls) + print(cls) return factory(cls, modules=modules, **kwargs) def survey_factory(cls=None, **kwargs): - #modules = ['obztak.survey','obztak.maglites','obztak.bliss','obztak.maglites2'] modules = ['obztak.survey']+MODULES if cls is None: cls = get_survey() cls = SURVEYS.get(cls,cls) @@ -108,7 +112,6 @@ def survey_factory(cls=None, **kwargs): def field_factory(cls=None, **kwargs): """Create a field array """ - #modules = ['obztak.field','obztak.maglites','obztak.bliss','obztak.maglites2'] modules = ['obztak.field']+MODULES if cls is None: cls = get_survey() cls = FIELDS.get(cls,cls) @@ -125,7 +128,6 @@ def tactician_factory(cls=None, **kwargs): -------- tac : The Tactician """ - #modules = ['obztak.tactician','obztak.maglites','obztak.bliss','obztak.maglites2'] modules = ['obztak.tactician']+MODULES if cls is None: cls = get_survey() cls = TACTICIANS.get(cls,cls) diff --git a/obztak/magic.py b/obztak/magic.py new file mode 100644 index 0000000..0731311 --- /dev/null +++ b/obztak/magic.py @@ -0,0 +1,409 @@ +#!/usr/bin/env python +""" +Code related to the DECam Dwarf Galaxy Survey. +""" +from __future__ import print_function + +import os,sys +import logging +import copy +from collections import OrderedDict as odict + +import pandas as pd +import numpy as np +import fitsio +from matplotlib.path import Path + +from obztak.field import FieldArray, SISPI_DICT, SEP +from obztak.survey import Survey +from obztak.scheduler import Scheduler +from obztak.tactician import Tactician + +from obztak.utils.projector import cel2gal, angsep +from obztak.utils import constants +from obztak.utils import fileio +from obztak.utils.constants import BANDS,SMASH_POLE,CCD_X,CCD_Y,STANDARDS,DECAM +from obztak.utils.constants import COLORS, CMAPS +from obztak.utils.date import datestring, setdefaults, nite2utc,utc2nite,datestr + +NAME = 'MAGIC' +PROGRAM = NAME.lower() +PROPID = '2023B-646244' +PROPOSER = 'Chiti' +BANDS = ['N395'] +TILINGS = [1] +DONE = -1 + +class MagicSurvey(Survey): + """ Survey sublcass for BLISS. """ + + nights_2023B = [ + ['2023/08/10', 'first'], + ['2023/08/11', 'full'], + ['2023/08/13', 'full'], + ['2023/08/14', 'full'], + ['2023/08/16', 'first'], + ['2023/08/17', 'first'], + ['2023/08/19', 'first'], + ['2023/08/20', 'first'], + ['2023/08/22', 'second'], + ['2023/08/23', 'second'], + ] + + extra_nights = [] + + nights = nights_2023B + extra_nights + + 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') + logging.info("Reading tiles from: %s"%os.path.basename(infile)) + data = fitsio.read(infile) + + fields = self.create_magic_fields(data) + + logging.info("Masking bright stars...") + mask = self.bright_stars(fields['RA'],fields['DEC']) + fields['PRIORITY'][mask] = DONE + + # Can't go lower + mask = fields['DEC'] < -89.0 + fields['PRIORITY'][mask] = DONE + + # Exclusion + exclude = [] + fields['PRIORITY'][np.in1d(fields.unique_id,exclude)] = 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(color='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(color='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 + + @classmethod + def update_covered_fields(cls, fields): + """ Update the priority of covered fields. """ + # Currently NOOP + fields = copy.deepcopy(fields) + frac, depth = cls.covered(fields) + done = (fields['PRIORITY'] == DONE) + print("Found %i exposures already done."%done.sum()) + + return fields + + def create_magic_fields(self, data, plot=False): + """ Create the wide field observations """ + logging.info("Creating MAGIC fields...") + EXPTIME = [720] + TILINGS = [1] + + nhexes = len(np.unique(data['TILEID'])) + nbands = len(BANDS) + + nfields = len(data)*nbands + + logging.info(" Number of hexes: %d"%nhexes) + logging.info(" Filters: %s"%BANDS) + logging.info(" Exposure time: %s"%EXPTIME) + logging.info(" Tilings: %s"%TILINGS) + + fields = FieldArray(nfields) + fields['PROGRAM'] = PROGRAM + fields['HEX'] = np.repeat(data['TILEID'],nbands) + fields['TILING'] = np.repeat(data['PASS'],nbands) + fields['RA'] = np.repeat(data['RA'],nbands) + fields['DEC'] = np.repeat(data['DEC'],nbands) + + fields['FILTER'] = np.tile(BANDS,len(data)) + fields['EXPTIME'] = np.tile(EXPTIME,len(data)) + fields['PRIORITY'] = fields['TILING'] + + sel = self.footprintMAGIC(fields['RA'],fields['DEC']) + sel &= (fields['TILING'] == 1) + + fields = fields[sel] + + if plot: self.plot_depth(fields,depth,f'{PROGRAM}-%s-gt%i.png') + + logging.info("Number of target fields: %d"%len(fields)) + + outfile = f'{PROGRAM}-fields.fits.fz' + logging.info("Writing %s..."%outfile) + fields.write(outfile,clobber=True) + + return fields + + @staticmethod + def footprintMAGIC(ra,dec): + """ Selecting wide-field exposures plane """ + ra,dec = np.copy(ra), np.copy(dec) + ra -= 360 * (ra > 180) + + vertices = [ + [90, -30], + [ 0, -30], + [-50, -30], + [-60, -32], + [-80, -45], + [-80, -60], + [-80, -80], + [ 0, -80], + [120, -80], + [120, -60], + [105, -45], + [ 90, -30], + ] + path = Path(vertices) + points = np.vstack([ra,dec]).T + sel = path.contains_points(points) + + return sel + + def plot_depth(self, fields, depth, outbase, proj='mcbryde', **kwargs): + import skymap, skymap.survey + import pylab as plt + bands = np.unique(fields['FILTER']) + ra,dec = fields['RA'],fields['DEC'] + for b in bands: + sel = fields['FILTER']==b + for d in np.unique(fields[sel]['EXPTIME']*fields[sel]['TILING'])[:-1]: + plt.figure() + if proj == 'mcbryde': smap = skymap.McBrydeSkymap() + elif proj == 'maglites': smap = skymap.survey.MaglitesSkymap() + smap.scatter(*smap(ra[sel],dec[sel]),c=depth[sel],vmax=d,edgecolor='none',s=3) + smap.draw_lmc(fc='none') + smap.draw_smc(fc='none') + plt.colorbar() + plt.savefig(outbase%(b,d),bbox_inches='tight') + plt.close() + + +class MagicFieldArray(FieldArray): + PROGRAM = PROGRAM + PROPID = PROPID + PROPOSER = PROPOSER + + SISPI_DICT = copy.deepcopy(SISPI_DICT) + SISPI_DICT["program"] = PROGRAM + SISPI_DICT["propid"] = PROPID + SISPI_DICT["proposer"] = PROPOSER + + OBJECT_FMT = NAME.upper() + ' field'+SEP+' %s' + SEQID_FMT = NAME.upper() + ' scheduled'+SEP+' %(DATE)s' + BANDS = BANDS + + @classmethod + def query(cls, **kwargs): + """ Generate the database query. + + Parameters: + ----------- + kwargs : Keyword arguments to fill the query. + + Returns: + -------- + query : The query string. + """ + defaults = dict(propid=cls.SISPI_DICT['propid'], limit='', + object_fmt = cls.OBJECT_FMT%'') + #date_column = 'date' or 'to_timestamp(utc_beg)' + defaults['date_column'] = 'date' + kwargs = setdefaults(kwargs,copy.deepcopy(defaults)) + + query =""" + SELECT object, seqid, seqnum, telra as RA, teldec as dec, + expTime, filter, + to_char(%(date_column)s, 'YYYY/MM/DD HH24:MI:SS.MS') AS DATE, + COALESCE(airmass,-1) as AIRMASS, COALESCE(moonangl,-1) as MOONANGLE, + COALESCE(ha, -1) as HOURANGLE, COALESCE(slewangl,-1) as SLEW, PROGRAM + FROM exposure where propid in ('%(propid)s') + and exptime > 89 + and discard = False and delivered = True and flavor = 'object' + and object LIKE '%(object_fmt)s%%' + and ( + (COALESCE(qc_teff,-1) NOT BETWEEN 0 and 0.2 + AND COALESCE(qc_fwhm,1) BETWEEN 0.5 and 1.5) + OR %(date_column)s > (now() - interval '14 hours') + ) + ORDER BY %(date_column)s %(limit)s + """%kwargs + return query + + +class MagicScheduler(Scheduler): + _defaults = odict(list(Scheduler._defaults.items()) + [ + ('tactician','coverage'), + ('windows',fileio.get_datafile("magic-windows-20230714.csv.gz")), + ('targets',fileio.get_datafile("magic-fields-20230714.csv.gz")), + ]) + + FieldType = MagicFieldArray + + +class MagicTactician(Tactician): + CONDITIONS = odict([ + (None, [1.0, 1.4]), + ('magic', [1.0, 1.4]), + ]) + + def __init__(self, *args, **kwargs): + super(MagicTactician,self).__init__(*args,**kwargs) + #Default to mode 'wide' if no mode in kwargs + self.mode = kwargs.get('mode','magic') + + @property + def viable_fields(self): + viable = super(MagicTactician,self).viable_fields + viable &= (self.fields['PRIORITY'] >= 0) + return viable + + def skybright_select(self): + """Select fields based on skybrightness and band. + All MAGIC observations should be dark. + + Parameters: + ----------- + None + + Returns: + -------- + sel : boolean selection + """ + sel = np.ones(len(self.fields),dtype=bool) + return sel + + @property + def weight(self): + """ Calculate the weight from set of programs. """ + return self.weight_magic() + + def weight_magic(self): + """ Calculate the field weight for the WIDE survey. + + Parameters + ---------- + None + + Returns + ------- + weight : array of weights per field + """ + airmass = self.airmass + moon_angle = self.moon_angle + + sel = self.viable_fields + weight = np.zeros(len(sel)) + + # Prefer DES region + sel &= (self.fields['DEC'] > -50) & (self.fields['DEC'] < -40) + sel &= ((self.fields['RA'] > 290) | (self.fields['RA'] < 90)) + inDES = Survey.footprintDES(self.fields['RA'],self.fields['DEC']) + weight += 1e3 * ~inDES + + # Airmass cut + airmass_min, airmass_max = self.CONDITIONS['magic'] + + if False: # Don't use seeing + sel &= ((airmass > airmass_min) & (airmass < airmass_max)) + elif self.fwhm <= 1.4: + sel &= ((airmass > airmass_min) & (airmass < airmass_max)) + else: + sel &= ((airmass > airmass_min) & (airmass < 1.3)) + + # 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 = 50. + (self.moon.phase/10.) + 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 += 10.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 += 100. * (airmass - 1.)**3 + #weight += 1e3 * (airmass - 1.)**2 + + # Set infinite weight to all disallowed fields + weight[~sel] = np.inf + + return weight + + def select_index(self): + weight = self.weight + index = np.array([np.argmin(weight)],dtype=int) + if np.any(~np.isfinite(weight[index])): + plot = (logging.getLogger().getEffectiveLevel()==logging.DEBUG) + msg = "Infinite weight selected..." + logging.warn(msg) + logging.info(">>> To plot fields enter 'plot=True'") + logging.info(">>> Enter 'c' to continue") + import pdb; pdb.set_trace() + if plot: + import obztak.utils.ortho, pylab as plt + airmass = self.CONDITIONS[self.mode][1] + if len(self.completed_fields): + last_field =self.completed_fields[-1] + else: + last_field = self.fields[-1] + smap = obztak.utils.ortho.plotFields(last_field,self.fields,self.completed_fields,options_basemap=dict(airmass=airmass)) + plt.show() + logging.info(">>> Enter 'c' to continue") + pdb.set_trace() + raise ValueError(msg) + + return index diff --git a/obztak/survey.py b/obztak/survey.py index 2d75589..114ab50 100644 --- a/obztak/survey.py +++ b/obztak/survey.py @@ -16,7 +16,7 @@ from obztak.utils import fileio from obztak.field import FieldArray -from obztak.utils.projector import cel2gal +from obztak.utils.projector import cel2gal, angsep from obztak.utils.date import datestring from obztak.utils.constants import BANDS,SMASH_POLE,CCD_X,CCD_Y,STANDARDS,DECAM @@ -382,6 +382,17 @@ def footprintMilkyWay(ra,dec,angsep=10.): glon,glat = cel2gal(ra,dec) return (np.fabs(glat) < angsep) + @staticmethod + def bright_stars(ra,dec): + """ Load bright star list """ + ra,dec = np.copy(ra), np.copy(dec) + sel = np.zeros(len(ra),dtype=bool) + filename = fileio.get_datafile('famous-bright-stars.csv') + targets = fileio.read_csv(filename).to_records() + for t in targets: + sel |= (angsep(t['ra'],t['dec'],ra,dec) < t['radius']) + return sel + @staticmethod def no_dither(ra,dec,dx,dy): """Non-op""" diff --git a/obztak/utils/constants.py b/obztak/utils/constants.py index 4c7efb0..3eb5f6b 100644 --- a/obztak/utils/constants.py +++ b/obztak/utils/constants.py @@ -72,6 +72,9 @@ ('z','magenta'), ('Y','black'), ('VR','gray'), + ('N','blue'), + ('N395','blue'), + ]) # Band colormaps @@ -84,6 +87,8 @@ ('z','RdPu'), ('Y','Greys'), ('VR','Greys'), + ('N','Blues'), + ('N395','Blues'), ]) # Tiling colors diff --git a/obztak/utils/ortho.py b/obztak/utils/ortho.py index b7585e0..c0f1be8 100644 --- a/obztak/utils/ortho.py +++ b/obztak/utils/ortho.py @@ -602,7 +602,8 @@ def project(self, basemap, ra, dec): ############################################################ -def makePlot(date=None, name=None, figsize=(10.5,8.5), dpi=80, s=50, center=None, airmass=True, moon=True, des=True, smash=False, maglites=None, bliss=None, galaxy=True): +def makePlot(date=None, name=None, figsize=(10.5,8.5), dpi=80, s=50, center=None, airmass=True, moon=True, + des=True, smash=False, maglites=None, bliss=None, delve=None, galaxy=True): """ Create map in orthographic projection """ From d613fdb6fe74e312ff3101c5f13edb307e1135f8 Mon Sep 17 00:00:00 2001 From: Alex Drlica-Wagner Date: Thu, 4 Jan 2024 11:02:30 -0600 Subject: [PATCH 2/6] Updates for MAGIC 2023B run --- bin/schedule_survey | 3 +- obztak/field.py | 2 +- obztak/magic.py | 141 +++++++++++++++++++++++++++++++++++------- obztak/scheduler.py | 5 +- obztak/tactician.py | 7 +-- obztak/utils/ortho.py | 13 +++- 6 files changed, 140 insertions(+), 31 deletions(-) diff --git a/bin/schedule_survey b/bin/schedule_survey index 1cbb59c..fad59ad 100755 --- a/bin/schedule_survey +++ b/bin/schedule_survey @@ -25,6 +25,7 @@ def main(): logging.info(basedir) try: + print(args.utc_start, args.utc_end) survey = scheduler.schedule_survey(start=args.utc_start,end=args.utc_end, chunk=args.chunk,plot=args.plot, mode=args.mode,write=True, @@ -37,7 +38,7 @@ def main(): scheduler.completed_fields.write('survey_fields.csv') for nite,chunks in survey.items(): - survey.write_nite(nite,chunks,dirname=basedir) + scheduler.write_nite(nite,chunks,dirname=basedir) return survey diff --git a/obztak/field.py b/obztak/field.py index 6b1f173..727bb9b 100644 --- a/obztak/field.py +++ b/obztak/field.py @@ -20,7 +20,7 @@ ('RA', dict(dtype=float,value=None)), ('DEC', dict(dtype=float,value=None)), #('FILTER', dict(dtype='S1',value='')), - ('FILTER', dict(dtype=(np.str_,1),value='')), + ('FILTER', dict(dtype=(np.str_,5),value='')), ('EXPTIME', dict(dtype=float,value=90)), ('TILING', dict(dtype=int,value=0)), ('PRIORITY', dict(dtype=int,value=1)), diff --git a/obztak/magic.py b/obztak/magic.py index 0731311..d7cffe3 100644 --- a/obztak/magic.py +++ b/obztak/magic.py @@ -98,6 +98,7 @@ def prepare_fields(self, infile=None, outfile=None, plot=True, **kwargs): smap = skymap.survey.MaglitesSkymap() smap.draw_fields(fields[sel],alpha=0.3,edgecolor='none') smap.draw_des(color='r') + smap.draw_milky_way(15,color='gray') smap.draw_milky_way() #smap.draw_smash() @@ -105,6 +106,7 @@ def prepare_fields(self, infile=None, outfile=None, plot=True, **kwargs): smap = skymap.survey.SurveyMcBryde() smap.draw_fields(fields[sel],alpha=0.3,edgecolor='none') smap.draw_des(color='r') + smap.draw_milky_way(15,color='gray') smap.draw_milky_way() #smap.draw_smash() @@ -173,31 +175,114 @@ def create_magic_fields(self, data, plot=False): return fields @staticmethod - def footprintMAGIC(ra,dec): + def footprintMAGIC(ra, dec, radius=0.0): """ Selecting wide-field exposures plane """ + filename = fileio.get_datafile('magic-poly.txt') + return Survey.select_in_path(filename,ra,dec,radius=radius) + + @staticmethod + def region1(ra,dec): + ra,dec = np.copy(ra), np.copy(dec) + ra -= 360 * (ra > 180) + + vertices = [[-50,-45], + [10,-45], + [10,-60], + [-50,-60]] + + path = Path(vertices) + points = np.vstack([ra,dec]).T + sel = path.contains_points(points) + + return sel + + @staticmethod + def region3(ra,dec): + ra,dec = np.copy(ra), np.copy(dec) + ra -= 360 * (ra > 180) + + vertices = [ + [-50,-45], + [-15,-45], + [0,-52], + [20,-70], + [0,-70], + [-30,-60], + [-50,-60], + [-50,-45], + ] + + path = Path(vertices) + points = np.vstack([ra,dec]).T + sel = path.contains_points(points) + + return sel + + def region3b(ra,dec): ra,dec = np.copy(ra), np.copy(dec) ra -= 360 * (ra > 180) vertices = [ - [90, -30], - [ 0, -30], - [-50, -30], - [-60, -32], [-80, -45], + [-15, -45], + [ 10, -50], + [ 20, -70], + [ 0, -70], + [-30, -60], [-80, -60], - [-80, -80], - [ 0, -80], - [120, -80], - [120, -60], - [105, -45], - [ 90, -30], + [-80, -45], ] + path = Path(vertices) points = np.vstack([ra,dec]).T sel = path.contains_points(points) return sel + def region3c(ra,dec): + ra,dec = np.copy(ra), np.copy(dec) + ra -= 360 * (ra > 180) + + vertices = [ + [-70, -50], + [-55, -50], + [-15, -50], + [ 10, -50], + [ 20, -70], + [ 0, -70], + [-30, -60], + [-80, -60], + [-70, -50], + ] + + path = Path(vertices) + points = np.vstack([ra,dec]).T + sel = path.contains_points(points) + + return sel + + def region3d(ra,dec): + ra,dec = np.copy(ra), np.copy(dec) + ra -= 360 * (ra > 180) + + vertices = [ + [-70, -50], + [-55, -50], + [-15, -50], + [ 10, -50], + [ 10, -57], + [-30, -57], + [-70, -57], + [-70, -50], + ] + + path = Path(vertices) + points = np.vstack([ra,dec]).T + sel = path.contains_points(points) + + return sel + + def plot_depth(self, fields, depth, outbase, proj='mcbryde', **kwargs): import skymap, skymap.survey import pylab as plt @@ -269,11 +354,16 @@ def query(cls, **kwargs): return query +class MagicConfig(Config): + _defaults = odict( + ) + pass + class MagicScheduler(Scheduler): _defaults = odict(list(Scheduler._defaults.items()) + [ ('tactician','coverage'), - ('windows',fileio.get_datafile("magic-windows-20230714.csv.gz")), - ('targets',fileio.get_datafile("magic-fields-20230714.csv.gz")), + ('windows',fileio.get_datafile("magic-windows.csv.gz")), + ('targets',fileio.get_datafile("magic-fields.csv.gz")), ]) FieldType = MagicFieldArray @@ -282,7 +372,7 @@ class MagicScheduler(Scheduler): class MagicTactician(Tactician): CONDITIONS = odict([ (None, [1.0, 1.4]), - ('magic', [1.0, 1.4]), + ('magic', [1.0, 1.5]), ]) def __init__(self, *args, **kwargs): @@ -293,7 +383,8 @@ def __init__(self, *args, **kwargs): @property def viable_fields(self): viable = super(MagicTactician,self).viable_fields - viable &= (self.fields['PRIORITY'] >= 0) + #viable &= (self.fields['PRIORITY'] >= 0) + viable &= (self.fields['PRIORITY'] != DONE) return viable def skybright_select(self): @@ -333,12 +424,16 @@ def weight_magic(self): sel = self.viable_fields weight = np.zeros(len(sel)) + sel &=(self.fields['DEC'] < -40) + sel &= ((self.fields['RA'] > 180) | (self.fields['RA'] < 30)) # Prefer DES region - sel &= (self.fields['DEC'] > -50) & (self.fields['DEC'] < -40) - sel &= ((self.fields['RA'] > 290) | (self.fields['RA'] < 90)) + #sel &= ((self.fields['RA'] > 290) | (self.fields['RA'] < 90)) inDES = Survey.footprintDES(self.fields['RA'],self.fields['DEC']) weight += 1e3 * ~inDES + inReg3 = MagicSurvey.region3d(self.fields['RA'],self.fields['DEC']) + weight += 5e4 * ~inReg3 + # Airmass cut airmass_min, airmass_max = self.CONDITIONS['magic'] @@ -363,20 +458,22 @@ def weight_magic(self): # Higher weight for rising fields (higher hour angle) # HA [min,max] = [-53,54] (for airmass 1.4) - weight += 10.0 * self.hour_angle - #weight += 1.0 * self.hour_angle + #weight += 10.0 * self.hour_angle + weight += 1.0 * self.hour_angle #weight += 0.1 * self.hour_angle + #weight += 10.0 * np.abs(self.hour_angle) # Higher weight for larger slews # slew = 10 deg -> weight = 1e2 - weight += self.slew**2 - #weight += self.slew + #weight += self.slew**2 + weight += self.slew #weight += 1e3 * self.slew # Higher weight for higher airmass # airmass = 1.4 -> weight = 6.4 - weight += 100. * (airmass - 1.)**3 + #weight += 100. * (airmass - 1.)**3 #weight += 1e3 * (airmass - 1.)**2 + weight += 10. * airmass**3 # Set infinite weight to all disallowed fields weight[~sel] = np.inf diff --git a/obztak/scheduler.py b/obztak/scheduler.py index c2cc522..ae20e52 100644 --- a/obztak/scheduler.py +++ b/obztak/scheduler.py @@ -480,6 +480,9 @@ def schedule_survey(self,start=None,end=None,chunk=60,plot=False,mode=None, self.scheduled_nites = odict() + if start is None: start = self.windows[0][0] + if end is None: end = self.windows[-1][1] + for tstart,tend in self.windows: if start is not None and ephem.Date(tstart) < ephem.Date(start): continue @@ -490,7 +493,7 @@ def schedule_survey(self,start=None,end=None,chunk=60,plot=False,mode=None, nite = get_nite(tstart) try: - chunks = self.schedule_nite(tstart,chunk,clip=True,plot=False,mode=mode) + chunks = self.schedule_nite(tstart,chunk=chunk,clip=True,plot=False,mode=mode) except ValueError as error: ortho.plotField(self.completed_fields[-1:],self.target_fields, self.completed_fields) diff --git a/obztak/tactician.py b/obztak/tactician.py index acf1b43..e0f2f36 100644 --- a/obztak/tactician.py +++ b/obztak/tactician.py @@ -9,9 +9,6 @@ import ephem from collections import OrderedDict as odict -from obztak import get_survey -from obztak.utils.projector import angsep - from obztak.utils import projector as proj from obztak.ctio import CTIO from obztak.utils import constants @@ -131,8 +128,8 @@ def slew(self): previous_field = None if previous_field: - return angsep(previous_field['RA'],previous_field['DEC'], - self.fields['RA'], self.fields['DEC']) + return proj.angsep(previous_field['RA'],previous_field['DEC'], + self.fields['RA'], self.fields['DEC']) else: return np.zeros(len(self.fields)) diff --git a/obztak/utils/ortho.py b/obztak/utils/ortho.py index c0f1be8..6e6191c 100644 --- a/obztak/utils/ortho.py +++ b/obztak/utils/ortho.py @@ -261,7 +261,7 @@ def draw_des(self,**kwargs): defaults=dict(color='red', lw=2) setdefaults(kwargs,defaults) - filename = fileio.get_datafile('round13-poly.txt') + filename = fileio.get_datafile('des-round19-poly.txt') self.draw_polygon(filename,**kwargs) def draw_smash(self,**kwargs): @@ -322,6 +322,15 @@ def draw_delve(self,**kwargs): #self.tissot(RA_LMC,DEC_LMC,25,100,fc='none',**kwargs) #self.tissot(RA_SMC,DEC_SMC,10,100,fc='none',**kwargs) + def draw_magic(self,**kwargs): + """ Draw the MAGIC footprint on this Basemap instance. + """ + defaults=dict(color='magenta', lw=2) + setdefaults(kwargs,defaults) + + filename = fileio.get_datafile('magic-poly.txt') + self.draw_polygon(filename,**kwargs) + def draw_airmass(self, observatory, airmass, npts=360, **kwargs): defaults = dict(color='green', lw=2) @@ -634,6 +643,8 @@ def makePlot(date=None, name=None, figsize=(10.5,8.5), dpi=80, s=50, center=None if airmass is True: airmass = 1.4 if survey=='delve' or delve: smap.draw_delve() + if survey=='magic': + smap.draw_magic() if airmass: airmass = 2.0 if isinstance(airmass,bool) else airmass From d5346c2d681853d85c5817c1f6734c4c9e5a50c3 Mon Sep 17 00:00:00 2001 From: Alex Drlica-Wagner Date: Thu, 4 Jan 2024 11:17:15 -0600 Subject: [PATCH 3/6] adding des and magic polygons --- obztak/data/des-round19-poly.txt | 601 +++++++++++++++++++++++++++++++ obztak/data/magic-poly.txt | 39 ++ 2 files changed, 640 insertions(+) create mode 100644 obztak/data/des-round19-poly.txt create mode 100644 obztak/data/magic-poly.txt diff --git a/obztak/data/des-round19-poly.txt b/obztak/data/des-round19-poly.txt new file mode 100644 index 0000000..5e52884 --- /dev/null +++ b/obztak/data/des-round19-poly.txt @@ -0,0 +1,601 @@ +# +# DES round19 footprint +# March 19, 2019 +# Eric Neilsen +# +# This is a minor update of round17 to add back some of the southern region of the footprint +# near the LMC that was completed an the end of the survey. +# +# +# DES round17 footprint +# August 30, 2017 +# Alex Drlica-Wagner +# +# +# This is a minor update of round13 to remove the southern region of the footprint +# near the LMC that has been phased out of obstac. +# +# +# DES round13 footprint +# August 20, 2013 +# Jim Annis +# +# Consisting of the SPT-SZ survey area, the SDSS equatorial area, +# a 3000 sq-degree circle centered at ra,dec= 38.8, -39.5 (r=30.91 deg), +# and the weak lensing poop deck in the East centered at a declination +# corresponding to CTIO zenith, an area optimal for DES weak lensing. +# We attempted to stay in regions where the stellar density was < 7*rho_{sp}, +# where rho_{sp} is the south pole stellar desnity, both as measured by 2MASS J-band star counts. +# We also attempted to stary in regions where the SFD dust map estimates the i-band +# extinction is < 0.15 mags. We did a better job with the stars than with the dust +# as the star density is smooth, whereas the dust can be found in clouds, particularily in the NE +# We estimate the footprint area at 5200 sq-degrees, +# though my current 1-sigma error estimate is 150 sq-degrees +# +# The footprint consists of 567 coordinate pairs. +# For questions of whether a point is inside the footprint and area, +# we recommend ray casting algorithms; your milage may vary. +# Point in polygon algorithms are well studied (think: video games and movies) +# +# With that, we shall consider the footprint complete. +# (Note that a 2014 iteration would natually be called round14.) +# +# typedef struct { +# double ra; +# double dec; +# } COORDINATE; +# + +23.0 -7.0 +22.0 -7.0 +21.0 -7.0 +20.0 -7.0 +19.0 -7.0 +18.0 -7.0 +17.0 -7.0 +16.0 -7.0 +15.0 -7.0 +14.0 -7.0 +13.0 -7.0 +12.0 -7.0 +11.0 -7.0 +10.0 -7.0 +9.0 -7.0 +8.0 -7.0 +7.0 -7.0 +6.0 -7.0 +5.0 -7.0 +4.0 -7.0 +3.0 -7.0 +2.0 -7.0 +1.0 -7.0 +0.0 -7.0 +0.0 -6.0 +0.0 -5.0 +0.0 -4.0 +0.0 -3.0 +0.0 -2.0 +-1.0 -2.0 +-2.0 -2.0 +-3.0 -2.0 +-4.0 -2.0 +-5.0 -2.0 +-6.0 -2.0 +-7.0 -2.0 +-8.0 -2.0 +-9.0 -2.0 +-10.0 -2.0 +-11.0 -2.0 +-12.0 -2.0 +-13.0 -2.0 +-14.0 -2.0 +-15.0 -2.0 +-16.0 -2.0 +-17.0 -2.0 +-18.0 -2.0 +-19.0 -2.0 +-20.0 -2.0 +-21.0 -2.0 +-22.0 -2.0 +-23.0 -2.0 +-24.0 -2.0 +-25.0 -2.0 +-26.0 -2.0 +-27.0 -2.0 +-28.0 -2.0 +-29.0 -2.0 +-30.0 -2.0 +-31.0 -2.0 +-32.0 -2.0 +-33.0 -2.0 +-34.0 -2.0 +-35.0 -2.0 +-36.0 -2.0 +-37.0 -2.0 +-38.0 -2.0 +-39.0 -2.0 +-40.0 -2.0 +-41.0 -2.0 +-42.0 -2.0 +-43.0 -2.0 +-43.0 -1.0 +-43.0 0.0 +-43.0 1.0 +-43.0 2.0 +-42.0 2.0 +-41.0 2.0 +-40.0 2.0 +-39.0 2.0 +-38.0 2.0 +-37.0 2.0 +-36.0 2.0 +-35.0 2.0 +-34.0 2.0 +-33.0 2.0 +-32.0 2.0 +-31.0 2.0 +-30.0 2.0 +-29.0 2.0 +-28.0 2.0 +-27.0 2.0 +-26.0 2.0 +-25.0 2.0 +-24.0 2.0 +-23.0 2.0 +-22.0 2.0 +-21.0 2.0 +-20.0 2.0 +-19.0 2.0 +-18.0 2.0 +-17.0 2.0 +-16.0 2.0 +-15.0 2.0 +-14.0 2.0 +-13.0 2.0 +-12.0 2.0 +-11.0 2.0 +-10.0 2.0 +-9.0 2.0 +-8.0 2.0 +-7.0 2.0 +-6.0 2.0 +-5.0 2.0 +-4.0 2.0 +-3.0 2.0 +-2.0 2.0 +-1.0 2.0 +0.0 2.0 +0.0 2.0 +0.0 3.0 +0.0 4.0 +0.0 5.0 +1.0 5.0 +2.0 5.0 +3.0 5.0 +4.0 5.0 +5.0 5.0 +6.0 5.0 +7.0 5.0 +8.0 5.0 +9.0 5.0 +10.0 5.0 +11.0 5.0 +12.0 5.0 +13.0 5.0 +14.0 5.0 +15.0 5.0 +16.0 5.0 +17.0 5.0 +18.0 5.0 +19.0 5.0 +20.0 5.0 +21.0 5.0 +22.0 5.0 +23.0 5.0 +24.0 5.0 +25.0 5.0 +26.0 5.0 +27.0 5.0 +28.0 5.0 +29.0 5.0 +30.0 5.0 +31.0 5.0 +32.0 5.0 +33.0 5.0 +34.0 5.0 +35.0 5.0 +36.0 5.0 +37.0 5.0 +38.0 5.0 +39.0 5.0 +40.0 5.0 +41.0 5.0 +42.0 5.0 +43.0 5.0 +44.0 5.0 +45.0 5.0 +45.0 5.0 +45.0 4.0 +45.0 3.0 +45.0 2.0 +45.0 1.0 +45.0 0.0 +45.0 -1.0 +45.0 -2.0 +45.0 -3.0 +45.0 -4.0 +45.0 -5.0 +45.0 -6.0 +45.0 -7.0 +45.0 -8.0 +45.0 -9.0 +45.835840000000005 -9.06842 +46.36744 -9.145669999999999 +46.89697 -9.22888 +47.42429 -9.3181 +47.94928 -9.41337 +48.47183 -9.51474 +48.99181 -9.62226 +49.50912 -9.73598 +50.02364 -9.855939999999999 +50.53529 -9.98221 +51.04396 -10.11482 +51.54955 -10.25382 +52.05199 -10.39926 +52.55118 -10.55119 +53.047059999999995 -10.70965 +53.53954 -10.87467 +54.02856 -11.0463 +54.51405 -11.22457 +54.99596 -11.40952 +55.474230000000006 -11.601180000000001 +55.948809999999995 -11.79957 +56.41965 -12.004710000000001 +56.88672 -12.21663 +57.34998 -12.43534 +57.80939 -12.660860000000001 +58.26493000000001 -12.893180000000001 +58.71657 -13.132320000000002 +59.16429 -13.37827 +59.60807 -13.631020000000001 +60.0479 -13.89057 +60.48376999999999 -14.156889999999999 +60.91568 -14.42997 +61.3436 -14.70979 +61.76755 -14.996310000000001 +62.18753 -15.2895 +62.60354 -15.589310000000001 +63.01557 -15.89572 +63.42365 -16.208660000000002 +63.827780000000004 -16.52808 +64.22797 -16.85393 +66.0 -18.0 +67.0 -18.0 +68.0 -18.0 +69.0 -18.0 +70.0 -18.0 +71.0 -18.0 +72.0 -18.0 +73.0 -18.0 +74.0 -18.0 +75.0 -18.0 +76.0 -18.0 +77.0 -18.0 +78.0 -18.0 +79.0 -18.0 +80.0 -18.0 +81.0 -18.0 +82.0 -18.0 +83.0 -18.0 +84.0 -18.0 +85.0 -18.0 +86.0 -18.0 +86.66667 -19.0 +87.33333 -20.0 +88.0 -21.0 +88.66667 -22.0 +89.41596 -23.1317 +89.68146 -24.3655 +89.95879000000001 -25.59111 +90.24749 -26.80814 +90.54705 -28.01619 +90.8569 -29.214879999999997 +91.17643000000001 -30.403809999999996 +91.50499 -31.582629999999998 +91.84185 -32.75095 +92.18623000000001 -33.908409999999996 +92.53729 -35.05464 +92.89409 -36.18931 +93.25565 -37.31205 +93.62088 -38.42252 +93.98862 -39.5204 +94.35759 -40.60535 +94.72643000000001 -41.677040000000005 +95.09366999999999 -42.735170000000004 +95.45770999999999 -43.77942 +95.81685 -44.809490000000004 +96.16922 -45.82508 +96.51286 -46.8259 +96.84562 -47.811679999999996 +97.16521 -48.78213 +97.46918000000001 -49.736979999999996 +97.75487 -50.67597 +98.01948 -51.59884 +98.25999 -52.505359999999996 +98.47317 -53.39526 +98.65561 -54.268319999999996 +98.80364 -55.1243 +98.91339 -55.962990000000005 +98.98075 -56.784169999999996 +99.00135999999999 -57.587619999999994 +98.97062 -58.37314 +98.88371 -59.14055 +98.73552 -59.88964 +98.52073 -60.62023000000001 +98.23379 -61.33214 +98.0 -61.5 +97.0 -61.5 +96.0 -61.5 +95.0 -61.5 +94.0 -61.5 +93.0 -61.5 +92.0 -61.5 +91.0 -61.5 +90.0 -61.5 +89.0 -61.5 +88.0 -61.5 +87.0 -61.5 +86.0 -61.5 +85.0 -61.5 +84.0 -61.5 +83.0 -62.0 +78.66667 -63.0 +74.33333 -64.0 +69.1922 -65.62708 +68.293 -65.99135 +67.35218 -66.34555 +66.36917 -66.68914000000001 +65.34355 -66.9 +64.27503 -66.9 +63.1635 -66.9 +62.00905 -66.9 +60.811969999999995 -66.9 +59.5728 -66.9 +58.29235 -66.9 +56.97169 -66.9 +55.6122 -66.9 +54.21558 -66.9 +52.783809999999995 -66.9 +51.31925 -66.9 +49.82454 -66.9 +48.30265 -66.5 +46.75683 -66.5 +45.19062 -66.5 +43.60779 -66.5 +42.0123 -66.5 +40.4083 -66.5 +23.384420000000002 -65.5 +21.9878 -65.5 +20.62831 -65.5 +19.30765 -65.5 +18.0272 -65.5 +16.78803 -65.5 +15.59095 -65.5 +14.4365 -65.5 +13.32497 -65.5 +12.25645 -65.5 +11.230830000000001 -65.5 +10.247819999999999 -65.5 +9.307 -65.2 +8.4078 -65.2 +7.54955 -65.2 +4.0 -65.0 +3.0 -65.0 +2.0 -65.0 +1.0 -65.0 +0.0 -65.0 +-1.0 -65.0 +-2.0 -65.0 +-3.0 -65.0 +-4.0 -65.0 +-5.0 -65.0 +-6.0 -65.0 +-7.0 -65.0 +-8.0 -65.0 +-9.0 -65.0 +-10.0 -65.0 +-11.0 -65.0 +-12.0 -65.0 +-13.0 -65.0 +-14.0 -65.0 +-15.0 -65.0 +-16.0 -65.0 +-17.0 -65.0 +-18.0 -65.0 +-19.0 -65.0 +-20.0 -65.0 +-21.0 -65.0 +-22.0 -65.0 +-23.0 -65.0 +-24.0 -65.0 +-25.0 -65.0 +-26.0 -65.0 +-27.0 -65.0 +-28.0 -65.0 +-29.0 -65.0 +-30.0 -65.0 +-31.0 -65.0 +-32.0 -65.0 +-33.0 -65.0 +-34.0 -65.0 +-35.0 -65.0 +-36.0 -65.0 +-37.0 -65.0 +-38.0 -65.0 +-39.0 -65.0 +-40.0 -65.0 +-41.0 -65.0 +-42.0 -65.0 +-43.0 -65.0 +-44.0 -65.0 +-45.0 -65.0 +-46.0 -65.0 +-47.0 -65.0 +-48.0 -65.0 +-49.0 -65.0 +-50.0 -65.0 +-51.0 -65.0 +-52.0 -65.0 +-53.0 -65.0 +-54.0 -65.0 +-55.0 -65.0 +-56.0 -65.0 +-57.0 -65.0 +-56.8 -64.0 +-56.6 -63.0 +-56.4 -62.0 +-56.2 -61.0 +-56.0 -60.0 +-60.0 -60.0 +-60.0 -55.2685 +-60.0 -52.4931 +-59.9266 -50.9207 +-58.355 -50.0 +-56.6089 -50.0 +-54.9615 -50.0 +-54.8 -48.0 +-54.7 -47.0 +-54.6 -46.0 +-54.5 -45.0 +-54.4 -44.0 +-54.3 -43.0 +-54.2 -42.0 +-54.1 -41.0 +-54.0 -40.0 +-53.0 -40.0 +-52.0 -40.0 +-51.0 -40.0 +-50.0 -40.0 +-49.0 -40.0 +-48.0 -40.0 +-47.0 -40.0 +-46.0 -40.0 +-45.0 -40.0 +-44.0 -40.0 +-43.0 -40.0 +-42.0 -40.0 +-41.0 -40.0 +-40.0 -40.0 +-39.0 -40.0 +-38.0 -40.0 +-37.0 -40.0 +-36.0 -40.0 +-35.0 -40.0 +-34.0 -40.0 +-33.0 -40.0 +-32.0 -40.0 +-31.0 -40.0 +-30.0 -40.0 +-29.0 -40.0 +-28.0 -40.0 +-27.0 -40.0 +-26.0 -40.0 +-25.0 -40.0 +-24.0 -40.0 +-23.0 -40.0 +-22.0 -40.0 +-21.0 -40.0 +-20.0 -40.0 +-19.0 -40.0 +-18.0 -40.0 +-17.0 -40.0 +-16.0 -40.0 +-15.0 -40.0 +-14.0 -40.0 +-13.0 -40.0 +-12.0 -40.0 +-11.0 -40.0 +-10.0 -40.0 +-9.0 -40.0 +-8.0 -40.0 +-7.0 -40.0 +-6.0 -40.0 +-5.0 -40.0 +-4.0 -40.0 +-3.0 -40.0 +-1.4721899999999999 -38.64048 +-1.27518 -38.12814 +-1.07231 -37.61674 +-0.8637600000000001 -37.1064 +-0.6497 -36.597229999999996 +-0.43028 -36.08933 +-0.20564000000000002 -35.58282 +0.024059999999999998 -35.07782 +0.25871 -34.57444 +0.49818 -34.0728 +0.74235 -33.57301 +0.99113 -33.0752 +1.24441 -32.5795 +1.50209 -32.086009999999995 +1.7641 -31.59488 +2.03036 -31.106209999999997 +2.30079 -30.62015 +2.57532 -30.136809999999997 +2.85391 -29.65632 +3.1364799999999997 -29.17881 +3.423 -28.70441 +3.7134199999999997 -28.23325 +4.0077 -27.765459999999997 +4.30581 -27.30116 +4.60772 -26.84048 +4.9134 -26.38355 +5.22284 -25.93051 +5.53601 -25.48147 +5.8529 -25.03656 +6.17351 -24.59591 +6.49782 -24.15964 +6.8258399999999995 -23.72788 +7.15756 -23.30074 +7.49299 -22.87835 +7.83212 -22.460810000000002 +8.17498 -22.04826 +8.52155 -21.6408 +8.87186 -21.23855 +9.22592 -20.8416 +9.583739999999999 -20.45008 +9.94533 -20.06407 +10.3107 -19.68369 +10.679889999999999 -19.30903 +11.05289 -18.940179999999998 +11.429730000000001 -18.57723 +11.81042 -18.220270000000003 +12.194980000000001 -17.86938 +12.58343 -17.52465 +12.975769999999999 -17.186139999999998 +13.372029999999999 -16.85393 +13.77222 -16.52808 +14.17635 -16.208660000000002 +14.58443 -15.89572 +14.99646 -15.589310000000001 +15.41247 -15.2895 +15.83245 -14.996310000000001 +16.2564 -14.70979 +16.68432 -14.42997 +17.116229999999998 -14.156889999999999 +17.5521 -13.89057 +17.99193 -13.631020000000001 +18.43571 -13.37827 +18.88343 -13.132320000000002 +19.33507 -12.893180000000001 +19.79061 -12.660860000000001 +20.250020000000003 -12.43534 +20.713279999999997 -12.21663 +21.18035 -12.004710000000001 +21.65119 -11.79957 +22.125770000000003 -11.601180000000001 +22.604039999999998 -11.40952 +23.08595 -11.22457 +23.0 -10.0 +23.0 -9.0 +23.0 -8.0 +23.0 -7.0 diff --git a/obztak/data/magic-poly.txt b/obztak/data/magic-poly.txt new file mode 100644 index 0000000..9365208 --- /dev/null +++ b/obztak/data/magic-poly.txt @@ -0,0 +1,39 @@ +# MAGIC Polygon +#RA DEC +90 -30 +80 -30 +70 -30 +60 -30 +50 -30 +40 -30 +30 -30 +20 -30 +10 -30 + 0 -30 +-10 -30 +-20 -30 +-30 -30 +-40 -30 +-50 -30 +-60 -32 +-65 -38 +-70 -45 +-80 -65 +-80 -70 +-80 -75 +-80 -80 +-70 -80 +-60 -80 +-40 -80 +-20 -80 + 0 -80 + 20 -80 + 40 -80 + 60 -80 + 80 -80 +100 -80 +120 -80 +120 -70 +110 -60 +105 -45 + 90 -30 From 6e02c7860d3048bd639cfc1a1ed2584a1a895d81 Mon Sep 17 00:00:00 2001 From: Alex Drlica-Wagner Date: Thu, 4 Jan 2024 11:17:58 -0600 Subject: [PATCH 4/6] remove config --- obztak/magic.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/obztak/magic.py b/obztak/magic.py index d7cffe3..bacf521 100644 --- a/obztak/magic.py +++ b/obztak/magic.py @@ -354,11 +354,6 @@ def query(cls, **kwargs): return query -class MagicConfig(Config): - _defaults = odict( - ) - pass - class MagicScheduler(Scheduler): _defaults = odict(list(Scheduler._defaults.items()) + [ ('tactician','coverage'), From 3dcb0a12ac50249bd944fb845aa2ace494d2a60f Mon Sep 17 00:00:00 2001 From: Alex Drlica-Wagner Date: Fri, 5 Jan 2024 00:34:55 -0600 Subject: [PATCH 5/6] fix/filter warnings --- obztak/utils/ortho.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/obztak/utils/ortho.py b/obztak/utils/ortho.py index 82150b2..98cb277 100644 --- a/obztak/utils/ortho.py +++ b/obztak/utils/ortho.py @@ -32,9 +32,6 @@ from obztak.utils.constants import COLORS, CMAPS, TCOLORS from obztak.utils.constants import FIGSIZE, SCALE, DPI -# ADW: This is bad... -#plt.ion() - ############################################################ params = { @@ -672,13 +669,15 @@ def plotField(field, target_fields=None, completed_fields=None, options_basemap= -------- basemap : The basemap object """ + warnings.filterwarnings("ignore", category=UserWarning, message="No data for colormapping provided via") + if isinstance(field,np.core.records.record): tmp = FieldArray(1) tmp[0] = field field = tmp band = field[0]['FILTER'] cmap = matplotlib.cm.get_cmap(CMAPS[band]) - defaults = dict(marker='H',s=100,edgecolor='',vmin=-1,vmax=4,cmap=cmap) + #defaults = dict(marker='H',s=100,edgecolor='',vmin=-1,vmax=4,cmap=cmap) #defaults = dict(edgecolor='none', s=50, vmin=0, vmax=4, cmap='summer_r') #defaults = dict(edgecolor='none', s=50, vmin=0, vmax=4, cmap='gray_r') defaults = dict(marker='H',s=100,edgecolor='none',vmin=-1,vmax=4,cmap=cmap) @@ -698,9 +697,9 @@ def plotField(field, target_fields=None, completed_fields=None, options_basemap= if target_fields is not None and len(target_fields): sel = target_fields['FILTER']==band x,y = basemap.proj(target_fields['RA'], target_fields['DEC']) - kw = dict(kwargs,c='w',edgecolor='0.6',s=0.8*kwargs['s']) + kw = dict(c='w',edgecolor='0.6',s=0.8*kwargs['s'],marker=kwargs['marker']) basemap.scatter(x[sel], y[sel], **kw) - kw = dict(kwargs,c='w',edgecolor='0.8',s=0.8*kwargs['s']) + kw = dict(c='w',edgecolor='0.8',s=0.8*kwargs['s'],marker=kwargs['marker']) basemap.scatter(x[~sel], y[~sel], **kw) # Plot completed fields @@ -725,7 +724,7 @@ def plotField(field, target_fields=None, completed_fields=None, options_basemap= # Show the selected field x,y = basemap.proj(field['RA'], field['DEC']) - kw = dict(kwargs,edgecolor='k') + kw = dict(marker=kwargs['marker'],s=kwargs['s'],edgecolor='k') basemap.scatter(x,y,c=COLORS[band],**kw) return basemap From 838561421b2dd37401b215b0d8424fc5f4b91231 Mon Sep 17 00:00:00 2001 From: Alex Drlica-Wagner Date: Fri, 5 Jan 2024 00:35:05 -0600 Subject: [PATCH 6/6] magic weights --- obztak/magic.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/obztak/magic.py b/obztak/magic.py index bacf521..95ac454 100644 --- a/obztak/magic.py +++ b/obztak/magic.py @@ -420,19 +420,19 @@ def weight_magic(self): weight = np.zeros(len(sel)) sel &=(self.fields['DEC'] < -40) - sel &= ((self.fields['RA'] > 180) | (self.fields['RA'] < 30)) + #sel &= ((self.fields['RA'] > 180) | (self.fields['RA'] < 30)) # Prefer DES region #sel &= ((self.fields['RA'] > 290) | (self.fields['RA'] < 90)) inDES = Survey.footprintDES(self.fields['RA'],self.fields['DEC']) weight += 1e3 * ~inDES - inReg3 = MagicSurvey.region3d(self.fields['RA'],self.fields['DEC']) - weight += 5e4 * ~inReg3 + #inReg3 = MagicSurvey.region3d(self.fields['RA'],self.fields['DEC']) + #weight += 5e4 * ~inReg3 # Airmass cut airmass_min, airmass_max = self.CONDITIONS['magic'] - if False: # Don't use seeing + if True: # Don't use seeing to set airmass limit sel &= ((airmass > airmass_min) & (airmass < airmass_max)) elif self.fwhm <= 1.4: sel &= ((airmass > airmass_min) & (airmass < airmass_max))