Skip to content

Commit ec07be9

Browse files
committed
fix snythetic spectra to work cleanly with wcs again
1 parent d9af176 commit ec07be9

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

examples/ch3cn_110_synthspec.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@
2525

2626
R.temperature = temperature
2727
R.run_radex()
28-
S = pyradex.synthspec.SyntheticSpectrum(110.326*u.GHz,110.388*u.GHz,R.get_table())
28+
wcs = pyradex.synthspec.FrequencyArray(110.326*u.GHz,110.388*u.GHz, npts=1000)
29+
S = pyradex.synthspec.SyntheticSpectrum.from_RADEX(wcs,R)
2930

3031
# spectral colors
3132
color = mpl.cm.spectral(float(ii)/len(temperatures))
3233
S.plot(label='%i K' % temperature,color=color)
3334

3435
for ii in xrange(nlines):
35-
fluxes[ii].append(S.table[ii]['flux'])
36+
fluxes[ii].append(S.T_B[ii].value)
3637

3738
pl.savefig("CH3CN_6-5_synthetic_spectra.pdf",bbox_inches='tight')
3839

@@ -42,7 +43,7 @@
4243
pl.clf()
4344
pl.subplot(1,2,1)
4445
for ii in xrange(nlines):
45-
pl.plot(temperatures,fluxes[ii],label=linenames[ii])
46+
pl.plot(temperatures,np.array(fluxes[ii]),label=linenames[ii])
4647

4748
# Line #4 is the "reference line" at lowest energy
4849
pl.subplot(1,2,2)

examples/h2co_grids.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
R.abundance = abundance # reset column to the appropriate value
4444
R.run_radex(reuse_last=False, reload_molfile=True)
4545

46-
TI = R.total_intensity
46+
TI = R.source_brightness
4747
taugrid_6[jj,ii] = R.tau[0]
4848
texgrid_6[jj,ii] = R.tex[0].value
4949
fluxgrid_6[jj,ii] = TI[0].value

examples/h2cs_thermometer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ def latex_float(f):
5050
for temperature in [10,50,100]:
5151
R.temperature = temperature
5252
R.run_radex()
53-
S = pyradex.synthspec.SyntheticSpectrum(103.0*u.GHz,103.1*u.GHz,R.get_table(),linewidth=10*u.km/u.s)
53+
wcs = pyradex.synthspec.FrequencyArray(103.0*u.GHz, 103.1*u.GHz, npts=1000)
54+
S = pyradex.synthspec.SyntheticSpectrum.from_RADEX(wcs, R,
55+
linewidth=10*u.km/u.s)
5456
S.plot(label='%i K' % temperature)
5557

5658
pl.legend(loc='best')

pyradex/synthspec.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ def from_RADEX(cls, wcs, rad,
181181

182182
data = self.get_profile()
183183

184+
self.table = rad.get_table()
185+
184186
super(Spectrum,self).__init__(data=data, wcs=self.wcs,
185187
unit=u.Unit(rad.T_B.unit))
186188

@@ -211,14 +213,15 @@ def plot(self, update_data=False, *args, **kwargs):
211213
if update_data:
212214
self.data = self.get_profile()
213215

214-
pl.gca().set_xlabel(self.dispersion.unit.to_string())
216+
dispersion = self.wcs(np.arange(self.wcs.npts))
217+
pl.gca().set_xlabel(dispersion.unit.to_string())
215218
if hasattr(self.data,'unit'):
216219
pl.gca().set_ylabel(self.data.unit.to_string())
217220
data = self.data.value
218221
else:
219222
data = self.data
220223

221-
return pl.plot(self.dispersion.value, data, *args, **kwargs)
224+
return pl.plot(dispersion.value, data, *args, **kwargs)
222225

223226
def __call__(self, linewidth=None, velocity_offset=0*u.km/u.s, **kwargs):
224227
"""

0 commit comments

Comments
 (0)