tjlane / pypad

Intuitive, high-level interface to the CSPAD
Other
2 stars 1 forks source link

score crashes when input metrology is in `cheetah` format #39

Closed sellberg closed 11 years ago

sellberg commented 11 years ago

Would be nice if we could fix this ASAP, as I would like to try and optimize my sample-detector distance for the ice hits with PyPad. I'll implement support for the hexagonal unit cell in score.py

The ugly fix is to write a separate script that converts cheetah metrology to cspad object.. Do we already have this?

[pypad:612 22:00:23] score score_params.yaml

--- SCORING CSPAD GEOMETRY ---  

Figure Explanation: Left Panel: The assembled image, superimposed with white circles where theoretically there should be powder rings. The red dot visualizes where the forward beam intersects the detector plane. Right Panel: The radial projection for each individual quad, dotted lines are theoretical peak predictions.

To plot additional samples: Press: l for previous sample Press: n for next sample

Loaded: score_params.yaml Loading: gold-minus490mm.h5 found: 10 peaks Loading: gold-minus470mm.h5 found: 8 peaks

--- Optimized Energy & Detector Distance --- Detector offest: 582.00 mm Energy: 9.690 keV

Total Residuals: 0.007827 inv. Angstroms Residuals for each peak: [ 0.00046626 0.0008697 0.00415692 0.00233418]

Plotting calibration sample: 0 (may take a moment) distance: 92.00 mm Loading: gold-minus490mm.h5 Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/Current/bin/score", line 5, in pkg_resources.run_script('pypad==0.0.1', 'score') File "/Library/Frameworks/Python.framework/Versions/6.3/lib/python2.6/site-packages/pkg_resources.py", line 467, in run_script self.require(requires)[0].run_script(script_name, ns) File "/Library/Frameworks/Python.framework/Versions/6.3/lib/python2.6/site-packages/pkg_resources.py", line 1200, in run_script execfile(script_filename, namespace, namespace) File "/Library/Frameworks/Python.framework/Versions/6.3/lib/python2.6/site-packages/pypad-0.0.1-py2.6.egg/EGG-INFO/scripts/score", line 54, in sref.display() File "/Library/Frameworks/Python.framework/Versions/6.3/lib/python2.6/site-packages/pypad-0.0.1-py2.6.egg/pypad/autogeom/score.py", line 416, in display self._plot_cal_sample(self._current_image) File "/Library/Frameworks/Python.framework/Versions/6.3/lib/python2.6/site-packages/pypad-0.0.1-py2.6.egg/pypad/autogeom/score.py", line 445, in _plot_cal_sample plot.imshow_cspad( self.cspad(img), vmin=0, ax=self._axL ) File "/Library/Frameworks/Python.framework/Versions/6.3/lib/python2.6/site-packages/pypad-0.0.1-py2.6.egg/pypad/cspad.py", line 461, in call return self._assemble_image(raw_image) File "/Library/Frameworks/Python.framework/Versions/6.3/lib/python2.6/site-packages/pypad-0.0.1-py2.6.egg/pypad/cspad.py", line 1115, in _assemble_image quad_index_image = self._assemble_quad( raw_image[quad_index], quad_index ) File "/Library/Frameworks/Python.framework/Versions/6.3/lib/python2.6/site-packages/pypad-0.0.1-py2.6.egg/pypad/cspad.py", line 1086, in _assemble_quad raise ValueError('rs: out of bounds in rows') ValueError: rs: out of bounds in rows

tjlane commented 11 years ago

@sellberg this is the same bug as #34 -- I can fix it soon.

The easy fix:

geom = cspad.CSPad.load_cheetah(filename)
geom.save('my.cspad')

and use my.cspad.

Going through these pypad issues is high on my to-do list.

sellberg commented 11 years ago

@tjlane i tried what you just told me, I still get the same error... too bad, it sounded so promising :)

tjlane commented 11 years ago

hmmm right your right sorry. I can fix this tomorrow. It would be great to get some feedback from you Jonas if you can skype -- I want to chat about the best way to place the quads on the 2D plane.

For a rapid fix, you can disable the left hand plot (of the assembled image) to just get the score part out. This error is due to pypad attempting to assemble the image. The fix would be to mess around here:

https://github.com/tjlane/pypad/blob/master/pypad/autogeom/score.py#L445

comment out line 445, should work

sellberg commented 11 years ago

@tjlane yeah, i saw the optimization, i'm just greedy n want the image to check it found the correct peaks ;-P but i can do it with right hand side only for now. Don't worry about it tonight, i wont have more time for it until tomorrow after lunch. Btw, how was L-P's party? Sorry i missed it, i was dead last night after dinner...

tjlane commented 11 years ago

@sellberg I'll see if I can crack it tomorrow -- might also have to be after lunch.

LP's was great, missed you there!