def read_field_information(self, trimester=None): """Read in all the FLD files.""" self.fldPar = queueTools.readAllFLDfiles(trimester) # Read in the colormap colormap = tableau_colormap.tableau20(raw=True) color = [tuple_to_hex(colormap[x % len(colormap)]) for x in range(len(self.fldPar))] self.fldPar['color'] = color
def schedule_to_text(trimester): """Parse the schedule.dat file to text""" print(trimester) obsPars = queueTools.readAllFLDfiles(trimester) schedule_file = "schedule.dat" f = open(schedule_file, 'r') currentNight = 0 for line in f.readlines(): startD, startT, endD, endT, afield, nvisit = line.strip().split() if startD != currentNight: print(''.join(['*']*80)) print(''.join(['*']*80)) print("Starting UT Night of %s" % startD) print(''.join(['*']*80)) print(''.join(['*']*80)) print("") currentNight = startD # Get this data par = obsPars[obsPars["objid"] == afield] print("".join(['*']*80)) print("") print("Field: %s" % afield) print("Obs Type: %s" % par['obstype'].values[0]) print("PI: %s" % par['PI'].values[0]) print("Start Time (UT): %s" % startT) print("") print("RA: %s" % par['ra'].values[0]) print("DEC: %s" % par['dec'].values[0]) print("Estimated Mag: %s" % par['mag'].values[0]) print("") print("Mask: %s" % par['mask'].values[0]) print("") exptime = [float(x)*60.0 for x in par['exptime'].values][0] print("Exposure Time: %s" % exptime) print("Number of points per dither pattern: %s" % par['nexp'].values[0]) print("Number of Dither Patterns to Run Tonight: %s" % nvisit) print("") print("Dithersize: %s" % par['dithersize'].values[0]) print("Filter: %s" % par['filter'].values[0]) print("Grism: %s" % par['grism'].values[0]) print("Gain: %s" % par['gain'].values[0]) print("ReadTab: %s" % par['readtab'].values[0]) print("") print("Requested Seeing: %s" % par['seeing'].values[0]) print("Photometric Required?: %s" % par['photometric'].values[0]) for _ in range(3): print("")
def schedule_to_text(trimester): """Parse the schedule.dat file to text""" print(trimester) obsPars = queueTools.readAllFLDfiles(trimester) schedule_file = "schedule.dat" f = open(schedule_file, 'r') currentNight = 0 for line in f.readlines(): startD, startT, endD, endT, afield, nvisit = line.strip().split() if startD != currentNight: print(''.join(['*'] * 80)) print(''.join(['*'] * 80)) print("Starting UT Night of %s" % startD) print(''.join(['*'] * 80)) print(''.join(['*'] * 80)) print("") currentNight = startD # Get this data par = obsPars[obsPars["objid"] == afield] print("".join(['*'] * 80)) print("") print("Field: %s" % afield) print("Obs Type: %s" % par['obstype'].values[0]) print("PI: %s" % par['PI'].values[0]) print("Start Time (UT): %s" % startT) print("") print("RA: %s" % par['ra'].values[0]) print("DEC: %s" % par['dec'].values[0]) print("Estimated Mag: %s" % par['mag'].values[0]) print("") print("Mask: %s" % par['mask'].values[0]) print("") exptime = [float(x) * 60.0 for x in par['exptime'].values][0] print("Exposure Time: %s" % exptime) print("Number of points per dither pattern: %s" % par['nexp'].values[0]) print("Number of Dither Patterns to Run Tonight: %s" % nvisit) print("") print("Dithersize: %s" % par['dithersize'].values[0]) print("Filter: %s" % par['filter'].values[0]) print("Grism: %s" % par['grism'].values[0]) print("Gain: %s" % par['gain'].values[0]) print("ReadTab: %s" % par['readtab'].values[0]) print("") print("Requested Seeing: %s" % par['seeing'].values[0]) print("Photometric Required?: %s" % par['photometric'].values[0]) for _ in range(3): print("")
def read_field_information(self, trimester=None): """Read in all the FLD files.""" self.fldPar = queueTools.readAllFLDfiles(trimester) # Read in the colormap colormap = tableau_colormap.tableau20(raw=True) color = [ tuple_to_hex(colormap[x % len(colormap)]) for x in range(len(self.fldPar)) ] self.fldPar['color'] = color
def main(args): """Main module where the bulk of the work is completed.""" # Get all of the observations for this dataset if len(args) > 1: trimester = args[1] else: trimester = None # The default is handled in queueTools obsPars = queueTools.readAllFLDfiles(trimester) # Create the blank done file if it doesn't exist donePar = queueTools.createBlankDoneMask(obsPars) donefile = 'donefile.dat' if os.path.isfile(donefile): # Read in the existing file f = open(donefile) for line in f.readlines(): if line[0] != "#" and line.strip() != '': split = line.strip().split() id = split[0] pi = split[1] visits = float(split[2]) donetime = float(split[3]) completed = int(split[4]) if max(donePar['objid'] == id) is "False": raise Exception("No Match found for %s" % id) if donePar.loc[donePar['objid'] == id, 'doneVisit'].max() > 0: raise Exception("Field %s is listed multiple times in donefile" % id) donePar.loc[donePar['objid'] == id, 'doneVisit'] = visits donePar.loc[donePar['PI'] == pi, 'doneTime'] += donetime donePar.loc[donePar['objid'] == id, 'complete'] = completed origDonePar = donePar.copy() # Run one call of obsUpdateRow as a test date_file = "fitdates.dat" f = open(date_file, 'r') allDates = [] for line in f.readlines(): if line[0] != '#': allDates.append(line.strip()) finishedFlag = False for iter in range(5): # Check to see if I reached a success mark if finishedFlag is True: continue print("") print("**** ITERATION # %i ********" % (iter+1)) fullSched = [] for date in allDates: sys.stdout.write("\r Working on Date %s " % date) schedule = obsOneNight(obsPars, donePar, date) for line in schedule: fullSched.append(line) # Now, fill in previous weights and zero out entries in a # new donePar newDone = donePar.copy() newDone.loc[:, 'complete'] = origDonePar['complete'] newDone.loc[:, 'doneTime'] = origDonePar['doneTime'] newDone.loc[:, 'doneVisit'] = origDonePar['doneVisit'] # Make a list of PIS and see if they got all the fields they # asked for. allDone = {} for ii in range(len(newDone)): PI = newDone["PI"].values[ii] if PI not in allDone: completed = donePar[donePar['PI'] == PI]['complete'].values if min(completed) == 1: allDone[PI] = True else: allDone[PI] = False weightMod = int(allDone[PI]) newDone.loc[ii, 'prevWeight'] = \ donePar.loc[ii, 'currentWeight']*(1-weightMod*0.9) if min(allDone.values()) == 1: # We've scheduled everything, stop iterating finishedFlag = True newDone.loc[:, 'currentWeight'] = 0.0 pprint(donePar) if iter != 5: donePar = newDone # Format the schedule for output f = open('schedule.dat', 'w') for sched in fullSched: startTime = sched[0] duration = sched[1] field = sched[2] nVisit = sched[3] FORMAT = "%Y/%m/%d %H:%M:%S" outStart = startTime.strftime(FORMAT) endTime = startTime + datetime.timedelta(seconds=duration) outEnd = endTime.strftime(FORMAT) f.write("%s %s %s %s\n" % (outStart, outEnd, field, nVisit)) f.close()
dt = datetime.datetime(y, m, d, H, M, S) return dt def string2decTime(time): """Convert a time to decimal.""" h, m, s = map(float, time.split(":")) seconds = h * 3600.0 + m * 60.0 + s return seconds / 3600.0 def tuple_to_hex(rgb): return "#%02x%02x%02x" % rgb fldPar = queueTools.readAllFLDfiles() schedfile = "schedule.dat" f = open(schedfile, "r") # We will use these colors to color each group by a different color colormap = tableau20(raw=True) startDate = [] startTime = [] startTimeOrig = [] endTime = [] field = [] repeats = [] zeroDateOrig = None zeroDate = None duration = []
def main(args): """Main module where the bulk of the work is completed.""" # Get all of the observations for this dataset if len(args) > 1: trimester = args[1] else: trimester = None # The default is handled in queueTools obsPars = queueTools.readAllFLDfiles(trimester) # Create the blank done file if it doesn't exist donePar = queueTools.createBlankDoneMask(obsPars) donefile = 'donefile.dat' if os.path.isfile(donefile): # Read in the existing file f = open(donefile) for line in f.readlines(): if line[0] != "#" and line.strip() != '': split = line.strip().split() id = split[0] pi = split[1] visits = float(split[2]) donetime = float(split[3]) completed = int(split[4]) if max(donePar['objid'] == id) is "False": raise Exception("No Match found for %s" % id) if donePar.loc[donePar['objid'] == id, 'doneVisit'].max() > 0: raise Exception( "Field %s is listed multiple times in donefile" % id) donePar.loc[donePar['objid'] == id, 'doneVisit'] = visits donePar.loc[donePar['PI'] == pi, 'doneTime'] += donetime donePar.loc[donePar['objid'] == id, 'complete'] = completed origDonePar = donePar.copy() # Run one call of obsUpdateRow as a test date_file = "fitdates.dat" f = open(date_file, 'r') allDates = [] for line in f.readlines(): if line[0] != '#': allDates.append(line.strip()) finishedFlag = False for iter in range(5): # Check to see if I reached a success mark if finishedFlag is True: continue print("") print("**** ITERATION # %i ********" % (iter + 1)) fullSched = [] for date in allDates: sys.stdout.write("\r Working on Date %s " % date) schedule = obsOneNight(obsPars, donePar, date) for line in schedule: fullSched.append(line) # Now, fill in previous weights and zero out entries in a # new donePar newDone = donePar.copy() newDone.loc[:, 'complete'] = origDonePar['complete'] newDone.loc[:, 'doneTime'] = origDonePar['doneTime'] newDone.loc[:, 'doneVisit'] = origDonePar['doneVisit'] # Make a list of PIS and see if they got all the fields they # asked for. allDone = {} for ii in range(len(newDone)): PI = newDone["PI"].values[ii] if PI not in allDone: completed = donePar[donePar['PI'] == PI]['complete'].values if min(completed) == 1: allDone[PI] = True else: allDone[PI] = False weightMod = int(allDone[PI]) newDone.loc[ii, 'prevWeight'] = \ donePar.loc[ii, 'currentWeight']*(1-weightMod*0.9) if min(allDone.values()) == 1: # We've scheduled everything, stop iterating finishedFlag = True newDone.loc[:, 'currentWeight'] = 0.0 pprint(donePar) if iter != 5: donePar = newDone # Format the schedule for output f = open('schedule.dat', 'w') for sched in fullSched: startTime = sched[0] duration = sched[1] field = sched[2] nVisit = sched[3] FORMAT = "%Y/%m/%d %H:%M:%S" outStart = startTime.strftime(FORMAT) endTime = startTime + datetime.timedelta(seconds=duration) outEnd = endTime.strftime(FORMAT) f.write("%s %s %s %s\n" % (outStart, outEnd, field, nVisit)) f.close()
dt = datetime.datetime(y, m, d, H, M, S) return dt def string2decTime(time): """Convert a time to decimal.""" h, m, s = map(float, time.split(':')) seconds = h * 3600.0 + m * 60.0 + s return seconds / 3600. def tuple_to_hex(rgb): return '#%02x%02x%02x' % rgb fldPar = queueTools.readAllFLDfiles() schedfile = 'schedule.dat' f = open(schedfile, 'r') # We will use these colors to color each group by a different color colormap = tableau20(raw=True) startDate = [] startTime = [] startTimeOrig = [] endTime = [] field = [] repeats = [] zeroDateOrig = None zeroDate = None duration = []