示例#1
0
 def test_overwrite(self):
     """test_overwrite: File existence check"""
     shutil.copy(self.infile, self.outfile)
     with self.assertRaisesRegexp(RuntimeError, '.* exists\.$') as cm:
         importnro(infile=self.infile,
                   outputvis=self.outfile,
                   overwrite=False)
示例#2
0
 def test_invaliddata(self):
     """test_invaliddata: Invalid data check"""
     with open(self.infile, 'wb') as f:
         f.write('AA')
     #os.remove(os.path.join(self.infile, 'table.info'))
     with self.assertRaisesRegexp(RuntimeError,
                                  '.* is not a valid NOSTAR data\.$') as cm:
         importnro(infile=self.infile,
                   outputvis=self.outfile,
                   overwrite=False)
示例#3
0
 def test_normal(self):
     """test_normal: Normal data import"""
     ret = importnro(infile=self.infile, outputvis=self.outfile, overwrite=True)
     self.assertTrue(os.path.exists(self.outfile))
     try:
         # to check if outfile is valid MS
         myms.open(self.outfile)
         myms.close()
         
     except Exception, e:
         print e
         self.fail('outputvis is not a valid ms')
示例#4
0
    def test_normal(self):
        """test_normal: Normal data import"""
        ret = importnro(infile=self.infile,
                        outputvis=self.outfile,
                        overwrite=True)
        self.assertTrue(os.path.exists(self.outfile))
        try:
            # to check if outfile is valid MS
            myms.open(self.outfile)
            myms.close()

        except Exception, e:
            print e
            self.fail('outputvis is not a valid ms')
示例#5
0
    def test_timestamp(self):
        """test_timestamp: Check if timestamp is properly converted to UTC"""
        ret = importnro(infile=self.infile,
                        outputvis=self.outfile,
                        overwrite=True)
        self.assertTrue(os.path.exists(self.outfile))

        # test if telescope elevation has reasonable value
        (myme, ) = gentools(['me'])
        # make sure me tool is initialized
        myme.done()

        # antenna_position should be a position measure
        antenna_position = get_antenna_position(self.outfile, 0)
        self.assertTrue(myme.ismeasure(antenna_position))
        self.assertTrue(antenna_position['type'] == 'position')

        # pointing_time should be a time (epoch) measure
        # pointing_direction should be a direction measure
        # pointing_direction should not be [0,0]
        pointing_time, pointing_direction = get_valid_pointing_info(
            self.outfile)
        self.assertTrue(myme.ismeasure(pointing_time))
        self.assertTrue(pointing_time['type'] == 'epoch')
        self.assertTrue(myme.ismeasure(pointing_direction))
        self.assertTrue(pointing_direction['type'] == 'direction')
        self.assertFalse(pointing_direction['m0']['value'] == 0.0
                         and pointing_direction['m1']['value'])

        # convert pointing_direction (J2000) to AZELGEO
        # frame configuration
        myme.doframe(pointing_time)
        myme.doframe(antenna_position)

        # frame cnversion
        azel = myme.measure(v=pointing_direction, rf='AZELGEO')
        myme.done()

        # check if elevation is in range [0deg, 90deg]
        elevation = qa.convert(azel['m1'], 'deg')
        msg = 'Timestamp used for the conversion could be wrong.: calculated elevation={value}{unit}'.format(
            **elevation)
        self.assertLessEqual(
            elevation['value'],
            90.0,
            msg='Elevation is above the upper limit (> 90deg). {}'.format(msg))
        self.assertGreaterEqual(
            elevation['value'],
            0.0,
            msg='Elevation is below the lower limit (< 0deg). {}'.format(msg))
示例#6
0
 def test_invaliddata(self):
     """test_invaliddata: Invalid data check"""
     with open(self.infile, 'wb') as f: f.write('AA')
     #os.remove(os.path.join(self.infile, 'table.info'))
     with self.assertRaisesRegexp(RuntimeError, '.* is not a valid NOSTAR data\.$') as cm:
         importnro(infile=self.infile, outputvis=self.outfile, overwrite=False)
示例#7
0
 def test_overwrite(self):
     """test_overwrite: File existence check"""
     shutil.copy(self.infile, self.outfile)
     with self.assertRaisesRegexp(RuntimeError, '.* exists\.$') as cm:
         importnro(infile=self.infile, outputvis=self.outfile, overwrite=False)