diff --git a/CAL/CalibrationCommon/lib/datacontainers/holography_dataset.py b/CAL/CalibrationCommon/lib/datacontainers/holography_dataset.py index f77a87333fc17ba7d340eda4bacf4037f81a6dc5..846d04809b1ce77abc202c962dfd82a0a3feaf9b 100644 --- a/CAL/CalibrationCommon/lib/datacontainers/holography_dataset.py +++ b/CAL/CalibrationCommon/lib/datacontainers/holography_dataset.py @@ -84,6 +84,8 @@ class HolographyDataset(): # a dict of dicts and eventually str, ndarray or that can be converted in a ndarray calling # numpy.array() self.derived_data = None + # the index of the central beamlet + self.central_beamlet = None @staticmethod def compare_dicts(dict1, dict2): @@ -179,7 +181,9 @@ class HolographyDataset(): # and iterate over the beamlets. for beamlet in beamlets: beamlet_string = str(beamlet) - (ra, dec, epoch) = ra_dec[frequency_string][beamlet_string] + ra = ra_dec[frequency_string][beamlet_string]['RA'] + dec = ra_dec[frequency_string][beamlet_string]['DEC'] + # calculate a pseudo distance that is an indicator if this # beamlet is closer to the source than the ones before. # Note that I am too lazy to calculate the spherical distance. @@ -187,7 +191,7 @@ class HolographyDataset(): # the geometrical distance are not really cutting it since RA # and DEC are coordinates of a spherical coordinate system. # But here the pseudo distance is good enough. - pseudo_distance[frequency][beamlet] = math.abs(ra - source_ra) + math.abs(dec - source_dec) + pseudo_distance[frequency_string][beamlet_string] = abs(ra - source_ra) + abs(dec - source_dec) # OK. Done with all the iteration business. Now check if across all # frequencies the same beamlet is the central one. It is allowed that @@ -220,7 +224,7 @@ class HolographyDataset(): logger.debug("All is good, unicorns everywhere, there is only one central beamlet \"%s\" for all frequencies.", self.central_beamlet) else: logger.warn("Multiple central beamlets have been identified: ", central_beamlet) - return central_beamlet + return list(central_beamlet) def load_from_beam_specification_and_ms(self, station_name, list_of_hbs_ms_tuples): """ @@ -231,10 +235,14 @@ class HolographyDataset(): """ logger.info("Creating a holography data set for station \"%s\"...", station_name) - self.__collect_preliminary_information(station_name, list_of_hbs_ms_tuples) - self.__read_data(station_name, list_of_hbs_ms_tuples) - self.central_beamlets = self.find_central_beamlets(self.source_position, self.ra_dec, self.frequencies, self.beamlets) - logger.info("Creation of a holography data set for station \"%s\" done.", station_name) + try: + self.__collect_preliminary_information(station_name, list_of_hbs_ms_tuples) + self.__read_data(station_name, list_of_hbs_ms_tuples) + self.central_beamlets = self.find_central_beamlets(self.source_position, self.ra_dec, self.frequencies, self.beamlets) + logger.info("Creation of a holography data set for station \"%s\" done.", station_name) + except Exception as e: + logger.exception("Errore creating dataset for station \"%s\": %s", station_name, e) + raise e def __read_data(self, station_name, list_of_hbs_ms_tuples): """