lightcurvelynx.astro_utils.dustmap

A wrapper for querying dust maps and returning E(B-V) values.

This module supports a variety of external dustmaps libaries, but was primarily designed to work with the dustmaps package: https://github.com/gregreen/dustmaps

Note that the dustmaps package is not included by default, because it uses dependencies that may not be compatible with all systems. Users can manually install dustmaps in their environment with “pip install dustmaps” or “conda install conda-forge::dustmaps”.

Classes

DustEBV

A wrapper that queries a dust map and returns the ebv for each location.

DustmapWrapper

A convenience wrapper for the dustmap package

ConstantHemisphereDustMap

A DustMap with a constant value in each hemisphere for testing

SFDMap

A dustmap using the sfdmap2 package.

Module Contents

class DustEBV(query_fn, ra=None, dec=None, **kwargs)[source]

Bases: lightcurvelynx.base_models.FunctionNode

A wrapper that queries a dust map and returns the ebv for each location.

This wrapper is designed to work with multiple dust map implementations by providing a standard interface.

query_fn

The function to query the dust map ebv value given (RA, dec).

Type:

function

Parameters:
  • query_fn (function) – The function to query the dust map ebv value given (RA, dec).

  • RA (parameter) – The object’s right ascension (in degrees).

  • dec (parameter) – The object’s declination (in degrees).

  • **kwargs (dict, optional) – Any additional keyword arguments.

class DustmapWrapper(dust_map, ra=None, dec=None, ebv_func=None, **kwargs)[source]

Bases: DustEBV, citation_compass.CiteClass

A convenience wrapper for the dustmap package https://github.com/gregreen/dustmaps

The DustmapWrapper is designed to take dust map objects from the dustmaps package, but can be used with any object that has a query(coords: SkyCoord) method.

Parameters:
  • dust_map (DustMap object) – The dust map. Since different dustmap’s query function may produce different outputs, you should include the corresponding ebv_func to transform the result into ebv if needed.

  • ebv_func (function, optional) – A function to translate the result of the dustmap query into an ebv. This is not needed for dustmaps that already produce ebv values.

  • RA (parameter) – The object’s right ascension (in degrees).

  • dec (parameter) – The object’s declination (in degrees).

  • **kwargs (dict, optional) – Any additional keyword arguments.

References

Green 2018, JOSS, 3(26), 695. https://github.com/gregreen/dustmaps

compute_ebv(ra, dec)[source]

Compute the E(B-V) value for a given location.

Parameters:
  • ra (float or np.array) – The object’s right ascension (in degrees).

  • dec (float or np.array) – The object’s declination (in degrees).

Returns:

ebv – The E(B-V) value or array of values.

Return type:

float or np.array

class ConstantHemisphereDustMap(north_ebv, south_ebv)[source]

A DustMap with a constant value in each hemisphere for testing and debugging purposes.

This class is designed to look like a DustMap object from the dustmaps package, so that it can be used to test DustmapWrapper.

north_ebv[source]

The DustMap’s ebv value at all points in the Northern Hemisphere.

Type:

float

south_ebv[source]

The DustMap’s ebv value at all points in the Southern Hemisphere.

Type:

float

north_ebv[source]
south_ebv[source]
compute_ebv(ra, dec)[source]

Compute the E(B-V) value for a given location.

Parameters:
  • ra (float or np.array) – The object’s right ascension (in degrees).

  • dec (float or np.array) – The object’s declination (in degrees).

Returns:

ebv – The E(B-V) value or array of values.

Return type:

float or np.array

query(coords)[source]

A query function to match the DustMap interface so that we can pass ConstantHemisphereDustMap into DustmapWrapper for testing purposes.

Note

This shouldn’t be used in production code. Use the compute_ebv() function directly.

Parameters:

coords (SkyCoord) – The object’s coordinates.

Returns:

ebv – The E(B-V) value or array of values.

Return type:

float or np.array

class SFDMap(data_dir=None, ra=None, dec=None, **kwargs)[source]

Bases: DustEBV

A dustmap using the sfdmap2 package.

This does not need to be used with DustmapWrapper, but rather is a standalone ParameterizedNode.

Note

If the dustmap data is not present in “data/dustmaps/sfdmap2”, it will automatically be downloaded there when the class is instantiated.

Citations

Software https://github.com/AmpelAstro/sfdmap2 Forked from https://github.com/kbarbary/sfdmap Dust map data from Schlegel, Finkbeiner and Davis (1998).

dustmap[source]

The dust map object.

Type:

sfdmap.SFDMap

Parameters:
  • data_dir (str, optional) – The directory containing the dust map data files. If None, the default directory will be used.

  • RA (parameter) – The object’s right ascension (in degrees).

  • dec (parameter) – The object’s declination (in degrees).

  • **kwargs (dict, optional) – Any additional keyword arguments.

dustmap[source]
compute_ebv(ra, dec)[source]

Compute the E(B-V) value for a given location.

Parameters:
  • ra (float or np.array) – The object’s right ascension (in degrees).

  • dec (float or np.array) – The object’s declination (in degrees).

Returns:

ebv – The E(B-V) value or array of values.

Return type:

float or np.array