From 7344bf8df5abfc07f240cf2c624d77ec58ee7f3f Mon Sep 17 00:00:00 2001 From: aaronpearlman Date: Thu, 10 Sep 2020 12:05:48 -0700 Subject: [PATCH 1/4] Fixed bugs writing large PSRFITS files, reading filterbank files, and specifying Stokes I pol for IQUV PSRFITS files --- your/formats/psrfits.py | 2 +- your/formats/pysigproc.py | 3 ++- your/writer.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/your/formats/psrfits.py b/your/formats/psrfits.py index f01bb7c..c6ae55e 100644 --- a/your/formats/psrfits.py +++ b/your/formats/psrfits.py @@ -266,7 +266,7 @@ def read_subint(self, isub, apply_weights=True, apply_scales=True, \ data += sdata[:, 1, :].squeeze() elif (len(shp) == 3 and shp[1] == self.npoln and self.poln_order == "IQUV"): - logger.warning("Polarization is IQUV") + logger.warning("Polarization is IQUV (pol = %i)" % pol) data = np.zeros((self.nsamp_per_subint, self.nchan), dtype=np.float32) if pol == 0: diff --git a/your/formats/pysigproc.py b/your/formats/pysigproc.py index f79c8a5..d15fbd4 100755 --- a/your/formats/pysigproc.py +++ b/your/formats/pysigproc.py @@ -82,7 +82,8 @@ class SigprocFile(object): _type['tstart'] = 'double' _type['tsamp'] = 'double' _type['nifs'] = 'int' - + _type['nsamples'] = 'int' + def __init__(self, fp=None, copy_hdr=None): # init all items to None for k in list(self._type.keys()): diff --git a/your/writer.py b/your/writer.py index 514841e..79cc42f 100644 --- a/your/writer.py +++ b/your/writer.py @@ -164,7 +164,7 @@ def to_fil(self): nloops = 1 nstarts = np.arange(self.nstart, self.nstart + interval * nloops, interval, dtype=int) nsamps = np.full(nloops, interval) - if nsamps % interval != 0: + if self.nsamp % interval != 0: nsamps = np.append(nsamps, [nsamps % interval]) logging.debug(f'nstarts is {nstarts}, nsamps is {nsamps}, nloops is {nloops}, interval is {interval}, ' From 3471d80645830ca1cf18d327c0a430ee6d2df365 Mon Sep 17 00:00:00 2001 From: aaronpearlman Date: Thu, 10 Sep 2020 12:55:41 -0700 Subject: [PATCH 2/4] added install command --- install_cmd.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 install_cmd.txt diff --git a/install_cmd.txt b/install_cmd.txt new file mode 100644 index 0000000..8f7ed2e --- /dev/null +++ b/install_cmd.txt @@ -0,0 +1 @@ +python3 setup.py install --user From 4c5d4e98f33516ca2bd6b10c121eee7c258e0d89 Mon Sep 17 00:00:00 2001 From: aaronpearlman Date: Thu, 10 Sep 2020 13:38:17 -0700 Subject: [PATCH 3/4] fixed bug with non-interger nloops variable, for writing filterbanks --- your/writer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/your/writer.py b/your/writer.py index 79cc42f..cee78b9 100644 --- a/your/writer.py +++ b/your/writer.py @@ -163,7 +163,7 @@ def to_fil(self): else: nloops = 1 nstarts = np.arange(self.nstart, self.nstart + interval * nloops, interval, dtype=int) - nsamps = np.full(nloops, interval) + nsamps = np.full(int(nloops), interval) if self.nsamp % interval != 0: nsamps = np.append(nsamps, [nsamps % interval]) From b7d37ad73fd97f2bb2acede913d1a323fd791d78 Mon Sep 17 00:00:00 2001 From: aaronpearlman Date: Fri, 11 Sep 2020 00:46:31 -0700 Subject: [PATCH 4/4] merge writer fix from main branch --- your/formats/filwriter.py | 7 ++++++- your/writer.py | 14 ++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/your/formats/filwriter.py b/your/formats/filwriter.py index fa218c2..14211a0 100644 --- a/your/formats/filwriter.py +++ b/your/formats/filwriter.py @@ -43,7 +43,12 @@ def make_sigproc_obj(filfile, your_object, nchans, chan_freq, nstart): fil_obj.pulsarcentric = 0 fil_obj.telescope_id = 6 # use only GBT for now fil_obj.data_type = 0 - + + # Enable these parameters for DSN data. + # fil_obj.telescope_id = 12 # For Canberra DSN (DSS-43) + # fil_obj.machine_id = 999 + # fil_obj.data_type = 1 + fil_obj.nchans = nchans fil_obj.foff = your_object.your_header.foff fil_obj.fch1 = chan_freq[0] diff --git a/your/writer.py b/your/writer.py index cee78b9..63657b0 100644 --- a/your/writer.py +++ b/your/writer.py @@ -153,22 +153,28 @@ def to_fil(self): # Calculate loop of spectra if not self.nsamp: self.nsamp = self.your_obj.your_header.native_nspectra - + interval = 4096 * 24 if self.nsamp < interval: interval = self.nsamp if self.nsamp > interval: - nloops = 1 + self.nsamp // interval + nloops = self.nsamp // interval else: nloops = 1 - nstarts = np.arange(self.nstart, self.nstart + interval * nloops, interval, dtype=int) + nsamps = np.full(int(nloops), interval) if self.nsamp % interval != 0: - nsamps = np.append(nsamps, [nsamps % interval]) + nsamps = np.append(nsamps, [self.nsamp % interval]) + nloops += 1 + nstarts = np.arange(self.nstart, self.nstart + interval * nloops, interval, dtype=int) logging.debug(f'nstarts is {nstarts}, nsamps is {nsamps}, nloops is {nloops}, interval is {interval}, ' f'nstart is {self.nstart}') + + assert np.sum(nsamps) == self.nsamp, "Sum of [nsamps] is not equal to total number of spectra to read." + + # Read data for st, samp in tqdm.tqdm(zip(nstarts, nsamps), total=len(nstarts), disable=self.progress): logger.debug(f'Reading spectra {st}-{st + samp} in file {self.your_obj.your_header.filename}')