1 | import sys
|
---|
2 | import os
|
---|
3 | import shutil
|
---|
4 | import datetime
|
---|
5 | from asap import scantable, selector, mask_not
|
---|
6 | from asap.logging import asaplog
|
---|
7 | asaplog.disable()
|
---|
8 |
|
---|
9 | from nose.tools import *
|
---|
10 |
|
---|
11 | def tempdir_setup():
|
---|
12 | os.makedirs("test_temp")
|
---|
13 |
|
---|
14 | def tempdir_teardown():
|
---|
15 | shutil.rmtree("test_temp", True)
|
---|
16 |
|
---|
17 | class TestNRO(object):
|
---|
18 | def setup(self):
|
---|
19 | s = scantable('data/B68test.nro', average=False)
|
---|
20 | sel = selector()
|
---|
21 | # make sure this order is always correct - it can be random
|
---|
22 | sel.set_order(["SCANNO", "POLNO"])
|
---|
23 | s.set_selection(sel)
|
---|
24 | self.st = s.copy()
|
---|
25 |
|
---|
26 | def test_init(self):
|
---|
27 | assert_equal(self.st.nrow(), 36)
|
---|
28 | assert_equal(self.st.get_fluxunit(), 'K')
|
---|
29 | assert_equal(self.st.nchan(), 2048)
|
---|
30 | assert_equal(self.st.nif(), 4)
|
---|
31 |
|
---|
32 | def test_spectrum(self):
|
---|
33 | import numpy
|
---|
34 | sp=numpy.array(self.st._getspectrum(0))
|
---|
35 | assert_equal(sp.max(),1.9524071216583252)
|
---|
36 | assert_equal(sp.min(),-0.0071961274370551109)
|
---|
37 | assert_equal(sp.argmax(),1648)
|
---|
38 | assert_equal(sp.argmin(),1614)
|
---|
39 |
|
---|
40 | def test_stats(self):
|
---|
41 | assert_equal(self.st.stats('rms')[0],1.1064267158508301)
|
---|
42 | assert_equal(self.st.stats('stddev')[0],0.29552212357521057)
|
---|
43 | assert_equal(self.st.stats('median')[0],1.0714811086654663)
|
---|
44 | assert_equal(self.st.stats('mean')[0],1.0662506818771362)
|
---|
45 | assert_equal(self.st.stats('sum')[0],2183.681396484375)
|
---|
46 |
|
---|
47 | def test_frequency(self):
|
---|
48 | rf=self.st.get_restfreqs()
|
---|
49 | assert_equal(len(rf),2)
|
---|
50 | assert_equal(rf[0][0],85162157000.0)
|
---|
51 | assert_equal(rf[1][0],86754330000.0)
|
---|
52 | self.st.set_unit('GHz')
|
---|
53 | abc=self.st._getabcissa(0)
|
---|
54 | assert_equal(abc[0],85.17337639557438)
|
---|