def _run(self, simData): # find the seasons associated with each visit. seasons = calcSeason(simData[self.raCol], simData[self.expMJDCol]) # check how many entries in the >10 season ind = np.where(seasons > 9)[0] # should be only 1 extra seasons .. if len(np.unique(seasons[ind])) > 1: raise ValueError( 'Too many seasons (more than 11). Check SeasonStacker.') if self.wrapLastSeason: print('Seasons to wrap ', np.unique(seasons[ind])) # wrap the season around: 10th == 0th seasons[ind] = seasons[ind] % 10 # Generate the spiral offset vertices. self._generateSpiralOffsets() # Add to RA and dec values. vertexID = 0 for s in np.unique(seasons): match = np.where(seasons == s)[0] vertexID = vertexID % self.numPoints simData['spiralDitherPerSeasonRa'][match] = simData[self.raCol][match] \ + self.xOff[vertexID]/np.cos(simData[self.decCol][match]) simData['spiralDitherPerSeasonDec'][match] = simData[ self.decCol][match] + self.yOff[vertexID] vertexID += 1 # Wrap into expected range. simData['spiralDitherPerSeasonRa'], simData['spiralDitherPerSeasonDec'] = \ wrapRADec(simData['spiralDitherPerSeasonRa'], simData['spiralDitherPerSeasonDec']) return simData
def _run(self, simData): # What 'year' is each visit in? year = np.floor( (simData[self.expMJDCol] - simData[self.expMJDCol][0]) / 365.25) # Define dither based on year. ditherRA = np.zeros(len(simData[self.raCol])) ditherDec = np.zeros(len(simData[self.decCol])) # In y1, y3, y5, y6, y8 & y10 ra dither = 0. # In y2 & y7, ra dither = +ditherOffset # In y4 & y9, ra dither = -ditherOffset condition = ((year == 2) | (year == 7)) ditherRA[condition] = self.ditherOffset condition = ((year == 4) | (year == 9)) ditherRA[condition] = -1. * self.ditherOffset # In y1, y2, y4, y6, y7 & y9, dec dither = 0 # In y3 & y8, dec dither = -ditherOffset # In y5 & y10, dec dither = ditherOffset condition = ((year == 3) | (year == 8)) ditherDec[condition] = -1. * self.ditherOffset condition = ((year == 5) | (year == 10)) ditherDec[condition] = self.ditherOffset # Calculate actual RA/Dec and wrap into appropriate range. simData['yearlyDitherRA'], simData['yearlyDitherDec'] = wrapRADec( simData[self.raCol] + ditherRA, simData[self.decCol] + ditherDec) return simData
def _run(self, simData): # Generate random numbers for dither, using defined seed value if desired. if self.randomSeed is not None: np.random.seed(self.randomSeed) # analysis is simplified if deal with each field separately. for fieldid in np.unique(simData[self.fieldIdCol]): # Identify observations of this field. match = np.where(simData[self.fieldIdCol] == fieldid)[0] noffsets = len(match) numTiles = np.ceil( np.sqrt(noffsets) * 1.5)**2 # number of tiles must be a perfect square. # arbitarily chosen factor of 1.5 to have more than necessary tiles inside hexagon. self._generateRepRandomOffsets(noffsets, numTiles) # Add to RA and dec values. simData['repulsiveRandomDitherFieldPerVisitRa'][match] = simData[ self.raCol][match] + self.xOff / np.cos( simData[self.decCol][match]) simData['repulsiveRandomDitherFieldPerVisitDec'][match] = simData[ self.decCol][match] + self.yOff # Wrap back into expected range. simData['repulsiveRandomDitherFieldPerVisitRa'], simData['repulsiveRandomDitherFieldPerVisitDec'] = \ wrapRADec(simData['repulsiveRandomDitherFieldPerVisitRa'], simData['repulsiveRandomDitherFieldPerVisitDec']) return simData
def _run(self, simData): # Generate random numbers for dither, using defined seed value if desired. if self.randomSeed is not None: np.random.seed(self.randomSeed) for fieldid in np.unique(simData[self.fieldIdCol]): # Identify observations of this field. match = np.where(simData[self.fieldIdCol] == fieldid)[0] noffsets = len(match) numTiles = np.ceil(np.sqrt(noffsets) * 1.5)**2 self._generateRepRandomOffsets(noffsets, numTiles) # Apply dithers, increasing each night. vertexIdxs = np.arange(0, len(match), 1) nights = simData[self.nightCol][match] vertexIdxs = np.searchsorted(np.unique(nights), nights) vertexIdxs = vertexIdxs % len(self.xOff) simData['repulsiveRandomDitherFieldPerNightRa'][match] = simData[self.raCol][match] + \ self.xOff[vertexIdxs]/np.cos(simData[self.decCol][match]) simData['repulsiveRandomDitherFieldPerNightDec'][match] = simData[ self.decCol][match] + self.yOff[vertexIdxs] # Wrap into expected range. simData['repulsiveRandomDitherFieldPerNightRa'], simData['repulsiveRandomDitherFieldPerNightDec'] = \ wrapRADec(simData['repulsiveRandomDitherFieldPerNightRa'], simData['repulsiveRandomDitherFieldPerNightDec']) return simData
def _run(self, simData): # Generate random numbers for dither, using defined seed value if desired. if self.randomSeed is not None: np.random.seed(self.randomSeed) for fieldid in np.unique(simData[self.fieldIdCol]): # Identify observations of this field. match = np.where(simData[self.fieldIdCol] == fieldid)[0] noffsets= len(match) numTiles= np.ceil(np.sqrt(noffsets)*1.5)**2 self._generateRepRandomOffsets(noffsets,numTiles) # Apply dithers, increasing each night. vertexIdxs = np.arange(0, len(match), 1) nights = simData[self.nightCol][match] vertexIdxs = np.searchsorted(np.unique(nights), nights) vertexIdxs = vertexIdxs % len(self.xOff) simData['repulsiveRandomDitherFieldPerNightRa'][match] = simData[self.raCol][match] + \ self.xOff[vertexIdxs]/np.cos(simData[self.decCol][match]) simData['repulsiveRandomDitherFieldPerNightDec'][match] = simData[self.decCol][match] + self.yOff[vertexIdxs] # Wrap into expected range. simData['repulsiveRandomDitherFieldPerNightRa'], simData['repulsiveRandomDitherFieldPerNightDec'] = \ wrapRADec(simData['repulsiveRandomDitherFieldPerNightRa'], simData['repulsiveRandomDitherFieldPerNightDec']) return simData
def run(self, simData): # Add new columns to simData. simData = self._addStackers(simData) # What 'year' is each visit in? year = np.floor((simData[self.expMJDCol] - simData[self.expMJDCol][0]) / 365.25) # Define dither based on year. ditherRA = np.zeros(len(simData[self.raCol])) ditherDec = np.zeros(len(simData[self.decCol])) # In y1, y3, y5, y6, y8 & y10 ra dither = 0. # In y2 & y7, ra dither = +ditherOffset # In y4 & y9, ra dither = -ditherOffset condition = ((year == 2) | (year == 7)) ditherRA[condition] = self.ditherOffset condition = ((year == 4) | (year == 9)) ditherRA[condition] = -1.*self.ditherOffset # In y1, y2, y4, y6, y7 & y9, dec dither = 0 # In y3 & y8, dec dither = -ditherOffset # In y5 & y10, dec dither = ditherOffset condition = ((year == 3) | (year == 8)) ditherDec[condition] = -1.*self.ditherOffset condition = ((year == 5) | (year == 10)) ditherDec[condition] = self.ditherOffset # Calculate actual RA/Dec and wrap into appropriate range. simData['yearlyDitherRA'], simData['yearlyDitherDec'] = wrapRADec(simData[self.raCol] + ditherRA, simData[self.decCol] + ditherDec) return simData
def _run(self, simData): # find the seasons associated with each visit. seasonSimData= SeasonStacker().run(simData) seasons= seasonSimData['season'] # check how many entries in the >10 season ind= np.where(seasons > 9)[0] # should be only 1 extra seasons .. if len(np.unique(seasons[ind])) > 1: raise ValueError('Too many seasons (more than 11). Check SeasonStacker.') if self.wrapLastSeason: print('Seasons to wrap ', np.unique(seasons[ind])) # wrap the season around: 10th == 0th seasons[ind]= seasons[ind]%10 # Generate the spiral offset vertices. self._generateSpiralOffsets() # Add to RA and dec values. vertexID= 0 for s in np.unique(seasons): match = np.where(seasons == s)[0] vertexID= vertexID % self.numPoints simData['spiralDitherPerSeasonRa'][match] = simData[self.raCol][match] + self.xOff[vertexID]/np.cos(simData[self.decCol][match]) simData['spiralDitherPerSeasonDec'][match] = simData[self.decCol][match] + self.yOff[vertexID] vertexID += 1 # Wrap into expected range. simData['spiralDitherPerSeasonRa'], simData['spiralDitherPerSeasonDec'] = \ wrapRADec(simData['spiralDitherPerSeasonRa'], simData['spiralDitherPerSeasonDec']) return simData
def _run(self, simData): # find the seasons associated with each visit. seasons = calcSeason(simData[self.raCol], simdata[self.expMJDCol]) # check how many entries in the >10 season ind = np.where(seasons > 9)[0] # should be only 1 extra seasons .. if len(np.unique(seasons[ind])) > 1: raise ValueError( 'Too many seasons (more than 11). Check SeasonStacker.') if self.wrapLastSeason: print('Seasons to wrap ', np.unique(seasons[ind])) # wrap the season around: 10th == 0th seasons[ind] = seasons[ind] % 10 # Generate the spiral offset vertices. self._generatePentagonOffsets() # Now apply to observations. for fieldid in np.unique(simData[self.fieldIdCol]): match = np.where(simData[self.fieldIdCol] == fieldid)[0] seasonsVisited = seasons[match] # Apply sequential dithers, increasing with each season. vertexIdxs = np.searchsorted(np.unique(seasonsVisited), seasonsVisited) vertexIdxs = vertexIdxs % len(self.xOff) simData['pentagonDitherFieldPerSeasonRa'][match] = simData[self.raCol][match] + \ self.xOff[vertexIdxs]/np.cos(simData[self.decCol][match]) simData['pentagonDitherFieldPerSeasonDec'][match] = simData[self.decCol][match] \ + self.yOff[vertexIdxs] # Wrap into expected range. simData['pentagonDitherFieldPerSeasonRa'], simData['pentagonDitherFieldPerSeasonDec'] = \ wrapRADec(simData['pentagonDitherFieldPerSeasonRa'], simData['pentagonDitherFieldPerSeasonDec']) return simData
def _run(self, simData): # find the seasons associated with each visit. seasonSimData= SeasonStacker().run(simData) seasons= seasonSimData['season'] # check how many entries in the >10 season ind= np.where(seasons > 9)[0] # should be only 1 extra seasons .. if len(np.unique(seasons[ind])) > 1: raise ValueError('Too many seasons (more than 11). Check SeasonStacker.') if self.wrapLastSeason: print('Seasons to wrap ', np.unique(seasons[ind])) # wrap the season around: 10th == 0th seasons[ind]= seasons[ind]%10 # Generate the spiral offset vertices. self._generateOffsets() # Now apply to observations. for fieldid in np.unique(simData[self.fieldIdCol]): match = np.where(simData[self.fieldIdCol] == fieldid)[0] seasonsVisited = seasons[match] # Apply sequential dithers, increasing with each season. vertexIdxs = np.searchsorted(np.unique(seasonsVisited), seasonsVisited) vertexIdxs = vertexIdxs % len(self.xOff) simData['pentagonDiamondDitherFieldPerSeasonRa'][match] = simData[self.raCol][match] + \ self.xOff[vertexIdxs]/np.cos(simData[self.decCol][match]) simData['pentagonDiamondDitherFieldPerSeasonDec'][match] = simData[self.decCol][match] + self.yOff[vertexIdxs] # Wrap into expected range. simData['pentagonDiamondDitherFieldPerSeasonRa'], simData['pentagonDiamondDitherFieldPerSeasonDec'] = \ wrapRADec(simData['pentagonDiamondDitherFieldPerSeasonRa'], simData['pentagonDiamondDitherFieldPerSeasonDec']) return simData
def _run(self, simData): # find the seasons associated with each visit. seasonSimData = SeasonStacker().run(simData) seasons = seasonSimData['season'] years = seasonSimData['year'] # check how many entries in the >10 season ind = np.where(seasons > 9)[0] # should be only 1 extra seasons .. if len(np.unique(seasons[ind])) > 1: raise ValueError( 'Too many seasons (more than 11). Check SeasonStacker.') if self.wrapLastSeason: # check how many entries in the >10 season print('Seasons to wrap ', np.unique(seasons[ind]), 'with total entries: ', len(seasons[ind])) seasons[ind] = seasons[ind] % 10 # Generate the spiral offset vertices. self._generatePentagonOffsets() # print details print('Total visits for all fields:', len(seasons)) print('') # Add to RA and dec values. vertexID = 0 for s in np.unique(seasons): match = np.where(seasons == s)[0] # print details print('season', s) print('numEntries ', len(match), '; ', float(len(match)) / len(seasons) * 100, '% of total') matchYears = np.unique(years[match]) print('Corresponding years: ', matchYears) for i in matchYears: print(' Entries in year', i, ': ', len(np.where(i == years[match])[0])) print('') vertexID = vertexID % len(self.xOff) simData['pentagonDitherPerSeasonRa'][match] = simData[ self.raCol][match] + self.xOff[vertexID] / np.cos( simData[self.decCol][match]) simData['pentagonDitherPerSeasonDec'][match] = simData[ self.decCol][match] + self.yOff[vertexID] vertexID += 1 # Wrap into expected range. simData['pentagonDitherPerSeasonRa'], simData['pentagonDitherPerSeasonDec'] = \ wrapRADec(simData['pentagonDitherPerSeasonRa'], simData['pentagonDitherPerSeasonDec']) return simData
def _run(self, simData): # Generate the spiral offset vertices. self._generateFermatSpiralOffsets() # Now apply to observations. for fieldid in np.unique(simData[self.fieldIdCol]): match = np.where(simData[self.fieldIdCol] == fieldid)[0] # Apply sequential dithers, increasing with each visit. vertexIdxs = np.arange(0, len(match), 1) vertexIdxs = vertexIdxs % self.numPoints simData['fermatSpiralDitherFieldPerVisitRa'][match] = simData[self.raCol][match] + \ self.xOff[vertexIdxs]/np.cos(simData[self.decCol][match]) simData['fermatSpiralDitherFieldPerVisitDec'][match] = simData[self.decCol][match] + self.yOff[vertexIdxs] # Wrap into expected range. simData['fermatSpiralDitherFieldPerVisitRa'], simData['fermatSpiralDitherFieldPerVisitDec'] = \ wrapRADec(simData['fermatSpiralDitherFieldPerVisitRa'], simData['fermatSpiralDitherFieldPerVisitDec']) return simData
def _run(self, simData): # Generate the spiral offset vertices. self._generateFermatSpiralOffsets() # Now apply to observations. for fieldid in np.unique(simData[self.fieldIdCol]): match = np.where(simData[self.fieldIdCol] == fieldid)[0] # Apply sequential dithers, increasing with each visit. vertexIdxs = np.arange(0, len(match), 1) vertexIdxs = vertexIdxs % self.numPoints simData['fermatSpiralDitherFieldPerVisitRa'][match] = simData[self.raCol][match] + \ self.xOff[vertexIdxs]/np.cos(simData[self.decCol][match]) simData['fermatSpiralDitherFieldPerVisitDec'][match] = simData[ self.decCol][match] + self.yOff[vertexIdxs] # Wrap into expected range. simData['fermatSpiralDitherFieldPerVisitRa'], simData['fermatSpiralDitherFieldPerVisitDec'] = \ wrapRADec(simData['fermatSpiralDitherFieldPerVisitRa'], simData['fermatSpiralDitherFieldPerVisitDec']) return simData
def _run(self, simData): # find the seasons associated with each visit. seasonSimData= SeasonStacker().run(simData) seasons= seasonSimData['season'] years= seasonSimData['year'] # check how many entries in the >10 season ind= np.where(seasons > 9)[0] # should be only 1 extra seasons .. if len(np.unique(seasons[ind])) > 1: raise ValueError('Too many seasons (more than 11). Check SeasonStacker.') if self.wrapLastSeason: # check how many entries in the >10 season print('Seasons to wrap ', np.unique(seasons[ind]), 'with total entries: ', len(seasons[ind])) seasons[ind]= seasons[ind]%10 # Generate the spiral offset vertices. self._generatePentagonOffsets() # print details print('Total visits for all fields:', len(seasons)) print('') # Add to RA and dec values. vertexID= 0 for s in np.unique(seasons): match = np.where(seasons == s)[0] # print details print('season', s) print('numEntries ', len(match), '; ', float(len(match))/len(seasons)*100, '% of total') matchYears= np.unique(years[match]) print('Corresponding years: ', matchYears) for i in matchYears: print(' Entries in year', i, ': ', len(np.where(i == years[match])[0])) print('') vertexID= vertexID % len(self.xOff) simData['pentagonDitherPerSeasonRa'][match] = simData[self.raCol][match] + self.xOff[vertexID]/np.cos(simData[self.decCol][match]) simData['pentagonDitherPerSeasonDec'][match] = simData[self.decCol][match] + self.yOff[vertexID] vertexID += 1 # Wrap into expected range. simData['pentagonDitherPerSeasonRa'], simData['pentagonDitherPerSeasonDec'] = \ wrapRADec(simData['pentagonDitherPerSeasonRa'], simData['pentagonDitherPerSeasonDec']) return simData
def _run(self, simData): # Generate the spiral offset vertices. self._generateFermatSpiralOffsets() vertexID= 0 nights = np.unique(simData[self.nightCol]) for n in nights: match = np.where(simData[self.nightCol] == n)[0] vertexID= vertexID % self.numPoints simData['fermatSpiralDitherPerNightRa'][match] = simData[self.raCol][match] + \ self.xOff[vertexID]/np.cos(simData[self.decCol][match]) simData['fermatSpiralDitherPerNightDec'][match] = simData[self.decCol][match] + self.yOff[vertexID] vertexID += 1 # Wrap into expected range. simData['fermatSpiralDitherPerNightRa'], simData['fermatSpiralDitherPerNightDec'] = \ wrapRADec(simData['fermatSpiralDitherPerNightRa'], simData['fermatSpiralDitherPerNightDec']) return simData
def _run(self, simData): # Generate the spiral offset vertices. self._generateFermatSpiralOffsets() vertexID = 0 nights = np.unique(simData[self.nightCol]) for n in nights: match = np.where(simData[self.nightCol] == n)[0] vertexID = vertexID % self.numPoints simData['fermatSpiralDitherPerNightRa'][match] = simData[self.raCol][match] + \ self.xOff[vertexID]/np.cos(simData[self.decCol][match]) simData['fermatSpiralDitherPerNightDec'][match] = simData[ self.decCol][match] + self.yOff[vertexID] vertexID += 1 # Wrap into expected range. simData['fermatSpiralDitherPerNightRa'], simData['fermatSpiralDitherPerNightDec'] = \ wrapRADec(simData['fermatSpiralDitherPerNightRa'], simData['fermatSpiralDitherPerNightDec']) return simData
def _run(self, simData): # Generate random numbers for dither, using defined seed value if desired. if self.randomSeed is not None: np.random.seed(self.randomSeed) # Generate the random dither values, one per night. nights = np.unique(simData[self.nightCol]) numNights= len(nights) numTiles= np.ceil(np.sqrt(numNights)*1.5)**2 self._generateRepRandomOffsets(numNights, numTiles) # Add to RA and dec values. for n, x, y in zip(nights, self.xOff, self.yOff): match = np.where(simData[self.nightCol] == n)[0] simData['repulsiveRandomDitherPerNightRa'][match] = simData[self.raCol][match] + x/np.cos(simData[self.decCol][match]) simData['repulsiveRandomDitherPerNightDec'][match] = simData[self.decCol][match] + y # Wrap RA/Dec into expected range. simData['repulsiveRandomDitherPerNightRa'], simData['repulsiveRandomDitherPerNightDec'] = \ wrapRADec(simData['repulsiveRandomDitherPerNightRa'], simData['repulsiveRandomDitherPerNightDec']) return simData
def _run(self, simData): # Generate random numbers for dither, using defined seed value if desired. if self.randomSeed is not None: np.random.seed(self.randomSeed) # analysis is simplified if deal with each field separately. for fieldid in np.unique(simData[self.fieldIdCol]): # Identify observations of this field. match = np.where(simData[self.fieldIdCol] == fieldid)[0] noffsets= len(match) numTiles= np.ceil(np.sqrt(noffsets)*1.5)**2 # number of tiles must be a perfect square. # arbitarily chosen factor of 1.5 to have more than necessary tiles inside hexagon. self._generateRepRandomOffsets(noffsets, numTiles) # Add to RA and dec values. simData['repulsiveRandomDitherFieldPerVisitRa'][match] = simData[self.raCol][match] + self.xOff/np.cos(simData[self.decCol][match]) simData['repulsiveRandomDitherFieldPerVisitDec'][match] = simData[self.decCol][match] + self.yOff # Wrap back into expected range. simData['repulsiveRandomDitherFieldPerVisitRa'], simData['repulsiveRandomDitherFieldPerVisitDec'] = \ wrapRADec(simData['repulsiveRandomDitherFieldPerVisitRa'], simData['repulsiveRandomDitherFieldPerVisitDec']) return simData
def _run(self, simData): # Generate random numbers for dither, using defined seed value if desired. if self.randomSeed is not None: np.random.seed(self.randomSeed) # Generate the random dither values, one per night. nights = np.unique(simData[self.nightCol]) numNights = len(nights) numTiles = np.ceil(np.sqrt(numNights) * 1.5)**2 self._generateRepRandomOffsets(numNights, numTiles) # Add to RA and dec values. for n, x, y in zip(nights, self.xOff, self.yOff): match = np.where(simData[self.nightCol] == n)[0] simData['repulsiveRandomDitherPerNightRa'][match] = simData[ self.raCol][match] + x / np.cos(simData[self.decCol][match]) simData['repulsiveRandomDitherPerNightDec'][match] = simData[ self.decCol][match] + y # Wrap RA/Dec into expected range. simData['repulsiveRandomDitherPerNightRa'], simData['repulsiveRandomDitherPerNightDec'] = \ wrapRADec(simData['repulsiveRandomDitherPerNightRa'], simData['repulsiveRandomDitherPerNightDec']) return simData