Skip to content

Commit 5f6dd95

Browse files
keflavichbsipocz
authored andcommitted
make all examples fully independent
1 parent 7f78c4e commit 5f6dd95

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

docs/linelists/cdms/cdms.rst

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ shown below:
156156

157157
import matplotlib.pyplot as plt
158158
from astroquery.linelists.cdms import CDMS
159-
from scipy.optimize import curve_fit
160159

161160
result = CDMS.get_species_table()
162161
mol = result[result['TAG'] == 28503] #do not include signs of TAG for this
@@ -203,11 +202,14 @@ other temperatures using curve fitting models:
203202

204203

205204
.. plot::
206-
:context:
205+
:context: reset
206+
207+
import matplotlib.pyplot as plt
208+
from astroquery.linelists.cdms import CDMS
209+
from scipy.optimize import curve_fit
207210

208211
result = CDMS.get_species_table()
209212
mol = result[result['TAG'] == 30501] #do not include signs of TAG for this
210-
from scipy.optimize import curve_fit
211213
def f(T, a):
212214
return np.log10(a*T**(1.5))
213215
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:
244246
>>> plt.ylabel("Fractional difference between linear and fitted")
245247

246248
.. plot::
247-
:context:
249+
:context: reset
250+
251+
import matplotlib.pyplot as plt
252+
from astroquery.linelists.cdms import CDMS
253+
from scipy.optimize import curve_fit
254+
255+
result = CDMS.get_species_table()
256+
mol = result[result['TAG'] == 30501] #do not include signs of TAG for this
257+
def f(T, a):
258+
return np.log10(a*T**(1.5))
259+
keys = [k for k in mol.keys() if 'lg' in k]
260+
def tryfloat(x):
261+
try:
262+
return float(x)
263+
except:
264+
return np.nan
265+
temp = np.array([float(k.split('(')[-1].split(')')[0]) for k in keys])
266+
part = np.array([tryfloat(x) for x in mol[keys][0]])
267+
param, cov = curve_fit(f, temp[np.isfinite(part)], part[np.isfinite(part)])
268+
x = np.linspace(2.7,500)
269+
y = f(x,param[0])
248270

249271
plt.clf()
250272
plt.plot(x, (10**y-interp_Q)/10**y)

0 commit comments

Comments
 (0)