spacetelescope / drizzlepac

AstroDrizzle for HST images.
https://drizzlepac.readthedocs.io
BSD 3-Clause "New" or "Revised" License
52 stars 38 forks source link

Astrodrizzle sky subtraction does not work as advertised #58

Closed ivastar closed 7 years ago

ivastar commented 7 years ago

The following does not actually work:

"However, if the sky subtraction step is turned off, AstroDrizzle will still use the sky value recorded in the MDRIZSKY keyword when performing single-image drizzling and cosmic ray identification, as it provides the only indication of the background sky level needed for the statistical computations used to identify cosmic rays."

The value stored in MDRIZSKY is always subtracted, independent of whether the sky subtraction is turned on or off.

mcara commented 7 years ago

@ivastar Could you, please, provide the version of the drizzlepac that you are using?

ivastar commented 7 years ago

Same as for the other issue I reported: AstroDrizzle Version 2.1.8(08-Feb-2017)

mcara commented 7 years ago

@ivastar Also, what instrument are you using and how do you call AstroDrizzle (parameters)?

ivastar commented 7 years ago

@mcara WFC3/IR data. These are the parameters I ended up using:

skysub=True (or False) skywidth = 0. skystat = '' skylower = None skyupper = None skyclip = 0. skylsigma = 0. skyusigma = 0. skyuser = 'MDRZSKY' (the name of the keyword does not matter, I've tried naming it other things) skyfile = ''

Astrodrizzle will subtract the background in "MDRZSKY" if subsky is set to True OR to False. I add the background to the FLT before I drizzle to get a correct image and wht map.

mcara commented 7 years ago

I can confirm that skysub is broken.

mcara commented 7 years ago

I add the background to the FLT before I drizzle to get a correct image and wht map.

This may not be the best workaround. I would suggest that you create a "skyuser" file, e.g., 'skyuser.txt' with the following content:

filename1.fits 0.0
filename2.fits 0.0
.......

and then call AstroDrizzle like:

>>> drizzlepac.astrodrizzle.AstroDrizzle(..., skysub=False, skyuser='@skyuser.txt')
mcara commented 7 years ago

Another workaround is to delete MDRIZSKY from image headers and then run AstroDrizzle like this:

>>> drizzlepac.astrodrizzle.AstroDrizzle(..., skysub=False)

That is, turning off sky subtraction currently works only when MDRIZSKY is not present in image headers.

mcara commented 7 years ago

A bug fix was created in https://github.com/spacetelescope/drizzlepac/pull/59 but it will take a couple of days before a bug-fix drizzlepac release is made.

ivastar commented 7 years ago

Thanks Mihai! These work-arounds are not suitable for me because I still want the sky value to be folded in the WHT map. If I just set it to zero, that will not happen.

mcara commented 7 years ago

These work-arounds are not suitable for me because I still want the sky value to be folded in the WHT map.

Actually, the first workaround above should work if instead of 0.0 for the sky value you enter your best estimate for the sky value for a given input image. It is one of the purposes of skyuser parameter. Try it.

mcara commented 7 years ago

@ivastar Can you please confirm that latest update fixes the skysub issue?

ivastar commented 7 years ago

I will take a look later. Ugh, now I have to change all my codes! ;)