def blendfitsdata(input_list, output_model): """ Primary interface for JWST pipeline use of fitsblender.blendheaders This function will update the output_model datamodel with the blended metadata from the list of FITS objects generated from the input_list of filenames. """ new_hdrs, new_table = blendheaders.get_blended_headers(input_list) # Now merge the keyword values from new_hdrs into the metatdata for the # output datamodel # # start by building dict which maps all FITS keywords in schema to their # attribute in the schema fits_dict = schema.build_fits_dict(output_model.schema) # Now assign values from new_hdrs to output_model.meta using fits_dict map for hdr in new_hdrs: for kw in hdr: if kw in fits_dict: output_model[fits_dict[kw]] = hdr[kw] # Now, append HDRTAB as new element in datamodel new_schema = build_tab_schema(new_table) output_model.add_schema_entry('hdrtab', new_schema) output_model.hdrtab = fits_support.from_fits_hdu(new_table, new_schema)
def blendmetadata(input_list, output_model): """ Primary interface for JWST pipeline use of fitsblender.blendheaders This function will update the output_model datamodel with the blended metadata from the list of FITS objects generated from the input_list of filenames. """ new_hdrs,new_table = blendheaders.get_blended_headers(input_list) # Now merge the keyword values from new_hdrs into the metatdata for the # output datamodel # # start by building dict which maps all FITS keywords in schema to their # attribute in the schema fits_dict = schema.build_fits_dict(output_model.schema) # Now assign values from new_hdrs to output_model.meta using fits_dict map for hdr in new_hdrs: for kw in hdr: if kw in fits_dict: output_model[fits_dict[kw]] = hdr[kw] # Now, append HDRTAB as new element in datamodel new_schema = build_tab_schema(new_table) output_model.add_schema_entry('hdrtab',new_schema) output_model.hdrtab = fits_support.from_fits_hdu(new_table, new_schema) ## CHANGED
def getTemplates(fnames, blend=True): """ Process all headers to produce a set of combined headers that follows the rules defined by each instrument. """ if not blend: newhdrs = blendheaders.getSingleTemplate(fnames[0]) newtab = None else: # apply rules to create final version of headers, plus table newhdrs, newtab = blendheaders.get_blended_headers(inputs=fnames) cleanTemplates(newhdrs[1], newhdrs[2], newhdrs[3]) return newhdrs, newtab
def getTemplates(fnames, blend=True): """ Process all headers to produce a set of combined headers that follows the rules defined by each instrument. """ if not blend: newhdrs = blendheaders.getSingleTemplate(fnames[0]) newtab = None else: # apply rules to create final version of headers, plus table newhdrs, newtab = blendheaders.get_blended_headers(inputs=fnames) cleanTemplates(newhdrs[1],newhdrs[2],newhdrs[3]) return newhdrs, newtab
def getTemplates(fnames, blend=True, rules_file=None): """ Process all headers to produce a set of combined headers that follows the rules defined by each instrument. """ if not blend: newhdrs = blendheaders.getSingleTemplate(fnames[0]) newtab = None else: # apply rules to create final version of headers, plus table # TODO: NEED to add pointer to dataset-specific rules file as # 'rules_file' parameter. newhdrs, newtab = blendheaders.get_blended_headers( inputs=fnames, rules_file=rules_file) cleanTemplates(newhdrs[1], newhdrs[2], newhdrs[3]) return newhdrs, newtab