def set_extra_attr(fits_file: str, nimages: int, config_port: ConfigPort, image_out_port: OutputPort, first_index: int) -> int: """ Function which adds extra attributes to the central database. Parameters ---------- fits_file : str Absolute path and filename of the FITS file. nimages : int Number of images. config_port : pynpoint.core.dataio.ConfigPort Configuration port. image_out_port : pynpoint.core.dataio.OutputPort Output port of the images to which the attributes are stored. first_index : int First image index of the current subset. Returns ------- int First image index for the next subset. """ pixscale = config_port.get_attribute('PIXSCALE') image_index = np.arange(first_index, first_index + nimages, 1) for item in image_index: image_out_port.append_attribute_data('INDEX', item) image_out_port.append_attribute_data('FILES', fits_file) image_out_port.add_attribute('PIXSCALE', pixscale, static=True) return first_index + nimages
def set_nonstatic_attr(header: fits.header.Header, config_port: ConfigPort, image_out_port: OutputPort, check: bool = True) -> None: """ Function which adds the non-static attributes to the central database. Parameters ---------- header : astropy.io.fits.header.Header Header information from the FITS file that is read. config_port : pynpoint.core.dataio.ConfigPort Configuration port. image_out_port : pynpoint.core.dataio.OutputPort Output port of the images to which the non-static attributes are stored. Returns ------- NoneType None """ attributes = get_attributes() nonstatic = [] for key, value in six.iteritems(attributes): if value['attribute'] == 'non-static': nonstatic.append(key) for attr in nonstatic: if attributes[attr]['config'] == 'header': fitskey = config_port.get_attribute(attr) # if type(fitskey) == np.bytes_: # fitskey = str(fitskey.decode('utf-8')) if fitskey != 'None': if fitskey in header: image_out_port.append_attribute_data(attr, header[fitskey]) elif header['NAXIS'] == 2 and attr == 'NFRAMES': image_out_port.append_attribute_data(attr, 1) elif check: warnings.warn( 'Non-static attribute %s (=%s) not found in the ' 'FITS header.' % (attr, fitskey)) image_out_port.append_attribute_data(attr, -1)