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

SW-43: minor fixes in the beamlet searching

parent 9aa42457
No related branches found
No related tags found
1 merge request!44Merge back holography to master
...@@ -84,6 +84,8 @@ class HolographyDataset(): ...@@ -84,6 +84,8 @@ class HolographyDataset():
# a dict of dicts and eventually str, ndarray or that can be converted in a ndarray calling # a dict of dicts and eventually str, ndarray or that can be converted in a ndarray calling
# numpy.array() # numpy.array()
self.derived_data = None self.derived_data = None
# the index of the central beamlet
self.central_beamlet = None
@staticmethod @staticmethod
def compare_dicts(dict1, dict2): def compare_dicts(dict1, dict2):
...@@ -179,7 +181,9 @@ class HolographyDataset(): ...@@ -179,7 +181,9 @@ class HolographyDataset():
# and iterate over the beamlets. # and iterate over the beamlets.
for beamlet in beamlets: for beamlet in beamlets:
beamlet_string = str(beamlet) 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 # calculate a pseudo distance that is an indicator if this
# beamlet is closer to the source than the ones before. # beamlet is closer to the source than the ones before.
# Note that I am too lazy to calculate the spherical distance. # Note that I am too lazy to calculate the spherical distance.
...@@ -187,7 +191,7 @@ class HolographyDataset(): ...@@ -187,7 +191,7 @@ class HolographyDataset():
# the geometrical distance are not really cutting it since RA # the geometrical distance are not really cutting it since RA
# and DEC are coordinates of a spherical coordinate system. # and DEC are coordinates of a spherical coordinate system.
# But here the pseudo distance is good enough. # 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 # OK. Done with all the iteration business. Now check if across all
# frequencies the same beamlet is the central one. It is allowed that # frequencies the same beamlet is the central one. It is allowed that
...@@ -220,7 +224,7 @@ class HolographyDataset(): ...@@ -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) logger.debug("All is good, unicorns everywhere, there is only one central beamlet \"%s\" for all frequencies.", self.central_beamlet)
else: else:
logger.warn("Multiple central beamlets have been identified: ", central_beamlet) 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): def load_from_beam_specification_and_ms(self, station_name, list_of_hbs_ms_tuples):
""" """
...@@ -231,10 +235,14 @@ class HolographyDataset(): ...@@ -231,10 +235,14 @@ class HolographyDataset():
""" """
logger.info("Creating a holography data set for station \"%s\"...", station_name) logger.info("Creating a holography data set for station \"%s\"...", station_name)
self.__collect_preliminary_information(station_name, list_of_hbs_ms_tuples) try:
self.__read_data(station_name, list_of_hbs_ms_tuples) self.__collect_preliminary_information(station_name, list_of_hbs_ms_tuples)
self.central_beamlets = self.find_central_beamlets(self.source_position, self.ra_dec, self.frequencies, self.beamlets) self.__read_data(station_name, list_of_hbs_ms_tuples)
logger.info("Creation of a holography data set for station \"%s\" done.", station_name) 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): def __read_data(self, station_name, list_of_hbs_ms_tuples):
""" """
......
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