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