NSLS-II-CSX / csxtools

Useful python tools for CSX (23-ID)
http://nsls-ii-csx.github.io/csxtools
Other
4 stars 13 forks source link

DEV: _get_images can take header or list of headers as input #61

Closed licode closed 6 years ago

licode commented 6 years ago

This is to be compatible with previous api that _get_images can take list of headers as input.

coveralls commented 6 years ago

Coverage Status

Coverage decreased (-0.2%) to 28.723% when pulling 8a4e8ca17369e64136e6fdad9f57cb6ba97aee5f on licode:multi_headers into 372787065423ca933e992e11e17c7f520f611b75 on NSLS-II-CSX:master.

codecov-io commented 6 years ago

Codecov Report

Merging #61 into master will decrease coverage by 0.2%. The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #61      +/-   ##
==========================================
- Coverage   28.92%   28.72%   -0.21%     
==========================================
  Files          10       10              
  Lines         280      282       +2     
==========================================
  Hits           81       81              
- Misses        199      201       +2
Impacted Files Coverage Δ
csxtools/utils.py 20% <0%> (-0.41%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 3727870...8a4e8ca. Read the comment docs.

tacaswell commented 6 years ago

@mpmdean What is the expected signature of this function?

mpmdean commented 6 years ago

@tacaswell

Below is the error from the latest CSX kernal on srv1. It's trying to access the _get_images method on the list of two headers. This works in older kernals.

AttributeError Traceback (most recent call last) in () 3 4 old_scan_no = 85528 ----> 5 slicerator = get_fastccd_images(db[old_scan_no], (db[old_scan_no-1, old_scan_no+1], None, None))

/opt/conda_envs/analysis-2018-1.0/lib/python3.6/site-packages/csxtools/utils.py in get_fastccd_images(light_header, dark_headers, flat, gain, tag, roi) 85 # Get the images 86 ---> 87 bgnd_events = _get_images(d, tag, roi) 88 89 # We assume that all images are for the background

/opt/conda_envs/analysis-2018-1.0/lib/python3.6/site-packages/csxtools/utils.py in _get_images(header, tag, roi) 179 def _get_images(header, tag, roi=None): 180 t = ttime.time() --> 181 images = header.db.get_images(header, tag) 182 t = ttime.time() - t 183 logger.info("Took %.3f seconds to read data using get_images", t)

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

I believe this comes from this change:

-def _get_images(header, tag, roi=None, handler_override=None): +def _get_images(header, tag, roi=None): t = ttime.time()

images = get_images(header, tag, handler_override=handler_override) images = header.db.get_images(header, tag) results in an incompatibility described below. Or at least something that previously worked now does not. The variable header becomes a list if one wants to use.

licode commented 6 years ago

I think this should work. I also did some local test. any more comment?

ambarb commented 5 years ago

Hi All, I am using the current version of the SRV1 server at CSX (assuming /opt/conda_envs/analysis-2018-2.1). The version of csxtools is '0.1.13'. I am unable to use multiple dark images, but the discussion here indicates that this is the fix. what version of csxtools is supposed to this ability repaired?

ambarb commented 5 years ago

I am not sure what happened, but now this functionality seems to work. What is very scary is that the version of csxtools remains the same so I don't really understand why I had the issue in the first place. I tried all 3 23id1 servers before and found this issue. But just this week, I forgot and ran other notebooks and it seemed to be fixed. I am going to close the issue on csxtools