1 | #!/usr/bin/env python
|
---|
2 | import os
|
---|
3 | from asap import *
|
---|
4 | from nose.tools import assert_almost_equals
|
---|
5 | rcParams['verbose'] = 0
|
---|
6 | rcParams['plotter.gui'] = 0
|
---|
7 |
|
---|
8 |
|
---|
9 | DATA=os.path.join(os.path.split(__file__)[0], "..", "data",
|
---|
10 | "mopra_dualif.rpf")
|
---|
11 |
|
---|
12 |
|
---|
13 | class TestMopra(object):
|
---|
14 | def setup(self):
|
---|
15 | self.st = scantable(DATA)
|
---|
16 |
|
---|
17 | def _plotfit(self, scan, ifno):
|
---|
18 | scan.set_selection(ifs=ifno)
|
---|
19 | f = fitter()
|
---|
20 | f.set_scan(scan)
|
---|
21 | f.set_function(gauss=ifno+1) # fit gaussian(s)
|
---|
22 | f.fit()
|
---|
23 | f.plot(filename='output/moprafit_if%d.png' % ifno)
|
---|
24 | fp = f.get_parameters()
|
---|
25 | assert True
|
---|
26 |
|
---|
27 | def test_reduction(self):
|
---|
28 | restfreqs = [110.201, 86.243] # 13CO-1/0, SiO the two IF
|
---|
29 | self.st.set_restfreqs(restfreqs,"GHz")
|
---|
30 | q = self.st.auto_quotient()
|
---|
31 | q.set_unit("km/s") # set the unit to be used from now on
|
---|
32 | q.set_freqframe("LSRK") # set frequency frame
|
---|
33 | q.auto_poly_baseline(insitu=True) # determine and subtract a poly
|
---|
34 | # baseline automatically
|
---|
35 | q.convert_flux() # K -> Jy
|
---|
36 | msk = q.create_mask([-70,20], [20,70]) # line free region - two windows
|
---|
37 | rms = q.stats("rms", msk)
|
---|
38 | med = q.stats("median", msk)
|
---|
39 | regrms = [35.801266, 38.808666]
|
---|
40 | regmed = [1.197934, 2.593804]
|
---|
41 | for i in range(len(rms)):
|
---|
42 | assert_almost_equals(rms[i], regrms[i], 6)
|
---|
43 | assert_almost_equals(med[i], regmed[i], 6)
|
---|
44 |
|
---|
45 | for ifno in q.getifnos():
|
---|
46 | self._plotfit(q, ifno)
|
---|