Combining Models¶
Now we might want to combine different models together. For example, we might want to fit a transit simultaneously with its systematics (polynomials in time, x, y, background etc.). This is very similar to the Transit and Polynomial tutorials, so if you haven't looked at those tutorials I recommend you do before this one!
# import chromatic_fitting of course!
from chromatic_fitting import *
# import any prior distributions we want to use for our parameters - I've chosen Normal and Uniform from pymc3
# and QuadLimbDark and ImpactParameter from exoplanet
from pymc3 import Normal, Uniform
from exoplanet import QuadLimbDark, ImpactParameter
# import astropy table just for this tutorial (pandas dataframes don't show up nicely on the docs pages!)
from astropy.table import Table
plt.matplotlib.style.use('default')
Running chromatic_fitting v0.0.2! This program is running on: Python v3.9.12 (main, Jun 1 2022, 06:34:44) [Clang 12.0.0 ] numpy v1.22.1 chromatic v0.3.14 pymc3 v3.11.5 pymc3_ext v0.1.1 exoplanet v0.5.2
Generate some simulated data. This time we will use the handy .inject_systematics() and .inject_noise() functions in chromatic
# create a basic simulated data set
s = SimulatedRainbow()
# inject a transit and noise as well as systematics in x, y, background and time.
s = s.inject_transit(planet_radius=np.linspace(0.2, 0.15, s.nwave)).inject_noise(signal_to_noise=500).inject_systematics(amplitude=0.005)
# show all the Rainbow.fluxlike quantities:
s.imshow_quantities();
# finally, we will bin our lightcurves to make this tutorial run faster!
s = s.bin(nwavelengths=int(s.nwave/5), dt=5 * u.minute)
0%| | 0/231 [00:00<?, ?it/s]
0%| | 0/61 [00:00<?, ?it/s]
Set up the transit and polynomial models. This is where we can set the distributions for every parameter, the names of the models, the degree of the polynomials, the variables we want to relate the polynomials to, etc. Here we decided to just model linear polynomials (with degree=1) for each systematic variable:
# set up transit model:
t = TransitModel()
# t.initialize_empty_model()
t.setup_parameters(
period=1,
epoch=Fitted(Uniform,lower=-0.05,upper=0.05),
stellar_radius = Fitted(Uniform, lower=0.8, upper=1.2,testval=1),
stellar_mass =Fitted(Uniform, lower=0.8, upper=1.2,testval=1),
radius_ratio=WavelikeFitted(Normal, mu=0.1, sigma=0.05),
impact_parameter=Fitted(ImpactParameter,ror=0.15,testval=0.44),
limb_darkening=Fitted(QuadLimbDark,testval=[0.05,0.35]),
baseline = 1.0
)
# set up time polynomial model:
b = PolynomialModel(degree=1, name='stime')
# b.initialize_empty_model()
b.setup_parameters(
p_0 = 1.0,
p_1 = Fitted(Normal,mu=0.0,sigma=0.01),
)
# set up x polynomial model:
b_x = PolynomialModel(degree=1, independant_variable="x", name='sx')
# b_x.initialize_empty_model()
b_x.setup_parameters(
p_1 = Fitted(Normal,mu=0.0,sigma=0.01),
)
# set up y polynomial model:
b_y = PolynomialModel(degree=1, independant_variable="y", name='sy')
# b_y.initialize_empty_model()
b_y.setup_parameters(
p_1 = Fitted(Normal,mu=0.0,sigma=0.01),
)
# set up bkg polynomial model:
b_bkg = PolynomialModel(degree=1, independant_variable="background", name='sbkg')
# b_bkg.initialize_empty_model()
b_bkg.setup_parameters(
p_1 = Fitted(Normal,mu=0.0,sigma=0.01),
)
We can combine the models by using the standard arithmetic operators: +, -, and /. In this case I will multiply the transit model by the sum of all the systematic polynomials. Note: we have to be careful here not to have multiple different variables that all describe some constant offset.* For example, in the transit model we have the 'baseline' parameter that determines the out-of-transit constant flux. But in the polynomials we can also fit for the 0th order flux, 'p_0'. We should be careful not to fit for both! (By default 'p_0' will be set to 0.0 in the models where we don't define it.)
cmod = t * (b + b_x + b_y + b_bkg)
cmod
<chromatic combined model 'combined' 🌈, models: <chromatic polynomial model 'stime' 🌈> + <chromatic polynomial model 'sx' 🌈> + <chromatic polynomial model 'sy' 🌈> + <chromatic polynomial model 'sbkg' 🌈> * <chromatic transit model 'transit' 🌈>
The individual models will be stored in a dictionary under .chromatic_models:
cmod._chromatic_models
{'stime': <chromatic polynomial model 'stime' 🌈>,
'sx': <chromatic polynomial model 'sx' 🌈>,
'sy': <chromatic polynomial model 'sy' 🌈>,
'sbkg': <chromatic polynomial model 'sbkg' 🌈>,
'transit': <chromatic transit model 'transit' 🌈>}
Let's see what parameters we have in our models:
cmod.summarize_parameters()
A CombinedModel itself does not have any parameters, however each of its constituent models do: stime_p_0 = <🧮 Fixed | 1.0 🧮> stime_p_1 = <🧮 Fitted Normal(mu=0.0, sigma=0.01, name='stime_p_1') 🧮> sx_p_0 = <🧮 Fixed | 0.0 🧮> sx_p_1 = <🧮 Fitted Normal(mu=0.0, sigma=0.01, name='sx_p_1') 🧮> sy_p_0 = <🧮 Fixed | 0.0 🧮> sy_p_1 = <🧮 Fitted Normal(mu=0.0, sigma=0.01, name='sy_p_1') 🧮> sbkg_p_0 = <🧮 Fixed | 0.0 🧮> sbkg_p_1 = <🧮 Fitted Normal(mu=0.0, sigma=0.01, name='sbkg_p_1') 🧮> transit_stellar_radius = <🧮 Fitted Uniform(lower=0.8, upper=1.2, testval=1, name='transit_stellar_radius') 🧮> transit_stellar_mass = <🧮 Fitted Uniform(lower=0.8, upper=1.2, testval=1, name='transit_stellar_mass') 🧮> transit_radius_ratio = <🧮 WavelikeFitted Normal(mu=0.1, sigma=0.05, name='transit_radius_ratio') for each wavelength 🧮> transit_period = <🧮 Fixed | 1 🧮> transit_epoch = <🧮 Fitted Uniform(lower=-0.05, upper=0.05, name='transit_epoch') 🧮> transit_baseline = <🧮 Fixed | 1.0 🧮> transit_impact_parameter = <🧮 Fitted ImpactParameter(ror=0.15, testval=0.44, name='transit_impact_parameter') 🧮> transit_eccentricity = <🧮 Fixed | 0.0 🧮> transit_omega = <🧮 Fixed | 1.5707963267948966 🧮> transit_limb_darkening = <🧮 Fitted QuadLimbDark(testval=[0.05, 0.35], name='transit_limb_darkening') 🧮>
Then we just attach the Rainbow data to the model and run .setup_lightcurves() and .setup_likelihood() as in the previous tutorials:
# attach the data to our model
cmod.attach_data(s)
# If we don't want to fit everything simultaneously we can change the optimization method (the options
# are "separate" or "white_light"). This has to be set BEFORE running .setup_lightcurves!
# cmod.choose_optimization_method('separate')
# The 'store_models' keyword can be useful later to speed up debugging/plotting, but it can slow
# down/break fitting for large numbers of wavelengths
cmod.setup_lightcurves(store_models=False)
# Finally use the observed data to fit the model (assuming Gaussian errors!)
cmod.setup_likelihood()
0%| | 0/5 [00:00<?, ?it/s]
If we look at our PyMC3 model we can see that it has a lot of parameters (the combination of all our models) to optimize! If we've chosen the separate wavelength fitting method (.choose_optimization_method("separate")) then ._pymc3_model will return a list of PyMC3 models (one for each wavelength).
print(cmod._pymc3_model)
stime_p_1 ~ Normal
sx_p_1 ~ Normal
sy_p_1 ~ Normal
sbkg_p_1 ~ Normal
transit_epoch_interval__ ~ TransformedDistribution
transit_impact_parameter_impact__ ~ TransformedDistribution
transit_stellar_radius_interval__ ~ TransformedDistribution
transit_stellar_mass_interval__ ~ TransformedDistribution
transit_limb_darkening_quadlimbdark__ ~ TransformedDistribution
transit_radius_ratio_w0 ~ Normal
transit_radius_ratio_w1 ~ Normal
transit_radius_ratio_w2 ~ Normal
transit_radius_ratio_w3 ~ Normal
transit_radius_ratio_w4 ~ Normal
transit_epoch ~ Uniform
transit_impact_parameter ~ ImpactParameter
transit_stellar_radius ~ Uniform
transit_stellar_mass ~ Uniform
transit_a_R* ~ Deterministic
transit_limb_darkening ~ QuadLimbDark
wavelength_0_data ~ Normal
wavelength_1_data ~ Normal
wavelength_2_data ~ Normal
wavelength_3_data ~ Normal
wavelength_4_data ~ Normal
We've got our polynomial parameters (stime_p_1, sx_p_1, sy_p_1, sbkg_p_1), our transit parameters that are wavelength-independant in this case (epoch, impact_parameter, stellar_radius, stellar_mass, a_R*, limb_darkening) and the wavelength-dependant parameters we've defined to be radius_ratio_w{N} only. The wavelength_{N}_data parameter just represents the fit of the data to the model at each wavelength (which we've defined to be a Normal distribution). If we've decided to store_models then we will also see a bunch of models!
But what do the actual light curves look like?
cmod.plot_lightcurves()
The summarize step has not been run yet. To include the 'best-fit' model please run {self}.summarize() before calling this step!
We can still see the transit for each wavelength, but it's clear that the systematics would affect any derivation of the transit parameters if we didn't model for these systematics!
PyMC3 Sampling¶
Now we can run the NUTS sampling for our light curves (first by optimizing our initial values)
# optimize for initial values!
opt = cmod.optimize(plot=False)
# put those initial values into the sampling and define the number of tuning and draw steps,
# as well as the number of chains. NOTE: if you do separate wavelength fitting then the number of steps
# is per wavelengths, not divided between the wavelengths!
cmod.sample(start=opt, tune=4000, draws=4000, cores=4, chains=4, return_inferencedata=False)
optimizing logp for variables: [transit_radius_ratio_w4, transit_radius_ratio_w3, transit_radius_ratio_w2, transit_radius_ratio_w1, transit_radius_ratio_w0, transit_limb_darkening, transit_stellar_mass, transit_stellar_radius, transit_impact_parameter, transit_epoch, sbkg_p_1, sy_p_1, sx_p_1, stime_p_1]
message: Desired error not necessarily achieved due to precision loss. logp: -1717106.2513462622 -> 2199.549971771612 Multiprocess sampling (4 chains in 4 jobs) NUTS: [transit_radius_ratio_w4, transit_radius_ratio_w3, transit_radius_ratio_w2, transit_radius_ratio_w1, transit_radius_ratio_w0, transit_limb_darkening, transit_stellar_mass, transit_stellar_radius, transit_impact_parameter, transit_epoch, sbkg_p_1, sy_p_1, sx_p_1, stime_p_1]
/Users/camu5866/opt/anaconda3/envs/chromaticfitting/lib/python3.9/site-packages/scipy/stats/_continuous_distns.py:624: RuntimeWarning: overflow encountered in _beta_ppf return _boost._beta_ppf(q, a, b) /Users/camu5866/opt/anaconda3/envs/chromaticfitting/lib/python3.9/site-packages/scipy/stats/_continuous_distns.py:624: RuntimeWarning: overflow encountered in _beta_ppf return _boost._beta_ppf(q, a, b) /Users/camu5866/opt/anaconda3/envs/chromaticfitting/lib/python3.9/site-packages/scipy/stats/_continuous_distns.py:624: RuntimeWarning: overflow encountered in _beta_ppf return _boost._beta_ppf(q, a, b) /Users/camu5866/opt/anaconda3/envs/chromaticfitting/lib/python3.9/site-packages/scipy/stats/_continuous_distns.py:624: RuntimeWarning: overflow encountered in _beta_ppf return _boost._beta_ppf(q, a, b) Sampling 4 chains for 4_000 tune and 4_000 draw iterations (16_000 + 16_000 draws total) took 731 seconds. There were 448 divergences after tuning. Increase `target_accept` or reparameterize. There were 2 divergences after tuning. Increase `target_accept` or reparameterize. The acceptance probability does not match the target. It is 0.9592361395084303, but should be close to 0.9. Try to increase the number of tuning steps. There were 8 divergences after tuning. Increase `target_accept` or reparameterize. There were 38 divergences after tuning. Increase `target_accept` or reparameterize. The estimated number of effective samples is smaller than 200 for some parameters.
At this stage the sampler may print out some warnings that we don't have enough tuning steps! We can then see the results of our sampling by running .summarize()
# print out a nice summary table (or list of tables) of our results!
cmod.summarize(round_to=7, hdi_prob=0.68, fmt='wide')
mean sd hdi_16% hdi_84% \
stime_p_1 0.049339 0.000200 0.049125 4.952880e-02
sx_p_1 0.001261 0.000029 0.001233 1.291200e-03
sy_p_1 0.007420 0.000014 0.007406 7.433200e-03
sbkg_p_1 -0.001715 0.000015 -0.001729 -1.698800e-03
transit_radius_ratio_w0 0.195240 0.000184 0.195042 1.954005e-01
transit_radius_ratio_w1 0.185358 0.000191 0.185177 1.855684e-01
transit_radius_ratio_w2 0.175103 0.000176 0.174916 1.752610e-01
transit_radius_ratio_w3 0.165385 0.000185 0.165184 1.655537e-01
transit_radius_ratio_w4 0.155327 0.000199 0.155139 1.555361e-01
transit_epoch -0.000017 0.000017 -0.000034 -4.000000e-07
transit_impact_parameter 0.023518 0.016733 0.000034 2.900050e-02
transit_stellar_radius 1.178083 0.012958 1.169949 1.199994e+00
transit_stellar_mass 0.848710 0.028156 0.804244 8.688209e-01
transit_a_R* 3.381649 0.003498 3.378232 3.385032e+00
transit_limb_darkening[0] 0.282498 0.012396 0.269608 2.940019e-01
transit_limb_darkening[1] 0.180402 0.026366 0.155023 2.070311e-01
mcse_mean mcse_sd ess_bulk \
stime_p_1 1.490000e-05 1.060000e-05 184.837395
sx_p_1 3.000000e-07 2.000000e-07 11797.329392
sy_p_1 1.000000e-07 1.000000e-07 9041.600916
sbkg_p_1 2.000000e-07 2.000000e-07 4716.183470
transit_radius_ratio_w0 4.900000e-06 3.500000e-06 1391.440092
transit_radius_ratio_w1 1.270000e-05 9.000000e-06 233.666216
transit_radius_ratio_w2 5.900000e-06 4.200000e-06 879.718617
transit_radius_ratio_w3 4.000000e-06 2.800000e-06 2224.877119
transit_radius_ratio_w4 1.660000e-05 1.170000e-05 148.049329
transit_epoch 2.000000e-07 1.000000e-07 11721.303948
transit_impact_parameter 1.691000e-04 1.195000e-04 7917.394022
transit_stellar_radius 8.298000e-04 5.874000e-04 221.913775
transit_stellar_mass 1.850100e-03 1.309800e-03 189.391291
transit_a_R* 4.150000e-05 2.930000e-05 6607.131765
transit_limb_darkening[0] 1.425000e-04 1.007000e-04 7598.550517
transit_limb_darkening[1] 2.262000e-04 1.611000e-04 13537.057601
ess_tail r_hat
stime_p_1 441.082720 1.016853
sx_p_1 6712.230612 1.004810
sy_p_1 7342.981067 1.004344
sbkg_p_1 11259.752053 1.002245
transit_radius_ratio_w0 10438.368716 1.004046
transit_radius_ratio_w1 2148.698163 1.014034
transit_radius_ratio_w2 9963.086431 1.006147
transit_radius_ratio_w3 10214.886672 1.003548
transit_radius_ratio_w4 174.677545 1.020150
transit_epoch 9182.658689 1.005004
transit_impact_parameter 5963.922156 1.003497
transit_stellar_radius 270.690914 1.013625
transit_stellar_mass 71.735716 1.016158
transit_a_R* 11118.913650 1.002467
transit_limb_darkening[0] 7343.149424 1.002188
transit_limb_darkening[1] 10037.522436 1.007783
An important parameter to look out for here to check whether your samplings have converged is r_hat. This rank normalized R-hat diagnostic tests for lack of convergence by comparing the variance between multiple chains to the variance within each chain. If convergence has been achieved, the between-chain and within-chain variances should be identicalm therefore, the closer it is to 1 the better the chance that your sampling successfully converged. If you're interested in the sampling see the PyMC3 docs for much more detail!
Then we can plot the posterior distributions and check that they look sensible (but beware if you've chosen the "separate" optimization method then it will plot the posteriors for every wavelength!):
# cmod.plot_posteriors()
But what are the results?? We can easily see the results using the handy .get_results() function:
results = cmod.get_results(uncertainty=['hdi_16%','hdi_84%'])
# results is a pandas dataframe, however, it doesn't show up properly on Git docs so I'll convert it to an
# astropy table
Table.from_pandas(results)
| stime_p_0 | stime_p_0_hdi_16% | stime_p_0_hdi_84% | stime_p_1 | stime_p_1_hdi_16% | stime_p_1_hdi_84% | wavelength | sx_p_0 | sx_p_0_hdi_16% | sx_p_0_hdi_84% | sx_p_1 | sx_p_1_hdi_16% | sx_p_1_hdi_84% | sy_p_0 | sy_p_0_hdi_16% | sy_p_0_hdi_84% | sy_p_1 | sy_p_1_hdi_16% | sy_p_1_hdi_84% | sbkg_p_0 | sbkg_p_0_hdi_16% | sbkg_p_0_hdi_84% | sbkg_p_1 | sbkg_p_1_hdi_16% | sbkg_p_1_hdi_84% | transit_baseline | transit_baseline_hdi_16% | transit_baseline_hdi_84% | transit_eccentricity | transit_eccentricity_hdi_16% | transit_eccentricity_hdi_84% | transit_epoch | transit_epoch_hdi_16% | transit_epoch_hdi_84% | transit_impact_parameter | transit_impact_parameter_hdi_16% | transit_impact_parameter_hdi_84% | transit_limb_darkening | transit_limb_darkening_hdi_16% | transit_limb_darkening_hdi_84% | transit_omega | transit_omega_hdi_16% | transit_omega_hdi_84% | transit_period | transit_period_hdi_16% | transit_period_hdi_84% | transit_radius_ratio | transit_radius_ratio_hdi_16% | transit_radius_ratio_hdi_84% | transit_stellar_mass | transit_stellar_mass_hdi_16% | transit_stellar_mass_hdi_84% | transit_stellar_radius | transit_stellar_radius_hdi_16% | transit_stellar_radius_hdi_84% |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object | object |
| 1.0 | 1.0 | 1.0 | 0.0493392 | 0.0491252 | 0.0495288 | 0.6427920004250605 micron | 0.0 | 0.0 | 0.0 | 0.0012609 | 0.0012333 | 0.0012912 | 0.0 | 0.0 | 0.0 | 0.0074197 | 0.0074063 | 0.0074332 | 0.0 | 0.0 | 0.0 | -0.0017147 | -0.0017287 | -0.0016988 | 1.0 | 1.0 | 1.0 | 0.0 | 0.0 | 0.0 | -1.66e-05 | -3.43e-05 | -4e-07 | 0.0235176 | 3.41e-05 | 0.0290005 | [0.2824984, 0.1804024] | [0.2696084, 0.1550234] | [0.2940019, 0.2070311] | 1.5707963267948966 | 1.5707963267948966 | 1.5707963267948966 | 1 | 1 | 1 | 0.1952398 | 0.1950422 | 0.1954005 | 0.8487097 | 0.8042439 | 0.8688209 | 1.1780828 | 1.169949 | 1.1999936 |
| 1.0 | 1.0 | 1.0 | 0.0493392 | 0.0491252 | 0.0495288 | 1.0182498867257213 micron | 0.0 | 0.0 | 0.0 | 0.0012609 | 0.0012333 | 0.0012912 | 0.0 | 0.0 | 0.0 | 0.0074197 | 0.0074063 | 0.0074332 | 0.0 | 0.0 | 0.0 | -0.0017147 | -0.0017287 | -0.0016988 | 1.0 | 1.0 | 1.0 | 0.0 | 0.0 | 0.0 | -1.66e-05 | -3.43e-05 | -4e-07 | 0.0235176 | 3.41e-05 | 0.0290005 | [0.2824984, 0.1804024] | [0.2696084, 0.1550234] | [0.2940019, 0.2070311] | 1.5707963267948966 | 1.5707963267948966 | 1.5707963267948966 | 1 | 1 | 1 | 0.185358 | 0.1851766 | 0.1855684 | 0.8487097 | 0.8042439 | 0.8688209 | 1.1780828 | 1.169949 | 1.1999936 |
| 1.0 | 1.0 | 1.0 | 0.0493392 | 0.0491252 | 0.0495288 | 1.6129831557857937 micron | 0.0 | 0.0 | 0.0 | 0.0012609 | 0.0012333 | 0.0012912 | 0.0 | 0.0 | 0.0 | 0.0074197 | 0.0074063 | 0.0074332 | 0.0 | 0.0 | 0.0 | -0.0017147 | -0.0017287 | -0.0016988 | 1.0 | 1.0 | 1.0 | 0.0 | 0.0 | 0.0 | -1.66e-05 | -3.43e-05 | -4e-07 | 0.0235176 | 3.41e-05 | 0.0290005 | [0.2824984, 0.1804024] | [0.2696084, 0.1550234] | [0.2940019, 0.2070311] | 1.5707963267948966 | 1.5707963267948966 | 1.5707963267948966 | 1 | 1 | 1 | 0.1751033 | 0.1749156 | 0.175261 | 0.8487097 | 0.8042439 | 0.8688209 | 1.1780828 | 1.169949 | 1.1999936 |
| 1.0 | 1.0 | 1.0 | 0.0493392 | 0.0491252 | 0.0495288 | 2.5550846553145785 micron | 0.0 | 0.0 | 0.0 | 0.0012609 | 0.0012333 | 0.0012912 | 0.0 | 0.0 | 0.0 | 0.0074197 | 0.0074063 | 0.0074332 | 0.0 | 0.0 | 0.0 | -0.0017147 | -0.0017287 | -0.0016988 | 1.0 | 1.0 | 1.0 | 0.0 | 0.0 | 0.0 | -1.66e-05 | -3.43e-05 | -4e-07 | 0.0235176 | 3.41e-05 | 0.0290005 | [0.2824984, 0.1804024] | [0.2696084, 0.1550234] | [0.2940019, 0.2070311] | 1.5707963267948966 | 1.5707963267948966 | 1.5707963267948966 | 1 | 1 | 1 | 0.165385 | 0.1651841 | 0.1655537 | 0.8487097 | 0.8042439 | 0.8688209 | 1.1780828 | 1.169949 | 1.1999936 |
| 1.0 | 1.0 | 1.0 | 0.0493392 | 0.0491252 | 0.0495288 | 4.0474431319424164 micron | 0.0 | 0.0 | 0.0 | 0.0012609 | 0.0012333 | 0.0012912 | 0.0 | 0.0 | 0.0 | 0.0074197 | 0.0074063 | 0.0074332 | 0.0 | 0.0 | 0.0 | -0.0017147 | -0.0017287 | -0.0016988 | 1.0 | 1.0 | 1.0 | 0.0 | 0.0 | 0.0 | -1.66e-05 | -3.43e-05 | -4e-07 | 0.0235176 | 3.41e-05 | 0.0290005 | [0.2824984, 0.1804024] | [0.2696084, 0.1550234] | [0.2940019, 0.2070311] | 1.5707963267948966 | 1.5707963267948966 | 1.5707963267948966 | 1 | 1 | 1 | 0.1553267 | 0.1551388 | 0.1555361 | 0.8487097 | 0.8042439 | 0.8688209 | 1.1780828 | 1.169949 | 1.1999936 |
We can also make a transmission spectrum table using .make_transmission_spectrum_table()
# this will show errors for the models that aren't transit and return a list!
transmission_spectrum = cmod.make_transmission_spectrum_table(uncertainty=['hdi_16%','hdi_84%'])
Table.from_pandas(transmission_spectrum)
Error applying make_transmission_spectrum_table to <chromatic polynomial model 'stime' 🌈>: 'PolynomialModel' object has no attribute 'make_transmission_spectrum_table' Error applying make_transmission_spectrum_table to <chromatic polynomial model 'sx' 🌈>: 'PolynomialModel' object has no attribute 'make_transmission_spectrum_table' Error applying make_transmission_spectrum_table to <chromatic polynomial model 'sy' 🌈>: 'PolynomialModel' object has no attribute 'make_transmission_spectrum_table' Error applying make_transmission_spectrum_table to <chromatic polynomial model 'sbkg' 🌈>: 'PolynomialModel' object has no attribute 'make_transmission_spectrum_table'
/Users/camu5866/opt/anaconda3/envs/chromaticfitting/lib/python3.9/site-packages/chromatic_fitting/models/transit.py:366: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
trans_table[f"{self.name}_radius_ratio_neg_error"] = (
| wavelength | transit_radius_ratio | transit_radius_ratio_neg_error | transit_radius_ratio_pos_error |
|---|---|---|---|
| object | object | object | object |
| 0.6427920004250605 micron | 0.1952398 | 0.00019759999999999223 | 0.0001607000000000136 |
| 1.0182498867257213 micron | 0.185358 | 0.00018139999999999823 | 0.00021039999999999948 |
| 1.6129831557857937 micron | 0.1751033 | 0.0001876999999999851 | 0.0001577000000000106 |
| 2.5550846553145785 micron | 0.165385 | 0.00020090000000000385 | 0.00016869999999999385 |
| 4.0474431319424164 micron | 0.1553267 | 0.0001879000000000186 | 0.00020939999999999848 |
We can also create (or call if you set store_models=True) the final best-fit models using the .get_models() function. This can take a minute if generating the models from parameters for lots of wavelengths.
models = cmod.get_model()
models.keys()
dict_keys(['stime', 'sx', 'sy', 'sbkg', 'transit', 'total'])
As the .get_model() process can take time to generate the models, we store the models for use later...
cmod._fit_models
{'stime': {'w0': array([0.9948605 , 0.99503182, 0.99520313, 0.99537445, 0.99554577,
0.99571708, 0.9958884 , 0.99605972, 0.99623103, 0.99640235,
0.99657367, 0.99674498, 0.9969163 , 0.99708762, 0.99725893,
0.99743025, 0.99760157, 0.99777288, 0.9979442 , 0.99811552,
0.99828683, 0.99845815, 0.99862947, 0.99880078, 0.9989721 ,
0.99914342, 0.99931473, 0.99948605, 0.99965737, 0.99982868,
1. , 1.00017132, 1.00034263, 1.00051395, 1.00068527,
1.00085658, 1.0010279 , 1.00119922, 1.00137053, 1.00154185,
1.00171317, 1.00188448, 1.0020558 , 1.00222712, 1.00239843,
1.00256975, 1.00274107, 1.00291238, 1.0030837 , 1.00325502,
1.00342633, 1.00359765, 1.00376897, 1.00394028, 1.0041116 ,
1.00428292, 1.00445423, 1.00462555, 1.00479687, 1.00496818,
1.0051395 ]),
'w1': array([0.9948605 , 0.99503182, 0.99520313, 0.99537445, 0.99554577,
0.99571708, 0.9958884 , 0.99605972, 0.99623103, 0.99640235,
0.99657367, 0.99674498, 0.9969163 , 0.99708762, 0.99725893,
0.99743025, 0.99760157, 0.99777288, 0.9979442 , 0.99811552,
0.99828683, 0.99845815, 0.99862947, 0.99880078, 0.9989721 ,
0.99914342, 0.99931473, 0.99948605, 0.99965737, 0.99982868,
1. , 1.00017132, 1.00034263, 1.00051395, 1.00068527,
1.00085658, 1.0010279 , 1.00119922, 1.00137053, 1.00154185,
1.00171317, 1.00188448, 1.0020558 , 1.00222712, 1.00239843,
1.00256975, 1.00274107, 1.00291238, 1.0030837 , 1.00325502,
1.00342633, 1.00359765, 1.00376897, 1.00394028, 1.0041116 ,
1.00428292, 1.00445423, 1.00462555, 1.00479687, 1.00496818,
1.0051395 ]),
'w2': array([0.9948605 , 0.99503182, 0.99520313, 0.99537445, 0.99554577,
0.99571708, 0.9958884 , 0.99605972, 0.99623103, 0.99640235,
0.99657367, 0.99674498, 0.9969163 , 0.99708762, 0.99725893,
0.99743025, 0.99760157, 0.99777288, 0.9979442 , 0.99811552,
0.99828683, 0.99845815, 0.99862947, 0.99880078, 0.9989721 ,
0.99914342, 0.99931473, 0.99948605, 0.99965737, 0.99982868,
1. , 1.00017132, 1.00034263, 1.00051395, 1.00068527,
1.00085658, 1.0010279 , 1.00119922, 1.00137053, 1.00154185,
1.00171317, 1.00188448, 1.0020558 , 1.00222712, 1.00239843,
1.00256975, 1.00274107, 1.00291238, 1.0030837 , 1.00325502,
1.00342633, 1.00359765, 1.00376897, 1.00394028, 1.0041116 ,
1.00428292, 1.00445423, 1.00462555, 1.00479687, 1.00496818,
1.0051395 ]),
'w3': array([0.9948605 , 0.99503182, 0.99520313, 0.99537445, 0.99554577,
0.99571708, 0.9958884 , 0.99605972, 0.99623103, 0.99640235,
0.99657367, 0.99674498, 0.9969163 , 0.99708762, 0.99725893,
0.99743025, 0.99760157, 0.99777288, 0.9979442 , 0.99811552,
0.99828683, 0.99845815, 0.99862947, 0.99880078, 0.9989721 ,
0.99914342, 0.99931473, 0.99948605, 0.99965737, 0.99982868,
1. , 1.00017132, 1.00034263, 1.00051395, 1.00068527,
1.00085658, 1.0010279 , 1.00119922, 1.00137053, 1.00154185,
1.00171317, 1.00188448, 1.0020558 , 1.00222712, 1.00239843,
1.00256975, 1.00274107, 1.00291238, 1.0030837 , 1.00325502,
1.00342633, 1.00359765, 1.00376897, 1.00394028, 1.0041116 ,
1.00428292, 1.00445423, 1.00462555, 1.00479687, 1.00496818,
1.0051395 ]),
'w4': array([0.9948605 , 0.99503182, 0.99520313, 0.99537445, 0.99554577,
0.99571708, 0.9958884 , 0.99605972, 0.99623103, 0.99640235,
0.99657367, 0.99674498, 0.9969163 , 0.99708762, 0.99725893,
0.99743025, 0.99760157, 0.99777288, 0.9979442 , 0.99811552,
0.99828683, 0.99845815, 0.99862947, 0.99880078, 0.9989721 ,
0.99914342, 0.99931473, 0.99948605, 0.99965737, 0.99982868,
1. , 1.00017132, 1.00034263, 1.00051395, 1.00068527,
1.00085658, 1.0010279 , 1.00119922, 1.00137053, 1.00154185,
1.00171317, 1.00188448, 1.0020558 , 1.00222712, 1.00239843,
1.00256975, 1.00274107, 1.00291238, 1.0030837 , 1.00325502,
1.00342633, 1.00359765, 1.00376897, 1.00394028, 1.0041116 ,
1.00428292, 1.00445423, 1.00462555, 1.00479687, 1.00496818,
1.0051395 ])},
'sx': {'w0': array([-1.33533682e-03, -1.22235119e-03, -1.28578029e-03, -1.44295529e-03,
-1.08331731e-03, -1.14209803e-03, -8.69411978e-04, -6.58532413e-04,
-4.56098197e-04, -5.27273785e-04, -2.27299322e-04, -5.68515678e-05,
-6.88653086e-05, 1.28760615e-04, -6.65134697e-05, 2.20008571e-05,
-1.63401084e-04, 2.16417820e-04, 3.23109984e-04, 1.53648407e-04,
1.42205779e-04, -2.03528705e-04, -5.06973927e-05, -2.42908958e-04,
-2.33707631e-04, -5.80425698e-04, -3.76377725e-04, -7.41817283e-04,
-7.79383475e-04, -1.16040825e-03, -1.25584121e-03, -4.99662776e-04,
-5.87122361e-04, -3.13474979e-04, -2.07416241e-04, 5.21018632e-05,
5.91827604e-04, 3.06617510e-04, 8.58873336e-04, 8.67068791e-04,
1.14737806e-03, 1.30882370e-03, 1.66715524e-03, 1.54633140e-03,
1.43711723e-03, 1.79986256e-03, 1.45899102e-03, 9.07067349e-04,
4.47946686e-04, -1.48289054e-04, -6.70241495e-04, -9.28451470e-04,
-1.23604855e-03, -1.38469725e-03, -1.51222356e-03, -1.58482390e-03,
-1.48759534e-03, -1.31891016e-03, -6.97935500e-04, -4.50689152e-04,
-7.67972409e-04]),
'w1': array([-1.33533682e-03, -1.22235119e-03, -1.28578029e-03, -1.44295529e-03,
-1.08331731e-03, -1.14209803e-03, -8.69411978e-04, -6.58532413e-04,
-4.56098197e-04, -5.27273785e-04, -2.27299322e-04, -5.68515678e-05,
-6.88653086e-05, 1.28760615e-04, -6.65134697e-05, 2.20008571e-05,
-1.63401084e-04, 2.16417820e-04, 3.23109984e-04, 1.53648407e-04,
1.42205779e-04, -2.03528705e-04, -5.06973927e-05, -2.42908958e-04,
-2.33707631e-04, -5.80425698e-04, -3.76377725e-04, -7.41817283e-04,
-7.79383475e-04, -1.16040825e-03, -1.25584121e-03, -4.99662776e-04,
-5.87122361e-04, -3.13474979e-04, -2.07416241e-04, 5.21018632e-05,
5.91827604e-04, 3.06617510e-04, 8.58873336e-04, 8.67068791e-04,
1.14737806e-03, 1.30882370e-03, 1.66715524e-03, 1.54633140e-03,
1.43711723e-03, 1.79986256e-03, 1.45899102e-03, 9.07067349e-04,
4.47946686e-04, -1.48289054e-04, -6.70241495e-04, -9.28451470e-04,
-1.23604855e-03, -1.38469725e-03, -1.51222356e-03, -1.58482390e-03,
-1.48759534e-03, -1.31891016e-03, -6.97935500e-04, -4.50689152e-04,
-7.67972409e-04]),
'w2': array([-1.33533682e-03, -1.22235119e-03, -1.28578029e-03, -1.44295529e-03,
-1.08331731e-03, -1.14209803e-03, -8.69411978e-04, -6.58532413e-04,
-4.56098197e-04, -5.27273785e-04, -2.27299322e-04, -5.68515678e-05,
-6.88653086e-05, 1.28760615e-04, -6.65134697e-05, 2.20008571e-05,
-1.63401084e-04, 2.16417820e-04, 3.23109984e-04, 1.53648407e-04,
1.42205779e-04, -2.03528705e-04, -5.06973927e-05, -2.42908958e-04,
-2.33707631e-04, -5.80425698e-04, -3.76377725e-04, -7.41817283e-04,
-7.79383475e-04, -1.16040825e-03, -1.25584121e-03, -4.99662776e-04,
-5.87122361e-04, -3.13474979e-04, -2.07416241e-04, 5.21018632e-05,
5.91827604e-04, 3.06617510e-04, 8.58873336e-04, 8.67068791e-04,
1.14737806e-03, 1.30882370e-03, 1.66715524e-03, 1.54633140e-03,
1.43711723e-03, 1.79986256e-03, 1.45899102e-03, 9.07067349e-04,
4.47946686e-04, -1.48289054e-04, -6.70241495e-04, -9.28451470e-04,
-1.23604855e-03, -1.38469725e-03, -1.51222356e-03, -1.58482390e-03,
-1.48759534e-03, -1.31891016e-03, -6.97935500e-04, -4.50689152e-04,
-7.67972409e-04]),
'w3': array([-1.33533682e-03, -1.22235119e-03, -1.28578029e-03, -1.44295529e-03,
-1.08331731e-03, -1.14209803e-03, -8.69411978e-04, -6.58532413e-04,
-4.56098197e-04, -5.27273785e-04, -2.27299322e-04, -5.68515678e-05,
-6.88653086e-05, 1.28760615e-04, -6.65134697e-05, 2.20008571e-05,
-1.63401084e-04, 2.16417820e-04, 3.23109984e-04, 1.53648407e-04,
1.42205779e-04, -2.03528705e-04, -5.06973927e-05, -2.42908958e-04,
-2.33707631e-04, -5.80425698e-04, -3.76377725e-04, -7.41817283e-04,
-7.79383475e-04, -1.16040825e-03, -1.25584121e-03, -4.99662776e-04,
-5.87122361e-04, -3.13474979e-04, -2.07416241e-04, 5.21018632e-05,
5.91827604e-04, 3.06617510e-04, 8.58873336e-04, 8.67068791e-04,
1.14737806e-03, 1.30882370e-03, 1.66715524e-03, 1.54633140e-03,
1.43711723e-03, 1.79986256e-03, 1.45899102e-03, 9.07067349e-04,
4.47946686e-04, -1.48289054e-04, -6.70241495e-04, -9.28451470e-04,
-1.23604855e-03, -1.38469725e-03, -1.51222356e-03, -1.58482390e-03,
-1.48759534e-03, -1.31891016e-03, -6.97935500e-04, -4.50689152e-04,
-7.67972409e-04]),
'w4': array([-1.33533682e-03, -1.22235119e-03, -1.28578029e-03, -1.44295529e-03,
-1.08331731e-03, -1.14209803e-03, -8.69411978e-04, -6.58532413e-04,
-4.56098197e-04, -5.27273785e-04, -2.27299322e-04, -5.68515678e-05,
-6.88653086e-05, 1.28760615e-04, -6.65134697e-05, 2.20008571e-05,
-1.63401084e-04, 2.16417820e-04, 3.23109984e-04, 1.53648407e-04,
1.42205779e-04, -2.03528705e-04, -5.06973927e-05, -2.42908958e-04,
-2.33707631e-04, -5.80425698e-04, -3.76377725e-04, -7.41817283e-04,
-7.79383475e-04, -1.16040825e-03, -1.25584121e-03, -4.99662776e-04,
-5.87122361e-04, -3.13474979e-04, -2.07416241e-04, 5.21018632e-05,
5.91827604e-04, 3.06617510e-04, 8.58873336e-04, 8.67068791e-04,
1.14737806e-03, 1.30882370e-03, 1.66715524e-03, 1.54633140e-03,
1.43711723e-03, 1.79986256e-03, 1.45899102e-03, 9.07067349e-04,
4.47946686e-04, -1.48289054e-04, -6.70241495e-04, -9.28451470e-04,
-1.23604855e-03, -1.38469725e-03, -1.51222356e-03, -1.58482390e-03,
-1.48759534e-03, -1.31891016e-03, -6.97935500e-04, -4.50689152e-04,
-7.67972409e-04])},
'sy': {'w0': array([ 4.93184744e-03, 9.92022007e-03, 1.04783620e-02, 1.50285309e-02,
1.48815123e-02, 1.70299479e-02, 1.41056283e-02, 1.55699461e-02,
1.56871802e-02, 1.54776229e-02, 1.08426930e-02, 1.06685946e-02,
8.43471395e-03, 6.53350098e-03, 6.67849364e-03, 4.95516107e-03,
4.92612083e-03, 5.94841918e-03, 3.08100671e-03, 1.76157770e-03,
1.45518823e-03, -1.83126452e-03, -3.28668325e-03, -4.23116461e-03,
-4.80020299e-03, -5.07181206e-03, -4.53856396e-03, -3.56549872e-03,
-4.44341285e-03, -1.56696515e-03, -1.78746068e-03, 1.07745132e-05,
1.33253829e-03, 2.48845850e-03, 2.99144086e-03, 1.81032621e-03,
1.50686840e-03, 7.71252252e-04, -9.84891234e-05, 2.95212445e-03,
6.09821485e-04, -6.75806850e-04, 1.35193241e-03, 1.03050924e-03,
3.22837466e-03, 3.54899136e-03, 3.29345661e-03, 3.37347312e-03,
6.39853037e-03, 9.59863927e-03, 1.34470597e-02, 1.38063062e-02,
1.62849631e-02, 1.79338868e-02, 1.84004002e-02, 1.71467616e-02,
1.71814282e-02, 1.50221518e-02, 1.31676788e-02, 1.19042058e-02,
1.26073855e-02]),
'w1': array([ 4.93184744e-03, 9.92022007e-03, 1.04783620e-02, 1.50285309e-02,
1.48815123e-02, 1.70299479e-02, 1.41056283e-02, 1.55699461e-02,
1.56871802e-02, 1.54776229e-02, 1.08426930e-02, 1.06685946e-02,
8.43471395e-03, 6.53350098e-03, 6.67849364e-03, 4.95516107e-03,
4.92612083e-03, 5.94841918e-03, 3.08100671e-03, 1.76157770e-03,
1.45518823e-03, -1.83126452e-03, -3.28668325e-03, -4.23116461e-03,
-4.80020299e-03, -5.07181206e-03, -4.53856396e-03, -3.56549872e-03,
-4.44341285e-03, -1.56696515e-03, -1.78746068e-03, 1.07745132e-05,
1.33253829e-03, 2.48845850e-03, 2.99144086e-03, 1.81032621e-03,
1.50686840e-03, 7.71252252e-04, -9.84891234e-05, 2.95212445e-03,
6.09821485e-04, -6.75806850e-04, 1.35193241e-03, 1.03050924e-03,
3.22837466e-03, 3.54899136e-03, 3.29345661e-03, 3.37347312e-03,
6.39853037e-03, 9.59863927e-03, 1.34470597e-02, 1.38063062e-02,
1.62849631e-02, 1.79338868e-02, 1.84004002e-02, 1.71467616e-02,
1.71814282e-02, 1.50221518e-02, 1.31676788e-02, 1.19042058e-02,
1.26073855e-02]),
'w2': array([ 4.93184744e-03, 9.92022007e-03, 1.04783620e-02, 1.50285309e-02,
1.48815123e-02, 1.70299479e-02, 1.41056283e-02, 1.55699461e-02,
1.56871802e-02, 1.54776229e-02, 1.08426930e-02, 1.06685946e-02,
8.43471395e-03, 6.53350098e-03, 6.67849364e-03, 4.95516107e-03,
4.92612083e-03, 5.94841918e-03, 3.08100671e-03, 1.76157770e-03,
1.45518823e-03, -1.83126452e-03, -3.28668325e-03, -4.23116461e-03,
-4.80020299e-03, -5.07181206e-03, -4.53856396e-03, -3.56549872e-03,
-4.44341285e-03, -1.56696515e-03, -1.78746068e-03, 1.07745132e-05,
1.33253829e-03, 2.48845850e-03, 2.99144086e-03, 1.81032621e-03,
1.50686840e-03, 7.71252252e-04, -9.84891234e-05, 2.95212445e-03,
6.09821485e-04, -6.75806850e-04, 1.35193241e-03, 1.03050924e-03,
3.22837466e-03, 3.54899136e-03, 3.29345661e-03, 3.37347312e-03,
6.39853037e-03, 9.59863927e-03, 1.34470597e-02, 1.38063062e-02,
1.62849631e-02, 1.79338868e-02, 1.84004002e-02, 1.71467616e-02,
1.71814282e-02, 1.50221518e-02, 1.31676788e-02, 1.19042058e-02,
1.26073855e-02]),
'w3': array([ 4.93184744e-03, 9.92022007e-03, 1.04783620e-02, 1.50285309e-02,
1.48815123e-02, 1.70299479e-02, 1.41056283e-02, 1.55699461e-02,
1.56871802e-02, 1.54776229e-02, 1.08426930e-02, 1.06685946e-02,
8.43471395e-03, 6.53350098e-03, 6.67849364e-03, 4.95516107e-03,
4.92612083e-03, 5.94841918e-03, 3.08100671e-03, 1.76157770e-03,
1.45518823e-03, -1.83126452e-03, -3.28668325e-03, -4.23116461e-03,
-4.80020299e-03, -5.07181206e-03, -4.53856396e-03, -3.56549872e-03,
-4.44341285e-03, -1.56696515e-03, -1.78746068e-03, 1.07745132e-05,
1.33253829e-03, 2.48845850e-03, 2.99144086e-03, 1.81032621e-03,
1.50686840e-03, 7.71252252e-04, -9.84891234e-05, 2.95212445e-03,
6.09821485e-04, -6.75806850e-04, 1.35193241e-03, 1.03050924e-03,
3.22837466e-03, 3.54899136e-03, 3.29345661e-03, 3.37347312e-03,
6.39853037e-03, 9.59863927e-03, 1.34470597e-02, 1.38063062e-02,
1.62849631e-02, 1.79338868e-02, 1.84004002e-02, 1.71467616e-02,
1.71814282e-02, 1.50221518e-02, 1.31676788e-02, 1.19042058e-02,
1.26073855e-02]),
'w4': array([ 4.93184744e-03, 9.92022007e-03, 1.04783620e-02, 1.50285309e-02,
1.48815123e-02, 1.70299479e-02, 1.41056283e-02, 1.55699461e-02,
1.56871802e-02, 1.54776229e-02, 1.08426930e-02, 1.06685946e-02,
8.43471395e-03, 6.53350098e-03, 6.67849364e-03, 4.95516107e-03,
4.92612083e-03, 5.94841918e-03, 3.08100671e-03, 1.76157770e-03,
1.45518823e-03, -1.83126452e-03, -3.28668325e-03, -4.23116461e-03,
-4.80020299e-03, -5.07181206e-03, -4.53856396e-03, -3.56549872e-03,
-4.44341285e-03, -1.56696515e-03, -1.78746068e-03, 1.07745132e-05,
1.33253829e-03, 2.48845850e-03, 2.99144086e-03, 1.81032621e-03,
1.50686840e-03, 7.71252252e-04, -9.84891234e-05, 2.95212445e-03,
6.09821485e-04, -6.75806850e-04, 1.35193241e-03, 1.03050924e-03,
3.22837466e-03, 3.54899136e-03, 3.29345661e-03, 3.37347312e-03,
6.39853037e-03, 9.59863927e-03, 1.34470597e-02, 1.38063062e-02,
1.62849631e-02, 1.79338868e-02, 1.84004002e-02, 1.71467616e-02,
1.71814282e-02, 1.50221518e-02, 1.31676788e-02, 1.19042058e-02,
1.26073855e-02])},
'sbkg': {'w0': array([0.00078587, 0.00070199, 0.00075736, 0.00055492, 0.00049444,
0.00090451, 0.00083641, 0.0008047 , 0.00055907, 0.00074967,
0.00046397, 0.00049806, 0.00099945, 0.00055318, 0.00072847,
0.0005659 , 0.00044724, 0.00053499, 0.00066728, 0.00054633,
0.00084912, 0.00067663, 0.0007867 , 0.00057108, 0.00100038,
0.00056276, 0.0007149 , 0.00079571, 0.00112168, 0.00075336,
0.00084134, 0.00103872, 0.00084475, 0.0009118 , 0.00132285,
0.00100128, 0.00072515, 0.00068686, 0.00049999, 0.00081779,
0.00076029, 0.00079575, 0.00063099, 0.00070394, 0.00046572,
0.0005136 , 0.00070881, 0.00086536, 0.00072387, 0.00055285,
0.00038867, 0.00052069, 0.00033368, 0.00077226, 0.00043765,
0.00060704, 0.00048226, 0.0003393 , 0.00023539, 0.00050981,
0.00029222]),
'w1': array([0.00225317, 0.00201269, 0.00217144, 0.00159101, 0.00141762,
0.00259334, 0.00239807, 0.00230717, 0.00160293, 0.00214938,
0.00133025, 0.00142799, 0.00286554, 0.00158604, 0.00208862,
0.0016225 , 0.00128228, 0.00153388, 0.00191317, 0.0015664 ,
0.00243453, 0.00193998, 0.00225557, 0.00163736, 0.00286821,
0.0016135 , 0.0020497 , 0.00228138, 0.00321598, 0.00215997,
0.00241223, 0.00297813, 0.00242199, 0.00261423, 0.00379275,
0.00287077, 0.00207909, 0.0019693 , 0.00143354, 0.00234471,
0.00217984, 0.00228152, 0.00180911, 0.00201827, 0.00133528,
0.00147256, 0.00203224, 0.00248108, 0.00207542, 0.00158508,
0.00111437, 0.00149287, 0.00095671, 0.00221415, 0.00125479,
0.00174045, 0.00138268, 0.00097281, 0.00067488, 0.0014617 ,
0.00083783]),
'w2': array([-6.55554696e-05, -5.85587295e-05, -6.31776076e-05, -4.62900037e-05,
-4.12453899e-05, -7.54526249e-05, -6.97714166e-05, -6.71265651e-05,
-4.66369048e-05, -6.25357503e-05, -3.87034530e-05, -4.15471967e-05,
-8.33723860e-05, -4.61455567e-05, -6.07680345e-05, -4.72062674e-05,
-3.73076283e-05, -4.46278624e-05, -5.56634295e-05, -4.55741295e-05,
-7.08322831e-05, -5.64433698e-05, -6.56252500e-05, -4.76385421e-05,
-8.34501176e-05, -4.69445144e-05, -5.96357502e-05, -6.63764417e-05,
-9.35681860e-05, -6.28439886e-05, -7.01833574e-05, -8.66480885e-05,
-7.04672861e-05, -7.60606199e-05, -1.10349411e-04, -8.35245637e-05,
-6.04906410e-05, -5.72963884e-05, -4.17086470e-05, -6.82188190e-05,
-6.34221232e-05, -6.63803706e-05, -5.26358339e-05, -5.87212656e-05,
-3.88496563e-05, -4.28438781e-05, -5.91277058e-05, -7.21866463e-05,
-6.03840297e-05, -4.61176113e-05, -3.24224456e-05, -4.34348103e-05,
-2.78351812e-05, -6.44203301e-05, -3.65077753e-05, -5.06381665e-05,
-4.02288879e-05, -2.83038102e-05, -1.96354235e-05, -4.25278362e-05,
-2.43764981e-05]),
'w3': array([-0.00267159, -0.00238645, -0.00257468, -0.00188646, -0.00168088,
-0.00307493, -0.0028434 , -0.00273562, -0.0019006 , -0.00254853,
-0.00157729, -0.00169318, -0.00339768, -0.00188058, -0.00247649,
-0.0019238 , -0.0015204 , -0.00181872, -0.00226846, -0.00185729,
-0.00288664, -0.00230024, -0.00267443, -0.00194142, -0.00340085,
-0.00191314, -0.00243034, -0.00270505, -0.00381319, -0.00256109,
-0.00286019, -0.00353118, -0.00287176, -0.00309971, -0.00449708,
-0.00340389, -0.00246518, -0.00233501, -0.00169976, -0.00278013,
-0.00258465, -0.00270521, -0.00214507, -0.00239307, -0.00158324,
-0.00174602, -0.00240964, -0.00294183, -0.00246084, -0.00187944,
-0.00132132, -0.0017701 , -0.00113437, -0.00262533, -0.00148781,
-0.00206366, -0.00163945, -0.00115347, -0.0008002 , -0.00173314,
-0.00099342]),
'w4': array([-0.00288555, -0.00257758, -0.00278089, -0.00203755, -0.0018155 ,
-0.0033212 , -0.00307113, -0.00295471, -0.00205282, -0.00275264,
-0.00170361, -0.00182878, -0.0036698 , -0.00203119, -0.00267483,
-0.00207788, -0.00164217, -0.00196438, -0.00245014, -0.00200604,
-0.00311782, -0.00248447, -0.00288863, -0.0020969 , -0.00367322,
-0.00206636, -0.00262499, -0.00292169, -0.00411859, -0.0027662 ,
-0.00308926, -0.00381399, -0.00310176, -0.00334796, -0.00485725,
-0.0036765 , -0.00266262, -0.00252201, -0.00183589, -0.00300279,
-0.00279165, -0.00292186, -0.00231687, -0.00258473, -0.00171004,
-0.00188586, -0.00260262, -0.00317744, -0.00265792, -0.00202996,
-0.00142714, -0.00191187, -0.00122522, -0.00283559, -0.00160696,
-0.00222894, -0.00177075, -0.00124585, -0.00086429, -0.00187195,
-0.00107298])},
'transit': {'w0': array([1. , 1. , 1. , 1. , 1. ,
1. , 1. , 1. , 1. , 1. ,
1. , 1. , 1. , 1. , 0.99869004,
0.9935652 , 0.986365 , 0.97809176, 0.96982765, 0.96362439,
0.96170439, 0.96037858, 0.95938205, 0.95861148, 0.95800996,
0.95754194, 0.95718377, 0.9569193 , 0.95673752, 0.95663126,
0.9565965 , 0.95663194, 0.95673889, 0.95692142, 0.95718673,
0.95754586, 0.95801504, 0.95861798, 0.95939039, 0.96038947,
0.96171923, 0.96364851, 0.96990203, 0.97817283, 0.98644044,
0.9936258 , 0.99872473, 1. , 1. , 1. ,
1. , 1. , 1. , 1. , 1. ,
1. , 1. , 1. , 1. , 1. ,
1. ]),
'w1': array([1. , 1. , 1. , 1. , 1. ,
1. , 1. , 1. , 1. , 1. ,
1. , 1. , 1. , 1. , 0.99919025,
0.99458638, 0.98784203, 0.98003464, 0.97231198, 0.96711033,
0.96543275, 0.96425387, 0.96336404, 0.96267462, 0.96213582,
0.9617163 , 0.9613951 , 0.96115785, 0.96099475, 0.9608994 ,
0.96086821, 0.96090001, 0.96099598, 0.96115976, 0.96139776,
0.96171982, 0.96214037, 0.96268043, 0.9633715 , 0.96426359,
0.9654459 , 0.96713054, 0.97238042, 0.98011104, 0.98791314,
0.99464249, 0.99921897, 1. , 1. , 1. ,
1. , 1. , 1. , 1. , 1. ,
1. , 1. , 1. , 1. , 1. ,
1. ]),
'w2': array([1. , 1. , 1. , 1. , 1. ,
1. , 1. , 1. , 1. , 1. ,
1. , 1. , 1. , 1. , 0.9996008 ,
0.99555575, 0.98928345, 0.98195771, 0.97480401, 0.97056742,
0.9691088 , 0.96807026, 0.96728332, 0.96667247, 0.96619457,
0.9658222 , 0.96553698, 0.96532624, 0.96518133, 0.96509661,
0.96506889, 0.96509715, 0.96518242, 0.96532793, 0.96553934,
0.96582533, 0.9661986 , 0.96667763, 0.96728993, 0.96807884,
0.96912035, 0.97058464, 0.97486608, 0.98202927, 0.98935011,
0.99560718, 0.99962267, 1. , 1. , 1. ,
1. , 1. , 1. , 1. , 1. ,
1. , 1. , 1. , 1. , 1. ,
1. ]),
'w3': array([1. , 1. , 1. , 1. , 1. ,
1. , 1. , 1. , 1. , 1. ,
1. , 1. , 1. , 1. , 0.99987644,
0.99638945, 0.9905637 , 0.98369259, 0.97708687, 0.97368316,
0.97240902, 0.9714929 , 0.97079648, 0.97025501, 0.96983099,
0.96950041, 0.96924709, 0.96905987, 0.96893112, 0.96885583,
0.9688312 , 0.96885631, 0.96893209, 0.96906138, 0.96924919,
0.96950318, 0.96983457, 0.97025959, 0.97080233, 0.97150048,
0.97241917, 0.97369802, 0.97714263, 0.98375956, 0.99062614,
0.99643643, 0.99989047, 1. , 1. , 1. ,
1. , 1. , 1. , 1. , 1. ,
1. , 1. , 1. , 1. , 1. ,
1. ]),
'w4': array([1. , 1. , 1. , 1. , 1. ,
1. , 1. , 1. , 1. , 1. ,
1. , 1. , 1. , 1. , 1. ,
0.99716519, 0.99180095, 0.98539837, 0.97937222, 0.9767374 ,
0.97563464, 0.97483515, 0.97422556, 0.97375089, 0.97337884,
0.97308861, 0.97286613, 0.97270166, 0.97258852, 0.97252237,
0.97250072, 0.97252279, 0.97258938, 0.97270298, 0.97286797,
0.97309105, 0.97338198, 0.9737549 , 0.97423069, 0.97484178,
0.97564349, 0.97675015, 0.97942105, 0.98546058, 0.99185907,
0.99720751, 1. , 1. , 1. , 1. ,
1. , 1. , 1. , 1. , 1. ,
1. , 1. , 1. , 1. , 1. ,
1. ])},
'total': {'w0': array([0.99924288, 1.00443168, 1.00515308, 1.00951494, 1.0098384 ,
1.01250944, 1.00996102, 1.01177583, 1.01202119, 1.01210236,
1.00765303, 1.00785479, 1.0062816 , 1.00430306, 1.0032834 ,
0.99651938, 0.98913819, 0.98246648, 0.97178244, 0.96418048,
0.96240966, 0.95759347, 0.95562011, 0.95372045, 0.95316107,
0.95184834, 0.95250763, 0.95306716, 0.95248601, 0.95457897,
0.95449012, 0.95732181, 0.95858807, 0.96036704, 0.9617737 ,
0.96110821, 0.96170507, 0.96145927, 0.96191446, 0.96632356,
0.96578794, 0.96684133, 0.97543617, 0.9835605 , 0.99386799,
1.00200426, 1.0069166 , 1.00805828, 1.01065405, 1.01325822,
1.01659183, 1.01699619, 1.01915156, 1.02126173, 1.02143742,
1.02045189, 1.02063032, 1.01866809, 1.017502 , 1.01693151,
1.01727113]),
'w1': array([1.00071018, 1.00574237, 1.00656715, 1.01055103, 1.01076158,
1.01419827, 1.01152269, 1.0132783 , 1.01306504, 1.01350208,
1.00851931, 1.00878472, 1.00814769, 1.00533592, 1.00514496,
0.99859448, 0.99144426, 0.98539699, 0.97548317, 0.96865495,
0.96767136, 0.96267572, 0.96100154, 0.95878932, 0.95906315,
0.95700839, 0.95798166, 0.95871663, 0.95873693, 0.96018957,
0.96026183, 0.96345654, 0.96436911, 0.96625695, 0.96837947,
0.96709562, 0.96714896, 0.96676835, 0.9668054 , 0.97169396,
0.97090087, 0.97177182, 0.97907429, 0.98679758, 0.99621083,
1.00398335, 1.00873729, 1.00967401, 1.0120056 , 1.01429045,
1.01731752, 1.01796838, 1.01977459, 1.02270363, 1.02225456,
1.02158531, 1.02153075, 1.0193016 , 1.01794149, 1.0178834 ,
1.01781674]),
'w2': array([0.99839146, 1.00367113, 1.00433254, 1.00891374, 1.00930272,
1.01152948, 1.00905484, 1.010904 , 1.01141548, 1.01129016,
1.00715036, 1.00731518, 1.00519878, 1.00370373, 1.00340943,
0.99790546, 0.99158549, 0.98578057, 0.97606409, 0.97055303,
0.96892796, 0.96455317, 0.96266596, 0.96114221, 0.96025705,
0.9594905 , 0.96007219, 0.96060807, 0.95971937, 0.96223844,
0.96206416, 0.96470703, 0.96616457, 0.96785021, 0.96878253,
0.96837075, 0.96916107, 0.96882345, 0.9693108 , 0.97320271,
0.97242209, 0.97296366, 0.9797621 , 0.98668923, 0.99630036,
1.00344834, 1.00705425, 1.00712074, 1.00986979, 1.01265925,
1.01617073, 1.01643207, 1.01879005, 1.02042505, 1.02096327,
1.01979422, 1.02010784, 1.01830049, 1.01724697, 1.01637917,
1.01695454]),
'w3': array([0.99578542, 1.00134324, 1.00182103, 1.00707356, 1.00766308,
1.00853 , 1.00628121, 1.00823551, 1.00956152, 1.00880417,
1.00561177, 1.00566355, 1.00188446, 1.0018693 , 1.0012707 ,
0.99687132, 0.99139962, 0.98577703, 0.97618781, 0.97190468,
0.96948945, 0.96578354, 0.96362972, 0.9628668 , 0.9606538 ,
0.96133532, 0.9614635 , 0.96176643, 0.95984388, 0.96356609,
0.96311171, 0.96512742, 0.96720379, 0.96866331, 0.968253 ,
0.9688392 , 0.97047603, 0.97020339, 0.9712209 , 0.97400784,
0.97328046, 0.97351525, 0.98000547, 0.98613129, 0.99605545,
1.00258701, 1.00497379, 1.00425109, 1.00746934, 1.01082593,
1.01488184, 1.0147054 , 1.01768351, 1.01786414, 1.01951197,
1.01778119, 1.01850861, 1.01717532, 1.01646641, 1.01468856,
1.01598549]),
'w4': array([0.99557146, 1.00115211, 1.00161483, 1.00692248, 1.00752846,
1.00828374, 1.00605349, 1.00801642, 1.0094093 , 1.00860006,
1.00548545, 1.00552794, 1.00161235, 1.00171869, 1.00119609,
0.99749379, 0.99251715, 0.9873429 , 0.97829313, 0.97480806,
0.97247984, 0.96892656, 0.96682482, 0.96618466, 0.96390296,
0.9647442 , 0.96486411, 0.96517007, 0.96316996, 0.96701313,
0.9665368 , 0.96850475, 0.97063087, 0.97206194, 0.97151767,
0.97215932, 0.97383361, 0.9735164 , 0.97451811, 0.9771407 ,
0.97630567, 0.97635518, 0.98212231, 0.98764754, 0.99716936,
1.00322341, 1.00489089, 1.00401549, 1.00727225, 1.01067541,
1.01477601, 1.01456364, 1.01759266, 1.01765388, 1.01939281,
1.01761592, 1.01837731, 1.01708294, 1.01640232, 1.01454975,
1.01590593])}}
Plotting the final results¶
We have several different methods (mostly wrappers to chromatic functions) to plot the modelled results. I'll demonstrate several of them below:
plot_model() is an especially useful function for CombinedModels because it allows us to split the model into constituent models and see the relative contribution of each!
cmod.plot_model()
We can also just choose to see a single model or wavelength:
cmod._chromatic_models['transit'].plot_model(wavelength=0)
# plot the 2D light curves for each wavelength with the model (black) now overlaid
cmod.plot_lightcurves()
cmod.plot_with_model_and_residuals()
No model attached to data. Running `add_model_to_rainbow` now. You can access this data later using [self].data_with_model
# plot the 3D light curves (flux as a function of time and wavelength) with the residuals
cmod.imshow_with_models(vspan_residuals=0.001)
Plot the transmission spectrum:
cmod.plot_transmission_spectrum(uncertainty=['hdi_16%','hdi_84%'])
plt.plot(SimulatedRainbow().wavelength, np.linspace(0.2, 0.15, SimulatedRainbow().nwave), label="True Rp/R*");
Error applying plot_transmission_spectrum to <chromatic polynomial model 'stime' 🌈>: 'PolynomialModel' object has no attribute 'plot_transmission_spectrum' Error applying plot_transmission_spectrum to <chromatic polynomial model 'sx' 🌈>: 'PolynomialModel' object has no attribute 'plot_transmission_spectrum' Error applying plot_transmission_spectrum to <chromatic polynomial model 'sy' 🌈>: 'PolynomialModel' object has no attribute 'plot_transmission_spectrum' Error applying plot_transmission_spectrum to <chromatic polynomial model 'sbkg' 🌈>: 'PolynomialModel' object has no attribute 'plot_transmission_spectrum'
/Users/camu5866/opt/anaconda3/envs/chromaticfitting/lib/python3.9/site-packages/chromatic_fitting/models/transit.py:366: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
trans_table[f"{self.name}_radius_ratio_neg_error"] = (