def standardizeInstrumentHeaders(self, rc): """ This primitive is used to make the changes and additions to the keywords in the headers of NIRI data, specifically. """ # Instantiate the log log = logutils.get_logger(__name__) # Log the standard "starting primitive" debug message log.debug(gt.log_message("primitive", "standardizeInstrumentHeaders", "starting")) # Define the keyword to be used for the time stamp for this primitive timestamp_key = self.timestamp_keys["standardizeInstrumentHeaders"] # Initialize the list of output AstroData objects adoutput_list = [] # Loop over each input AstroData object in the input list for ad in rc.get_inputs_as_astrodata(): # Check whether the standardizeInstrumentHeaders primitive has been # run previously if ad.phu_get_key_value(timestamp_key): log.warning("No changes will be made to %s, since it has " "already been processed by " "standardizeInstrumentHeaders" % ad.filename) # Append the input AstroData object to the list of output # AstroData objects without further processing adoutput_list.append(ad) continue # Standardize the headers of the input AstroData object. Update the # keywords in the headers that are specific to NIRI log.status("Updating keywords that are specific to NIRI") # Filter name (required for IRAF?) gt.update_key_from_descriptor( adinput=ad, descriptor="filter_name(stripID=True, pretty=True)", keyword="FILTER", extname="PHU") # Pixel scale gt.update_key_from_descriptor( adinput=ad, descriptor="pixel_scale()", extname="PHU") # Read noise (new keyword, should it be written?) gt.update_key_from_descriptor( adinput=ad, descriptor="read_noise()", extname="SCI") # Gain (new keyword, should it be written?) gt.update_key_from_descriptor( adinput=ad, descriptor="gain()", extname="SCI") # Non linear level gt.update_key_from_descriptor( adinput=ad, descriptor="non_linear_level()", extname="SCI") # Saturation level gt.update_key_from_descriptor( adinput=ad, descriptor="saturation_level()", extname="SCI") # Dispersion axis (new keyword, should it be written?) if "SPECT" in ad.types: gt.update_key_from_descriptor( adinput=ad, descriptor="dispersion_axis()", extname="SCI") # Convention seems to be to multiply the exposure time by coadds in prepared data gt.update_key_from_descriptor( adinput=ad, descriptor="exposure_time()", extname="PHU") # Add the appropriate time stamps to the PHU gt.mark_history(adinput=ad, keyword=timestamp_key) # Change the filename ad.filename = gt.filename_updater(adinput=ad, suffix=rc["suffix"], strip=True) # Append the output AstroData object to the list of output # AstroData objects adoutput_list.append(ad) # Report the list of output AstroData objects to the reduction context rc.report_output(adoutput_list) yield rc