xdust.grainpop

The SingleGrainPop object is used to model a population of dust grains based on three distinct properties:

Furthermore, the GrainPop object contains a list of SingleGrainPop objects, which can be called upon using keys, like a dictionary. Keys have to be specified when the GrainPop object is initialized.

Module provides

SingleGrainPop

class xdust.grainpop.SingleGrainPop(dtype, cmtype, stype, shape='Sphere', md=0.0001, scatm_from_file=None, **kwargs)[source]

Bases: GrainDist

SingleGrainPop unifies the grain size distribution (its parent class) with extinction model calculations. It provides attributes and convenience functions for easy access to frequently needed information. Only one dust composition can be modeled at a time.

Parameters:
  • dtype (string or custom xdust.graindist.sizedist) – Defines the grain radius distribution, string options: ‘Grain’, ‘Powerlaw’, ‘ExpCutoff’

  • cmtype (string or custom xdust.graindist.composition) – Defines the optical constants and material density of the compound, string options: ‘Drude’, ‘Silicate’, ‘Graphite’

  • stype (string or custom xdust.scatteringmodel) – Defines what extinction model calculator to use, string options: ‘RG’ (Rayleigh-Gans), ‘Mie’ (Mie scattering)

  • shape (string) – Only ‘Sphere’ is supported, some day might be used to define a custom shape

  • md (float) – Dust mass column [g cm^-2]

  • scatm_from_file (string) – If provided, will read in a scattering model from a FITS file, and use the scattering model parameters and scattering properties from the file.

  • **kwargs – Extra inputs passed to GrainDist.__init__.

Note

If an input for scatm_from_file is provided, then the stype input will be ignored.

lam

wavelength or energy used for the extinction computation

Type:

astropy.units.Quantity

tau_sca

scattering optical depth for this grain population

Type:

numpy.ndarray float

tau_abs

absorption optical depth for this grain population

Type:

numpy.ndarray float

tau_ext

extinction (scattering + absorption) optical depth for this grain population

Type:

numpy.ndarray float

diff

[cm^2 ster^-1] differential scattering cross-section as a function of wavelength/energy, grain size, and angle (NE x NA x NTH)

Type:

astropy.units.Quantity

int_diff

[ster^-1] differential cross-section integrated over grain size distribution, \(d au/d\Omega\) (NE x NTH)

Type:

astropy.units.Quantity

calculate_ext(lam, theta=0.0, **kwargs)[source]

Calculate the extinction model.

Parameters:
  • lam (astropy.units.Quantity or numpy.ndarray) – Wavelength or energy values for calculating the cross-sections; if no units specified, defaults to keV

  • theta (astropy.units.Quantity or numpy.ndarray or float) – Scattering angles for computing the differential scattering cross-section; if no units specified, defaults to radian.

  • **kwargs – Passed to self.scatm.calculate.

info()[source]

Print information about this grain population

plot_ext(ax, keyword, unit=None, **kwargs)[source]

Plot the extinction properties of the grain population.

Parameters:
  • ax (matplotlib.pyplot.axes object)

  • keyword (str) – Extinction value(s) to plot. Options: 'ext', 'sca', 'abs', 'all'.

  • unit (str, optional) – Unit for the x-axis, parsable by astropy.units. If None, defaults to the unit of self.lam.

  • **kwargs – Passed to ax.legend().

plot_sdist(ax, **kwargs)[source]

Plot information about the grain size distribution (calls GrainDist.plot)

Parameters:

ax (matplotlib.pyplot.axes object)

write_extinction_table(outfile, **kwargs)[source]

Write the contents of the extinction calculation to a FITS file. (Runs ScatteringModel.write_table)

Parameters:
  • outfile (str) – Name of file to write.

  • **kwargs – Passed to self.scatm.write_table.

GrainPop

class xdust.grainpop.GrainPop(gpoplist, keys=None, description='Custom_GrainPopDict')[source]

Bases: object

A collection of SingleGrainPop objects. Each SingleGrainPop represents a different composition (or perhaps different geometries of grain size distribution). Each SingleGrainPop object has a label string, and can be accessed in the same was as key-value pairs are accessed in a Python dictionary.

Parameters:
  • gpoplist (Python list of SingleGrainPop objects) – Will be paired, in order, with the values in keys

  • keys (Python list of strings) – Labels for each SingleGrainPop object. (Default: None, will make the keys a list of integers starting with 0)

  • description (string) – A description for this collection

keys

Labels for each SingleGrainPop object.

Type:

Python list of strings

gpoplist

Paired, in order, with the values in keys

Type:

Python list of SingleGrainPop objects

description

A description for this collection

Type:

string

lam

Wavelength or energy used for the extinction computation

Type:

astropy.units.Quantity

md

Total dust mass column [g cm^-2], sum of the md values from each SingleGrainPop in the collection

Type:

float

tau_ext

Total extinction optical depth as a function of wavelength / energy

Type:

numpy.ndarray

tau_sca

Total scattering optical depth as a function of wavelength / energy

Type:

numpy.ndarray

tau_abs

Total absorption optical depth as a function of wavelength / energy

Type:

numpy.ndarray

calculate_ext(lam, **kwargs)[source]

Calculate the extinction model.

Parameters:
  • lam (astropy.units.Quantity or numpy.ndarray) – Wavelength or energy values for calculating the cross-sections; if no units specified, defaults to keV.

  • theta (astropy.units.Quantity or numpy.ndarray or float) – Scattering angles for computing the differential scattering cross-section; if no units specified, defaults to radian.

  • **kwargs – Passed to each SingleGrainPop.calculate_ext.

info(key=None)[source]

Print information about this collection of grain populations

Parameters:

key (int or string) – The key-value for the SingleGrainPopulation of interest. If None, systematically prints information for every SingleGrainPop in the collection.

property md

Return the sum of the md values from each SingleGrainPop

plot_ext(ax, keyword, unit=None, **kwargs)[source]

Plot the sum of the extinction properties across all grain populations

Parameters:
  • ax (matplotlib.pyplot.axes object)

  • keyword (str) – Extinction value(s) to plot. Options: 'ext', 'sca', 'abs', 'all'.

  • unit (str, optional) – Unit for the x-axis, parsable by astropy.units. If None, defaults to the unit of self.lam.

  • **kwargs – Passed to ax.legend().

property tau_abs

Return the sum of the tau_abs values from each SingleGrainPop

property tau_ext

Return the sum of the tau_ext values from each SingleGrainPop

property tau_sca

Return the sum of the tau_sca values from each SingleGrainPop

Helper functions

xdust.grainpop.make_MRN(amin=0.005, amax=0.3, p=3.5, md=0.0001, fsil=0.6, **kwargs)[source]

Builds a xdust.grainpop object describing an MRN dust grain size distribution, which is a mixture of silicate and graphite grains. Applies the 1/3 parallel, 2/3 perpendicular assumption of graphite grain orientations.

Parameters:
  • amin (astropy.units.Quantity or float) – Minimum grain radius; if a float, micron units assumed

  • amax (astropy.units.Quantity or float) – Maximum grain radius; if a float, micron units assumed

  • p (float) – Powerlaw slope for grain size distribution

  • md (float) – Dust mass column [g cm^-2]

  • fsil (float) – Fraction of dust mass in silicate grains

  • **kwargs – Passed to graindist.sizedist.Powerlaw().

Returns:

A xdust.grainpop with keys 'sil', 'gra_para', and 'gra_perp' for the silicate, graphite parallel, and graphite perpendicular grain populations, respectively.

Return type:

GrainPop

xdust.grainpop.make_MRN_RGDrude(amin=0.005, amax=0.3, p=3.5, rho=3.0, md=0.0001, **kwargs)[source]

Builds a SingleGrainPop object describing an MRN dust grain size distribution, but uses Rayleigh-Gans scattering with the Drude approximation, which approximates the dust grain as a sphere of free electrons.

Parameters:
  • amin (astropy.units.Quantity or float) – Minimum grain radius; if a float, micron units assumed

  • amax (astropy.units.Quantity or float) – Maximum grain radius; if a float, micron units assumed

  • p (float) – Powerlaw slope for grain size distribution

  • rho (float) – Density of the dust grain material [g cm^-3]

  • md (float) – Dust mass column [g cm^-2]

  • **kwargs – Passed to graindist.sizedist.Powerlaw().

Returns:

A SingleGrainPop using the 'RG' scattering model and 'Drude' composition.

Return type:

SingleGrainPop