Keck-DataReductionPipelines / MosfireDRP

http://keck-datareductionpipelines.github.io/MosfireDRP
10 stars 13 forks source link

Issue with a vignetted slit in the edge #124

Open itjung opened 6 years ago

itjung commented 6 years ago

Hello,

I have a question about the issue that I have with a slit (slit#30 below), maybe vignetted around the edge of the mask. While I am running the pipeline, it's stuck with the error message as below during the background subtraction procedure. Is there any way to skip the problematic slit to finish the entire reduction procedure? Or if I can get help to make a proper modification in the source code.

Thank you very much!

Best, Intae Jung

=============================================================
...
2018-06-15 14:51:27,988 -   Background.   handle_background - INFO: Handling A - B
2018-06-15 14:51:28,164 -   Background.background_subtract_helper - INFO: Background subtracting slit 0 [2034,2003]
2018-06-15 14:51:28,164 -   Background.background_subtract_helper - INFO: Background subtracting slit 1 [1993,1952]
2018-06-15 14:51:28,164 -   Background.background_subtract_helper - INFO: Background subtracting slit 3 [1854,1815]
2018-06-15 14:51:28,164 -   Background.background_subtract_helper - INFO: Background subtracting slit 4 [1811,1771]
2018-06-15 14:51:28,165 -   Background.background_subtract_helper - INFO: Background subtracting slit 5 [1767,1728]
2018-06-15 14:51:28,165 -   Background.background_subtract_helper - INFO: Background subtracting slit 6 [1721,1682]
2018-06-15 14:51:28,164 -   Background.background_subtract_helper - INFO: Background subtracting slit 2 [1944,1860]
2018-06-15 14:51:28,165 -   Background.background_subtract_helper - INFO: Background subtracting slit 7 [1676,1593]
2018-06-15 14:51:28,512 -   Background.background_subtract_helper - INFO: Background subtracting slit 8 [1588,1549]
2018-06-15 14:51:28,544 -   Background.background_subtract_helper - INFO: Background subtracting slit 9 [1544,1461]
2018-06-15 14:51:28,578 -   Background.background_subtract_helper - INFO: Background subtracting slit 10 [1457,1373]
2018-06-15 14:51:28,582 -   Background.background_subtract_helper - INFO: Background subtracting slit 11 [1366,1284]
2018-06-15 14:51:28,587 -   Background.background_subtract_helper - INFO: Background subtracting slit 12 [1278,1239]
2018-06-15 14:51:28,592 -   Background.background_subtract_helper - INFO: Background subtracting slit 13 [1233,1149]
2018-06-15 14:51:28,820 -   Background.background_subtract_helper - INFO: Background subtracting slit 14 [1145,1107]
2018-06-15 14:51:28,916 -   Background.background_subtract_helper - INFO: Background subtracting slit 15 [1101,1091]
2018-06-15 14:51:28,944 -   Background.background_subtract_helper - WARNING: Failed on slit 15
2018-06-15 14:51:28,945 -   Background.background_subtract_helper - INFO: Background subtracting slit 16 [1060,975]
2018-06-15 14:51:29,019 -   Background.background_subtract_helper - INFO: Background subtracting slit 17 [968,885]
2018-06-15 14:51:29,049 -   Background.background_subtract_helper - INFO: Background subtracting slit 18 [880,797]
2018-06-15 14:51:29,171 -   Background.background_subtract_helper - INFO: Background subtracting slit 19 [790,707]
2018-06-15 14:51:29,284 -   Background.background_subtract_helper - INFO: Background subtracting slit 20 [702,619]
2018-06-15 14:51:29,322 -   Background.background_subtract_helper - INFO: Background subtracting slit 21 [612,574]
2018-06-15 14:51:29,331 -   Background.background_subtract_helper - INFO: Background subtracting slit 22 [567,529]
2018-06-15 14:51:29,355 -   Background.background_subtract_helper - INFO: Background subtracting slit 23 [526,442]
2018-06-15 14:51:29,622 -   Background.background_subtract_helper - INFO: Background subtracting slit 24 [437,398]
2018-06-15 14:51:29,719 -   Background.background_subtract_helper - INFO: Background subtracting slit 25 [393,354]
2018-06-15 14:51:29,728 -   Background.background_subtract_helper - INFO: Background subtracting slit 26 [348,265]
2018-06-15 14:51:29,896 -   Background.background_subtract_helper - INFO: Background subtracting slit 27 [260,177]
2018-06-15 14:51:29,901 -   Background.background_subtract_helper - INFO: Background subtracting slit 28 [169,85]
2018-06-15 14:51:29,906 -   Background.background_subtract_helper - INFO: Background subtracting slit 29 [78,-1]
2018-06-15 14:51:29,982 -   Background.background_subtract_helper - INFO: Background subtracting slit 30 [42,4]
2018-06-15 14:51:30,007 -   Background.background_subtract_helper - WARNING: Failed on slit 30
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/Users/itjung/anaconda2/envs/mospy_2018_macos/lib/python3.6/multiprocessing/pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
  File "/Users/itjung/anaconda2/envs/mospy_2018_macos/lib/python3.6/multiprocessing/pool.py", line 44, in mapstar
    return list(map(*args))
  File "/Users/itjung/anaconda2/envs/mospy_2018_macos/lib/python3.6/site-packages/MOSFIRE-1.0.dev0-py3.6.egg/MOSFIRE/Background.py", line 659, in background_subtract_helper
    dl = np.ma.median(np.diff(lslit[lslit.shape[0]//2,:]))
  File "/Users/itjung/anaconda2/envs/mospy_2018_macos/lib/python3.6/site-packages/numpy/ma/core.py", line 3220, in __getitem__
    dout = self.data[indx]
IndexError: index 0 is out of bounds for axis 0 with size 0
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "Driver.py", line 41, in <module>
    Background.handle_background(obsfiles,Wavelength_file,maskname,band,waveops)
  File "/Users/itjung/anaconda2/envs/mospy_2018_macos/lib/python3.6/site-packages/MOSFIRE-1.0.dev0-py3.6.egg/MOSFIRE/Background.py", line 491, in handle_background
    solutions = p.map(background_subtract_helper, list(range(len(bs.ssl))))
  File "/Users/itjung/anaconda2/envs/mospy_2018_macos/lib/python3.6/multiprocessing/pool.py", line 266, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
  File "/Users/itjung/anaconda2/envs/mospy_2018_macos/lib/python3.6/multiprocessing/pool.py", line 644, in get
    raise self._value
IndexError: index 0 is out of bounds for axis 0 with size 0
=============================================================
joshwalawender commented 6 years ago

@itjung Unfortunately, we don't have a great solution for this right now. I'm working on a major update to the DRP which (among other things) would allow one to control which slits the DRP analyzes, but that is going to take a while because that change has tendrils which reach in to many parts of the DRP's code, so I wouldn't wait on that.

An alternative hack to skip that problematic slit that has been used is the past is to replace the data (the pixel values) on the input file(s) for that slit with data from another unvignetted slit. One could do this via various astropy tools or via something like IRAF's imreplace. That should allow the DRP to proceed even though that slit's results would be unusable.

Sorry, I wish we had better news.

itjung commented 6 years ago

@joshwalawender Thank you very much for the comment. I will try the alternative way, and I think that it should be enough to run the pipeline with my data. Thanks again!