STScI-Citizen-Science / MTPipeline

Pipeline to produce CR rejected, astrodrizzled, png's of HST WFPC2 solar system data.
6 stars 1 forks source link

Reinsert DATE-OBS keyword after AstroDrizzle #154

Closed ktfhale closed 10 years ago

ktfhale commented 10 years ago

AstroDrizzle removes the DATE-OBS keyword from its output files, and we need that information for our database. The easiest thing to do is to use my get_metadata() function to reinsert it in run_astrodrizzle().

Unfortunately, we already have a pile of AstroDrizzle outputs. I'll have to write a separate script to insert it. Shouldn't be too hard. Do we know if this problem exists for only the ACS and WFC3 data, or is a problem with WFPC2 as well?

ktfhale commented 10 years ago

I've made get_metadata() get the DATE-OBS, and I've added the function below to run_astrodrizzle():

def insert_dateobs(output, dateobs):
    """ Put the DATE-OBS keyword back into the AstroDrizzle outputs.
    AstroDrizzle removes this keyword, and it is needed for the database and
    ephemeris later. 

    Parameters: 
        output: string
                The renamed AstroDrizzle output the DATE-OBS keyword needs to be
                put back into.
        dateobs: string
                 The value of the dateobs keyword from the original _flt or _c0m
                 file.

    Returns: nothing

    Outputs:
        The AstroDrizzle output file, edited to include DATE-OBS.
    """

    with fits.open(output, mode='readonly') as HDUlist:

        header = HDUlist[0].header
        header.append('date-obs', useblanks = True)
        header['date-obs'] = dateobs

        HDUlist.writeto(output,clobber='True')

The DATE-OBS keyword seems to be successfully added back into the header. I've tested across inputs from all six detectors, and it appears to function just fine.

ktfhale commented 10 years ago

So, it turns out that WFPC2 doesn't have a DATE-OBS keyword. I'm guessing this was already known, and the problem's only for ACS and WFC3? I'm running a script to get rid of all the bad re-insertions of DATE-OBS into WFPC2 AstroDrizzle outputs.

ktfhale commented 10 years ago

To my knowledge, all ACS and WFC3 _sci.fits and _img.fits files have had the DATE-OBS keyword reinserted. The pipeline should do this automatically from now on.

ktfhale commented 10 years ago

Alright, I'm confused. So at least some WFPC2 inputs do have a DATE-OBS keyword. Actually, I'm guessing all of them do. Something else must have been going wrong when I was trying to reinsert the keyword back into WFPC2 AstroDrizzle outputs.

... and it seems like at least some of the WFPC2 AstroDrizzle outputs still have a DATE-OBS keyword, even though I'm pretty sure I didn't put it there. I guess this was only a problem for ACS and WFC3 after all.

ktfhale commented 10 years ago

Okay, so some WFPC2 AstroDrizzle outputs have DATE-OBS, and some don't. I'm running a script to figure out what the deal is.

EDIT: Okay, it looks like, for some reason, thousands of AstroDrizzle outputs in mtpipeline_outputs/wfpc2, do have the DATE-OBS keyword, and thousands don't.

So I'm going to remove the logic in the date-obs branch that only does the reinsertion for ACS and WFC3, and run the reinsertion script over WFPC2 as well.

ktfhale commented 10 years ago

I'm confident DATE-OBS has been finally been added into all of the AstroDrizzle outputs in mtpipeline/mtpipeline_outputs/.