ResampleData

class romancal.resample.resample.ResampleData(input_models, output=None, single=False, blendheaders=True, pixfrac=1.0, kernel='square', fillval='INDEF', wht_type='ivm', good_bits=0, pscale_ratio=1.0, pscale=None, **kwargs)[source]

Bases: object

This is the controlling routine for the resampling process.

Notes

This routine performs the following operations:

  1. Extracts parameter settings from input model, such as pixfrac, weight type, exposure time (if relevant), and kernel, and merges them with any user-provided values.

  2. Creates output WCS based on input images and define mapping function between all input arrays and the output array. Alternatively, a custom, user-provided WCS object can be used instead.

  3. Updates output data model with output arrays from drizzle, including a record of metadata from all input models.

Parameters:
  • input_models (list of objects) – list of data models, one for each input image

  • output (str) – filename for output

  • kwargs (dict) –

    Other parameters.

    Note

    output_shape is in the x, y order.

    Note

    in_memory controls whether or not the resampled array from resample_many_to_many() should be kept in memory or written out to disk and deleted from memory. Default value is True to keep all products in memory.

Methods Summary

do_drizzle()

Pick the correct drizzling mode based on self.single.

drizzle_arrays(insci, inwht, input_wcs, ...)

Low level routine for performing 'drizzle' operation on one image.

resample_exposure_time(output_model)

Resample the exposure time from self.input_models to the output_model.

resample_many_to_many()

Resample many inputs to many outputs where outputs have a common frame.

resample_many_to_one()

Resample and coadd many inputs to a single output.

resample_variance_array(name, output_model)

Resample variance arrays from self.input_models to the output_model.

update_exposure_times(output_model, exptime_tot)

Update exposure time metadata (in-place).

Methods Documentation

do_drizzle()[source]

Pick the correct drizzling mode based on self.single.

static drizzle_arrays(insci, inwht, input_wcs, output_wcs, outsci, outwht, outcon, uniqid=1, xmin=None, xmax=None, ymin=None, ymax=None, pixfrac=1.0, kernel='square', fillval='INDEF', wtscale=1.0)[source]

Low level routine for performing ‘drizzle’ operation on one image.

The interface is compatible with STScI code. All images are Python ndarrays, instead of filenames. File handling (input and output) is performed by the calling routine.

Parameters:
  • insci (2d array) – A 2d numpy array containing the input image to be drizzled.

  • inwht (2d array) – A 2d numpy array containing the pixel by pixel weighting. Must have the same dimensions as insci. If none is supplied, the weighting is set to one.

  • input_wcs (gwcs.wcs.WCS object) – The world coordinate system of the input image.

  • output_wcs (gwcs.wcs.WCS object) – The world coordinate system of the output image.

  • outsci (2d array) – A 2d numpy array containing the output image produced by drizzling. On the first call it should be set to zero. Subsequent calls it will hold the intermediate results. This is modified in-place.

  • outwht (2d array) – A 2d numpy array containing the output counts. On the first call it should be set to zero. On subsequent calls it will hold the intermediate results. This is modified in-place.

  • outcon (2d or 3d array, optional) – A 2d or 3d numpy array holding a bitmap of which image was an input for each output pixel. Should be integer zero on first call. Subsequent calls hold intermediate results. This is modified in-place.

  • uniqid (int, optional) – The id number of the input image. Should be one the first time this function is called and incremented by one on each subsequent call.

  • xmin (float, None, optional) – on the input image. Only pixels on the input image inside this rectangle will have their flux added to the output image. Xmin sets the minimum value of the x dimension. The x dimension is the dimension that varies quickest on the image. If the value is zero, no minimum will be set in the x dimension. All four parameters are zero based, counting starts at zero.

  • xmax (float, None, optional) – Sets the maximum value of the x dimension on the bounding box of the input image. If the value is zero, no maximum will be set in the x dimension, the full x dimension of the output image is the bounding box.

  • ymin (float, None, optional) – Sets the minimum value in the y dimension on the bounding box. The y dimension varies less rapidly than the x and represents the line index on the input image. If the value is zero, no minimum will be set in the y dimension.

  • ymax (float, None, optional) – Sets the maximum value in the y dimension. If the value is zero, no maximum will be set in the y dimension, the full x dimension of the output image is the bounding box.

  • pixfrac (float, optional) – The fraction of a pixel that the pixel flux is confined to. The default value of 1 has the pixel flux evenly spread across the image. A value of 0.5 confines it to half a pixel in the linear dimension, so the flux is confined to a quarter of the pixel area when the square kernel is used.

  • kernel (str, optional) – The name of the kernel used to combine the input. The choice of kernel controls the distribution of flux over the kernel. The kernel names are: 'square', 'gaussian', 'point', 'tophat', 'turbo', 'lanczos2', and 'lanczos3'. The 'square' kernel is the default.

  • fillval (str, optional) – The value a pixel is set to in the output if the input image does not overlap it. The default value of INDEF does not set a value.

Returns:

A tuple with three values: a version string, the number of pixels on the input image that do not overlap the output image, and the number of complete lines on the input image that do not overlap the output input image.

Return type:

tuple

resample_exposure_time(output_model)[source]

Resample the exposure time from self.input_models to the output_model.

Create an exposure time image that is the drizzled sum of the input images.

resample_many_to_many()[source]

Resample many inputs to many outputs where outputs have a common frame.

Coadd only different detectors of the same exposure (e.g. map SCA 1 and 10 onto the same output image), as they image different areas of the sky.

Used for outlier detection

resample_many_to_one()[source]

Resample and coadd many inputs to a single output. Used for level 3 resampling

resample_variance_array(name, output_model)[source]

Resample variance arrays from self.input_models to the output_model.

Resample the name variance array to the same name in output_model, using a cumulative sum.

This modifies output_model in-place.

update_exposure_times(output_model, exptime_tot)[source]

Update exposure time metadata (in-place).