def add_mag_clouds(inmap=None, nside=32):
    if inmap is None:
        result = standard_goals(nside=nside)
    else:
        result = inmap
    ra, dec = utils.ra_dec_hp_map(nside=nside)

    lmc_ra = np.radians(80.893860)
    lmc_dec = np.radians(-69.756126)
    lmc_radius = np.radians(10.)

    smc_ra = np.radians(13.186588)
    smc_dec = np.radians(-72.828599)
    smc_radius = np.radians(5.)

    dist_to_lmc = _angularSeparation(lmc_ra, lmc_dec, ra, dec)
    lmc_pix = np.where(dist_to_lmc < lmc_radius)

    dist_to_smc = _angularSeparation(smc_ra, lmc_dec, ra, dec)
    smc_pix = np.where(dist_to_smc < smc_radius)

    for key in result:
        result[key][lmc_pix] = np.max(result[key])
        result[key][smc_pix] = np.max(result[key])
    return result
Beispiel #2
0
def nes_footprint(nside=32):
    """
    A quick function to generate the NES footprint
    """

    weight_dict = {'u': 0, 'g': 0.2, 'r': 0.46, 'i': 0.46, 'z': 0.4, 'y': 0}
    NES_min_EB = -30.0
    NES_max_EB = 10.0
    NES_dec_min = -20

    ra, dec = ra_dec_hp_map(nside=nside)

    coord = SkyCoord(ra=ra * u.rad, dec=dec * u.rad)
    gal_lon, gal_lat = coord.galactic.l.deg, coord.galactic.b.deg

    nes = NES_healpixels(nside=nside,
                         min_EB=NES_min_EB,
                         max_EB=NES_max_EB,
                         dec_min=NES_dec_min)
    nes_pix = np.where((nes > 0) & ((gal_lon > 90.) & (gal_lon < 270.)))[0]
    ze = np.zeros(hp.nside2npix(nside), dtype=float)

    result = {}
    for key in weight_dict:
        result[key] = ze + 0
        result[key][nes_pix] = weight_dict[key]
    return result
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
Beispiel #4
0
def big_sky_dust(
        nside=32,
        weights={
            'u': [0.31, 0.13, False],
            'g': [0.44, 0.13],
            'r': [1., 0.25],
            'i': [1., 0.25],
            'z': [0.9, 0.25],
            'y': [0.9, 0.25, False]
        },
        dust_limit=0.19):
    """
    Based on the Olsen et al Cadence White Paper
    """

    ebvDataDir = getPackageDir('sims_maps')
    filename = 'DustMaps/dust_nside_%i.npz' % nside
    dustmap = np.load(os.path.join(ebvDataDir, filename))['ebvMap']

    # wfd covers -72.25 < dec < 12.4. Avoid galactic plane |b| > 15 deg
    wfd_north = np.radians(12.4)
    wfd_south = np.radians(-72.25)

    # Set full north South, from +30 where that gets us a stripe up north
    full_north = np.radians(12.)

    ra, dec = ra_dec_hp_map(nside=nside)
    total_map = np.zeros(ra.size)

    # let's make a first pass here

    total_map[np.where(dec < full_north)] = 1e-6
    total_map[np.where((dec > wfd_south) & (dec < wfd_north)
                       & (dustmap < dust_limit))] = 1.

    # Now let's break it down by filter
    result = {}

    for key in weights:
        result[key] = total_map + 0.
        result[key][np.where(result[key] == 1)] = weights[key][0]
        result[key][np.where(result[key] == 1e-6)] = weights[key][1]
        if len(weights[key]) == 3:
            result[key][np.where(dec > wfd_north)] = 0.

    ## add in NES where it is less than WFD
    nes_fp = nes_footprint(nside=nside)
    for key in result:
        nes_pix = np.where(nes_fp[key] > result[key])
        result[key][nes_pix] = nes_fp[key][nes_pix]

    return result
def greedy_footprint(nside=32, exclude_lat=17.):
    """Make a footprint just for the greedy algo
    """

    base_footprints = standard_goals(nside=nside)

    ra, dec = ra_dec_hp_map(nside=nside)
    coord = SkyCoord(ra=ra * u.rad, dec=dec * u.rad, frame='icrs')
    eclip_lat = coord.barycentrictrueecliptic.lat.deg

    mask = np.where(np.abs(eclip_lat) <= exclude_lat)
    for key in base_footprints:
        base_footprints[key][mask] = 0

    return base_footprints
Beispiel #6
0
def big_sky_dust(
        nside=32,
        weights={
            'u': [0.31, 0.15, False],
            'g': [0.44, 0.15],
            'r': [1., 0.3],
            'i': [1., 0.3],
            'z': [0.9, 0.3],
            'y': [0.9, 0.3, False]
        },
        dust_limit=0.19):
    """
    Based on the Olsen et al Cadence White Paper
    """

    ebvDataDir = getPackageDir('sims_maps')
    filename = 'DustMaps/dust_nside_%i.npz' % nside
    dustmap = np.load(os.path.join(ebvDataDir, filename))['ebvMap']

    # wfd covers -72.25 < dec < 12.4. Avoid galactic plane |b| > 15 deg
    wfd_north = np.radians(12.4)
    wfd_south = np.radians(-72.25)
    full_north = np.radians(30.)

    ra, dec = utils.ra_dec_hp_map(nside=nside)
    total_map = np.zeros(ra.size)

    # let's make a first pass here

    total_map[np.where(dec < full_north)] = 1e-6
    total_map[np.where((dec > wfd_south) & (dec < wfd_north)
                       & (dustmap < dust_limit))] = 1.

    # Now let's break it down by filter
    result = {}

    for key in weights:
        result[key] = total_map + 0.
        result[key][np.where(result[key] == 1)] = weights[key][0]
        result[key][np.where(result[key] == 1e-6)] = weights[key][1]
        if len(weights[key]) == 3:
            result[key][np.where(dec > wfd_north)] = 0.

    return result
Beispiel #7
0
def big_sky(
    nside=32,
    weights={
        'u': [0.31, 0.15, False],
        'g': [0.44, 0.15],
        'r': [1., 0.3],
        'i': [1., 0.3],
        'z': [0.9, 0.3],
        'y': [0.9, 0.3, False]
    }):
    """
    Based on the Olsen et al Cadence White Paper
    """

    # wfd covers -72.25 < dec < 12.4. Avoid galactic plane |b| > 15 deg
    wfd_north = np.radians(12.4)
    wfd_south = np.radians(-72.25)
    full_north = np.radians(30.)
    g_lat_limit = np.radians(15.)

    ra, dec = utils.ra_dec_hp_map(nside=nside)
    total_map = np.zeros(ra.size)
    coord = SkyCoord(ra=ra * u.rad, dec=dec * u.rad)
    g_long, g_lat = coord.galactic.l.radian, coord.galactic.b.radian

    # let's make a first pass here

    total_map[np.where(dec < full_north)] = 1e-6
    total_map[np.where((dec > wfd_south) & (dec < wfd_north)
                       & (np.abs(g_lat) > g_lat_limit))] = 1.

    # Now let's break it down by filter
    result = {}

    for key in weights:
        result[key] = total_map + 0.
        result[key][np.where(result[key] == 1)] = weights[key][0]
        result[key][np.where(result[key] == 1e-6)] = weights[key][1]
        if len(weights[key]) == 3:
            result[key][np.where(dec > wfd_north)] = 0.

    return result
def big_sky(
    nside=32,
    weights={
        'u': [0.31, 0.15, False],
        'g': [0.44, 0.15],
        'r': [1., 0.3],
        'i': [1., 0.3],
        'z': [0.9, 0.3],
        'y': [0.9, 0.3, False]
    }):
    """
    Based on the Olsen et al Cadence White Paper
    """
    wfd_north = 12.4
    wfd_south = -72.25
    gal_lat_limit = 15.
    full_north = 30.

    # WFD in big sky = dec range -72.5 to 12.5, avoiding galactic plane |b| < 15. deg.
    bigsky = utils.WFD_no_gp_healpixels(nside,
                                        dec_min=wfd_south,
                                        dec_max=wfd_north,
                                        center_width=gal_lat_limit,
                                        gal_long1=0,
                                        gal_long2=360)
    # Add extention to the north, up to 30 deg.
    ra, dec = utils.ra_dec_hp_map(nside=nside)
    bigsky = np.where(
        (dec > np.radians(wfd_north)) & (dec < np.radians(full_north)), 1.e-6,
        bigsky)

    # Now let's break it down by filter
    result = {}
    for key in weights:
        result[key] = bigsky + 0.
        result[key][np.where(result[key] == 1)] = weights[key][0]
        result[key][np.where(result[key] == 1e-6)] = weights[key][1]
        if len(weights[key]) == 3:
            result[key][np.where(dec > np.radians(wfd_north))] = 0.
    return result
Beispiel #9
0
def new_regions(nside=32, north_limit=2.25):
    ra, dec = utils.ra_dec_hp_map(nside=nside)
    coord = SkyCoord(ra=ra * u.rad, dec=dec * u.rad)
    g_long, g_lat = coord.galactic.l.radian, coord.galactic.b.radian

    # OK, let's just define the regions
    north = np.where((dec > np.radians(north_limit))
                     & (dec < np.radians(30.)))[0]
    wfd = np.where(
        utils.WFD_healpixels(dec_min=-72.25, dec_max=north_limit, nside=nside)
        > 0)[0]
    nes = np.where(
        utils.NES_healpixels(dec_min=north_limit, min_EB=-30., max_EB=10.) > 0
    )[0]
    scp = np.where(utils.SCP_healpixels(nside=nside, dec_max=-72.25) > 0)[0]

    new_gp = np.where((dec < np.radians(north_limit))
                      & (dec > np.radians(-72.25))
                      & (np.abs(g_lat) < np.radians(15.))
                      & ((g_long < np.radians(90.))
                         | (g_long > np.radians(360. - 70.))))[0]

    anti_gp = np.where((dec < np.radians(north_limit))
                       & (dec > np.radians(-72.25))
                       & (np.abs(g_lat) < np.radians(15.))
                       & (g_long < np.radians(360. - 70.))
                       & (g_long > np.radians(90.)))[0]

    footprints = {
        'north': north,
        'wfd': wfd,
        'nes': nes,
        'scp': scp,
        'gp': new_gp,
        'gp_anti': anti_gp
    }

    return footprints
def combo_dust_fp(nside=32,
                  wfd_weights={
                      'u': 0.31,
                      'g': 0.44,
                      'r': 1.,
                      'i': 1.,
                      'z': 0.9,
                      'y': 0.9
                  },
                  wfd_dust_weights={
                      'u': 0.13,
                      'g': 0.13,
                      'r': 0.25,
                      'i': 0.25,
                      'z': 0.25,
                      'y': 0.25
                  },
                  nes_dist_eclip_n=10.,
                  nes_dist_eclip_s=-30.,
                  nes_south_limit=-5,
                  ses_dist_eclip=10.,
                  nes_weights={
                      'u': 0,
                      'g': 0.2,
                      'r': 0.46,
                      'i': 0.46,
                      'z': 0.4,
                      'y': 0
                  },
                  dust_limit=0.19,
                  wfd_north_dec=12.4,
                  wfd_south_dec=-72.25,
                  mc_wfd=True,
                  outer_bridge_l=240,
                  outer_bridge_width=10.,
                  outer_bridge_alt=13.,
                  bulge_lon_span=20.,
                  bulge_alt_span=10.,
                  north_weights={
                      'g': 0.03,
                      'r': 0.03,
                      'i': 0.03
                  },
                  north_limit=30.):
    """
    Based on the Olsen et al Cadence White Paper

    XXX---need to refactor and get rid of all the magic numbers everywhere.
    """

    ebvDataDir = getPackageDir('sims_maps')
    filename = 'DustMaps/dust_nside_%i.npz' % nside
    dustmap = np.load(os.path.join(ebvDataDir, filename))['ebvMap']

    # wfd covers -72.25 < dec < 12.4. Avoid galactic plane |b| > 15 deg
    wfd_north = wfd_north_dec
    wfd_south = wfd_south_dec

    ra, dec = np.degrees(ra_dec_hp_map(nside=nside))
    WFD_no_dust = np.zeros(ra.size)
    WFD_dust = np.zeros(ra.size)

    coord = SkyCoord(ra=ra * u.deg, dec=dec * u.deg)
    gal_lon, gal_lat = coord.galactic.l.deg, coord.galactic.b.deg

    # let's make a first pass here
    WFD_no_dust[np.where((dec > wfd_south) & (dec < wfd_north)
                         & (dustmap < dust_limit))] = 1.

    WFD_dust[np.where((dec > wfd_south) & (dec < wfd_north)
                      & (dustmap > dust_limit))] = 1.
    WFD_dust[np.where(dec < wfd_south)] = 1.

    # Fill in values for WFD and WFD_dusty
    result = {}
    for key in wfd_weights:
        result[key] = WFD_no_dust + 0.
        result[key][np.where(result[key] == 1)] = wfd_weights[key]
        result[key][np.where(WFD_dust == 1)] = wfd_dust_weights[key]

    coord = SkyCoord(ra=ra * u.deg, dec=dec * u.deg)
    eclip_lat = coord.barycentrictrueecliptic.lat.deg

    # Any part of the NES that is too low gets pumped up
    nes_indx = np.where((
        (eclip_lat < nes_dist_eclip_n) & (eclip_lat > nes_dist_eclip_s))
                        & (dec > nes_south_limit))
    nes_hp_map = ra * 0
    nes_hp_map[nes_indx] = 1
    for key in result:
        result[key][np.where((nes_hp_map > 0) & (
            result[key] < nes_weights[key]))] = nes_weights[key]

    if mc_wfd:
        mag_clouds = magellanic_clouds_healpixels(nside)
        mag_clouds_indx = np.where(mag_clouds > 0)[0]
    else:
        mag_clouds_indx = []
    for key in result:
        result[key][mag_clouds_indx] = wfd_weights[key]

    # Put in an outer disk bridge
    outer_disk = np.where((gal_lon < (outer_bridge_l + outer_bridge_width))
                          & (gal_lon > (outer_bridge_l - outer_bridge_width))
                          & (np.abs(gal_lat) < outer_bridge_alt))
    for key in result:
        result[key][outer_disk] = wfd_weights[key]

    # Make a bulge go WFD
    bulge_pix = np.where((
        (gal_lon > (360 - bulge_lon_span)) | (gal_lon < bulge_lon_span))
                         & (np.abs(gal_lat) < bulge_alt_span))
    for key in result:
        result[key][bulge_pix] = wfd_weights[key]

    # Set South ecliptic to the WFD values
    ses_indx = np.where((np.abs(eclip_lat) < ses_dist_eclip)
                        & (dec < nes_south_limit))
    for key in result:
        result[key][ses_indx] = wfd_weights[key]

    # Let's paint all the north as non-zero
    for key in north_weights:
        north = np.where((dec < north_limit) & (result[key] == 0))
        result[key][north] = north_weights[key]

    return result