def setUp(self): self.FileProcessor = fitsGBT.Reader(fits_test_file_name, 0) self.IFs_all = sp.array( self.FileProcessor.fitsdata.field('CRVAL1') / 1E6) self.IFs_all = self.IFs_all.round(0) self.IFs_all = sp.array(self.IFs_all, int) self.scans_all = sp.array(self.FileProcessor.fitsdata.field('SCAN'))
def setUp(self): self.Reader = fitsGBT.Reader(fits_test_file_name, 0) self.Blocks = list(self.Reader.read([], [])) # Manually add in RA and DEC fields as test data was created before # these were standard. for Data in self.Blocks: ntime = Data.dims[0] Data.set_field('RA', sp.arange(ntime, dtype=sp.float64), axis_names=('time', )) Data.set_field('DEC', sp.arange(ntime, 0, -1, dtype=sp.float64), axis_names=('time', ))
def test_writes_history(self): # Mock up a work flow history Block1 = self.Reader.read(0, 0) Block2 = self.Reader.read(0, 1) Block1.add_history('Processed.', ('Processing detail 1', )) Block2.add_history('Processed.', ('Processing detail 2', )) hist_entry = ("This is a long history entry that is much longer than " "80 characters and should cause a wrapping of the fits " "history key.") hist_detail = ("We really want to check that the pyfits " "mechanisms/any supporting code that Ive written can " "properly deal with this.", ) Block1.add_history(hist_entry, hist_detail) Block2.add_history(hist_entry, hist_detail) Writer = fitsGBT.Writer((Block1, Block2), 0) Writer.write('temp2.fits') newReader = fitsGBT.Reader('temp2.fits', 0) newBlock = newReader.read(0, 0) # These two line need to come before anything likly to fail. del newReader os.remove('temp2.fits') # See that we have all the history we expect. hist = newBlock.history self.assertTrue(hist.has_key('000: Read from file.')) self.assertEqual(len(hist['000: Read from file.']), 1) self.assertTrue(hist.has_key('001: Processed.')) self.assertEqual(len(hist['001: Processed.']), 2) self.assertEqual(hist['001: Processed.'][0], 'Processing detail 1') self.assertEqual(hist['001: Processed.'][1], 'Processing detail 2') self.assertTrue(hist.has_key('002: ' + hist_entry)) self.assertEqual(len(hist['002: ' + hist_entry]), 1) self.assertEqual(hist['002: ' + hist_entry][0], hist_detail[0]) self.assertTrue(hist.has_key('003: Written to file.')) self.assertEqual(len(hist['003: Written to file.']), 1) self.assertEqual(hist['003: Written to file.'][0], 'File name: ' + 'temp2.fits') self.assertTrue(hist.has_key('004: Read from file.'))
def circle(self): self.BlocksToWrite = copy.deepcopy(self.Blocks) self.Writer = fitsGBT.Writer(self.BlocksToWrite, 0) self.Writer.write('temp.fits') self.newReader = fitsGBT.Reader('temp.fits', 0) self.newBlocks = self.newReader.read() self.assertEqual(len(self.Blocks), len(self.newBlocks)) for ii in range(len(self.newBlocks)): OldDB = self.Blocks[ii] NewDB = self.newBlocks[ii] for jj in range(4): self.assertEqual(OldDB.dims[ii], NewDB.dims[ii]) self.assertTrue(ma.allclose(OldDB.data, NewDB.data)) for field, axis in fitsGBT.fields_and_axes.iteritems(): self.assertEqual(axis, OldDB.field_axes[field]) self.assertEqual(axis, NewDB.field_axes[field]) for field in [ 'SCAN', 'OBJECT', 'TIMESTAMP', 'OBSERVER', 'CRPIX1', 'CDELT1' ]: self.assertEqual(OldDB.field[field], NewDB.field[field]) for field in ['CRVAL1', 'BANDWID', 'RESTFREQ', 'DURATION']: self.assertAlmostEqual(OldDB.field[field], NewDB.field[field]) for field in [ 'LST', 'ELEVATIO', 'AZIMUTH', 'RA', 'DEC', 'OBSFREQ', 'CRVAL2', 'CRVAL3', 'EXPOSURE' ]: self.assertTrue( sp.allclose(OldDB.field[field], NewDB.field[field])) for field in ['DATE-OBS']: self.assertTrue( sp.alltrue(sp.equal(OldDB.field[field], NewDB.field[field]))) for field in ['CRVAL4', 'CAL']: self.assertTrue(all(OldDB.field[field] == NewDB.field[field]))
def setUp(self): self.FileProcessor = fitsGBT.Reader(fits_test_file_name, 0)
def setUp(self): # fits_test_file_name has no history. self.Reader = fitsGBT.Reader(fits_test_file_name, 0)
def setUp(self): self.Writer = fitsGBT.Writer(feedback=0) self.Reader = fitsGBT.Reader(fits_test_file_name, 0) Block = self.Reader.read(0, 0) self.Writer.add_data(Block)
def setUp(self): self.nscans = len(scan_set) self.nIFs = len(IF_set) self.Reader = fitsGBT.Reader(fits_test_file_name, 0)
def setUp(self): self.Reader = fitsGBT.Reader(fits_test_file_name, 0, 1) self.datashape = (ntimes_scan, npol, ncal, nfreq) self.DBlock = self.Reader.read(0, 0) self.DBlock.verify()
def setUp(self): self.Reader = fitsGBT.Reader(test_fits_file_name, 0) self.Data = self.Reader.read(0, 0)