[1853] | 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 *
|
---|
[2659] | 10 | from nose.plugins.skip import SkipTest
|
---|
[1853] | 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()
|
---|
[2668] | 26 | del s
|
---|
[1853] | 27 |
|
---|
[2668] | 28 | def tearDown(self):
|
---|
| 29 | del self.st
|
---|
| 30 |
|
---|
[1853] | 31 | def test_init(self):
|
---|
| 32 | assert_equal(self.st.nrow(), 36)
|
---|
| 33 | assert_equal(self.st.get_fluxunit(), 'K')
|
---|
| 34 | assert_equal(self.st.nchan(), 2048)
|
---|
| 35 | assert_equal(self.st.nif(), 4)
|
---|
| 36 |
|
---|
| 37 | def test_spectrum(self):
|
---|
| 38 | import numpy
|
---|
| 39 | sp=numpy.array(self.st._getspectrum(0))
|
---|
| 40 | assert_equal(sp.max(),1.9524071216583252)
|
---|
| 41 | assert_equal(sp.min(),-0.0071961274370551109)
|
---|
| 42 | assert_equal(sp.argmax(),1648)
|
---|
| 43 | assert_equal(sp.argmin(),1614)
|
---|
| 44 |
|
---|
| 45 | def test_stats(self):
|
---|
| 46 | assert_equal(self.st.stats('rms')[0],1.1064267158508301)
|
---|
| 47 | assert_equal(self.st.stats('stddev')[0],0.29552212357521057)
|
---|
| 48 | assert_equal(self.st.stats('median')[0],1.0714811086654663)
|
---|
| 49 | assert_equal(self.st.stats('mean')[0],1.0662506818771362)
|
---|
| 50 | assert_equal(self.st.stats('sum')[0],2183.681396484375)
|
---|
| 51 |
|
---|
[2659] | 52 |
|
---|
[1853] | 53 | def test_frequency(self):
|
---|
[2677] | 54 | raise SkipTest("Currently disabled")
|
---|
[1853] | 55 | rf=self.st.get_restfreqs()
|
---|
| 56 | assert_equal(len(rf),2)
|
---|
| 57 | assert_equal(rf[0][0],85162157000.0)
|
---|
| 58 | assert_equal(rf[1][0],86754330000.0)
|
---|
| 59 | self.st.set_unit('GHz')
|
---|
| 60 | abc=self.st._getabcissa(0)
|
---|
[2668] | 61 | assert_equal(abc[0],85.183349020848283)
|
---|