def xxx(header): """ """ ra, dec = 53.18118642, -27.79096316 hdu = utils.make_wcsheader(ra=ra, dec=dec, size=10, pixscale=0.06, get_hdu=True) out = grizli.jwst.hdu_to_imagemodel(hdu) from jwst.datamodels import ModelContainer, DrizProductModel product = DrizProductModel(out.data.shape) product.meta.wcs = out.meta.wcs from jwst.resample import gwcs_blot, gwcs_drizzle driz = gwcs_drizzle.GWCSDrizzle(product) #, outwcs=out.meta.wcs) driz.add_image(blot_data, wcs_model.meta.wcs, xmax=out.data.shape[1], ymax=out.data.shape[0]) from jwst.resample import resample_utils from drizzle import util input_wcs = wcs_model.meta.wcs output_wcs = out.meta.wcs fillval = 'INDEF' insci = blot_data inwht = None xmin = xmax = ymin = ymax = 0 uniqid = 1 outsci = driz.outsci * 1 outwht = driz.outwht * 1 outcon = driz.outcon * 1 in_units = 'cps' from jwst.resample import resample groups = ModelContainer([wcs_model]) sampler = resample.ResampleData(groups, output=driz)
def do_detection(self): """Flag outlier pixels in DQ of input images.""" self._convert_inputs() self.build_suffix(**self.outlierpars) pars = self.outlierpars save_intermediate_results = pars['save_intermediate_results'] if pars['resample_data']: # Start by creating resampled/mosaic images for # each group of exposures resamp = resample.ResampleData(self.input_models, single=True, blendheaders=False, **pars) drizzled_models = resamp.do_drizzle() if save_intermediate_results: for model in drizzled_models: log.info("Writing out resampled exposures...") model_output_path = self.make_output_path( basepath=model.meta.filename, suffix='outlier_i2d') model.save(model_output_path) else: # for non-dithered data, the resampled image is just the original image drizzled_models = self.input_models for i in range(len(self.input_models)): drizzled_models[i].wht = build_driz_weight( self.input_models[i], weight_type='ivm', good_bits=pars['good_bits']) # Initialize intermediate products used in the outlier detection median_model = datamodels.ImageModel(drizzled_models[0].data.shape) median_model.update(drizzled_models[0]) median_model.meta.wcs = drizzled_models[0].meta.wcs # Perform median combination on set of drizzled mosaics median_model.data = self.create_median(drizzled_models) if save_intermediate_results: median_output_path = self.make_output_path( basepath=self.input_models[0].meta.filename, suffix='median' ) log.info("Writing out MEDIAN image to: {}".format( median_output_path )) median_model.save(median_output_path) if pars['resample_data']: # Blot the median image back to recreate each input image specified # in the original input list/ASN/ModelContainer blot_models = self.blot_median(median_model) if save_intermediate_results: log.info("Writing out BLOT images...") for model in blot_models: model_path = self.make_output_path( basename=model.meta.filename, suffix='blot' ) model.save(model_path) else: # Median image will serve as blot image blot_models = datamodels.ModelContainer() for i in range(len(self.input_models)): blot_models.append(median_model) # Perform outlier detection using statistical comparisons between # each original input image and its blotted version of the median image self.detect_outliers(blot_models) # clean-up (just to be explicit about being finished with # these results) del median_model, blot_models