Ticket #9628 (closed: fixed)
Allow LARMOR Files to Work in Add Runs Tab
Reported by: | Peter Parker | Owned by: | Peter Parker |
---|---|---|---|
Priority: | critical | Milestone: | Release 3.2 |
Component: | SANS | Keywords: | |
Cc: | robert.dalgliesh@… | Blocked By: | |
Blocking: | Tester: | Samuel Jackson |
Description
Rob has pointed out that LARMOR files will not go through the "Add Runs" tab of the interface. This is because we have the following code in SANSadd2.py:
def _padZero(runNum, inst='SANS2D'): if inst.upper() == 'SANS2D' : numDigits = 8 elif inst.upper() == 'LOQ' : numDigits = 5 else : raise NotImplementedError('The arguement inst must be set to SANS or LOQ') run = str(runNum).zfill(numDigits) return run
which could easily be made more generic with:
def _padZero(runNum, inst): numDigits = config.getInstrument(inst).zeroPadding(0) run = str(runNum).zfill(numDigits) return run
The real fix would actually be to rely on the zero padding code we have elsewhere rather than have our own version, but I prefer this fix since it is very localised and wont require making larger changes to code that I simply do not trust at the moment.
Given that we know a fix and also given that Rob has tested this on his machine by pasting the code manually into his installation, it would make sense to get this in to the 3.2 release.
For the purposes of testing, the underlying "Add Runs" code can be called from Python as follows:
from SANSadd2 import add_runs def call_add_runs(runs, inst, bin_str=None): """ Wrap the actual function in something a bit nicer. """ # The GUI asks LoadRaw for its known "types". This appears to be necessary # for the purposes of loading sample data from raw files as well as loading # periods. I don't claim to fully understand, but we do this in the GUI so # I guess we should do it here, too. loadraw = AlgorithmManager.createUnmanaged("LoadRaw") loadraw.initialize() if bin_str == None: bin_str="Monitors" add_runs(runs=map(str, runs), inst=inst, rawTypes=tuple(loadraw.getProperty("Filename").allowedValues), binning=bin_str) # Change these to taste: inst = "LARMOR" runs = [208,209] bin_str = "5.5,45.5,50.0, 50.0,1000.0, 500.0,1500.0, 750.0,99750.0, 255.0,100005.0" # Uses monitor binning: call_add_runs(runs, inst) # Uses your own binning string: call_add_runs(runs, inst, bin_str) call_add_runs(runs, inst, bin_str)
Change History
comment:2 Changed 6 years ago by Peter Parker
Refs #9628 - Allow adding LARMOR data files.
Changeset: fb920e738fbd21a9fa13d708fe35646006b0035d
comment:4 Changed 6 years ago by Peter Parker
- Status changed from assigned to verify
- Resolution set to fixed
comment:5 Changed 6 years ago by Peter Parker
To test:
Make sure the script in the description runs, where before the changes it wouldn't.
comment:6 Changed 6 years ago by Samuel Jackson
- Status changed from verify to verifying
- Tester set to Samuel Jackson
comment:7 Changed 6 years ago by Samuel Jackson
Script seems to work. Code review looks good (I learnt a new python function!).
However I get the following warning at the end of the script output:
Could not find log file /archive/ndxlarmor/Instrument/data/cycle_13_5/LARMOR00000209.log
Which is because LARMOR doesn't have log files... We should tidy this up at some point.
comment:8 Changed 6 years ago by Samuel Jackson
- Status changed from verifying to closed
Merge remote-tracking branch 'origin/bugfix/9628_allow_larmor_files_to_work_in_add_runs_tab'
Full changeset: 3607021c3197dcb9e0a887e817ad2362eb173b10