def testBaseline(self): """ Set up a baseline survey and run for a few days. A crude way to touch lots of code. """ nside = fs.set_default_nside(nside=32) survey_length = 2.1 # days # Define what we want the final visit ratio map to look like target_map = fs.standard_goals(nside=nside) filters = ['u', 'g', 'r', 'i', 'z', 'y'] surveys = [] for filtername in filters: bfs = [] bfs.append(fs.M5_diff_basis_function(filtername=filtername, nside=nside)) bfs.append(fs.Target_map_basis_function(filtername=filtername, target_map=target_map[filtername], out_of_bounds_val=hp.UNSEEN, nside=nside)) bfs.append(fs.North_south_patch_basis_function(zenith_min_alt=50., nside=nside)) bfs.append(fs.Slewtime_basis_function(filtername=filtername, nside=nside)) bfs.append(fs.Strict_filter_basis_function(filtername=filtername)) weights = np.array([3.0, 0.3, 1., 3., 3.]) surveys.append(fs.Greedy_survey_fields(bfs, weights, block_size=1, filtername=filtername, dither=True, nside=nside)) surveys.append(fs.Pairs_survey_scripted([], [], ignore_obs='DD')) # Set up the DD dd_surveys = fs.generate_dd_surveys() surveys.extend(dd_surveys) scheduler = fs.Core_scheduler(surveys, nside=nside) observatory = Speed_observatory(nside=nside) observatory, scheduler, observations = fs.sim_runner(observatory, scheduler, survey_length=survey_length, filename=None) # Check that a second part of a pair was taken assert('scripted' in observations['note']) # Check that the COSMOS DD was observed assert('DD:COSMOS' in observations['note']) # And the u-band assert('DD:u,COSMOS' in observations['note']) # Make sure a few different filters were observed assert(len(np.unique(observations['filter'])) > 3) # Make sure lots of observations executed assert(observations.size > 1000)
def testsched(self): target_map = fs.standard_goals()['r'] bfs = [] bfs.append(fs.M5_diff_basis_function()) bfs.append(fs.Target_map_basis_function(target_map=target_map)) weights = np.array([1., 1]) survey = fs.Simple_greedy_survey_fields(bfs, weights) scheduler = fs.Core_scheduler([survey]) observatory = Speed_observatory() # Check that we can update conditions scheduler.update_conditions(observatory.return_status()) # Check that we can get an observation out obs = scheduler.request_observation() assert (obs is not None) # Check that we can flush the Queue scheduler.flush_queue() assert (len(scheduler.queue) == 0) # Check that we can add an observation scheduler.add_observation(obs)
from lsst.sims.speedObservatory import Speed_observatory import healpy as hp # Run a single-filter r-band survey. # 5-sigma depth percentile # standard target map (WFD, NES, SCP, GP) # Slewtime # mask lots of off-meridian space # No pairs # Greedy selection of opsim fields if __name__ == "__main__": survey_length = 365.25 * 10. # days # Define what we want the final visit ratio map to look like target_map = fs.standard_goals()['r'] filtername = 'r' bfs = [] bfs.append(fs.Depth_percentile_basis_function(filtername=filtername)) bfs.append( fs.Target_map_basis_function(target_map=target_map, filtername=filtername, out_of_bounds_val=hp.UNSEEN)) bfs.append(fs.North_south_patch_basis_function(zenith_min_alt=50.)) bfs.append(fs.Slewtime_basis_function(filtername=filtername)) weights = np.array([1., 0.2, 1., 2.]) survey = fs.Greedy_survey_fields(bfs, weights, block_size=1,
wfd = fs.WFD_healpixels(nside=nside) ra, dec = fs.ra_dec_hp_map(nside=nside) rolling_mask1 = np.zeros(ra.size, dtype=bool) rolling_mask1[np.where((wfd == 1) & (dec > dec_limits[0]))] = True rolling_mask2 = np.zeros(ra.size, dtype=bool) rolling_mask2[np.where((dec < dec_limits[0]) & (dec > dec_limits[1]))] = True rolling_mask3 = np.zeros(ra.size, dtype=bool) rolling_mask3[np.where((dec < dec_limits[1]) & (wfd == 1))] = True observatory = Speed_observatory(nside=nside) # Define what we want the final visit ratio map to look like years = np.round(survey_length/365.25) target_map = fs.standard_goals(nside=nside) filters = ['u', 'g', 'r', 'i', 'z', 'y'] surveys = [] for filtername in filters: bfs = [] bfs.append(fs.M5_diff_basis_function(filtername=filtername, nside=nside)) bfs.append(fs.Target_map_basis_function(filtername=filtername, target_map=target_map[filtername], out_of_bounds_val=hp.UNSEEN, nside=nside)) bfs.append(fs.North_south_patch_basis_function(zenith_min_alt=50., nside=nside)) bfs.append(fs.Rolling_mask_basis_function(rolling_mask1, year_mod=3, year_offset=0, mjd_start=observatory.mjd, nside=nside)) bfs.append(fs.Rolling_mask_basis_function(rolling_mask1, year_mod=3, year_offset=1, mjd_start=observatory.mjd, nside=nside))
import lsst.sims.featureScheduler as fs from lsst.sims.speedObservatory import Speed_observatory import matplotlib.pylab as plt import healpy as hp import time from rolling_slair import Target_map_modulo_basis_function from drive_cadence import Cadence_enhance_basis_function # Try out the rolling cadence survey_length = 365.25 * 10 # days nside = fs.set_default_nside(nside=32) years = np.round(survey_length / 365.25) t0 = time.time() target_map = fs.standard_goals(nside=nside) # Set up a map of where to drive the cadence cadence_area = target_map['r'] * 0 cadence_area[np.where(target_map['r'] == 1)] = 1. hp.mollview(cadence_area, title='Where to drive cadence') even_year_target = fs.standard_goals(nside=nside) odd_year_target = fs.standard_goals(nside=nside) up = 2.0 down = 0. # Let's find the healpix that divides the WFD area in half wfd = even_year_target['r'] * 0 wfd[np.where(even_year_target['r'] == 1)] = 1 wfd_accum = np.cumsum(wfd)
import numpy as np import lsst.sims.featureScheduler as fs from lsst.sims.speedObservatory import Speed_observatory import matplotlib.pylab as plt import healpy as hp from numpy.lib.recfunctions import append_fields if __name__ == '__main__': nside = fs.set_default_nside(nside=32) survey_length = 365.25*10 # days # Define what we want the final visit ratio map to look like years = np.round(survey_length/365.25) target_map = fs.standard_goals(nside=nside) filters = ['u', 'g', 'r', 'i', 'z', 'y'] surveys = [] for filtername in filters: bfs = [] bfs.append(fs.M5_diff_basis_function(filtername=filtername, nside=nside)) bfs.append(fs.Target_map_basis_function(filtername=filtername, target_map=target_map[filtername], out_of_bounds_val=hp.UNSEEN, nside=nside)) bfs.append(fs.North_south_patch_basis_function(zenith_min_alt=50., nside=nside)) #bfs.append(fs.Zenith_mask_basis_function(maxAlt=78., penalty=-100, nside=nside)) bfs.append(fs.Slewtime_basis_function(filtername=filtername, nside=nside)) bfs.append(fs.Strict_filter_basis_function(filtername=filtername)) weights = np.array([3.0, 0.4, 1., 2., 3.]) surveys.append(fs.Greedy_survey_fields(bfs, weights, block_size=1, filtername=filtername,
def generate_slair_scheduler(): nside = fs.set_default_nside(nside=32) # get rid of silly northern strip. target_map = fs.standard_goals(nside=nside) norm_factor = fs.calc_norm_factor(target_map) # List to hold all the surveys (for easy plotting later) surveys = [] # Set up observations to be taken in blocks filter1s = ['u', 'g', 'r', 'i', 'z', 'y'] filter2s = [None, 'g', 'r', 'i', None, None] pair_surveys = [] for filtername, filtername2 in zip(filter1s, filter2s): bfs = [] bfs.append( fs.M5_diff_basis_function(filtername=filtername, nside=nside)) if filtername2 is not None: bfs.append( fs.M5_diff_basis_function(filtername=filtername2, nside=nside)) bfs.append( fs.Target_map_basis_function(filtername=filtername, target_map=target_map[filtername], out_of_bounds_val=hp.UNSEEN, nside=nside, norm_factor=norm_factor)) if filtername2 is not None: bfs.append( fs.Target_map_basis_function( filtername=filtername2, target_map=target_map[filtername2], out_of_bounds_val=hp.UNSEEN, nside=nside, norm_factor=norm_factor)) bfs.append( fs.Slewtime_basis_function(filtername=filtername, nside=nside)) bfs.append(fs.Strict_filter_basis_function(filtername=filtername)) bfs.append( fs.Zenith_shadow_mask_basis_function(nside=nside, shadow_minutes=60., max_alt=76.)) weights = np.array([3.0, 3.0, .3, .3, 3., 3., 0.]) if filtername2 is None: # Need to scale weights up so filter balancing still works properly. weights = np.array([6.0, 0.6, 3., 3., 0.]) # XXX- # This is where we could add a look-ahead basis function to include m5_diff in the future. # Actually, having a near-future m5 would also help prevent switching to u or g right at twilight? # Maybe just need a "filter future" basis function? if filtername2 is None: survey_name = 'blob, %s' % filtername else: survey_name = 'blob, %s%s' % (filtername, filtername2) surveys.append( fs.Blob_survey(bfs, weights, filtername=filtername, filter2=filtername2, survey_note=survey_name)) pair_surveys.append(surveys[-1]) # Let's set up some standard surveys as well to fill in the gaps. This is my old silly masked version. # It would be good to put in Tiago's verion and lift nearly all the masking. That way this can also # chase sucker holes. filters = ['u', 'g', 'r', 'i', 'z', 'y'] #filters = ['i', 'z', 'y'] greedy_surveys = [] for filtername in filters: bfs = [] bfs.append( fs.M5_diff_basis_function(filtername=filtername, nside=nside)) bfs.append( fs.Target_map_basis_function(filtername=filtername, target_map=target_map[filtername], out_of_bounds_val=hp.UNSEEN, nside=nside, norm_factor=norm_factor)) bfs.append( fs.North_south_patch_basis_function(zenith_min_alt=50., nside=nside)) bfs.append( fs.Slewtime_basis_function(filtername=filtername, nside=nside)) bfs.append(fs.Strict_filter_basis_function(filtername=filtername)) bfs.append( fs.Zenith_shadow_mask_basis_function(nside=nside, shadow_minutes=60., max_alt=76.)) weights = np.array([3.0, 0.3, 1., 3., 3., 0.]) # Might want to try ignoring DD observations here, so the DD area gets covered normally--DONE surveys.append( fs.Greedy_survey_fields(bfs, weights, block_size=1, filtername=filtername, dither=True, nside=nside, ignore_obs='DD')) greedy_surveys.append(surveys[-1]) # Set up the DD surveys dd_surveys = fs.generate_dd_surveys() surveys.extend(dd_surveys) survey_list_o_lists = [dd_surveys, pair_surveys, greedy_surveys] # put in as list-of-lists so pairs get evaluated first. scheduler = fs.Core_scheduler(survey_list_o_lists, nside=nside) return scheduler
import numpy as np import healpy as hp import matplotlib.pylab as plt import lsst.sims.featureScheduler as fs from lsst.sims.featureScheduler.observatory import Speed_observatory if __name__ == "__main__": survey_length = 5.2 # days # Define what we want the final visit ratio map to look like target_maps = fs.standard_goals() filters = ['r', 'i'] weights = {} weights['r'] = [1., 1., 1.] weights['i'] = [1.5, 1., 0.] surveys = [] for filtername in filters: bfs = [] bfs.append(fs.Depth_percentile_basis_function(filtername=filtername)) bfs.append(fs.Target_map_basis_function(target_map=target_maps[filtername], filtername=filtername)) bfs.append(fs.Filter_change_basis_function(filtername=filtername)) weight = weights[filtername] surveys.append(fs.Simple_greedy_survey_fields(bfs, weight, filtername=filtername)) scheduler = fs.Core_scheduler(surveys) observatory = Speed_observatory() observatory, scheduler, observations = fs.sim_runner(observatory, scheduler, survey_length=survey_length, filename='two_filt.db')