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

SSB-42: modified interface of read_crosscorrelation in the holography_measurementset class

parent 3b1fcf0c
No related branches found
No related tags found
1 merge request!44Merge back holography to master
......@@ -48,9 +48,16 @@ class HolographyDataset():
# points at given a frequency and a beamlet number
self.data = None # array(NreferenceStations, Nfrequencies, Nbeamlets) that contains the
# 4 polarization crosscorrelation for the 4 polarizations, the l and m coordinates, and
# the timestamp in mjd of the sample
self.flags = None # array(NReferenceStations, Nfrequencies, Nbeamlet) that contains the
# an array of boolean that define if a data in time has been flagged
# the timestamp in mjd of the sample, and whether of not the data has been flagged
# numpy.dtype([('XX', numpy.float),
# ('YY', numpy.float),
# ('XY', numpy.float),
# ('YX', numpy.float),
# ('l', numpy.float),
# ('m', numpy.float),
# ('t', numpy.float),
# ('flag', numpy.bool)]
# )
def load_from_beam_specification_and_ms(self, station_name, list_of_hbs_ms_tuples):
"""
......@@ -80,7 +87,7 @@ class HolographyDataset():
frequency = ho.frequency
for beamlet in self.beamlets:
cross_correlation, reference_station_names, timestamp, flags =\
reference_station_names, cross_correlation =\
ho.ms_for_a_given_beamlet_number[beamlet].\
read_cross_correlation_time_flags_per_station_names(station_name,
self.reference_stations)
......@@ -101,9 +108,7 @@ class HolographyDataset():
self.flags[reference_station][frequency] = dict()
self.data[reference_station][frequency][beamlet] = \
cross_correlation[reference_station_index, :, :]
self.flags[reference_station][frequency][beamlet] = \
flags[reference_station_index, :]
cross_correlation[reference_station_index, :]
def __collect_preliminary_information(self, station_name, list_of_hbs_ho_tuples):
......@@ -179,12 +184,13 @@ class HolographyDataset():
n_frequencies = len(self.frequencies)
n_beamlets = len(beamlets)
ra_dec = numpy.zeros((n_frequencies, n_beamlets, 2))
self.ra_dec = numpy.zeros((n_frequencies, n_beamlets, 2))
for frequency_index, frequency in enumerate(self.frequencies):
for beamlet_index, beamlet in enumerate(self.beamlets):
ra_dec[frequency_index, beamlet_index, :] = \
self.ra_dec[frequency_index, beamlet_index, :] = \
virtual_pointing[(frequency, beamlet)]
# reads the target station position and the coordinate of its axes
# and does this only once since the coordinate will not change
first_holography_observation = list_of_hbs_ho_tuples[0][1]
......
......@@ -7,6 +7,10 @@ import numpy
class HolographyMeasurementSet(object):
ms_name_pattern = r'L(?P<sas_id>\d{6})_SB(?P<sub_band_id>\d{3})_uv\.MS'
CASA_XX_INDEX = 0
CASA_XY_INDEX = 1
CASA_YX_INDEX = 2
CASA_YY_INDEX = 3
def __init__(self, ms_name, ms_path):
self.path = os.path.join(ms_path, ms_name)
......@@ -118,7 +122,6 @@ class HolographyMeasurementSet(object):
def get_source_name(self):
return self.__extract_source_name_from_pointing()
def read_cross_correlation_time_flags_per_station_names(self, target_station, reference_stations):
"""
Read the crosscorrelation for a given station name and a list of reference stations
......@@ -170,11 +173,46 @@ class HolographyMeasurementSet(object):
n_polarizations], order='F')
flags = flags.reshape([n_reference_stations, n_timestamps], order='F')
beams_crosscorrelations_datatype = numpy.dtype([
('XX', numpy.float),
('XY', numpy.float),
('YX', numpy.float),
('YY', numpy.float),
('l', numpy.float),
('m', numpy.float),
('t', numpy.float),
('flag', numpy.bool)]
)
beams_crosscorrelations_array = numpy.empty([n_reference_stations, n_timestamps],
dtype=beams_crosscorrelations_datatype)
for reference_station_index, reference_station_name in enumerate(reference_stations):
beams_crosscorrelations_array[reference_station_index, :]['t'] = timestamps
beams_crosscorrelations_array[reference_station_index, :]['XX'] = \
crosscorrelations[
reference_station_index, :, HolographyMeasurementSet.CASA_XX_INDEX]
beams_crosscorrelations_array[reference_station_index, :]['XY'] = \
crosscorrelations[
reference_station_index, :, HolographyMeasurementSet.CASA_XY_INDEX]
beams_crosscorrelations_array[reference_station_index, :]['YX'] = \
crosscorrelations[
reference_station_index, :, HolographyMeasurementSet.CASA_YX_INDEX]
beams_crosscorrelations_array[reference_station_index, :]['YY'] = \
crosscorrelations[
reference_station_index, :, HolographyMeasurementSet.CASA_YY_INDEX]
beams_crosscorrelations_array[reference_station_index, :]['flag'] = \
flags[reference_station_index, :]
finally:
data_table.close()
antennas_table.close()
return (crosscorrelations, reference_stations_names, timestamps, flags)
return (reference_stations_names, beams_crosscorrelations_array)
def __repr__(self):
return 'MeasurementSet(%d) located in %s for sas_id %d and sub_band_id %d' % (id(self),
......
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