To use the astrodust
package, you can either predownload the two required models into a models
directory in the current working directory, or the package will automatically download the models for you when you instaniate the class, from our repository at Zenodo [https://zenodo.org/record/4662910#.YHy7FmRue3I]. After defining your input parameters, call the predict
function, and the result will be an array of predictions for 171 size bins.
predict
method¶Parameter Name | Data Type | Description |
---|---|---|
r | float | Distance from central star (AU) |
alpha | float | Turbulence parameter |
d2g | float | Dust-to-gas ratio in disk |
sigma | float | Surface density of gas (g/cm^2) |
tgas | float | Tempterature of gas (K) |
t | int | Absolute time (seconds) |
delta_t | int | Change in time at which prediction is being made (seconds) |
input_bins | list | 171-length array of initial dust densities |
Note that as of v.1.0.0 of astrodust
, mstar
(the mass of the central star) is not included, since in our training, we always had a stellar mass of 1. Future versions of the package may include this as a parameter if we train on variable stellar masses.
Let's take a look at how to install and import this package, and make a simple prediction about the evolution of dust particles in a protoplanetary disk.
First, we use a pip install
to fetch the package from the test pypi site where it's hosted. We include the --upgrade
command to make sure we get the most up-to-date version of the package, if we already had a previous version.
!pip install astrodust --upgrade
Requirement already up-to-date: astrodust in /Users/andrezazz/opt/anaconda3/lib/python3.8/site-packages (1.0.2) Requirement already satisfied, skipping upgrade: xgboost>=1.2 in /Users/andrezazz/opt/anaconda3/lib/python3.8/site-packages (from astrodust) (1.3.3) Requirement already satisfied, skipping upgrade: scikit-learn>=0.24.0 in /Users/andrezazz/opt/anaconda3/lib/python3.8/site-packages (from astrodust) (0.24.1) Requirement already satisfied, skipping upgrade: joblib>=1.0 in /Users/andrezazz/opt/anaconda3/lib/python3.8/site-packages (from astrodust) (1.0.1) Requirement already satisfied, skipping upgrade: tqdm>=4.50 in /Users/andrezazz/opt/anaconda3/lib/python3.8/site-packages (from astrodust) (4.50.2) Requirement already satisfied, skipping upgrade: numpy in /Users/andrezazz/opt/anaconda3/lib/python3.8/site-packages (from xgboost>=1.2->astrodust) (1.19.2) Requirement already satisfied, skipping upgrade: scipy in /Users/andrezazz/opt/anaconda3/lib/python3.8/site-packages (from xgboost>=1.2->astrodust) (1.5.2) Requirement already satisfied, skipping upgrade: threadpoolctl>=2.0.0 in /Users/andrezazz/opt/anaconda3/lib/python3.8/site-packages (from scikit-learn>=0.24.0->astrodust) (2.1.0)
Next, it's important to set the working directory correctly, since we need to make sure the code can find the directory which contains the pre-trained models. I have this in a higher directory, and this can and should be edited as needed.
%%capture
%cd '../../'
Now we import the astrodust
package
import astrodust
Next, we'll perform one prediction. First, set your input parameters. Then, we instantiate the DustModel
class from the package, and finally we make our prediction using the predict
method.
# define input parameters, according to table at top.
r = 439.38752621208494
alpha = 0.01
d2g = 0.001
sigma = 0.18457689506039313
tgas = 4.7706344303819845
t = 0
delta_t = 12520302808301.016
input_bins = [5.28829916e-022, 5.49518961e-022, 5.71017408e-022, 5.93356925e-022,
6.16570415e-022, 6.40692070e-022, 6.65757420e-022, 6.91803384e-022,
7.18868326e-022, 7.46992111e-022, 7.76216163e-022, 8.06583528e-022,
8.38138934e-022, 8.70928860e-022, 9.05001603e-022, 9.40407351e-022,
9.77198253e-022, 1.01542850e-021, 1.05515440e-021, 1.09643447e-021,
1.13932952e-021, 1.18390271e-021, 1.23021971e-021, 1.27834874e-021,
1.32836069e-021, 1.38032922e-021, 1.43433088e-021, 1.49044521e-021,
1.54875486e-021, 1.60934572e-021, 1.67230703e-021, 1.73773153e-021,
1.80571559e-021, 1.87635935e-021, 1.94976685e-021, 2.02604622e-021,
2.10530982e-021, 2.18767439e-021, 2.27326125e-021, 2.36219646e-021,
2.45461103e-021, 2.55064107e-021, 2.65042803e-021, 2.75411888e-021,
2.86186635e-021, 2.97382916e-021, 3.09017221e-021, 3.21106686e-021,
3.33669119e-021, 3.46723024e-021, 3.60287628e-021, 3.74382910e-021,
3.89029632e-021, 4.04249367e-021, 4.20064534e-021, 4.36498426e-021,
4.53575250e-021, 4.71320159e-021, 4.89759289e-021, 5.08919801e-021,
2.29624089e-119, 2.29624089e-119, 2.29624089e-119, 2.29624089e-119,
2.29624089e-119, 2.29624089e-119, 2.29624089e-119, 2.29624089e-119,
2.29624089e-119, 2.29624089e-119, 2.29624089e-119, 2.29624089e-119,
2.29624089e-119, 2.29624089e-119, 2.29624089e-119, 2.29624089e-119,
2.29624089e-119, 2.29624089e-119, 2.29624089e-119, 2.29624089e-119,
2.29624089e-119, 2.29624089e-119, 2.29624089e-119, 2.29624089e-119,
2.29624089e-119, 2.29624089e-119, 2.29624089e-119, 2.29624089e-119,
2.29624089e-119, 2.29624089e-119, 2.29624089e-119, 2.29624089e-119,
2.29624089e-119, 2.29624089e-119, 2.29624089e-119, 2.29624089e-119,
2.29624089e-119, 2.29624089e-119, 2.29624089e-119, 2.29624089e-119,
2.29624089e-119, 2.29624089e-119, 2.29624089e-119, 2.29624089e-119,
2.29624089e-119, 2.29624089e-119, 2.29624089e-119, 2.29624089e-119,
2.29624089e-119, 2.29624089e-119, 2.29624089e-119, 2.29624089e-119,
2.29624089e-119, 2.29624089e-119, 2.29624089e-119, 2.29624089e-119,
2.29624089e-119, 2.29624089e-119, 2.29624089e-119, 2.29624089e-119,
2.29624089e-119, 2.29624089e-119, 2.29624089e-119, 2.29624089e-119,
2.29624089e-119, 2.29624089e-119, 2.29624089e-119, 2.29624089e-119,
2.29624089e-119, 2.29624089e-119, 2.29624089e-119, 2.29624089e-119,
2.29624089e-119, 2.29624089e-119, 2.29624089e-119, 2.29624089e-119,
2.29624089e-119, 2.29624089e-119, 2.29624089e-119, 2.29624089e-119,
2.29624089e-119, 2.29624089e-119, 2.29624089e-119, 2.29624089e-119,
2.29624089e-119, 2.29624089e-119, 2.29624089e-119, 2.29624089e-119,
2.29624089e-119, 2.29624089e-119, 2.29624089e-119, 2.29624089e-119,
2.29624089e-119, 2.29624089e-119, 2.29624089e-119, 2.29624089e-119,
2.29624089e-119, 2.29624089e-119, 2.29624089e-119, 2.29624089e-119,
2.29624089e-119, 2.29624089e-119, 2.29624089e-119, 2.29624089e-119,
2.29624089e-119, 2.29624089e-119, 2.29624089e-119, 2.29624089e-119,
2.29624089e-119, 2.29624089e-119, 2.29624089e-119]
# instatiate DustModel class
model = astrodust.DustModel()
# run one prediction
prediction_1 = model.predict(
r=r,
alpha=alpha,
d2g=d2g,
sigma=sigma,
tgas=tgas,
t=t,
delta_t=delta_t,
input_bins=input_bins
)
print(prediction_1)
/Users/andrezazz/opt/anaconda3/lib/python3.8/site-packages/sklearn/base.py:310: UserWarning: Trying to unpickle estimator DecisionTreeRegressor from version 0.24.0 when using version 0.24.1. This might lead to breaking code or invalid results. Use at your own risk. warnings.warn( /Users/andrezazz/opt/anaconda3/lib/python3.8/site-packages/sklearn/base.py:310: UserWarning: Trying to unpickle estimator RandomForestRegressor from version 0.24.0 when using version 0.24.1. This might lead to breaking code or invalid results. Use at your own risk. warnings.warn(
[1.97765142e-21 1.56065349e-21 1.42099185e-21 1.49975679e-21 1.48338650e-21 1.47482621e-21 1.47619477e-21 1.48807562e-21 1.48676915e-21 1.49142454e-21 1.50217702e-21 1.51716331e-21 1.53683547e-21 1.56097094e-21 1.58926102e-21 1.62116909e-21 1.65637202e-21 1.69904832e-21 1.74970647e-21 1.80081874e-21 1.84504076e-21 1.88961574e-21 1.92497753e-21 1.96226807e-21 2.00304033e-21 2.04519138e-21 2.08734247e-21 2.12909460e-21 2.16933497e-21 2.20692841e-21 2.24071039e-21 2.26946143e-21 2.27749291e-21 2.20211173e-21 2.11818848e-21 2.04710100e-21 2.03370823e-21 2.10698633e-21 2.25725469e-21 2.49403795e-21 2.93170391e-21 3.55777367e-21 4.11812086e-21 4.40252489e-21 4.36139776e-21 3.95311982e-21 3.27658606e-21 2.57216752e-21 2.03282690e-21 1.69458996e-21 1.51575696e-21 1.43378394e-21 1.43759306e-21 1.48534669e-21 1.52655211e-21 1.57228939e-21 1.60389857e-21 1.59656723e-21 1.51048278e-21 1.16993751e-21 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00]
We also want to be able to make a prediction about dust evolution, and know if the prediction is confident or not.
This package also contains a model that will predict whether the prediction is a good fit or not and will raise a warning if it may not be a good fit.
# set up input parameters
r = 1.9306872603126473
alpha = 0.0001
d2g = 0.0001
sigma = 633.6960864580715
tgas = 71.96876241379886
t = 0.0
delta_t = 31570593343.205635
input_bins = [1.60440369e-016, 1.66717165e-016, 1.73239525e-016, 1.80017054e-016,
1.87059736e-016, 1.94377944e-016, 2.01982457e-016, 2.09884476e-016,
2.18095640e-016, 2.26628044e-016, 2.35494255e-016, 2.44707333e-016,
2.54280848e-016, 2.64228900e-016, 2.74566144e-016, 2.85307804e-016,
2.96469702e-016, 3.08068280e-016, 3.20120621e-016, 3.32644477e-016,
3.45658296e-016, 3.59181244e-016, 3.73233242e-016, 3.87834987e-016,
4.03007985e-016, 4.18774586e-016, 4.35158012e-016, 4.52182396e-016,
4.69872813e-016, 4.88255320e-016, 5.07356993e-016, 5.27205968e-016,
5.47831480e-016, 5.69263909e-016, 5.91534825e-016, 6.14677030e-016,
6.38724612e-016, 6.63712990e-016, 6.89678971e-016, 7.16660801e-016,
7.44698223e-016, 7.73832533e-016, 8.04106645e-016, 8.35565149e-016,
8.68254383e-016, 9.02222494e-016, 9.37519517e-016, 9.74197440e-016,
1.01231029e-015, 1.05191420e-015, 1.09306751e-015, 1.13583083e-015,
1.18026714e-015, 1.22644191e-015, 1.27442315e-015, 1.32428152e-015,
1.37609046e-015, 1.42992629e-015, 1.48586830e-015, 1.54399889e-015,
6.96650708e-114, 6.96650708e-114, 6.96650708e-114, 6.96650708e-114,
6.96650708e-114, 6.96650708e-114, 6.96650708e-114, 6.96650708e-114,
6.96650708e-114, 6.96650708e-114, 6.96650708e-114, 6.96650708e-114,
6.96650708e-114, 6.96650708e-114, 6.96650708e-114, 6.96650708e-114,
6.96650708e-114, 6.96650708e-114, 6.96650708e-114, 6.96650708e-114,
6.96650708e-114, 6.96650708e-114, 6.96650708e-114, 6.96650708e-114,
6.96650708e-114, 6.96650708e-114, 6.96650708e-114, 6.96650708e-114,
6.96650708e-114, 6.96650708e-114, 6.96650708e-114, 6.96650708e-114,
6.96650708e-114, 6.96650708e-114, 6.96650708e-114, 6.96650708e-114,
6.96650708e-114, 6.96650708e-114, 6.96650708e-114, 6.96650708e-114,
6.96650708e-114, 6.96650708e-114, 6.96650708e-114, 6.96650708e-114,
6.96650708e-114, 6.96650708e-114, 6.96650708e-114, 6.96650708e-114,
6.96650708e-114, 6.96650708e-114, 6.96650708e-114, 6.96650708e-114,
6.96650708e-114, 6.96650708e-114, 6.96650708e-114, 6.96650708e-114,
6.96650708e-114, 6.96650708e-114, 6.96650708e-114, 6.96650708e-114,
6.96650708e-114, 6.96650708e-114, 6.96650708e-114, 6.96650708e-114,
6.96650708e-114, 6.96650708e-114, 6.96650708e-114, 6.96650708e-114,
6.96650708e-114, 6.96650708e-114, 6.96650708e-114, 6.96650708e-114,
6.96650708e-114, 6.96650708e-114, 6.96650708e-114, 6.96650708e-114,
6.96650708e-114, 6.96650708e-114, 6.96650708e-114, 6.96650708e-114,
6.96650708e-114, 6.96650708e-114, 6.96650708e-114, 6.96650708e-114,
6.96650708e-114, 6.96650708e-114, 6.96650708e-114, 6.96650708e-114,
6.96650708e-114, 6.96650708e-114, 6.96650708e-114, 6.96650708e-114,
6.96650708e-114, 6.96650708e-114, 6.96650708e-114, 6.96650708e-114,
6.96650708e-114, 6.96650708e-114, 6.96650708e-114, 6.96650708e-114,
6.96650708e-114, 6.96650708e-114, 6.96650708e-114, 6.96650708e-114,
6.96650708e-114, 6.96650708e-114, 6.96650708e-114, 6.96650708e-114,
6.96650708e-114, 6.96650708e-114, 6.96650708e-114]
# make prediction
prediction_2 = model.predict(
r=r,
alpha=alpha,
d2g=d2g,
sigma=sigma,
tgas=tgas,
t=t,
delta_t=delta_t,
input_bins=input_bins
)
print(prediction_2)
[1.76730631e-18 1.91802344e-18 2.04422428e-18 2.31097643e-18 2.53084426e-18 2.72927809e-18 2.95017580e-18 3.26417309e-18 3.60223436e-18 3.97820082e-18 4.39793442e-18 4.88048204e-18 5.42866693e-18 6.05249027e-18 6.76094423e-18 7.56799718e-18 8.48647579e-18 9.53124083e-18 1.07173671e-17 1.20616531e-17 1.35810941e-17 1.52929845e-17 1.72142031e-17 1.93610019e-17 2.17484550e-17 2.43901804e-17 2.72981158e-17 3.04824866e-17 3.39519450e-17 3.77139728e-17 4.17755748e-17 4.61443115e-17 5.08297001e-17 5.58449811e-17 6.12091657e-17 6.69491391e-17 7.31014260e-17 7.97130672e-17 8.68410233e-17 9.45496867e-17 1.02906488e-16 1.11976137e-16 1.21814559e-16 1.32463818e-16 1.43949208e-16 1.56279300e-16 1.69449255e-16 1.83447281e-16 1.98263751e-16 2.13901877e-16 2.30388195e-16 2.47780570e-16 2.66171748e-16 2.85687752e-16 3.06481957e-16 3.28726466e-16 3.52602020e-16 3.78286621e-16 4.05942843e-16 4.35707067e-16 3.94236849e-16 3.57955447e-16 3.23987693e-16 2.93631905e-16 2.67179947e-16 2.44351932e-16 2.24630543e-16 2.07487073e-16 1.92502831e-16 1.79369420e-16 1.67852665e-16 1.57762463e-16 1.48936318e-16 1.41232086e-16 1.34523969e-16 1.28700051e-16 1.23662334e-16 1.19366908e-16 1.15712302e-16 1.12649901e-16 1.10420634e-16 1.08437505e-16 1.07059889e-16 1.05793877e-16 1.05100595e-16 1.04609083e-16 1.04442611e-16 1.04321613e-16 1.03781441e-16 1.03349196e-16 1.02988420e-16 1.02671057e-16 1.02293956e-16 1.01650771e-16 1.00530913e-16 9.89359946e-17 9.64604424e-17 9.30712911e-17 9.03316950e-17 8.78328463e-17 8.59236867e-17 8.47129248e-17 8.45252293e-17 8.58340033e-17 8.87290108e-17 9.22879719e-17 9.59552135e-17 9.97109554e-17 1.03577185e-16 1.07810432e-16 1.12109732e-16 1.16907873e-16 1.22334059e-16 1.27961221e-16 1.33874314e-16 1.40029845e-16 1.46509654e-16 1.53526648e-16 1.61007225e-16 1.69008453e-16 1.77501613e-16 1.86702655e-16 1.96799837e-16 2.08122182e-16 2.21697119e-16 2.37983756e-16 2.57779853e-16 2.81287245e-16 3.08337793e-16 3.36995549e-16 3.64607001e-16 3.87252210e-16 4.03286436e-16 4.13366156e-16 4.16743174e-16 4.11676949e-16 3.95991602e-16 3.67050579e-16 3.22720434e-16 2.65690546e-16 2.05230308e-16 1.50866008e-16 1.08813114e-16 8.20847383e-17 6.96464328e-17 6.69648459e-17 6.91669476e-17 7.32625838e-17 7.81108234e-17 8.35612099e-17 8.99911552e-17 9.79509509e-17 1.07608288e-16 1.18403119e-16 1.28873208e-16 1.37083658e-16 1.41034297e-16 1.39527314e-16 1.31789427e-16 1.17371819e-16 9.76254677e-17 7.59724181e-17 5.57856147e-17 3.92501218e-17 2.85612212e-17 2.29033927e-17 2.37873248e-17 1.68311049e-16 5.52996586e-16 1.74448279e-15 1.15849930e-14]
/Users/andrezazz/opt/anaconda3/lib/python3.8/site-packages/astrodust/astrodust.py:124: UserWarning: For the given input paramters, the resulting prediction is most likely not accurate. warnings.warn("For the given input paramters, the resulting prediction is most likely not accurate.")
We see that we got a warning that this prediction might not be accurate, so we should likely return to more traditional means of investigating this particular set of parameters.