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

Allow LARMOR Files to Work in Add Runs Tab #10471

Closed
PeterParker opened this issue Jun 10, 2014 · 1 comment
Closed

Allow LARMOR Files to Work in Add Runs Tab #10471

PeterParker opened this issue Jun 10, 2014 · 1 comment
Assignees
Labels
High Priority An issue or pull request that if not addressed is severe enough to postponse a release. SANS Issues and pull requests related to SANS
Milestone

Comments

@PeterParker
Copy link
Contributor

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:

#!python
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:

#!python
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:

#!python
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)
@PeterParker
Copy link
Contributor Author

This issue was originally trac ticket 9628

@PeterParker PeterParker added High Priority An issue or pull request that if not addressed is severe enough to postponse a release. SANS Issues and pull requests related to SANS labels Jun 3, 2015
@PeterParker PeterParker self-assigned this Jun 3, 2015
@PeterParker PeterParker added this to the Release 3.2 milestone Jun 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
High Priority An issue or pull request that if not addressed is severe enough to postponse a release. SANS Issues and pull requests related to SANS
Projects
None yet
Development

No branches or pull requests

1 participant