def generate_target_maps(nside): target_maps = {} target_maps['u'] = fs.generate_goal_map(NES_fraction=0., WFD_fraction=0.31, SCP_fraction=0.15, GP_fraction=0.15, WFD_upper_edge_fraction=0, nside=nside, generate_id_map=True) target_maps['g'] = fs.generate_goal_map(NES_fraction=0.2, WFD_fraction=0.44, SCP_fraction=0.15, WFD_upper_edge_fraction=0, GP_fraction=0.15, nside=nside, generate_id_map=True) target_maps['r'] = fs.generate_goal_map(NES_fraction=0.46, WFD_fraction=1.0, SCP_fraction=0.15, WFD_upper_edge_fraction=0, GP_fraction=0.15, nside=nside, generate_id_map=True) target_maps['i'] = fs.generate_goal_map(NES_fraction=0.46, WFD_fraction=1.0, SCP_fraction=0.15, WFD_upper_edge_fraction=0, GP_fraction=0.15, nside=nside, generate_id_map=True) target_maps['z'] = fs.generate_goal_map(NES_fraction=0.4, WFD_fraction=0.9, SCP_fraction=0.15, WFD_upper_edge_fraction=0, GP_fraction=0.15, nside=nside, generate_id_map=True) target_maps['y'] = fs.generate_goal_map(NES_fraction=0., WFD_fraction=0.9, SCP_fraction=0.15, WFD_upper_edge_fraction=0, GP_fraction=0.15, nside=nside, generate_id_map=True) just_targets = {} for key in target_maps: just_targets[key] = target_maps[key][0] norm_factor = fs.calc_norm_factor(just_targets) return target_maps, norm_factor
hp.mollview(wfd_accum) split_indx = np.max(np.where(wfd_accum < wfd_accum.max() / 2.)) indx = np.arange(even_year_target['r'].size) top_half_wfd = np.where((even_year_target['r'] == 1) & (indx <= split_indx)) bottom_half_wfd = np.where((even_year_target['r'] == 1) & (indx > split_indx)) top_half_wfd[0].size, bottom_half_wfd[0].size for filtername in even_year_target: even_year_target[filtername][top_half_wfd] *= up even_year_target[filtername][bottom_half_wfd] *= down odd_year_target[filtername][top_half_wfd] *= down odd_year_target[filtername][bottom_half_wfd] *= up even_norm = fs.calc_norm_factor(even_year_target) odd_norm = fs.calc_norm_factor(odd_year_target) surveys = [] mod_year = 2 offset = 1 # Set up observations to be taken in blocks filter1s = ['u', 'g', 'r', 'i', 'z', 'y'] filter2s = [None, 'r', 'i', 'z', None, None] 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(
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 import time import matplotlib.pylab as plt from drive_cadence import Cadence_enhance_basis_function 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) norm_factor = fs.calc_norm_factor(target_map) # 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') # Set up observations to be taken in blocks surveys = [] filter1s = ['u', 'g', 'r', 'i', 'z', 'y'] filter2s = [None, 'r', 'i', 'g', 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:
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
def generate_target_maps(nside, full_dec_min=-90., full_dec_max=+32., wfd_dec_min=-74., wfd_dec_max=12.5, galactic_avoid=15., full_val=0.2, wfd_val=1., mask_uy_north=True, wfd_weights={ 'u': 0.31, 'g': 0.44, 'r': 1., 'i': 1., 'z': 0.9, 'y': 0.9 }): """ Generate a goal map that takes out a lot of the galactic plane Parameters ---------- nside : int A valid healpix nside full_dec_min : float (-90.) How far to extend the entire survey to the south full_dec_max Useful notes: Observatory is at -30.23 degrees latitude. LMC is at dec = -69. SMC at -73. """ base_map = np.zeros(hp.nside2npix(nside), dtype=float) ra, dec = hpid2RaDec(nside, np.arange(hp.nside2npix(nside))) coord = SkyCoord(ra=ra * u.deg, dec=dec * u.deg) g_long, g_lat = coord.galactic.l.deg, coord.galactic.b.deg in_full_area = np.where((dec >= full_dec_min) & (dec <= full_dec_max)) base_map[in_full_area] = full_val in_wfd = np.where((dec >= wfd_dec_min) & (dec <= wfd_dec_max)) base_map[in_wfd] = wfd_val gp = np.where((np.abs(g_lat) < galactic_avoid) & (dec <= full_dec_max)) base_map[gp] = full_val filters = ['u', 'g', 'r', 'i', 'z', 'y'] wfd_pix = np.where(base_map == wfd_val) ratio_maps = {} for filtername in filters: ratio_maps[filtername] = base_map.copy() ratio_maps[filtername][wfd_pix] *= wfd_weights[filtername] # Let's take the north out of u and y if mask_uy_north: far_north = np.where(dec > wfd_dec_max) ratio_maps['u'][far_north] = 0 ratio_maps['y'][far_north] = 0 norm_factor = fs.calc_norm_factor(ratio_maps) return ratio_maps, norm_factor
def year_1_surveys(nside=32, mjd0=None): """ Generate a list of surveys for executing in year 1 """ nside = nside filters = ['u', 'g', 'r', 'i', 'z', 'y'] target_map = large_target_map(nside, dec_max=34.3) norm_factor = fs.calc_norm_factor({'r': target_map}) # set up a cloud map cloud_map = target_map * 0 + 0.7 # Set up map m5-depth limits: m5_limits = {} percentile_cut = 0.7 m52per = sb.M5percentiles() for filtername in filters: m5_limits[filtername] = m52per.percentile2m5map(percentile_cut, filtername=filtername, nside=nside) 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, 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=0., max_alt=76.)) bfs.append( fs.Moon_avoidance_basis_function(nside=nside, moon_distance=40.)) bfs.append( fs.Bulk_cloud_basis_function(max_cloud_map=cloud_map, nside=nside)) weights = [3.0, 0.3, 3., 3., 0, 0., 0.] # add in some constriants to make sure we only observe in good conditions and shut off after 3 good ones bfs.append( Limit_m5_map_basis_function(m5_limits[filtername], nside=nside, filtername=filtername)) bfs.append( Seeing_limit_basis_function(nside=nside, filtername=filtername)) bfs.append(Time_limit_basis_function(day_max=365.25)) # XXX--Do I need a m5-depth limit on here too? bfs.append( Nvis_limit_basis_function(nside=nside, filtername=filtername, n_limit=3, seeing_limit=1.2, time_lag=0.45, m5_limit_map=m5_limits[filtername])) weights.extend([0, 0, 0, 0]) #weights.extend([0., 0., 0.]) weights = np.array(weights) # 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', survey_name='templates')) # Do we want to cover all the potential area LSST could observe? In case a GW goes off # in the north not in the NES. return surveys