def test_fits_meta(self): # Write a FITS HDU including metadata and read it back. orig = MOC(order=10, cells=(4, 5, 6, 7), name='test-moc', mocid='ivo://TEST/...', origin='ivo://TEST', moctype='image') hdu = write_moc_fits_hdu(orig) copy = MOC() read_moc_fits_hdu(copy, hdu, include_meta=True) self.assertEqual(copy.name, 'test-moc') self.assertEqual(copy.id, 'ivo://TEST/...') self.assertEqual(copy.origin, 'ivo://TEST') self.assertEqual(copy.type, 'IMAGE') # Check that the MOC was normalized. self.assertEqual(copy.cells, 1) # Now check we do not overwrite metadata unless requested. other = MOC(order=10, cells=(4, 5, 6, 7), name='test-moc-modified', mocid='ivo://TEST2/...', origin='ivo://TEST2', moctype='catalog') read_moc_fits_hdu(other, hdu, include_meta=False) self.assertEqual(other.name, 'test-moc-modified') self.assertEqual(other.id, 'ivo://TEST2/...') self.assertEqual(other.origin, 'ivo://TEST2') self.assertEqual(other.type, 'CATALOG')
def test_fits_large_64(self): orig = MOC() orig.add(29, [3458700000000000000]) hdu = write_moc_fits_hdu(orig) self.assertIn('K', hdu.header['TFORM1']) copy = MOC() read_moc_fits_hdu(copy, hdu) self.assertEqual(copy.order, 29) self.assertEqual(copy[29], frozenset([3458700000000000000]))
def test_fits_large_32(self): orig = MOC() orig.add(13, [805306367]) hdu = write_moc_fits_hdu(orig) self.assertIn('J', hdu.header['TFORM1']) copy = MOC() read_moc_fits_hdu(copy, hdu) self.assertEqual(copy.order, 13) self.assertEqual(copy[13], frozenset([805306367]))
def test_fits_64(self): orig = MOC() orig.add(14, [0]) hdu = write_moc_fits_hdu(orig) self.assertIn('K', hdu.header['TFORM1']) copy = MOC() read_moc_fits_hdu(copy, hdu) self.assertEqual(copy.order, 14) self.assertEqual(copy[14], frozenset([0]))
def test_fits(self): orig = MOC() orig.add(10, [5, 6, 7, 8]) orig.add(11, [1000, 1001, 2000]) hdu = write_moc_fits_hdu(orig) copy = MOC() read_moc_fits_hdu(copy, hdu) self.assertEqual(copy.order, 11) self.assertEqual(copy[10], frozenset([5, 6, 7, 8])) self.assertEqual(copy[11], frozenset([1000, 1001, 2000]))