Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resfreshFromFiles fails for this experiment state file and off file #271

Closed
joefowler opened this issue Apr 11, 2024 · 1 comment · Fixed by #285
Closed

resfreshFromFiles fails for this experiment state file and off file #271

joefowler opened this issue Apr 11, 2024 · 1 comment · Fixed by #285
Labels
bug Something isn't working major
Milestone

Comments

@joefowler
Copy link
Member

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


# unix time in nanoseconds, state label
1697484378937217074, START
1697484745299889963, A
1697485399208931183, B
1697485926167354421, C
1697486056988285912, IGNORE
1697486140155652332, C
1697486494707281352, STOP

files = mass.off.getOffFileListFromOneFile(r'/home/pcuser/data/20231016/0000/20231016_run0000', 3)      
In [12]: files                                       
Out[12]: 
['/home/pcuser/data/20231016/0000/20231016_run0000_chan1.off',
 '/home/pcuser/data/20231016/0000/20231016_run0000_chan2.off',
 '/home/pcuser/data/20231016/0000/20231016_run0000_chan3.off']
data=mass.off.ChannelGroup(files)   
In [14]: data.refreshFromFiles()                                                                                                                                                                           
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Input In [14], in <cell line: 1>()
----> 1 data.refreshFromFiles()

File ~/qsp/src/mass/mass/off/channels.py:1169, in ChannelGroup.refreshFromFiles(self)
   1167     i0_unixnanos = len(ds)
   1168     ds.offFile._updateMmap()  # will update nRecords by mmapping more data in the offFile if available
-> 1169     ds._statesDict = self.experimentStateFile.calcStatesDict(
   1170         ds.unixnano[i0_unixnanos:], ds.statesDict, i0_allLabels, i0_unixnanos)
   1171     n_new_pulses_dict[ds.channum] = len(ds)-i0_unixnanos
   1172 return n_new_labels, n_new_pulses_dict

File ~/qsp/src/mass/mass/off/experiment_state.py:117, in ExperimentStateFile.calcStatesDict(self, unixnanos, statesDict, i0_allLabels, i0_unixnanos)
    115     last_key = k
    116 s = statesDict[last_key]
--> 117 s2 = slice(s.start, i0_unixnanos+len(unixnanos))  # set the slice from the start of the state to the last new record
    118 statesDict[k] = s2
    119 return statesDict

AttributeError: 'list' object has no attribute 'start'  

@joefowler
Copy link
Member Author

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


diff --git a/mass/off/experiment_state.py b/mass/off/experiment_state.py
index 1fb3cea33..de6626934 100644
--- a/mass/off/experiment_state.py
+++ b/mass/off/experiment_state.py
@@ -113,8 +113,13 @@ class ExperimentStateFile:
             assert i0_allLabels > 0
             for k in statesDict.keys():
                 last_key = k
-            s = statesDict[last_key]
-            s2 = slice(s.start, i0_unixnanos+len(unixnanos))  # set the slice from the start of the state to the last new record
+                s = statesDict[last_key]
+            if isinstance(s, slice):
+                s2 = slice(s.start, i0_unixnanos+len(unixnanos))  # set the slice from the start of the state to the last new record
+            if isinstance(s, list):
+                s_ = s[-1] # get last instance of same state
+                s[-1] = slice(s_.start, i0_unixnanos+len(unixnanos))  # set the slice from the start of the state to the last new record
+                s2 = s    
             statesDict[k] = s2
             return statesDict

appears to fix it, but since massgui only works with an older version of mass I can’t easily make a PR from the ebit computer

ggggggggg added a commit that referenced this issue May 22, 2024
ggggggggg added a commit that referenced this issue May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working major
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant