Skip to content
Snippets Groups Projects
Commit 1b734370 authored by Mattia Mancini's avatar Mattia Mancini
Browse files

SSB-42: dataset work in progress

parent f2c7c1ff
No related branches found
No related tags found
1 merge request!44Merge back holography to master
...@@ -2,6 +2,7 @@ from .holography_specification import HolographySpecification ...@@ -2,6 +2,7 @@ from .holography_specification import HolographySpecification
from lofar.calibration.common.datacontainers.holography_observation import HolographyObservation from lofar.calibration.common.datacontainers.holography_observation import HolographyObservation
import logging import logging
import numpy import numpy
from collections import defaultdict
import h5py import h5py
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
...@@ -58,7 +59,7 @@ class HolographyDataset(): ...@@ -58,7 +59,7 @@ class HolographyDataset():
n_beamlets = len(self.beamlets) n_beamlets = len(self.beamlets)
n_reference_stations = len(self.reference_stations) n_reference_stations = len(self.reference_stations)
data = dict() data = defaultdict()
for hbs, ho in list_of_hbs_ms_tuples: for hbs, ho in list_of_hbs_ms_tuples:
if station_name in hbs.target_station_names: if station_name in hbs.target_station_names:
frequency = ho.frequency frequency = ho.frequency
...@@ -196,7 +197,7 @@ class HolographyDataset(): ...@@ -196,7 +197,7 @@ class HolographyDataset():
:param path: path to file :param path: path to file
:return: the read dataset :return: the read dataset
""" """
f = h5py.File(path, "r") f = h5py.File(path, "r")
result = HolographyDataset() result = HolographyDataset()
...@@ -250,10 +251,10 @@ class HolographyDataset(): ...@@ -250,10 +251,10 @@ class HolographyDataset():
Stores the holography dataset at the given path Stores the holography dataset at the given path
:param path: path to file :param path: path to file
""" """
# Prepare the HDF5 data structs. # Prepare the HDF5 data structs.
f = h5py.File(path, "w") f = h5py.File(path, "w")
# Create the ATTRS # Create the ATTRS
# Start with the version information # Start with the version information
f.attrs["Version"] = self.HOLOGRAPHY_DATA_SET_VERSION f.attrs["Version"] = self.HOLOGRAPHY_DATA_SET_VERSION
...@@ -265,18 +266,18 @@ class HolographyDataset(): ...@@ -265,18 +266,18 @@ class HolographyDataset():
# RCU mode # RCU mode
f.attr["mode"] = self.mode f.attr["mode"] = self.mode
# Moan... Again this needs to be stored like that. # Moan... Again this needs to be stored like that.
f.attr["SAS id"] = numpy.array(self.sas_ids, dtype = h5py.special_dtype(vlen = str)) f.attr["SAS id"] = numpy.array(self.sas_ids, dtype = h5py.special_dtype(vlen = str))
f.attr["Target station name"] = self.target_station_name f.attr["Target station name"] = self.target_station_name
f.attr["Target station position"] = self.target_station_position f.attr["Target station position"] = self.target_station_position
f.attr["Source name"] = self.source_name f.attr["Source name"] = self.source_name
f.attr["Source position"] = self.source_position f.attr["Source position"] = self.source_position
f.attr["Observation time"] = numpy.array([self.start_time, self.end_time]) f.attr["Observation time"] = numpy.array([self.start_time, self.end_time])
f.attr["Rotation matrix"] = self.rotation_matrix f.attr["Rotation matrix"] = self.rotation_matrix
......
...@@ -135,19 +135,22 @@ class HolographyMeasurementSet(object): ...@@ -135,19 +135,22 @@ class HolographyMeasurementSet(object):
try: try:
antenna_name_index = antennas_table.index('NAME') antenna_name_index = antennas_table.index('NAME')
reference_antennas_indexes = [antenna_name_index[reference_station]
for reference_station in reference_stations]
target_antenna_index = antenna_name_index[target_station]
TAQL_query_syntax = '(ANTENNA1 = $target_antenna_index ' \
'OR' \
' ANTENNA2 = $target_antenna_index)' \
' AND ' \
'(ANTENNA1 IN $reference_antennas_indexes ' \
'OR' \
' ANTENNA2 IN $reference_antennas_indexes)'
table = data_table.query(TAQL_query_syntax)
baseline_selection = ','.join(reference_stations)
baseline_selection += '&&' + target_station
TAQL_query_syntax = 'mscal.baseline($baseline_selection)'
table = data_table.query(TAQL_query_syntax, columns='TIME,'
'FLAG_ROW,'
'DATA,'
'ANTENNA1,'
'ANTENNA2,'
'mscal.ant1name() as ANTENNA_NAME1,'
'mscal.ant2name() as ANTENNA_NAME2',
sortlist='TIME, ANTENNA1, ANTENNA2')
print(table.getcol('ANTENNA_NAME1'))
timestamps = list(table.getcol('TIME')) timestamps = list(table.getcol('TIME'))
flags = table.getcol('FLAG_ROW') flags = table.getcol('FLAG_ROW')
crosscorrelations = numpy.squeeze(table.getcol('DATA')) crosscorrelations = numpy.squeeze(table.getcol('DATA'))
......
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