Skip to content
Snippets Groups Projects
Commit 3b1fcf0c authored by Thomas Jürges's avatar Thomas Jürges
Browse files

Task SSB-42: Added HDF5 tests

The tests are not working yet.
parent fb263549
No related branches found
No related tags found
1 merge request!44Merge back holography to master
import logging import logging
import unittest import unittest
import tempfile
import os
from lofar.calibration.common.datacontainers import HolographyDataset, HolographySpecification from lofar.calibration.common.datacontainers import HolographyDataset, HolographySpecification
from lofar.calibration.common.datacontainers import HolographyObservation from lofar.calibration.common.datacontainers import HolographyObservation
logger = logging.getLogger('t_holography_dataset_class') logger = logging.getLogger('t_holography_dataset_class')
path_to_test_data = '/data/test/HolographyObservation' path_to_test_data = '/data/test/HolographyObservation'
path_to_test_data = '/home/thomas/workspace.astron/data/holography'
class TestHolographyDatasetClass(unittest.TestCase): class TestHolographyDatasetClass(unittest.TestCase):
def test_one(self): new_test_data_file = None
def tearDown(self):
if self.new_test_data_file is not None:
os.unlink(self.new_test_data_file)
# def test_one(self):
# holist = HolographyObservation.list_observations_in_path(path_to_test_data)
# hbsflist = HolographySpecification.list_bsf_files_in_path(path_to_test_data)
# for hbsf in hbsflist:
# hbsf.read_file()
# ho_per_ms = [(hbsf, ho) for hbsf, ho in zip(hbsflist, holist)]
#
# holography_dataset = HolographyDataset()
#
# holography_dataset.load_from_beam_specification_and_ms('CS013HBA0', ho_per_ms)
# self.assertEqual(holography_dataset.source_name, '3C 147')
def test_two(self):
holist = HolographyObservation.list_observations_in_path(path_to_test_data) holist = HolographyObservation.list_observations_in_path(path_to_test_data)
hbsflist = HolographySpecification.list_bsf_files_in_path(path_to_test_data) hbsflist = HolographySpecification.list_bsf_files_in_path(path_to_test_data)
for hbsf in hbsflist: for hbsf in hbsflist:
hbsf.read_file() hbsf.read_file()
ho_per_ms = [(hbsf, ho) for hbsf, ho in zip(hbsflist, holist)] ho_per_ms = [(hbsf, ho) for hbsf, ho in zip(hbsflist, holist)]
holography_dataset = HolographyDataset() holography_dataset = HolographyDataset()
holography_dataset.load_from_beam_specification_and_ms('CS013HBA0', ho_per_ms) holography_dataset.load_from_beam_specification_and_ms('CS013HBA0', ho_per_ms)
self.assertEqual(holography_dataset.source_name, '3C 147')
# Create an empty temporary data file
(fd, self.new_test_data_file) = tempfile.mkstemp()
print "**** %s " % (self.new_test_data_file)
os.close(fd)
# Now store the MS data in an HDF5 file.
holography_dataset.store_to_file(self.new_test_data_file)
# def test_three(self):
# # Read the MS data from an HDF5 file.
# holography_dataset = HolographyDataset.load_from_file(self.new_test_data_file)
# print holography_dataset
if __name__ == '__main__': if __name__ == '__main__':
logging.basicConfig(format='%(name)s : %(message)s') logging.basicConfig(format='%(name)s : %(message)s')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment