def test2(mrc1, mrc2): import Mrc import correlator cor = correlator.Correlator() im1 = Mrc.mrc_to_numeric(mrc1) im2 = Mrc.mrc_to_numeric(mrc2) ''' im1 = im1[:512,:512] im2 = im2[200:712,200:712] ''' cor.insertImage(im1) cor.insertImage(im2) pc = cor.phaseCorrelate() Mrc.numeric_to_mrc(pc, 'pc.mrc') print findSubpixelPeak(pc, npix=7, lpf=1.0)
def __init__(self, args: argparse.Namespace, mqtt_client: asyncio_mqtt.Client, device_alternate_id: str, num_msgs: int = 10): """PublishingState constructor :param args: the parsed command line arguments of the script (see the main() function) :param mqtt_client: the instance of an MQTT client to use :param device_alternate_id: the alternate ID of the simulated device :param num_msgs: the number of the measurement messages to send. """ self.mqtt_client = mqtt_client """The instance of an MQTT client to use""" self.device_alternate_id: str = device_alternate_id """The alternate ID of the simulated device""" self.num_msgs: int = num_msgs """The total number of messages to publish""" self.desired_message_rate: float = args.rate """The number of messages per second to publish""" self.samples_per_message: int = args.samples """The number of samples (measurement) per message to publish""" self.unconfirmed_measurements: Dict[str, datetime.datetime] = {} """The timestamp when the message with the given message ID--the key--was published. The messages referenced in the dictionary were not confirmed by the gateway (yet). As soon as the message is confirmed, the corresponding entry is removed from the dictionary. """ self.utc_start_ts: float | None = None """The timestamp when the first measurement message was posted""" self.messages_published: int = 0 """The number of measurement messages published""" self.bytes_published: int = 0 """The cumulative size of the measurement messages published (in bytes)""" self.messages_acked = 0 """The number of measurement messages successfully acknowledged by the gateway""" self.correlator = correlator.Correlator() """Measures how the latency correlates with the number of the published measurement messages. A positive correlation means that the gateway does not cope with the load and keeps buffering the incoming messages. """ self.digest = tdigest.TDigest() """Percentile estimation for streaming data"""
def __init__(self, prn, receiver, param_list=_M_ARRAY_DATA_NAMES): """ Constructs a Channel object with specified prn and measurement length. """ self.prn = prn self.receiver = receiver self.rawfile = self.receiver.rawfile self._measurement_logs_on = False self.init_measurement_logs(param_list=param_list) self._cpcount = 0 # internal codeperiod counter self.cp[0] = 0 # Initialize correlator. self.correlator = correlator.Correlator(self.prn, channel=self) # Initialize discriminators and loopfilters. self.cdiscriminator = discriminator.Discriminator(flavor='DLL', channel=self) self.idiscriminator = discriminator.Discriminator(flavor='PLL', channel=self) self.cloopfilter = loopfilter.LoopFilter(self.rawfile.T, Bnp=3.0, channel=self) self.iloopfilter = loopfilter.LoopFilter(self.rawfile.T, Bnp=40.0, channel=self) # Initialize lockdetector and snrmeter. self.lockdetector = lockdetector.LockDetector(N=20, k=1.5, lossthreshold=50, lockthreshold=240) self.snrmeter = snrmeter.SignalNoiseMeter(N=20, T=self.rawfile.T)
#!/usr/bin/env python import antenna_array import correlator import numpy as np import matplotlib.pyplot as plt BASELINE_LENGTH = 2.55 arr = antenna_array.AntennaArray(BASELINE_LENGTH * 2 * np.pi) ref = arr.each_pair_phase_difference_at_angle(0) corr = correlator.Correlator(ref, arr) response = corr.many_directions(-np.pi, np.pi, 900) x = response.keys() x.sort() y = [] for i_idx, i_val in enumerate(x): y.append(response[i_val]) plt.plot(x, y) plt.show()
#!/usr/bin/env python import correlator import matplotlib.pyplot as plt import numpy as np import time import logging import argparse logging.basicConfig() logger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG) parser = argparse.ArgumentParser("Get data from correlator and plot it") parser.add_argument('--acc_len', type=int) args = parser.parse_args() c = correlator.Correlator('localhost', 4, logger=logger.getChild('correlator')) #c.set_shift_schedule(0b1110101101) c.set_shift_schedule(4095) c.set_accumulation_len(args.acc_len) c.re_sync() time.sleep(10) to_plot = c.get_autos()[0].signal # 0x0 #to_plot = c.get_crosses()[0].signal # 0x1 print(to_plot) plt.plot(np.abs(to_plot), marker='.') plt.show()