cositools / cosipy

The COSI high-level data analysis tools
Apache License 2.0
3 stars 16 forks source link

An error in BinnedData class using a list for the time bin #115

Closed hiyoneda closed 5 months ago

hiyoneda commented 7 months ago

When I defined time_bins as a list in the input yaml file for the dataIO class, I received the following error. How can I set min_time? Maybe it should be self.min_time?

---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
File <timed exec>:5

File ~/Work/Exp/COSI/cosipy-2/soft/cosipy/copy/data_io/BinnedData.py:66, in BinnedData.get_binned_data(self, unbinned_data, output_name, make_binning_plots, psichi_binning, psichi_old)
     62     time_bin_edges = np.linspace(min_time,max_time,num_bins+1)
     64 if type(self.time_bins).__name__ == 'list':
     65     # Check that bins correspond to min and max time:
---> 66     if (self.time_bins[0] > min_time) | (self.time_bins[-1] < max_time):
     67         print()
     68         print("ERROR: Time bins do not cover the full selected data range!")

UnboundLocalError: local variable 'min_time' referenced before assignment
ckarwin commented 7 months ago

Hi @hiyoneda, Indeed this is a bug. I fixed it now in PR #114. Until this PR is merged, can you just comment out the lines 66-70 in BinnedData.py (linked below)? https://github.com/cositools/cosipy/blob/f9b2cba4c08f92b13e924bd0a37aee3f79631f89/cosipy/data_io/BinnedData.py#L66C1-L70C27.