Maps

class rubin_sim.maf.maps.BaseMap(**kwargs)[source]

Bases: object

Base for maps classes.

run(slice_points)[source]

Given slice_points (dict containing metadata about each slice_point, including ra/dec), adds additional metadata at each slice_point and returns updated dict.

class rubin_sim.maf.maps.DustMap(interp=False, nside=128, map_path=None)[source]

Bases: BaseMap

Add the E(B-V) values to the slice points.

Primarily, this calls eb_vhp to read a healpix map of E(B-V) values over the sky, then assigns ebv values to each slice_point. If the slicer is a healpix slicer, this is trivial. Otherwise, it either uses the nearest healpix grid point or interpolates.

The key added to the slice points is ebv.

Parameters:
  • interp (bool, opt) – Interpolate the dust map at each slice_point (True) or just use the nearest value (False). Default is False.

  • nside (int, opt) – Default nside value to read the dust map from disk. Primarily useful if the slicer is not a healpix slicer. Default 128.

  • map_path (str, opt) – Define a path to the directory holding the dust map files. Default None, which uses RUBIN_SIM_DATA_DIR.

run(slice_points)[source]

Given slice_points (dict containing metadata about each slice_point, including ra/dec), adds additional metadata at each slice_point and returns updated dict.

class rubin_sim.maf.maps.DustMap3D(nside=64, map_file=None, interp=True, filtername='r', dist_pc=3000, d_mag=15.2, r_x=None)[source]

Bases: BaseMap

Add 3-d E(B-V) values to the slice points.

See “notes” below for a discussion of the content of the map keys, and functionality that can be accessed by calling DustMap3d.distance_at_mag with the key values at a given slice point.

Parameters:
  • nside (int) – Healpixel resolution (2^x) to read from disk.

  • map_file (str, opt) – Path to dust map file.

  • interp (bool, opt) – Should returned values be interpolated (True) or just nearest neighbor (False). Default True, but is ignored if ‘pixels’ is provided.

  • filtername ('str', opt) – Name of the filter (to match the lsst filter names in rubin_sim.photUtils.DustValues) in which to calculate dust extinction magnitudes

  • dist_pc (float, opt) – Distance at which to precalculate the nearest ebv value (pc)

  • d_mag (float, opt) – Calculate the maximum distance which matches this d_mag d_mag == m-mO (dust extinction + distance modulus)

  • r_x (dict {str: float}, opt) – Per-filter dust extinction curve coefficients. Calculated by rubin_sim.photUtils.DustValues if “None”.

Notes

The slice point dictionary keys are expanded with the following keys: ebv3d_dists - the distances from the 3d dust map at each slice_point (in pc) ebv3d_ebvs - the E(B-V) values corresponding to each distance at each slice_point ebv3d_ebv_at_ - the (single) ebv value at the nearest distance to dist_pc ebv3d_dist_at_ - the (single) distance value corresponding to where extinction and distance modulus combine to create a m-Mo value of d_mag, for the filter specified in filtername (in pc). Note that <dist_pc> and <d_mag> will be formatted with a single decimal place.

The additional method ‘distance_at_mag’ can be called either with the distances and ebv values for the entire map or with the values from a single slice_point, in order to calculate the distance at which extinction and distance modulus combine to create a m-Mo value closest to ‘dmag’ in any filter. This is the same value as would be reported in ebv3d_dist_at_<d_mag>, but can be calculated on the fly, allowing variable filters and dmag values.

distance_at_dmag(dmag, dists, ebvs, filtername=None)[source]

Calculate the distance at which a given change of magnitude would occur (including distance modulus and dust extinction).

Parameters:
  • dmag (float) – The magnitude change expected.

  • dists (np.ndarray, (N,)) – The distances corresponding to the ebv values.

  • ebvs (np.ndarray, (N,)) – The ebv values at each distance.

  • filtername (str or None) – The filter in which to evaluate the magnitude change. If None, uses the default filter for the map. The filter translates ebv into magnitudes of extinction.

Returns:

dist_dmag – The distance at which the specified dmag occurs.

Return type:

float

run(slice_points)[source]

Given slice_points (dict containing metadata about each slice_point, including ra/dec), adds additional metadata at each slice_point and returns updated dict.

class rubin_sim.maf.maps.GalCoordsMap[source]

Bases: BaseMap

Add gall and galb (in radians) to the slice point dictionaries.

run(slice_points)[source]

Given slice_points (dict containing metadata about each slice_point, including ra/dec), adds additional metadata at each slice_point and returns updated dict.

class rubin_sim.maf.maps.GalacticPlanePriorityMap(interp=False, nside=64, map_path=None)[source]

Bases: BaseMap

Add the galactic plane priority map data to the slice points.

This calls galactic_plane_priority_map to read the map data, and then assigns the appropriate values to each slice_point. If the slicer is an nside=64 healpix slicer, this is trivial. (other use-cases currently experimental and not supported).

Add keys corresponding to each of the galplane priority map elements.

Parameters:
  • interp (bool, opt) – Interpolate the dust map at each slice_point (True) or just use the nearest value (False). Default is False.

  • nside (int, opt) – Default nside value to read the dust map from disk. Primarily useful if the slicer is not a healpix slicer. Default 64.

  • map_path (str, opt) – Define a path to the directory holding the dust map files. Default None, which uses RUBIN_SIM_DATA_DIR.

run(slice_points)[source]

Given slice_points (dict containing metadata about each slice_point, including ra/dec), adds additional metadata at each slice_point and returns updated dict.

class rubin_sim.maf.maps.MapsRegistry(name, bases, dict)[source]

Bases: type

Meta class for Maps, to build a registry of maps classes.

class rubin_sim.maf.maps.StellarDensityMap(startype='allstars', filtername='r', map_dir=None)[source]

Bases: BaseMap

Read and hold the cumulative stellar luminosity function for each slice point.

The underlying stellar luminosity function map is nside = 64, and contains stars per sq degree at a series of magnitudes (the map contains starLumFunc_ and starMapBins_). For slice points which do not match nside=64, the map uses the nearest healpix point on the nside=64 grid.

The stellar luminosity function comes from the GalFast model.

Parameters:
  • startype (str (‘allstars’, ‘wdstars’)) – Load the luminosity function for all stars (‘allstars’), which includes main-sequence stars white dwarfs, blue horozontal branch, RR Lyrae, and Cepheids. The ‘wdstars’ option only includes white dwarf stars.

  • filtername (str) – Filter to use. Options of u,g,r,i,z,y

run(slice_points)[source]

Given slice_points (dict containing metadata about each slice_point, including ra/dec), adds additional metadata at each slice_point and returns updated dict.

class rubin_sim.maf.maps.TrilegalDensityMap(filtername='r', nside=64, ext=True)[source]

Bases: BaseMap

Read and hold the cumulative stellar luminosity function for each slice point.

The stellar luminosity function comes from the TRILEGAL model.

Parameters:
  • filtername (str, opt) – Filter to use. Options of u,g,r,i,z,y. Default r.

  • nside (int, opt) – The HEALpix nside (can be 64 or 128). Default 64.

  • ext (bool, opt) – Use the full sky maps. Default True.

Notes

The underlying stellar luminosity function map is available in a variety of nsides, and contains stars per sq degree at a series of magnitudes (the map contains starLumFunc_ and starMapBins_). For slice points which do not match one of the native nside options, the map uses the nearest healpix point on the specified nside grid.

run(slice_points)[source]

Given slice_points (dict containing metadata about each slice_point, including ra/dec), adds additional metadata at each slice_point and returns updated dict.

rubin_sim.maf.maps.ebv_3d_hp(nside, map_file=None, ra=None, dec=None, pixels=None, interp=False)[source]

Reads and saves a 3d dust extinction file from disk, return extinction at specified points (ra/dec/ or pixels).

Parameters:
  • nside (int) – Healpixel resolution (2^x).

  • map_file (str, opt) – Path to dust map file.

  • ra (np.ndarray or float, opt) – RA (can take numpy array). Default None sets up healpix array of nside. Radians.

  • dec (np.ndarray or float, opt) – Dec (can take numpy array). Default None set up healpix array of nside. Radians.

  • pixels (np.ndarray, opt) – Healpixel IDs, to sub-select particular healpix points. Default uses all points. Easiest way to access healpix values. Note that the pixels in the healpix array MUST come from a h ealpix grid with the same nside as the ebv_3d_hp map. Using different nsides can potentially fail silently.

  • interp (bool, opt) – Should returned values be interpolated (True) or just nearest neighbor (False). Default False.

rubin_sim.maf.maps.galplane_priority_map(nside=64, get_keys=False, ra=None, dec=None, pixels=None, interp=False, map_path=None, use_alt_maps=False)[source]

Reads and saves the galactic plane priority maps.

Parameters:
  • nside (int) – Healpixel resolution (2^x). At present, this must be 64.

  • get_keys (bool, opt) – Set this to True to retrieve only the keys (such as the science map names) for the maps. Default False.

  • ra (np.ndarray or float, opt) – RA (can take numpy array). Default None sets up healpix array of nside. Radians.

  • dec (np.ndarray or float, opt) – Dec (can take numpy array). Default None set up healpix array of nside. Radians.

  • pixels (np.ndarray, opt) – Healpixel IDs, to sub-select particular healpix points. Default uses all points. Easiest way to access healpix values. Note that the pixels in the healpix array MUST come from a healpix grid with the same nside as the galactic plane priority map. Using different nsides can potentially fail silently.

  • interp (bool, opt) – Should returned values be interpolated (True) or just nearest neighbor (False). Default False.

  • map_path (str, opt) – Path to directory containing dust map files. Default None, uses $RUBIN_SIM_DATA_DIR/maps.

  • use_alt_maps (bool, opt) – Use the priority_GalPlane_footprint_alt_map_data_{ugrizysum}.fits files instead of the default priority_galPlane_footprint_map_data_{ugrizysum}.fits files.

rubin_sim.maf.maps.get_x_at_nearest_y(x, y, x_goal)[source]

Given a goal x value, find y values at the closest x value.

This could be used to fetch the nearest ebv value at a given distance, or the nearest distance to a given m-Mo value, for example.

Parameters:
  • x (np.array) – Can be either a map with x at each point in the map (2d array) or the x at a single point of the map (1d array)

  • y (np.array) – Can be either a map with y at each point in the map (2d array) or the y at a single point of the map (1d array) - but should match x dimensionality

  • x_goal (`float’) – The goal x value to look for the nearest y value

Returns:

x_closest, y_closest – 1-d array of x and y (single value or over map).

Return type:

np.array, np.array

rubin_sim.maf.maps.gp_priority_map_components_to_keys(filtername, science_map)[source]

A convenience function to help keep the map key formats in sync in various places.