def gen_greedy_surveys(nside): """ Make a quick set of greedy surveys """ target_map = standard_goals(nside=nside) norm_factor = calc_norm_factor(target_map) # Let's remove the bluer filters since this should only be near twilight filters = ['r', 'i', 'z', 'y'] surveys = [] for filtername in filters: bfs = [] bfs.append(bf.M5_diff_basis_function(filtername=filtername, nside=nside)) bfs.append(bf.Target_map_basis_function(filtername=filtername, target_map=target_map[filtername], out_of_bounds_val=np.nan, nside=nside, norm_factor=norm_factor)) bfs.append(bf.Slewtime_basis_function(filtername=filtername, nside=nside)) bfs.append(bf.Strict_filter_basis_function(filtername=filtername)) # Masks, give these 0 weight bfs.append(bf.Zenith_shadow_mask_basis_function(nside=nside, shadow_minutes=60., max_alt=76.)) bfs.append(bf.Moon_avoidance_basis_function(nside=nside, moon_distance=40.)) bfs.append(bf.Clouded_out_basis_function()) bfs.append(bf.Filter_loaded_basis_function(filternames=filtername)) weights = np.array([3.0, 0.3, 3., 3., 0., 0., 0., 0.]) surveys.append(Greedy_survey(bfs, weights, block_size=1, filtername=filtername, dither=True, nside=nside, ignore_obs='DD')) return surveys
def generate_third(nside, nexp=1, min_area=100.): """A survey to take a third observation in a night """ # OK, I want to see if there have been a successful pair taken in the night target_map = standard_goals(nside=nside) norm_factor = calc_norm_factor(target_map) surveys = [] to_pair = ['gi', 'rz'] for pairs in to_pair: for filtername in pairs: bfs = [] bfs.append( bf.M5_diff_basis_function(filtername=filtername, nside=nside)) bfs.append( bf.Target_map_basis_function(filtername=filtername, target_map=target_map[pairs[0]], out_of_bounds_val=np.nan, nside=nside, norm_factor=norm_factor)) bfs.append( bf.Third_observation_basis_function(filtername1=pairs[0], filtername2=pairs[1], gap_min=40., gap_max=120.)) # Masks, give these 0 weight bfs.append( bf.Zenith_shadow_mask_basis_function(nside=nside, shadow_minutes=60., max_alt=76.)) bfs.append( bf.Moon_avoidance_basis_function(nside=nside, moon_distance=30.)) bfs.append(bf.Clouded_out_basis_function()) filternames = [fn for fn in pairs] bfs.append( bf.Filter_loaded_basis_function(filternames=filternames)) bfs.append(bf.Not_twilight_basis_function()) weights = [1., 1., 1., 0, 0, 0, 0, 0] survey = Blob_survey(bfs, weights, filtername1=pairs[0], filtername2=None, ignore_obs='DD', nexp=nexp, nside=nside, min_area=min_area, survey_note='third, %s' % pairs[0]) surveys.append(survey) return surveys
def gen_too_surveys(nside, nvis=3, nexp=1): filters = ['g', 'r', 'i'] surveys = [] for filtername in filters: bfs = [] bfs.append( bf.M5_diff_basis_function(filtername=filtername, nside=nside)) bfs.append( bf.Footprint_nvis_basis_function(filtername=filtername, nside=nside, nvis=nvis)) bfs.append( bf.Slewtime_basis_function(filtername=filtername, nside=nside)) bfs.append(bf.Strict_filter_basis_function(filtername=filtername)) # Masks, give these 0 weight bfs.append( bf.Zenith_shadow_mask_basis_function(nside=nside, shadow_minutes=60., max_alt=76.)) bfs.append( bf.Moon_avoidance_basis_function(nside=nside, moon_distance=40.)) bfs.append(bf.Clouded_out_basis_function()) bfs.append(bf.Filter_loaded_basis_function(filternames=filtername)) weights = np.array([.1, 1., 0.1, 1., 0., 0., 0., 0.]) example_survey = ToO_survey(bfs, weights, filtername1=filtername, dither=True, nside=nside, nexp=nexp) surveys.append(ToO_master(example_survey)) return surveys
def blob_comcam(nexp=1, nside=256, filters=['g', 'r', 'i']): target_map = standard_goals(nside=nside) ra, dec = ra_dec_hp_map(nside=nside) # out_region = np.where((dec > np.radians(-40)) | (dec < np.radians(-50.))) in_region = np.where((dec <= np.radians(-40.)) & (dec >= np.radians(-50.))) for key in target_map: target_map[key] *= 0. target_map[key][in_region] = 1. final_tm = {} for key in filters: final_tm[key] = target_map[key] target_map = final_tm norm_factor = calc_norm_factor(target_map) survey_list = [] time_needed = 23. for filtername in filters: bfs = [] bfs.append( bf.M5_diff_basis_function(filtername=filtername, nside=nside)) bfs.append( bf.Target_map_basis_function(filtername=filtername, target_map=target_map[filtername], out_of_bounds_val=np.nan, nside=nside, norm_factor=norm_factor)) bfs.append( bf.Slewtime_basis_function(filtername=filtername, nside=nside)) bfs.append(bf.Strict_filter_basis_function(filtername=filtername)) bfs.append( bf.Zenith_shadow_mask_basis_function(nside=nside, shadow_minutes=60., max_alt=76.)) bfs.append( bf.Moon_avoidance_basis_function(nside=nside, moon_distance=40.)) bfs.append(bf.Clouded_out_basis_function()) bfs.append(bf.Filter_loaded_basis_function(filternames=filtername)) bfs.append(bf.Time_to_twilight_basis_function(time_needed=time_needed)) bfs.append(bf.Not_twilight_basis_function()) weights = np.array([3.0, 0.3, 6., 3., 0., 0., 0., 0, 0, 0]) # XXX-Note, need a new detailer here!, have to have dither=False until that can get passed through sv = surveys.Blob_survey( bfs, weights, filtername1=filtername, filtername2=None, dither=False, nside=nside, ignore_obs='DD', nexp=nexp, camera='comcam', detailers=[fs.detailers.Comcam_90rot_detailer()]) survey_list.append(sv) return survey_list
def generate_blobs(nside): target_map = standard_goals(nside=nside) norm_factor = 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] # Ideal time between taking pairs pair_time = 22. times_needed = [pair_time, pair_time*2] for filtername, filtername2 in zip(filter1s, filter2s): bfs = [] bfs.append(bf.M5_diff_basis_function(filtername=filtername, nside=nside)) if filtername2 is not None: bfs.append(bf.M5_diff_basis_function(filtername=filtername2, nside=nside)) bfs.append(bf.Target_map_basis_function(filtername=filtername, target_map=target_map[filtername], out_of_bounds_val=np.nan, nside=nside, norm_factor=norm_factor)) if filtername2 is not None: bfs.append(bf.Target_map_basis_function(filtername=filtername2, target_map=target_map[filtername2], out_of_bounds_val=np.nan, nside=nside, norm_factor=norm_factor)) bfs.append(bf.Slewtime_basis_function(filtername=filtername, nside=nside)) bfs.append(bf.Strict_filter_basis_function(filtername=filtername)) # Masks, give these 0 weight bfs.append(bf.Zenith_shadow_mask_basis_function(nside=nside, shadow_minutes=60., max_alt=76.)) bfs.append(bf.Moon_avoidance_basis_function(nside=nside, moon_distance=30.)) bfs.append(bf.Clouded_out_basis_function()) filternames = [fn for fn in [filtername, filtername2] if fn is not None] bfs.append(bf.Filter_loaded_basis_function(filternames=filternames)) if filtername2 is None: time_needed = times_needed[0] else: time_needed = times_needed[1] bfs.append(bf.Time_to_twilight_basis_function(time_needed=time_needed)) bfs.append(bf.Not_twilight_basis_function()) weights = np.array([3.0, 3.0, .3, .3, 3., 3., 0., 0., 0., 0., 0., 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., 0., 0., 0., 0., 0.]) if filtername2 is None: survey_name = 'blob, %s' % filtername else: survey_name = 'blob, %s%s' % (filtername, filtername2) surveys.append(Blob_survey(bfs, weights, filtername1=filtername, filtername2=filtername2, ideal_pair_time=pair_time, nside=nside, survey_note=survey_name, ignore_obs='DD', dither=True)) return surveys
def gen_greedy_surveys(nside, nexp=1, target_maps=None, mod_year=None, day_offset=None, norm_factor=None, max_season=10): """ Make a quick set of greedy surveys """ # Let's remove the bluer filters since this should only be near twilight filters = ['r', 'i', 'z', 'y'] surveys = [] for filtername in filters: bfs = [] bfs.append( bf.M5_diff_basis_function(filtername=filtername, nside=nside)) target_list = [tm[filtername] for tm in target_maps] bfs.append( bf.Target_map_modulo_basis_function(filtername=filtername, target_maps=target_list, season_modulo=mod_year, day_offset=day_offset, out_of_bounds_val=np.nan, nside=nside, norm_factor=norm_factor, max_season=max_season)) bfs.append( bf.Slewtime_basis_function(filtername=filtername, nside=nside)) bfs.append(bf.Strict_filter_basis_function(filtername=filtername)) # Masks, give these 0 weight bfs.append( bf.Zenith_shadow_mask_basis_function(nside=nside, shadow_minutes=60., max_alt=76.)) bfs.append( bf.Moon_avoidance_basis_function(nside=nside, moon_distance=40.)) bfs.append(bf.Clouded_out_basis_function()) bfs.append(bf.Filter_loaded_basis_function(filternames=filtername)) weights = np.array([3.0, 0.3, 3., 3., 0., 0., 0., 0.]) surveys.append( Greedy_survey(bfs, weights, block_size=1, filtername=filtername, dither=True, nside=nside, ignore_obs='DD', nexp=nexp)) return surveys
def gen_greedy_surveys(nside, nexp=1): """ Make a quick set of greedy surveys """ target_map = standard_goals(nside=nside) # Let's just set it to 1 in all filters for key in target_map: target_map[key][np.where(target_map[key] > 0)] = 1 norm_factor = calc_norm_factor(target_map) filters = ['u', 'g', 'r', 'i', 'z', 'y'] surveys = [] for filtername in filters: bfs = [] bfs.append( bf.M5_diff_basis_function(filtername=filtername, nside=nside)) bfs.append( bf.Target_map_basis_function(filtername=filtername, target_map=target_map[filtername], out_of_bounds_val=np.nan, nside=nside, norm_factor=norm_factor)) bfs.append( bf.Slewtime_basis_function(filtername=filtername, nside=nside)) bfs.append(bf.Strict_filter_basis_function(filtername=filtername)) # Masks, give these 0 weight bfs.append( bf.Zenith_shadow_mask_basis_function(nside=nside, shadow_minutes=60., max_alt=76.)) bfs.append( bf.Moon_avoidance_basis_function(nside=nside, moon_distance=40.)) bfs.append(bf.Clouded_out_basis_function()) bfs.append(bf.Filter_loaded_basis_function(filternames=filtername)) weights = np.array([3.0, 0.3, 3., 3., 0., 0., 0., 0.]) surveys.append( Greedy_survey(bfs, weights, block_size=1, filtername=filtername, dither=True, nside=nside, ignore_obs=['DD', 'blob'], nexp=nexp, exptime=1., survey_name='twilight')) return surveys
def dd_bfs(RA, dec, survey_name, ha_limits, frac_total=0.0185): """ Convienence function to generate all the feasibility basis functions """ bfs = [] bfs.append(basis_functions.Filter_loaded_basis_function(filternames=['r', 'g', 'i', 'z', 'y'])) bfs.append(basis_functions.Not_twilight_basis_function(sun_alt_limit=-18)) bfs.append(basis_functions.Time_to_twilight_basis_function(time_needed=62.)) bfs.append(basis_functions.Force_delay_basis_function(days_delay=2., survey_name=survey_name)) bfs.append(basis_functions.Hour_Angle_limit_basis_function(RA=RA, ha_limits=ha_limits)) bfs.append(basis_functions.Fraction_of_obs_basis_function(frac_total=frac_total, survey_name=survey_name)) bfs.append(basis_functions.Clouded_out_basis_function()) return bfs
def gen_greedy_surveys(nside, add_DD=True): """ Make a quick set of greedy surveys """ target_map = standard_goals(nside=nside) norm_factor = calc_norm_factor(target_map) filters = ['u', 'g', 'r', 'i', 'z', 'y'] surveys = [] for filtername in filters: bfs = [] bfs.append( bf.M5_diff_basis_function(filtername=filtername, nside=nside)) bfs.append( bf.Target_map_basis_function(filtername=filtername, target_map=target_map[filtername], out_of_bounds_val=np.nan, nside=nside, norm_factor=norm_factor)) bfs.append( bf.Slewtime_basis_function(filtername=filtername, nside=nside)) bfs.append(bf.Strict_filter_basis_function(filtername=filtername)) # Masks, give these 0 weight bfs.append( bf.Zenith_shadow_mask_basis_function(nside=nside, shadow_minutes=60., max_alt=76.)) bfs.append( bf.Moon_avoidance_basis_function(nside=nside, moon_distance=40.)) bfs.append(bf.Clouded_out_basis_function()) bfs.append(bf.Filter_loaded_basis_function(filternames=filtername)) weights = np.array([3.0, 0.3, 3., 3., 0., 0., 0., 0.]) surveys.append( Greedy_survey(bfs, weights, block_size=1, filtername=filtername, dither=True, nside=nside, ignore_obs='DD')) surveys.append(Pairs_survey_scripted(None, ignore_obs='DD')) if add_DD: dd_surveys = generate_dd_surveys(nside=nside) surveys.extend(dd_surveys) return surveys
def desc_dd_bfs(RA, dec, survey_name, ha_limits, frac_total=0.0185): """ Convienence function to generate all the feasibility basis functions """ bfs = [] bfs.append(basis_functions.Not_twilight_basis_function(sun_alt_limit=-18)) bfs.append( basis_functions.Time_to_twilight_basis_function(time_needed=30.)) bfs.append( basis_functions.Hour_Angle_limit_basis_function(RA=RA, ha_limits=ha_limits)) bfs.append(basis_functions.Rising_more_basis_function(RA=RA)) bfs.append(basis_functions.Clouded_out_basis_function()) return bfs
def dd_u_bfs(RA, dec, survey_name, ha_limits, frac_total=0.0015): """Convienence function to generate all the feasibility basis functions for u-band DDFs """ bfs = [] bfs.append(basis_functions.Filter_loaded_basis_function(filternames='u')) bfs.append(basis_functions.Not_twilight_basis_function(sun_alt_limit=-18)) bfs.append(basis_functions.Time_to_twilight_basis_function(time_needed=6.)) bfs.append(basis_functions.Hour_Angle_limit_basis_function(RA=RA, ha_limits=ha_limits)) # Modifying so that only 1-day lag in the u-band bfs.append(basis_functions.Force_delay_basis_function(days_delay=1., survey_name=survey_name)) bfs.append(basis_functions.Moon_down_basis_function()) bfs.append(basis_functions.Fraction_of_obs_basis_function(frac_total=frac_total, survey_name=survey_name)) bfs.append(basis_functions.Clouded_out_basis_function()) return bfs
def generate_greedy_sched(nexp=1, nside=32, filters=['r']): # Generate a target map target_map = standard_goals(nside=nside) norm_factor = calc_norm_factor(target_map) greedy_surveys = [] for filtername in filters: bfs = [] bfs.append( bf.M5_diff_basis_function(filtername=filtername, nside=nside)) bfs.append( bf.Target_map_basis_function(filtername=filtername, target_map=target_map[filtername], out_of_bounds_val=np.nan, nside=nside, norm_factor=norm_factor)) bfs.append( bf.Slewtime_basis_function(filtername=filtername, nside=nside)) bfs.append(bf.Strict_filter_basis_function(filtername=filtername)) bfs.append( bf.Zenith_shadow_mask_basis_function(nside=nside, shadow_minutes=60., max_alt=76.)) bfs.append( bf.Moon_avoidance_basis_function(nside=nside, moon_distance=40.)) bfs.append(bf.Clouded_out_basis_function()) bfs.append(bf.Filter_loaded_basis_function(filternames=filtername)) weights = np.array([3.0, 0.3, 3., 3., 0., 0., 0., 0.]) sv = surveys.Greedy_survey(bfs, weights, block_size=1, filtername=filtername, dither=True, nside=nside, ignore_obs='DD', nexp=nexp) greedy_surveys.append(sv) survey_list = greedy_surveys return survey_list
def gen_greedy_surveys(nside): """ Make a quick set of greedy surveys """ target_map = standard_goals(nside=nside) filters = ['g', 'r', 'i', 'z', 'y'] surveys = [] for filtername in filters: bfs = [] bfs.append( bf.M5_diff_basis_function(filtername=filtername, nside=nside)) bfs.append( bf.Target_map_basis_function(filtername=filtername, target_map=target_map[filtername], out_of_bounds_val=np.nan, nside=nside)) bfs.append( bf.Slewtime_basis_function(filtername=filtername, nside=nside)) bfs.append(bf.Strict_filter_basis_function(filtername=filtername)) # Masks, give these 0 weight bfs.append( bf.Zenith_shadow_mask_basis_function(nside=nside, shadow_minutes=60., max_alt=76.)) bfs.append( bf.Moon_avoidance_basis_function(nside=nside, moon_distance=30.)) bfs.append(bf.Clouded_out_basis_function()) bfs.append(bf.Filter_loaded_basis_function(filternames=filtername)) bfs.append(bf.Planet_mask_basis_function(nside=nside)) weights = np.array([3.0, 0.3, 3., 3., 0., 0., 0., 0., 0.]) surveys.append( Greedy_survey(bfs, weights, block_size=1, filtername=filtername, dither=True, nside=nside)) return surveys
bf.Target_map_modulo_basis_function(filtername=filtername2, target_maps=target_list, season_modulo=mod_year, day_offset=offset, out_of_bounds_val=np.nan, nside=nside, norm_factor=even_norm, max_season=max_season)) bfs.append(bf.Slewtime_basis_function(filtername=filtername, nside=nside)) bfs.append(bf.Strict_filter_basis_function(filtername=filtername)) bfs.append( bf.Zenith_shadow_mask_basis_function(nside=nside, shadow_minutes=60., max_alt=76.)) bfs.append(bf.Clouded_out_basis_function()) filternames = [fn for fn in [filtername, filtername2] if fn is not None] bfs.append(bf.Filter_loaded_basis_function(filternames=filternames)) if filtername2 is None: time_needed = times_needed[0] else: time_needed = times_needed[1] bfs.append(bf.Time_to_twilight_basis_function(time_needed=time_needed)) bfs.append(bf.Not_twilight_basis_function()) weights = np.array([3.0, 3.0, 0.3, 0.3, 3., 3., 0., 0, 0, 0, 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., 0, 0, 0, 0]) # XXX-
def gen_blob_surveys(nside): """ make a quick set of blob surveys """ target_map = standard_goals(nside=nside) norm_factor = calc_norm_factor(target_map) filter1s = ['u', 'g'] # , 'r', 'i', 'z', 'y'] filter2s = [None, 'g'] # , 'r', 'i', None, None] filter1s = ['g'] # , 'r', 'i', 'z', 'y'] filter2s = ['g'] # , 'r', 'i', None, None] pair_surveys = [] for filtername, filtername2 in zip(filter1s, filter2s): detailer_list = [] bfs = [] bfs.append( bf.M5_diff_basis_function(filtername=filtername, nside=nside)) if filtername2 is not None: bfs.append( bf.M5_diff_basis_function(filtername=filtername2, nside=nside)) bfs.append( bf.Target_map_basis_function(filtername=filtername, target_map=target_map[filtername], out_of_bounds_val=np.nan, nside=nside, norm_factor=norm_factor)) if filtername2 is not None: bfs.append( bf.Target_map_basis_function( filtername=filtername2, target_map=target_map[filtername2], out_of_bounds_val=np.nan, nside=nside, norm_factor=norm_factor)) bfs.append( bf.Slewtime_basis_function(filtername=filtername, nside=nside)) bfs.append(bf.Strict_filter_basis_function(filtername=filtername)) # Masks, give these 0 weight bfs.append( bf.Zenith_shadow_mask_basis_function(nside=nside, shadow_minutes=60., max_alt=76.)) bfs.append( bf.Moon_avoidance_basis_function(nside=nside, moon_distance=30.)) bfs.append(bf.Clouded_out_basis_function()) # feasibility basis fucntions. Also give zero weight. filternames = [ fn for fn in [filtername, filtername2] if fn is not None ] bfs.append(bf.Filter_loaded_basis_function(filternames=filternames)) bfs.append(bf.Time_to_twilight_basis_function(time_needed=22.)) bfs.append(bf.Not_twilight_basis_function()) bfs.append(bf.Planet_mask_basis_function(nside=nside)) weights = np.array( [3.0, 3.0, .3, .3, 3., 3., 0., 0., 0., 0., 0., 0., 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., 0., 0., 0., 0., 0., 0.]) if filtername2 is None: survey_name = 'blob, %s' % filtername else: survey_name = 'blob, %s%s' % (filtername, filtername2) if filtername2 is not None: detailer_list.append( detailers.Take_as_pairs_detailer(filtername=filtername2)) pair_surveys.append( Blob_survey(bfs, weights, filtername1=filtername, filtername2=filtername2, survey_note=survey_name, ignore_obs='DD', detailers=detailer_list)) return pair_surveys