[PIPE2D-1275] DoubleDetectorMap findWavelength method no longer accepting multivalue arrays Created: 02/Aug/23 Updated: 24/Aug/23 Resolved: 24/Aug/23 |
|
| Status: | Done |
| Project: | DRP 2-D Pipeline |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Normal |
| Reporter: | Wilfred Gee | Assignee: | price |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
`drp_stella` and `datamodel` see the error on `w.2023.30`, `w.2023.30a`, and `w.2023.31`. It was working with `w.2023.29`. |
||
| Attachments: |
|
| Reviewers: | price |
| Description |
|
The overloaded method `findWavelength` no longer accepts numpy arrays when there is more than one element in the array. I've attached a minimal working example script but the following is an example: # Works correctly DetectorMap.findWavelength(1, 340) DetectorMap.findWavelength(np.array([1]), 340) DetectorMap.findWavelength(2, np.array([341])) DetectorMap.findWavelength(np.array([2]), np.array([341])) # Overload error DetectorMap.findWavelength(np.array([1, 2]), np.array([340])) DetectorMap.findWavelength(np.array([1]), np.array([340, 341])) DetectorMap.findWavelength(np.array([1, 2]), np.array([340, 341]))
Edit: error message: 1: 649.9656811860972 Traceback (most recent call last): File "test-db-findWavelength.py", line 23, in <module> print('2: ', detector_map_used.findWavelength(1, np.array([340, 341]))) # Fails TypeError: findWavelength(): incompatible function arguments. The following argument types are supported: 1. (self: pfs.drp.stella.DetectorMap.DetectorMap, fiberId: int, row: float, throwOnError: bool = False) -> float 2. (self: pfs.drp.stella.DetectorMap.DetectorMap, fiberId: int, row: numpy.ndarray) -> numpy.ndarray 3. (self: pfs.drp.stella.DetectorMap.DetectorMap, fiberId: numpy.ndarray, row: numpy.ndarray) -> numpy.ndarray 4. (self: pfs.drp.stella.DetectorMap.DetectorMap, arg0: int, arg1: numpy.ndarray) -> numpy.ndarray 5. (self: pfs.drp.stella.DetectorMap.DetectorMap, arg0: numpy.ndarray, arg1: numpy.ndarray) -> numpy.ndarray Invoked with: <pfs.drp.stella.DoubleDetectorMap.DoubleDetectorMap object at 0x7ff1c5d96430>, 1, array([340, 341]) |
| Comments |
| Comment by price [ 02/Aug/23 ] |
|
pybind is very picky about getting the correct array type. The rule is that fiberIds are 32-bit integers, pixel positions are 32-bit floats (but there are typically additional overrides that will work with 64-bit floats, as a convenience) and wavelengths are 64-bit floats. The following works: print('2: ', detector_map_used.findWavelength(1, np.array([340, 341], dtype=np.float32))) # Now works print('3: ', detector_map_used.findWavelength(np.array([1, 2], dtype=np.int32), np.array([340, 340], dtype=np.float32))) # Now works |
| Comment by Wilfred Gee [ 02/Aug/23 ] |
|
Thanks price, I can confirm it works if I explicitly cast them. I've been using the `fiberId` and `wavelength` directly from an `ArcLineSet.data`, which was working without an explicit cast earlier, although I'm not sure why. I'll let you know if I encounter anything else, thanks! |
| Comment by price [ 24/Aug/23 ] |
|
No fix required. |