Keck-DataReductionPipelines / MosfireDRP

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

Background subtraction longslit: spline construction fails #63

Closed mheida closed 6 years ago

mheida commented 8 years ago

Hi,

I'm trying to reduce longslit data with a ~2000 pix slit and only one ABBA pattern. When I get to the background subtraction part I get this message: 2016-10-04 09:30:47,564 - Background.background_subtract_helper - INFO: Background subtracting slit 0 [2046,22] /Users/mheida/software/Ureka/variants/common/lib/python2.7/site-packages/numpy/lib/function_base.py:3569: RuntimeWarning: Invalid value encountered in median RuntimeWarning) 2016-10-04 09:30:51,449 - Background.background_subtract_helper - WARNING: Could not construct spline on slit 0

The pipeline produces output but it's only zeros. The background that's left after subtracting the B-A frames actually isn't too bad at all, so if there is no easy way to fix the spline fitting then just skipping the background subtraction step would probably also work. Can I switch that off somewhere?

Thanks, Marianne

joshwalawender commented 8 years ago

@mheida Can you send me a minimum data set (science frames, flats, wavelength cals, etc.) which triggers the problem? I'm going through to code to see what might be causing this, but it'll go faster if I can reproduce the problem here. If you can, email it to jwalawender@keck.hawaii.edu. Thanks!

mheida commented 8 years ago

@joshwalawender I've sent you the files. For now I've circumvented the issue by commenting out the last line in this bit of the background.py file: for i in range(3): try: delta = dl_0.9 knots = np.arange(knotstart, knotend, delta) bspline = II.splrep(ls[OK], ss[OK], k=5, task=-1, t=knots) except: delta = dl_1.4 knots = np.arange(knotstart, knotend, delta) try: bspline = II.splrep(ls[OK], ss[OK], k=5, task=-1, t=knots) except: warning("Could not construct spline on slit "+str(slitno))

return {"ok": False}

The result looks pretty reasonable but I'm not sure if I'm introducing some horrible errors this way.

joshwalawender commented 8 years ago

@mheida Sorry for the silence, I was out of town for several days. Can you check your scipy version?

In [1]: import scipy

In [3]: scipy.__version__
Out[3]: '0.18.0'

I'm having trouble reproducing this and I'm wondering if it is a symptom of different scipy.interpolate.splrep behavior. I'm still digging though.

mheida commented 8 years ago

@joshwalawender That could be the issue, my scipy version is 0.15.1 (I'm guessing that's the one that came with Ureka when I installed it). I'll try to upgrade and see if the problem persists.

joshwalawender commented 6 years ago

I'm going to assume this issue was resolved by the upgrade and thus I'm going to close it. Let me know if it remains and I'll reopen.