usnistgov / mass

Microcalorimeter pulse-analysis software
MIT License
6 stars 0 forks source link

ds.compute_noise(n_lags=100000) fails #257

Open joefowler opened 1 year ago

joefowler commented 1 year ago

Original report by Galen O'Neil (Bitbucket: oneilg, GitHub: oneilg).


ds.compute_noise(n_lags=100000) fails

I’m guessing it hasn’t been used to tested for a long time. We want to plot noise spectra from true bq pixels which have short records written but have very low f componenets.

with the below message

File ~/analysis/may-2023-am241/3_explore_and_make_off.py:57
     55 ds.summarize_data(use_cython=True)
     56 for ds in data:
---> 57     ds.compute_noise(n_lags=100000)
     58     ds.plot_noise()
     59 data.avg_pulses_auto_masks()

File ~/qsp/src/mass/mass/core/channel.py:1614, in MicrocalDataSet.compute_noise(self, max_excursion, n_lags, forceNew)
   1612     n_lags = self.noise_records.nSamples
   1613 if forceNew or all(self.noise_autocorr[:] == 0):
-> 1614     self.noise_records.compute_power_spectrum_reshape(
   1615         max_excursion=max_excursion, seg_length=n_lags)
   1616     self.noise_records.compute_autocorrelation(
   1617         n_lags=n_lags, plot=False, max_excursion=max_excursion)
   1619     self.noise_autocorr[:] = self.noise_records.autocorrelation[:len(
   1620         self.noise_autocorr[:])]

File ~/qsp/src/mass/mass/core/channel.py:201, in NoiseRecords.compute_power_spectrum_reshape(self, window, seg_length, max_excursion)
    199 psd = spectrum.spectrum()
    200 if self.hdf5_group is not None:
--> 201     self.noise_psd[:] = psd
    202     self.noise_psd.attrs["delta_f"] = freq[1] - freq[0]
    203 else:

File h5py/_objects.pyx:54, in h5py._objects.with_phil.wrapper()

File h5py/_objects.pyx:55, in h5py._objects.with_phil.wrapper()

File ~/qsp/lib/python3.8/site-packages/h5py/_hl/dataset.py:997, in Dataset.__setitem__(self, args, val)
    994     mshape = val.shape
    996 # Perform the write, with broadcasting
--> 997 mspace = h5s.create_simple(selection.expand_shape(mshape))
    998 for fspace in selection.broadcast(mshape):
    999     self.id.write(mspace, fspace, val, mtype, dxpl=self._dxpl)

File ~/qsp/lib/python3.8/site-packages/h5py/_hl/selections.py:264, in SimpleSelection.expand_shape(self, source_shape)
    262             eshape.append(t)
    263         else:
--> 264             raise TypeError("Can't broadcast %s -> %s" % (source_shape, self.array_shape))  # array shape
    266 if any([n > 1 for n in remaining_src_dims]):
    267     # All dimensions from target_shape should either have been popped
    268     # to match the selection shape, or be 1.
    269     raise TypeError("Can't broadcast %s -> %s" % (source_shape, self.array_shape))  # array shape

TypeError: Can't broadcast (50001,) -> (401,)

joefowler commented 1 year ago

Original comment by Galen O'Neil (Bitbucket: oneilg, GitHub: oneilg).


This part assumes n_lags==nSamples which is not consistent with taking n_lags as an argument.

https://bitbucket.org/joe_fowler/mass/src/b69e77f828b4dbc7340337e967a2892496aff740/mass/core/channel.py#lines-97

joefowler commented 11 months ago

Original comment by Joseph Fowler (Bitbucket: joe_fowler, ).


You said this is being fixed in some branch. Is that complete?

I want to tag a new release 0.8.1, but first we should wrap up any issues that are easy to close.