dust#
- pinballrt.dust.load(filename, device='cpu')#
Load a Dust object from a file or state_dict.
- Parameters:
- filenamestr, dict, or Dust
The filename to load the Dust object from, or a state_dict, or a Dust object.
- devicestr
The device to load the Dust object onto.
- class pinballrt.dust.Dust(lam=None, kabs=None, ksca=None, amax=None, p=None, device='cpu')#
Bases:
LightningDataModuleInitialize the Dust module with wavelength, absorption, and scattering coefficients.
- Parameters:
- lamastropy.units.Quantity
Wavelengths at which the dust opacities are defined.
- kabsastropy.units.Quantity
Absorption coefficients of the dust.
- kscaastropy.units.Quantity
Scattering coefficients of the dust.
- amaxastropy.units.Quantity
Maximum grain size for the size distribution.
- pfloat
Power-law index for the grain size distribution.
- devicestr
Device to run the computations on (e.g., “cpu” or “cuda”).
Methods Summary
learn([model, nsamples, test_split, ...])Learn a model for either the random_nu function or the ml_step function.
fit([epochs, batch_size, num_workers, ckpt_path])Run the model fit.
test_model([plot])Test the model fit.
run_dust_simulation([nphotons, tau_range, ...])Run a dust simulation that can be used to learn an ML-step model with the given parameters.
plot_opacity_model([model])Plot the learned opacity model against the interpolated opacity.
Plot the learned Planck mean opacity model against the interpolated Planck mean opacity.
plot_random_nu_model([nsamples])Plot samples drawn from the learned random_nu model against samples drawn from the random_nu_manual function.
plot_ml_step([tau, temperature, amax, p, ...])Plot the samples drawn from a sphere with the provided optical depth, temperature, and frequency.
save(filename)Save the Dust object to a file.
Methods Documentation
- learn(model='random_nu', nsamples=200000, test_split=0.1, valid_split=0.2, hidden_units=(48, 48, 48), tau_range=(3.0, 10000.0), temperature_range=(<Quantity 0.1 K>, <Quantity 10000. K>), amax_range=(<Quantity 1. micron>, <Quantity 10. cm>), p_range=(2.5, 4.5), nu_range=None, overwrite=False)#
Learn a model for either the random_nu function or the ml_step function.
- Parameters:
- modelstr
The model to learn. Either “random_nu” or “ml_step”.
- nsamplesint
The total number of samples to generate for the learning process (including validation and testing)
- test_splitfloat
The fraction of the samples to use for testing.
- valid_splitfloat
The fraction of the remaining samples (after testing) to use for validation.
- hidden_unitstuple
The number of hidden units in each layer of the neural network.
- tau_rangetuple
The range of optical depths to sample from for the ml_step model.
- temperature_rangetuple
The range of temperatures to sample from for the ml_step model.
- amax_rangetuple
The range of maximum grain sizes to sample from for the ml_step model.
- p_rangetuple
The range of power-law indices to sample from for the ml_step model.
- nu_rangetuple
The range of frequencies to sample from (in GHz) for the ml_step model. If None, use the full range of the dust opacities.
- fit(epochs=10, batch_size=100, num_workers=1, ckpt_path=None)#
Run the model fit.
- test_model(plot=False)#
Test the model fit.
- run_dust_simulation(nphotons=1000, tau_range=(3.0, 10000.0), temperature_range=(<Quantity 0.1 K>, <Quantity 10000. K>), amax_range=(<Quantity 1. micron>, <Quantity 10. cm>), p_range=(2.5, 4.5), nu_range=None, use_ml_step=False, position=0)#
Run a dust simulation that can be used to learn an ML-step model with the given parameters.
- Parameters:
- nphotonsint
The number of photons to simulate.
- tau_rangetuple
The range of optical depths to sample from (in log10).
- temperature_rangetuple
The range of temperatures to sample from (in log10).
- amax_rangetuple
The range of maximum grain sizes to sample from (in log10).
- p_rangetuple
The range of power-law indices to sample from.
- nu_rangetuple
The range of frequencies to sample from (in GHz). If None, use the full range of the dust opacities.
- plot_opacity_model(model='kabs')#
Plot the learned opacity model against the interpolated opacity.
- Parameters:
- modelstr
The model to plot. Either “kabs” or “ksca”.
- plot_pmo_model()#
Plot the learned Planck mean opacity model against the interpolated Planck mean opacity.
- plot_random_nu_model(nsamples=100000)#
Plot samples drawn from the learned random_nu model against samples drawn from the random_nu_manual function.
- Parameters:
- nsamplesint
The number of samples to draw from each model for the plot.
- plot_ml_step(tau=30.0, temperature=<Quantity 100. K>, amax=<Quantity 1. micron>, p=3.5, nu=<Quantity 1000. GHz>, nsamples=1000, plot_columns=array(['log10_nu', 'log10_Eabs', 'log10_tau', 'yaw', 'pitch', 'direction_yaw', 'direction_pitch'], dtype='<U15'))#
Plot the samples drawn from a sphere with the provided optical depth, temperature, and frequency.
- Parameters:
- taufloat
The log-optical depth to use for the samples.
- temperaturefloat
The temperature to use for the samples.
- amaxfloat
The maximum grain size to use for the samples.
- pfloat
The power-law index to use for the samples.
- nufloat
The frequency to use for the samples.
- nsamplesint
The number of samples to generate.
- plot_columnsnumpy.ndarray
The columns to plot in the triangle plots.
- save(filename)#
Save the Dust object to a file.
- Parameters:
- filenamestr
The filename to save the Dust object to.