Ticket #9117 (closed: fixed)

Opened 7 years ago

Last modified 5 years ago

Calibration: Ignore spectra which are not assigned to a detector

Reported by: Gesner Passos Owned by: Peter Parker
Priority: major Milestone: Release 3.2
Component: Tools Keywords:
Cc: peter.parker@… Blocked By:
Blocking: Tester: Karl Palmen

Description

If the workspace has a spectrum with no detector assigned, the calibration will break.

Try to run the script in #8845 and you will get an exception and it will stop running.

Attachments

ignore_not_defined_detector.patch (1.3 KB) - added by Gesner Passos 7 years ago.

Change History

Changed 7 years ago by Gesner Passos

comment:1 Changed 7 years ago by Gesner Passos

  • Cc peter.parker@… added

I do not know which Component to assign for calibration related tickets.

comment:2 Changed 7 years ago by Gesner Passos

The error is:

RuntimeError: Instrument: Detector with ID 3100000 not found. search object 
at line 21 in 'Z:/Mantidscripts/SANS2d_tubes_calib1.py'
caused by line 396 in 'C:/MantidInstall/scripts/Calibration\tube.py'
caused by line 362 in 'C:/MantidInstall/scripts/Calibration\tube_spec.py'
caused by line 336 in 'C:/MantidInstall/scripts/Calibration\tube_spec.py'

comment:3 Changed 7 years ago by Nick Draper

  • Status changed from new to assigned
  • Summary changed from Calibration Ignore not assigned detector to Calibration: Ignore spectra which are not assigned to a detector

comment:4 Changed 7 years ago by Gesner Passos

  • Owner changed from Gesner Passos to Peter Parker

You might be interesting in publishing this before next week, or Richard will have problems with any new version of mantid. Bear in mind also that he must check that new versions of Mantid override this file that he changed in his machine.

comment:5 Changed 7 years ago by Peter Parker

  • Status changed from assigned to inprogress

Refs #9117 - Ignore unnasigned spectra suring tube calibration.

But also print a warning of which ones were skipped.

Also had to fix some problematic indentation surrounding my changes.

Changeset: 2db8f32480072d58a8e9c55446f7af430cd8ee72

comment:6 Changed 7 years ago by Peter Parker

  • Status changed from inprogress to verify
  • Resolution set to fixed

comment:7 Changed 7 years ago by Peter Parker

Tester (if not Gesner):

Copy work_with_this_data.nxs from
olympic\babylon5\Public\PGP\Test Data\9117 into one of your managed data directories.

The following script should complete, and also print out warning messages for each skipped histogram:

import tube
from tube_calib_fit_params import TubeCalibFitParams
import numpy

ws = Load('work_with_this_data.nxs')
known_pos1 = numpy.array([-0.475,       -0.437, -0.353, -0.315, -0.231, -0.193, -0.109, -0.071, 0.013,  0.051,  0.135,  0.173,  0.257,  0.295,  0.379,  0.417])
known_pos2 = numpy.array([-0.445,       -0.407, -0.323, -0.285, -0.201, -0.163, -0.079, -0.041, 0.043,  0.081,  0.165,  0.203,  0.287,  0.325,  0.409,  0.447])

# left tubes
knownPositions = known_pos1
funcForm = [2]*len(knownPositions)
pixel_positions = numpy.array([20, 39, 80, 100, 140, 160, 200, 220, 262, 282, 323, 342, 383, 401, 444, 462])
margin=10
fitPar = TubeCalibFitParams(pixel_positions, outEdge=10.0, inEdge=10.0)
tubes = range(60)
caltable = tube.calibrate(ws, 'rear-detector',knownPositions, funcForm, rangeList=tubes,plotTube=[10,20,30,40,50], margin=margin, fitPar=fitPar)

# right tubes
knownRight = known_pos2
pixel_right = [29, 47, 90, 109, 152, 172, 215, 234, 277, 297, 340, 359, 402, 422, 465, 484]

fitPar = TubeCalibFitParams(pixel_right, outEdge=10.0, inEdge=10.0)
tubes = range(60,120)
caltable = tube.calibrate(ws, 'rear-detector',knownRight, funcForm, rangeList=tubes, plotTube= [60,80,90,100], margin=margin, fitPar=fitPar, calibTable=caltable)

ApplyCalibration(ws, caltable)
Last edited 7 years ago by Peter Parker (previous) (diff)

comment:8 Changed 7 years ago by Karl Palmen

  • Status changed from verify to verifying
  • Tester set to Karl Palmen

comment:9 Changed 7 years ago by Karl Palmen

  • Status changed from verifying to reopened
  • Resolution fixed deleted

The warning is printed for every tube. This is not acceptable. The array of histograms without detectors needs to be sent to a higher level so that it is only printed once.

comment:10 Changed 7 years ago by Peter Parker

A fair criticism. I will do as you suggest.

comment:11 Changed 7 years ago by Peter Parker

Refs #9117 - Print only one "detectors missing" warning per call.

Also, only print the number of detectors that were missing rather than the indices of each and every histogram.

Changeset: 66979da7cffb4e23627182581ce91485d150dff1

comment:12 Changed 7 years ago by Peter Parker

  • Status changed from reopened to verify
  • Resolution set to fixed

comment:13 Changed 7 years ago by Karl Palmen

  • Status changed from verify to verifying

comment:14 Changed 7 years ago by Karl Palmen

Yes it works the way would like. I had thought of a slightly better more objected orientated solution, which would be to make the set spectra without a detector an attribute of the tubeSpec and add a method to the tubeSpec to print the warning if necessary. Other diagnostic methods could be added.

However, I won't insist on this and pass the test.

comment:15 Changed 7 years ago by Karl Palmen

  • Status changed from verifying to closed

Merge remote-tracking branch 'origin/feature/9117_handle_unassigned_spectra_during_calibration'

Full changeset: 0541871e7f886ecd20b0942976dc6412f5d0e952

comment:16 Changed 7 years ago by Peter Parker

Thanks.

Perhaps there could be a separate ticket based on logging, to include your suggestions. It may also be an opportunity to utilise the various logging levels within Mantid (warning, information, etc.) rather than just print statements.

comment:17 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 9960

Note: See TracTickets for help on using tickets.