Skip to content

Commit 794cd40

Browse files
committed
refactor plots
1 parent fc70899 commit 794cd40

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

docs/linelists/cdms/cdms.rst

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,15 @@ other temperatures using curve fitting models:
221221
param, cov = curve_fit(f, temp[np.isfinite(part)], part[np.isfinite(part)])
222222
x = np.linspace(2.7,500)
223223
y = f(x,param[0])
224-
plt.scatter(temp,part,c='r')
225-
plt.plot(x,y,'k')
224+
plt.clf()
225+
plt.scatter(temp,part,c='r',label='CDMS Data')
226+
plt.plot(x,y,'k',label='Fitted')
227+
interp_Q = np.interp(x, temp, 10**part)
228+
plt.plot(x, np.log10(interp_Q), label='Interpolated')
226229
plt.title('Partition Function vs Temperature')
227230
plt.xlabel('Temperature')
228231
plt.ylabel('Log10 of Partition Function')
232+
plt.legend(loc='best')
229233

230234

231235
We can then compare linear interpolation to the fitted interpolation above:
@@ -241,22 +245,8 @@ We can then compare linear interpolation to the fitted interpolation above:
241245
.. plot::
242246
:context:
243247

244-
result = CDMS.get_species_table()
245-
mol = result[result['TAG'] == 30501] #do not include signs of TAG for this
246-
def f(T, a):
247-
return np.log10(a*T**(1.5))
248-
keys = [k for k in mol.keys() if 'lg' in k]
249-
def tryfloat(x):
250-
try:
251-
return float(x)
252-
except:
253-
return np.nan
254-
x = np.linspace(2.7,500)
255-
y = f(x,param[0])
256-
temp = np.array([float(k.split('(')[-1].split(')')[0]) for k in keys])
257-
part = np.array([tryfloat(x) for x in mol[keys][0]])
258-
param, cov = curve_fit(f, temp[np.isfinite(part)], part[np.isfinite(part)])
259248
interp_Q = np.interp(x, temp, 10**part)
249+
plt.clf()
260250
plt.plot(x, (10**y-interp_Q)/10**y)
261251
plt.xlabel("Temperature")
262252
plt.ylabel("Fractional difference between linear and fitted")

0 commit comments

Comments
 (0)