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
示例#2
0
def gen_greedy_surveys(nside, nexp=1):
    """
    Make a quick set of greedy surveys
    """
    target_map = u_heavy_footprint(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 = []

    detailer = detailers.Camera_rot_detailer(min_rot=-87., max_rot=87.)

    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.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.])
        surveys.append(Greedy_survey(bfs, weights, block_size=1, filtername=filtername,
                                     dither=True, nside=nside, ignore_obs='DD', nexp=nexp,
                                     detailers=[detailer]))

    return surveys
def gen_greedy_surveys(nside, nexp=1):
    """
    Make a quick set of greedy surveys
    """
    target_map = altfootprint(nside=nside)
    norm_factor = calc_norm_factor(target_map)
    # Let's remove the bluer filters since this should only be near twilight
    filters = ['y']
    surveys = []

    dec_limits = [[-24, 10], [-90, -20]]

    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.Dec_modulo_basis_function(nside=nside, dec_limits=dec_limits))
        # 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., 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 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_high_am(nside, nexp=1, n_high_am=2, template_weight=6.):
    """Let's set this up like the blob, but then give it a little extra weight.
    """
    target_map = standard_goals(nside=nside)['r']
    target_map[np.where(target_map > 0)] = 1.
    filters = ['u', 'g']
    surveys = []
    survey_name = 'high_am'
    blob_time = 22.  # set to something
    for filtername in filters:
        detailer_list = []
        detailer_list.append(
            detailers.Camera_rot_detailer(min_rot=-87., max_rot=87.))
        detailer_list.append(detailers.Close_alt_detailer())
        bfs = []
        bfs.append(
            bf.M5_diff_basis_function(filtername=filtername, nside=nside))
        bfs.append(
            bf.Slewtime_basis_function(filtername=filtername, nside=nside))
        bfs.append(bf.Strict_filter_basis_function(filtername=filtername))
        bfs.append(
            bf.N_obs_high_am_basis_function(nside=nside,
                                            footprint=target_map,
                                            filtername=filtername,
                                            n_obs=n_high_am,
                                            season=300.,
                                            out_of_bounds_val=np.nan))
        bfs.append(bf.Constant_basis_function())
        # 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.Filter_loaded_basis_function(filternames=filtername))
        bfs.append(bf.Time_to_twilight_basis_function(time_needed=blob_time))
        bfs.append(bf.Not_twilight_basis_function())
        bfs.append(bf.Planet_mask_basis_function(nside=nside))
        weights = np.array(
            [6., 0.6, 3., template_weight * 2, 1., 0., 0., 0., 0., 0., 0.])
        surveys.append(
            Blob_survey(bfs,
                        weights,
                        filtername1=filtername,
                        filtername2=None,
                        ideal_pair_time=blob_time,
                        nside=nside,
                        survey_note=survey_name,
                        ignore_obs='DD',
                        dither=True,
                        nexp=nexp,
                        detailers=detailer_list))
    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 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):
    """
    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
示例#9
0
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 generate_high_am(nside, nexp=1, n_high_am=2, hair_weight=6., pair_time=22.,
                     camera_rot_limits=[-80., 80.], season=300., season_start_hour=-4., season_end_hour=2.,
                     shadow_minutes=60., max_alt=76., moon_distance=30., ignore_obs='DD',
                     m5_weight=6., footprint_weight=0.6, slewtime_weight=3.,
                     stayfilter_weight=3., template_weight=12., const_weight=1, min_area=288.,
                     mask_east=True, mask_west=False, survey_name='high_am', filters='ug'):
    """Let's set this up like the blob, but then give it a little extra weight.
    """
    target_maps = standard_goals(nside=nside)
    surveys = []

    for filtername in filters:
        survey_name_final = survey_name+', %s' % filtername
        target_map = target_maps[filtername]*0
        target_map[np.where(target_maps[filtername] == np.max(target_maps[filtername]))] = 1.
        detailer_list = []
        detailer_list.append(detailers.Spider_rot_detailer())
        detailer_list.append(detailers.Close_alt_detailer())
        bfs = []
        bfs.append((bf.M5_diff_basis_function(filtername=filtername, nside=nside), m5_weight))
        bfs.append((bf.Slewtime_basis_function(filtername=filtername, nside=nside), slewtime_weight))
        bfs.append((bf.Strict_filter_basis_function(filtername=filtername), slewtime_weight))
        bfs.append((bf.N_obs_high_am_basis_function(nside=nside, footprint=target_map, filtername=filtername,
                                                    n_obs=n_high_am, season=season,
                                                    out_of_bounds_val=np.nan), hair_weight))
        bfs.append((bf.Constant_basis_function(), const_weight))
        # Masks, give these 0 weight
        bfs.append((bf.Zenith_shadow_mask_basis_function(nside=nside, shadow_minutes=shadow_minutes, max_alt=max_alt,
                                                         penalty=np.nan, site='LSST'), 0.))
        bfs.append((bf.Moon_avoidance_basis_function(nside=nside, moon_distance=moon_distance), 0.))
        bfs.append((bf.Filter_loaded_basis_function(filternames=filtername), 0))
        bfs.append((bf.Time_to_twilight_basis_function(time_needed=pair_time), 0.))
        bfs.append((bf.Not_twilight_basis_function(), 0.))
        bfs.append((bf.Planet_mask_basis_function(nside=nside), 0.))
        if mask_east:
            bfs.append((bf.Mask_azimuth_basis_function(az_min=0., az_max=180.), 0.))
        if mask_west:
            bfs.append((bf.Mask_azimuth_basis_function(az_min=180., az_max=360.), 0.))

        weights = [val[1] for val in bfs]
        basis_functions = [val[0] for val in bfs]
        surveys.append(Blob_survey(basis_functions, weights, filtername1=filtername, filtername2=None,
                                   ideal_pair_time=pair_time, nside=nside,
                                   survey_note=survey_name_final, ignore_obs=ignore_obs, dither=True,
                                   nexp=nexp, detailers=detailer_list, min_area=min_area))
    return surveys
示例#11
0
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
示例#12
0
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 = []
    cloud_map = target_map['r'][0] * 0 + 0.7

    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=40.))
        bfs.append(
            bf.Bulk_cloud_basis_function(max_cloud_map=cloud_map, nside=nside))

        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))
    return surveys
示例#13
0
def gen_greedy_surveys(nside=32,
                       nexp=1,
                       exptime=30.,
                       filters=['r', 'i', 'z', 'y'],
                       camera_rot_limits=[-80., 80.],
                       shadow_minutes=60.,
                       max_alt=76.,
                       moon_distance=30.,
                       ignore_obs='DD',
                       m5_weight=3.,
                       footprint_weight=0.3,
                       slewtime_weight=3.,
                       stayfilter_weight=3.,
                       footprints=None):
    """
    Make a quick set of greedy surveys

    This is a convienence function to generate a list of survey objects that can be used with
    lsst.sims.featureScheduler.schedulers.Core_scheduler.
    To ensure we are robust against changes in the sims_featureScheduler codebase, all kwargs are
    explicitly set.

    Parameters
    ----------
    nside : int (32)
        The HEALpix nside to use
    nexp : int (1)
        The number of exposures to use in a visit.
    exptime : float (30.)
        The exposure time to use per visit (seconds)
    filters : list of str (['r', 'i', 'z', 'y'])
        Which filters to generate surveys for.
    camera_rot_limits : list of float ([-80., 80.])
        The limits to impose when rotationally dithering the camera (degrees).
    shadow_minutes : float (60.)
        Used to mask regions around zenith (minutes)
    max_alt : float (76.
        The maximium altitude to use when masking zenith (degrees)
    moon_distance : float (30.)
        The mask radius to apply around the moon (degrees)
    ignore_obs : str or list of str ('DD')
        Ignore observations by surveys that include the given substring(s).
    m5_weight : float (3.)
        The weight for the 5-sigma depth difference basis function
    footprint_weight : float (0.3)
        The weight on the survey footprint basis function.
    slewtime_weight : float (3.)
        The weight on the slewtime basis function
    stayfilter_weight : float (3.)
        The weight on basis function that tries to stay avoid filter changes.
    """
    # Define the extra parameters that are used in the greedy survey. I
    # think these are fairly set, so no need to promote to utility func kwargs
    greed_survey_params = {
        'block_size': 1,
        'smoothing_kernel': None,
        'seed': 42,
        'camera': 'LSST',
        'dither': True,
        'survey_name': 'greedy'
    }

    surveys = []
    detailer = detailers.Camera_rot_detailer(min_rot=np.min(camera_rot_limits),
                                             max_rot=np.max(camera_rot_limits))

    for filtername in filters:
        bfs = []
        bfs.append((bf.M5_diff_basis_function(filtername=filtername,
                                              nside=nside), m5_weight))
        bfs.append(
            (bf.Footprint_basis_function(filtername=filtername,
                                         footprint=footprints,
                                         out_of_bounds_val=np.nan,
                                         nside=nside), footprint_weight))
        bfs.append((bf.Slewtime_basis_function(filtername=filtername,
                                               nside=nside), slewtime_weight))
        bfs.append((bf.Strict_filter_basis_function(filtername=filtername),
                    stayfilter_weight))
        # Masks, give these 0 weight
        bfs.append((bf.Zenith_shadow_mask_basis_function(
            nside=nside, shadow_minutes=shadow_minutes, max_alt=max_alt), 0))
        bfs.append(
            (bf.Moon_avoidance_basis_function(nside=nside,
                                              moon_distance=moon_distance), 0))

        bfs.append(
            (bf.Filter_loaded_basis_function(filternames=filtername), 0))
        bfs.append((bf.Planet_mask_basis_function(nside=nside), 0))

        weights = [val[1] for val in bfs]
        basis_functions = [val[0] for val in bfs]
        surveys.append(
            Greedy_survey(basis_functions,
                          weights,
                          exptime=exptime,
                          filtername=filtername,
                          nside=nside,
                          ignore_obs=ignore_obs,
                          nexp=nexp,
                          detailers=[detailer],
                          **greed_survey_params))

    return surveys
示例#14
0
def generate_blobs(nside,
                   nexp=1,
                   exptime=30.,
                   filter1s=['u', 'u', 'g', 'r', 'i', 'z', 'y'],
                   filter2s=['g', 'r', 'r', 'i', 'z', 'y', 'y'],
                   pair_time=22.,
                   camera_rot_limits=[-80., 80.],
                   n_obs_template=3,
                   season=300.,
                   season_start_hour=-4.,
                   season_end_hour=2.,
                   shadow_minutes=60.,
                   max_alt=76.,
                   moon_distance=30.,
                   ignore_obs='DD',
                   m5_weight=6.,
                   footprint_weight=0.6,
                   slewtime_weight=3.,
                   stayfilter_weight=3.,
                   template_weight=12.,
                   footprints=None):
    """
    Generate surveys that take observations in blobs.

    Parameters
    ----------
    nside : int (32)
        The HEALpix nside to use
    nexp : int (1)
        The number of exposures to use in a visit.
    exptime : float (30.)
        The exposure time to use per visit (seconds)
    filter1s : list of str
        The filternames for the first set
    filter2s : list of str
        The filter names for the second in the pair (None if unpaired)
    pair_time : float (22)
        The ideal time between pairs (minutes)
    camera_rot_limits : list of float ([-80., 80.])
        The limits to impose when rotationally dithering the camera (degrees).
    n_obs_template : int (3)
        The number of observations to take every season in each filter
    season : float (300)
        The length of season (i.e., how long before templates expire) (days)
    season_start_hour : float (-4.)
        For weighting how strongly a template image needs to be observed (hours)
    sesason_end_hour : float (2.)
        For weighting how strongly a template image needs to be observed (hours)
    shadow_minutes : float (60.)
        Used to mask regions around zenith (minutes)
    max_alt : float (76.
        The maximium altitude to use when masking zenith (degrees)
    moon_distance : float (30.)
        The mask radius to apply around the moon (degrees)
    ignore_obs : str or list of str ('DD')
        Ignore observations by surveys that include the given substring(s).
    m5_weight : float (3.)
        The weight for the 5-sigma depth difference basis function
    footprint_weight : float (0.3)
        The weight on the survey footprint basis function.
    slewtime_weight : float (3.)
        The weight on the slewtime basis function
    stayfilter_weight : float (3.)
        The weight on basis function that tries to stay avoid filter changes.
    template_weight : float (12.)
        The weight to place on getting image templates every season
    """

    blob_survey_params = {
        'slew_approx': 7.5,
        'filter_change_approx': 140.,
        'read_approx': 2.,
        'min_pair_time': 15.,
        'search_radius': 30.,
        'alt_max': 85.,
        'az_range': 90.,
        'flush_time': 30.,
        'smoothing_kernel': None,
        'nside': nside,
        'seed': 42,
        'dither': True,
        'twilight_scale': True
    }

    surveys = []

    times_needed = [pair_time, pair_time * 2]
    for filtername, filtername2 in zip(filter1s, filter2s):
        detailer_list = []
        detailer_list.append(
            detailers.Camera_rot_detailer(min_rot=np.min(camera_rot_limits),
                                          max_rot=np.max(camera_rot_limits)))
        detailer_list.append(detailers.Close_alt_detailer())
        # List to hold tuples of (basis_function_object, weight)
        bfs = []

        if filtername2 is not None:
            bfs.append(
                (bf.M5_diff_basis_function(filtername=filtername,
                                           nside=nside), m5_weight / 2.))
            bfs.append(
                (bf.M5_diff_basis_function(filtername=filtername2,
                                           nside=nside), m5_weight / 2.))

        else:
            bfs.append((bf.M5_diff_basis_function(filtername=filtername,
                                                  nside=nside), m5_weight))

        if filtername2 is not None:
            bfs.append((bf.Footprint_basis_function(filtername=filtername,
                                                    footprint=footprints,
                                                    out_of_bounds_val=np.nan,
                                                    nside=nside),
                        footprint_weight / 2.))
            bfs.append((bf.Footprint_basis_function(filtername=filtername2,
                                                    footprint=footprints,
                                                    out_of_bounds_val=np.nan,
                                                    nside=nside),
                        footprint_weight / 2.))
        else:
            bfs.append(
                (bf.Footprint_basis_function(filtername=filtername,
                                             footprint=footprints,
                                             out_of_bounds_val=np.nan,
                                             nside=nside), footprint_weight))

        bfs.append((bf.Slewtime_basis_function(filtername=filtername,
                                               nside=nside), slewtime_weight))
        bfs.append((bf.Strict_filter_basis_function(filtername=filtername),
                    stayfilter_weight))

        if filtername2 is not None:
            bfs.append((bf.N_obs_per_year_basis_function(
                filtername=filtername,
                nside=nside,
                footprint=footprints.get_footprint(filtername),
                n_obs=n_obs_template,
                season=season,
                season_start_hour=season_start_hour,
                season_end_hour=season_end_hour), template_weight / 2.))
            bfs.append((bf.N_obs_per_year_basis_function(
                filtername=filtername2,
                nside=nside,
                footprint=footprints.get_footprint(filtername2),
                n_obs=n_obs_template,
                season=season,
                season_start_hour=season_start_hour,
                season_end_hour=season_end_hour), template_weight / 2.))
        else:
            bfs.append((bf.N_obs_per_year_basis_function(
                filtername=filtername,
                nside=nside,
                footprint=footprints.get_footprint(filtername),
                n_obs=n_obs_template,
                season=season,
                season_start_hour=season_start_hour,
                season_end_hour=season_end_hour), template_weight))
        # Masks, give these 0 weight
        bfs.append((bf.Zenith_shadow_mask_basis_function(
            nside=nside,
            shadow_minutes=shadow_minutes,
            max_alt=max_alt,
            penalty=np.nan,
            site='LSST'), 0.))
        bfs.append(
            (bf.Moon_avoidance_basis_function(nside=nside,
                                              moon_distance=moon_distance),
             0.))
        filternames = [
            fn for fn in [filtername, filtername2] if fn is not None
        ]
        bfs.append(
            (bf.Filter_loaded_basis_function(filternames=filternames), 0))
        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), 0.))
        bfs.append((bf.Not_twilight_basis_function(), 0.))
        bfs.append((bf.Planet_mask_basis_function(nside=nside), 0.))

        # unpack the basis functions and weights
        weights = [val[1] for val in bfs]
        basis_functions = [val[0] for val in bfs]
        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))
        surveys.append(
            Blob_survey(basis_functions,
                        weights,
                        filtername1=filtername,
                        filtername2=filtername2,
                        exptime=exptime,
                        ideal_pair_time=pair_time,
                        survey_note=survey_name,
                        ignore_obs=ignore_obs,
                        nexp=nexp,
                        detailers=detailer_list,
                        **blob_survey_params))

    return surveys
def generate_blobs(nside,
                   mixed_pairs=False,
                   nexp=1,
                   no_pairs=False,
                   offset=None,
                   template_weight=6.):
    target_map = wfd_only_fp(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']
    if mixed_pairs:
        filter2s = [None, 'r', 'i', 'z', None, None]
    else:
        filter2s = [None, 'g', 'r', 'i', None, None]

    if no_pairs:
        filter2s = [None, None, None, None, None, None]

    # Ideal time between taking pairs
    pair_time = 22.
    times_needed = [pair_time, pair_time * 2]
    for filtername, filtername2 in zip(filter1s, filter2s):
        detailer_list = []
        detailer_list.append(
            detailers.Camera_rot_detailer(min_rot=-87., max_rot=87.))
        detailer_list.append(detailers.Close_alt_detailer())
        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))
        bfs.append(
            bf.N_obs_per_year_basis_function(filtername=filtername,
                                             nside=nside,
                                             footprint=target_map[filtername],
                                             n_obs=3,
                                             season=300.))
        if filtername2 is not None:
            bfs.append(
                bf.N_obs_per_year_basis_function(
                    filtername=filtername2,
                    nside=nside,
                    footprint=target_map[filtername2],
                    n_obs=3,
                    season=300.))
        # 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.))
        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())
        bfs.append(bf.Planet_mask_basis_function(nside=nside))
        weights = np.array([
            3.0, 3.0, .3, .3, 3., 3., template_weight, template_weight, 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., template_weight * 2, 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))
        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,
                        nexp=nexp,
                        detailers=detailer_list))

    return surveys
示例#16
0
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
def generate_twilight_neo(nside,
                          night_pattern=None,
                          nexp=1,
                          exptime=1,
                          camera_rot_limits=[-80., 80.],
                          footprint_weight=0.1,
                          slewtime_weight=3.,
                          stayfilter_weight=3.):
    # XXX finish eliminating magic numbers and document this one
    slew_estimate = 4.5
    filters = 'riz'
    survey_name = 'twilight_neo'
    footprint = ecliptic_target(nside=nside)
    footprints = {}
    for filtername in filters:
        footprints[filtername] = footprint

    sum_footprints = 0
    for key in footprints:
        sum_footprints += np.sum(footprints[key])

    surveys = []
    for filtername in filters:
        detailer_list = []
        detailer_list.append(
            detailers.Camera_rot_detailer(min_rot=np.min(camera_rot_limits),
                                          max_rot=np.max(camera_rot_limits)))
        detailer_list.append(detailers.Close_alt_detailer())
        detailer_list.append(
            detailers.Twilight_triple_detailer(slew_estimate=slew_estimate,
                                               n_repeat=3))
        bfs = []

        bfs.append(
            (bf.Footprint_basis_function(filtername=filtername,
                                         footprint=footprints[filtername],
                                         out_of_bounds_val=np.nan,
                                         nside=nside,
                                         all_footprints_sum=sum_footprints),
             footprint_weight))

        bfs.append((bf.Slewtime_basis_function(filtername=filtername,
                                               nside=nside), slewtime_weight))
        bfs.append((bf.Strict_filter_basis_function(filtername=filtername),
                    stayfilter_weight))
        # Need a toward the sun, reward high airmass, with an airmass cutoff basis function.
        bfs.append((bf.Near_sun_twilight_basis_function(nside=nside,
                                                        max_airmass=2.), 0))
        bfs.append((bf.Zenith_shadow_mask_basis_function(nside=nside,
                                                         shadow_minutes=60.,
                                                         max_alt=76.), 0))
        bfs.append((bf.Moon_avoidance_basis_function(nside=nside,
                                                     moon_distance=30.), 0))
        bfs.append(
            (bf.Filter_loaded_basis_function(filternames=filtername), 0))
        bfs.append((bf.Planet_mask_basis_function(nside=nside), 0))
        bfs.append((bf.Sun_alt_limit_basis_function(), 0))
        bfs.append((bf.Time_in_twilight_basis_function(time_needed=5.), 0))
        bfs.append((bf.Night_modulo_basis_function(pattern=night_pattern), 0))
        # unpack the basis functions and weights
        weights = [val[1] for val in bfs]
        basis_functions = [val[0] for val in bfs]

        # Set huge ideal pair time and use the detailer to cut down the list of observations to fit twilight?
        surveys.append(
            Blob_survey(basis_functions,
                        weights,
                        filtername1=filtername,
                        filtername2=None,
                        ideal_pair_time=3.,
                        nside=nside,
                        exptime=exptime,
                        survey_note=survey_name,
                        ignore_obs=['DD', 'greedy', 'blob'],
                        dither=True,
                        nexp=nexp,
                        detailers=detailer_list,
                        az_range=180.,
                        twilight_scale=False))

    return surveys
                                            day_offset=offset,
                                            out_of_bounds_val=np.nan,
                                            nside=nside,
                                            norm_factor=even_norm,
                                            max_season=max_season))
    if filtername2 is not None:
        bfs.append(
            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))
def generate_twilight_neo(nside, night_pattern=None):
    surveys = []
    nexp = 1
    filters = 'riz'
    survey_name = 'twilight_neo'
    target_map_one = ecliptic_target(nside=nside)
    target_map = {}
    for filtername in filters:
        target_map[filtername] = target_map_one

    norm_factor = calc_norm_factor(target_map)
    exptime = 1.

    for filtername in filters:
        detailer_list = []
        detailer_list.append(
            detailers.Camera_rot_detailer(min_rot=-87., max_rot=87.))
        detailer_list.append(detailers.Close_alt_detailer())
        detailer_list.append(
            detailers.Twilight_triple_detailer(slew_estimate=4.5, n_repeat=3))
        bfs = []

        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))
        # XXX
        # Need a toward the sun, reward high airmass, with an airmass cutoff basis function.
        bfs.append(
            bf.Near_sun_twilight_basis_function(nside=nside, max_airmass=2.))
        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.Filter_loaded_basis_function(filternames=filtername))
        bfs.append(bf.Planet_mask_basis_function(nside=nside))
        bfs.append(bf.Sun_alt_limit_basis_function())
        bfs.append(bf.Time_in_twilight_basis_function(time_needed=5.))
        bfs.append(bf.Night_modulo_basis_function(pattern=night_pattern))
        weights = [0.1, 3., 3., 3., 0., 0., 0., 0., 0., 0., 0.]
        # Set huge ideal pair time and use the detailer to cut down the list of observations to fit twilight?
        surveys.append(
            Blob_survey(bfs,
                        weights,
                        filtername1=filtername,
                        filtername2=None,
                        ideal_pair_time=3.,
                        nside=nside,
                        exptime=exptime,
                        survey_note=survey_name,
                        ignore_obs=['DD', 'greedy', 'blob'],
                        dither=True,
                        nexp=nexp,
                        detailers=detailer_list,
                        az_range=180.,
                        twilight_scale=False))

    return surveys
示例#20
0
     basis_functions.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(
         basis_functions.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(
     basis_functions.Slewtime_basis_function(filtername=filtername,
                                             nside=nside))
 bfs.append(
     basis_functions.Strict_filter_basis_function(filtername=filtername))
 # Masks, give these 0 weight
 bfs.append(
     basis_functions.Zenith_shadow_mask_basis_function(nside=nside,
                                                       shadow_minutes=60.,
                                                       max_alt=76.))
 bfs.append(
     basis_functions.Moon_avoidance_basis_function(nside=nside,
                                                   moon_distance=30.))
 bfs.append(
     basis_functions.Bulk_cloud_basis_function(max_cloud_map=cloud_map,
                                               nside=nside))
 filternames = [fn for fn in [filtername, filtername2] if fn is not None]
 bfs.append(