make all examples fully independent
@@ -156,7 +156,6 @@ shown below:
import matplotlib.pyplot as plt
from astroquery.linelists.cdms import CDMS
- from scipy.optimize import curve_fit
result = CDMS.get_species_table()
mol = result[result['TAG'] == 28503] #do not include signs of TAG for this
@@ -203,11 +202,14 @@ other temperatures using curve fitting models:
.. plot::
- :context:
+ :context: reset
+
+ import matplotlib.pyplot as plt
+ from astroquery.linelists.cdms import CDMS
+ from scipy.optimize import curve_fit
result = CDMS.get_species_table()
mol = result[result['TAG'] == 30501] #do not include signs of TAG for this
- from scipy.optimize import curve_fit
def f(T, a):
return np.log10(a*T**(1.5))
keys = [k for k in mol.keys() if 'lg' in k]
@@ -244,7 +246,27 @@ We can then compare linear interpolation to the fitted interpolation above:
>>> plt.ylabel("Fractional difference between linear and fitted")
.. plot::
- :context:
+ :context: reset
+
+ import matplotlib.pyplot as plt
+ from astroquery.linelists.cdms import CDMS
+ from scipy.optimize import curve_fit
+
+ result = CDMS.get_species_table()
+ mol = result[result['TAG'] == 30501] #do not include signs of TAG for this
+ def f(T, a):
+ return np.log10(a*T**(1.5))
+ keys = [k for k in mol.keys() if 'lg' in k]
+ def tryfloat(x):
+ try:
+ return float(x)
+ except:
+ return np.nan
+ temp = np.array([float(k.split('(')[-1].split(')')[0]) for k in keys])
+ part = np.array([tryfloat(x) for x in mol[keys][0]])
+ param, cov = curve_fit(f, temp[np.isfinite(part)], part[np.isfinite(part)])
+ x = np.linspace(2.7,500)
+ y = f(x,param[0])
plt.clf()
plt.plot(x, (10**y-interp_Q)/10**y)
