示例#1
0
 def test_construction(self):
     """Test construction of DelayCorrection object."""
     descr = self.delays.description
     delays2 = katpoint.DelayCorrection(descr)
     delays_dict = json.loads(descr)
     delays2_dict = json.loads(delays2.description)
     self.assertEqual(delays2_dict, delays_dict,
                      'Objects created through description strings differ')
     self.assertRaises(ValueError, katpoint.DelayCorrection,
                       [self.ant1, self.ant2], self.ant3)
     self.assertRaises(ValueError, katpoint.DelayCorrection,
                       [self.ant1, self.ant2])
     self.assertRaises(ValueError, katpoint.DelayCorrection, '')
     delays3 = katpoint.DelayCorrection([], self.ant1)
     self.assertEqual(
         delays3._params.shape, (0, len(katpoint.DelayModel())),
         "Delay correction with no antennas should fail gracefully")
示例#2
0
 def setUp(self):
     self.target1 = katpoint.construct_azel_target('45:00:00.0',
                                                   '75:00:00.0')
     self.target2 = katpoint.Target('Sun, special')
     self.ant1 = katpoint.Antenna('A1, -31.0, 18.0, 0.0, 12.0, 0.0 0.0 0.0')
     self.ant2 = katpoint.Antenna(
         'A2, -31.0, 18.0, 0.0, 12.0, 10.0 -10.0 0.0')
     self.ant3 = katpoint.Antenna(
         'A3, -31.0, 18.0, 0.0, 12.0, 5.0 10.0 3.0')
     self.ts = katpoint.Timestamp('2013-08-14 08:25')
     self.delays = katpoint.DelayCorrection([self.ant2, self.ant3],
                                            self.ant1, 1.285e9)
示例#3
0
    def get_delay_polynomials(self, epoch, duration=10.0):
        """
        calculate and return the polynomials

        Arguments:
        timestamp -- the observation time in datatime object or epoch seconds
        duration -- the duration in which the polynomial is calcuated

        return:
        polynomials in the order of beam, antenna, (delay, rate)

        """
        timestamp = DelayPolynomial.check_time(epoch)
        antennaObjectList = self.antennas
        timestamp = (timestamp, timestamp + duration)

        target_array = []
        for target in self.targets:
            dc = katpoint.DelayCorrection(self.antennas, self.reference,
                                          self.frequency)
            delay, phase = dc.corrections(target, timestamp)
            delayArray = np.array(
                dict_to_antenna_ordered_list(delay, self.antennas))
            """
            [:, 0, :]: only take first rate output
            """
            target_array.append(delayArray[:, 0, :])
        target_array = np.array(target_array)
        """
        subtract the boresight beam form the offset beams
        """
        dc = katpoint.DelayCorrection(self.antennas, self.reference,
                                      self.frequency)
        delay, phase = dc.corrections(self.bore_sight, timestamp)
        bore_sight_delay = np.array(
            dict_to_antenna_ordered_list(delay, self.antennas))[:, 0, :]

        target_array = target_array - bore_sight_delay
        return target_array
示例#4
0
    def update_config_params(self):
        """
        In this method parameters related to the resources assigned, are updated every time assign, release
        or configure commands are executed.

        :param argin: None

        :return: None

        """
        assigned_receptors_dict = {}
        assigned_receptors = []
        self.fsids_list = []

        self.logger.info("Updating config parameters.")

        # Load a set of antenna descriptions and construct Antenna objects from them
        with importlib.resources.open_text("cspsubarrayleafnode",
                                           "ska_antennas.txt") as f:
            descriptions = f.readlines()
        antennas = [katpoint.Antenna(line) for line in descriptions]
        # Create a dictionary including antenna objects
        antennas_dict = {ant.name: ant for ant in antennas}
        antenna_keys_list = antennas_dict.keys()
        for receptor in self.device_data.receptorIDList_str:
            if receptor in antenna_keys_list:
                assigned_receptors.append(antennas_dict[receptor])
                # Create a dictionary including antennas (objects) assigned to the Subarray
                assigned_receptors_dict[receptor] = antennas_dict[receptor]
        # Antenna having key 'ref_ant' from antennas_dict, is referred as a reference antenna.
        ref_ant = antennas_dict["ref_ant"]
        # Create DelayCorrection Object
        self.delay_correction_object = katpoint.DelayCorrection(
            assigned_receptors, ref_ant)
        self.antenna_names = list(
            self.delay_correction_object.ant_models.keys())
        # list of frequency slice ids
        for fsp_entry in self.device_data.fsp_ids_object:
            self.fsids_list.append(fsp_entry["fspID"])
        self.logger.info("Completed updating config parameters.")
示例#5
0
 def download_IERS_file(self):
     """ This method performs one delay calculation with dummy values to download the IERS file in advanced 
     to the delay calcualtions at the initialization of the device ."""
     # Create an example radec target
     ra = '21:08:47.92'
     dec = '-88:57:22.9'
     target = katpoint.Target.from_radec(ra, dec)
     descriptions = '''
     ref_ant, -30:42:39.8, 21:26:38.0, 1086, 13.5, 0 0 0 0 0 0,0, 0
     ref_ant, -30:42:39.8, 21:26:38.0, 1086, 13.5, 0 0 0 0 0 0,0, 0
     '''.strip().split('\n')
     antennas = [katpoint.Antenna(line) for line in descriptions]
     ref_ant = antennas[0]
     ants = antennas[1:]
     try:
         delay_correction = katpoint.DelayCorrection(ants, ref_ant)
     except Exception as delay_execption:
         log_msg = f"Exception in DelayCorrection Katpoint API {delay_execption}"
         self.logger.exception(log_msg)
     # Get delays towards target for example timestamp
     exa_time_t0 = '2021-05-04 12:54:09.686556'
     time_t0_obj = datetime.strptime(exa_time_t0, '%Y-%m-%d %H:%M:%S.%f')
     delays = delay_correction.delays(target, time_t0_obj)
     self.logger.info("delays are: '%s'", delays)
inputs = [ant.name + active_pol for ant in data.ants]
baseline_inds = [(inputs.index(inpA), inputs.index(inpB)) for inpA, inpB in data.corr_products]
baseline_names = [('%s - %s' % (inpA[:-1], inpB[:-1])) for inpA, inpB in data.corr_products]
num_bls = data.shape[2]
if num_bls == 0:
    raise RuntimeError('No baselines based on the requested antennas and polarisation found in data set')

# Reference antenna and excluded sources
excluded_targets = opts.exclude.split(',')
old_positions = np.array([ant.position_enu for ant in data.ants])
old_cable_lengths = np.array([ant.delay_model['FIX_' + active_pol.upper()] for ant in data.ants])
old_receiver_delays = old_cable_lengths / cable_lightspeed
# Pick reference position of first antenna as array antenna (and hope the rest are identical)
array_ant = katpoint.Antenna('ref', *(data.ants[0].ref_position_wgs84))
# Original delay model
correlator_model = katpoint.DelayCorrection(data.ants, array_ant, center_freq)

# Phase differences are associated with frequencies at midpoints between channels
mid_freqs = np.convolve(data.channel_freqs, [0.5, 0.5], mode='valid')
freq_diff = np.abs(np.diff(data.channel_freqs))
num_chans, sample_period = len(data.channel_freqs), data.dump_period

# Since phase slope is sampled in frequency, the derived delay exhibits aliasing with period of 1 / channel_bandwidth
# The maximum delay that can be reliably represented is therefore +- 0.5 delay_period
delay_period = 1. / data.channel_width
# Maximum standard deviation of delay occurs when delay samples are uniformly distributed between +- max_delay
# In this case, delay is completely random / unknown, and its estimate cannot be trusted
# The division by sqrt(N-1) converts the per-channel standard deviation to a per-snapshot deviation
max_sigma_delay = delay_period / np.sqrt(12) / np.sqrt(num_chans - 1)

ant_list = ', '.join([(ant.name + ' (*ref*)' if ind == ref_ant_ind else ant.name) for ind, ant in enumerate(data.ants)])