def get_bpm(image, pipeline_context): bpm_filename = dbs.get_bpm(image.telescope_id, image.ccdsum, db_address=pipeline_context.db_address) if bpm_filename is None: bpm = None image.header['L1IDMASK'] = ('', 'Id. of mask file used') else: bpm_hdu = fits_utils.open_fits_file(bpm_filename) bpm_extensions = fits_utils.get_extensions_by_name(bpm_hdu, 'BPM') if len(bpm_extensions) > 1: extension_shape = bpm_extensions[0].data.shape bpm_shape = (len(bpm_extensions), extension_shape[0], extension_shape[1]) bpm = np.zeros(bpm_shape, dtype=np.uint8) for i, extension in enumerate(bpm_extensions): bpm[i, :, :] = extension.data[:, :] elif len(bpm_extensions) == 1: bpm = np.array(bpm_extensions[0].data, dtype=np.uint8) else: bpm = np.array(bpm_hdu[0].data, dtype=np.uint8) if not bpm_has_valid_size(bpm, image): tags = logs.image_config_to_tags(image, None) logs.add_tag(tags, 'filename', image.filename) logger.error('BPM shape mismatch', extra=tags) err_msg = 'BPM shape mismatch for {filename} ' \ '{site}/{instrument}'.format(filename=image.filename, site=image.site, instrument=image.instrument) raise ValueError(err_msg) image.header['L1IDMASK'] = (os.path.basename(bpm_filename), 'Id. of mask file used') return bpm
def get_bpm(image, pipeline_context): bpm_filename = dbs.get_bpm(image.telescope_id, image.ccdsum, db_address=pipeline_context.db_address) if bpm_filename is None: bpm = None image.header['L1IDMASK'] = ('', 'Id. of mask file used') else: bpm = np.array(fits.getdata(bpm_filename), dtype=np.uint8) image.header['L1IDMASK'] = (os.path.basename(bpm_filename), 'Id. of mask file used') return bpm
def get_bpm(image, pipeline_context): bpm_filename = dbs.get_bpm(image.telescope_id, image.ccdsum, db_address=pipeline_context.db_address) if bpm_filename is None: bpm_data = np.zeros((image.ny, image.nx), dtype=np.uint8) image.header['L1IDMASK'] = ('', 'Id. of mask file used') else: bpm_data = fits.getdata(bpm_filename) image.header['L1IDMASK'] = (os.path.basename(bpm_filename), 'Id. of mask file used') return np.array(bpm_data, dtype=np.uint8)