ZigongXu / time_converter

0 stars 0 forks source link

.dps_h operand shape issue. #2

Open juld88 opened 2 months ago

juld88 commented 2 months ago

Windows 11. Running LNDData(num).dps_h.protons where num = 3, 7, 9, 14, 15, 16, 17, 21, 25, 26, 28, 29, 30, 32, 34, or 35 returns the following error. For each lunar day with this issue, the two operand shapes in the final line differ. Sometimes, they are only different by 1. In other cases, the difference is sometimes higher.

ValueError Traceback (most recent call last) Cell In[96], line 2 1 data = LNDData(30) # 3 7 9 14 15 16 17 21 25 26 28 29 30 32 34 35 ----> 2 protons = data.dps_h.protons 3 flux = protons.to_flux().bins('hm').mean(axis=0)

File ~\AppData\Roaming\Python\Python312\site-packages\lnd_loader\lnd.py:156, in LNDData.dps_h(self) 154 data, time = self._load_data_with_time('DPSH') 155 , xmastime = self._load_data_with_time('SCI_HIST') --> 156 return DpsH(data, time, xmastime, self.l2 if not self._ignore_l2 else None)

File ~\AppData\Roaming\Python\Python312\site-packages\lnd_loader\data_products\dps_h.py:21, in DpsH.init(self, dps_h, time, xmastime, l2, acctime) 19 self._time = time 20 if l2 is not None and xmastime is not None: ---> 21 deadtime = get_dead_time(time, l2, 'DPS_H') 22 acctime = get_dps_accumulation_time(time, xmastime, 'DPS_H') 23 self._acctime = (- deadtime).add(acctime, axis=0)

File ~\AppData\Roaming\Python\Python312\site-packages\lnd_loader\utilities.py:117, in get_dead_time(time, l2, data_source) 113 if indices[-1] == len(counters.index): 114 # for the last DPS_H packet before we turn off, we seem to have no corresponding L2 packet 115 # Imperfect solution: duplicate one value from the previous DPS_H packet. 116 indices[-1] = len(counters.index) - 1 --> 117 if not np.all(np.unique(indices) == indices): 118 warnings.warn('Missing L2 data! Calculation of dead times may not be accurate.') 119 deadtimes = trigger_counts.iloc[indices] * constants.DEAD_TIME_PER_COUNT

ValueError: operands could not be broadcast together with shapes (17334,) (17337,)

This affects the proton spectrum - convert to flux code from examples.rst. When the range includes one of the above problematic values, it returns the same error as well as a messed up plot. When the range does not include one of the above values, it returns no errors, but a completely empty plot.