lenstronomy.Data package — lenstronomy 1.9.1 documentation

# lenstronomy.Data package

## Submodules

## lenstronomy.Data.coord_transforms module

class lenstronomy.Data.coord_transforms.Coordinates(transform_pix2angle, ra_at_xy_0, dec_at_xy_0)

  Bases: `object`

  class to handle linear coordinate transformations of a square pixel image

  coordinate_grid(nx, ny)
    Parameters

      - nx – number of pixels in x-direction

      - ny – number of pixels in y-direction

    Returns

      2d arrays with coordinates in RA/DEC with ra_coord[y-axis, x-axis]

  map_coord2pix(ra, dec)

    maps the (ra,dec) coordinates of the system into the pixel coordinate of the image

    Parameters

      - ra – relative RA coordinate as defined by the coordinate frame

      - dec – relative DEC coordinate as defined by the coordinate frame

    Returns

      (x, y) pixel coordinates

  map_pix2coord(x, y)

    maps the (x,y) pixel coordinates of the image into the system coordinates

    Parameters

      - x – pixel coordinate (can be 1d numpy array), defined in the center of the pixel

      - y – pixel coordinate (can be 1d numpy array), defined in the center of the pixel

    Returns

      relative (RA, DEC) coordinates of the system

  property pixel_area

    angular area of a pixel in the image :return: area [arcsec^2]

  property pixel_width

    size of pixel :return: sqrt(pixel_area)

  property radec_at_xy_0
    Returns

      RA, DEC coordinate at (0,0) pixel coordinate

  shift_coordinate_system(x_shift, y_shift, pixel_unit=False)

    shifts the coordinate system :param x_shift: shift in x (or RA) :param y_shift: shift in y (or DEC) :param pixel_unit: bool, if True, units of pixels in input, otherwise RA/DEC :return: updated data class with change in coordinate system

  property transform_angle2pix
    Returns

      transformation matrix from angular to pixel coordinates

  property transform_pix2angle
    Returns

      transformation matrix from pixel to angular coordinates

  property xy_at_radec_0
    Returns

      pixel coordinate at angular (0,0) point

class lenstronomy.Data.coord_transforms.Coordinates1D(transform_pix2angle, ra_at_xy_0, dec_at_xy_0)

  Bases: `lenstronomy.Data.coord_transforms.Coordinates`

  coordinate grid described in 1-d arrays

  coordinate_grid(nx, ny)
    Parameters

      - nx – number of pixels in x-direction

      - ny – number of pixels in y-direction

    Returns

      2d arrays with coordinates in RA/DEC with ra_coord[y-axis, x-axis]

## lenstronomy.Data.imaging_data module

class lenstronomy.Data.imaging_data.ImageData(image_data, exposure_time=None, background_rms=None, noise_map=None, gradient_boost_factor=None, ra_at_xy_0=0, dec_at_xy_0=0, transform_pix2angle=None, ra_shift=0, dec_shift=0)

  Bases: `lenstronomy.Data.pixel_grid.PixelGrid`, `lenstronomy.Data.image_noise.ImageNoise`

  class to handle the data, coordinate system and masking, including convolution with various numerical precisions

  The Data() class is initialized with keyword arguments:

  - ‘image_data’: 2d numpy array of the image data

  - ‘transform_pix2angle’ 2x2 transformation matrix (linear) to transform a pixel shift into a coordinate shift (x, y) -> (ra, dec)

  - ‘ra_at_xy_0’ RA coordinate of pixel (0,0)

  - ‘dec_at_xy_0’ DEC coordinate of pixel (0,0)

  optional keywords for shifts in the coordinate system: - ‘ra_shift’: shifts the coordinate system with respect to ‘ra_at_xy_0’ - ‘dec_shift’: shifts the coordinate system with respect to ‘dec_at_xy_0’

  optional keywords for noise properties: - ‘background_rms’: rms value of the background noise - ‘exp_time’: float, exposure time to compute the Poisson noise contribution - ‘exposure_map’: 2d numpy array, effective exposure time for each pixel. If set, will replace ‘exp_time’ - ‘noise_map’: Gaussian noise (1-sigma) for each individual pixel. If this keyword is set, the other noise properties will be ignored.

  the likelihood for the data given model P(data|model) is defined in the function below. Please make sure that your definitions and units of ‘exposure_map’, ‘background_rms’ and ‘image_data’ are in accordance with the likelihood function. In particular, make sure that the Poisson noise contribution is defined in the count rate.

  property data
    Returns

      2d numpy array of data

  log_likelihood(model, mask, additional_error_map=0)

    computes the likelihood of the data given the model p(data|model) The Gaussian errors are estimated with the covariance matrix, based on the model image. The errors include the background rms value and the exposure time to compute the Poisson noise level (in Gaussian approximation).

    Parameters

      - model – the model (same dimensions and units as data)

      - mask – bool (1, 0) values per pixel. If =0, the pixel is ignored in the likelihood

      - additional_error_map – additional error term (in same units as covariance matrix). This can e.g. come from model errors in the PSF estimation.

    Returns

      the natural logarithm of the likelihood p(data|model)

  update_data(image_data)

    update the data as well as the error matrix estimated from it when done so using the data

    Parameters

      image_data – 2d numpy array of same size as nx, ny

    Returns

      None

## lenstronomy.Data.psf module

class lenstronomy.Data.psf.PSF(psf_type='NONE', fwhm=None, truncation=5, pixel_size=None, kernel_point_source=None, psf_error_map=None, point_source_supersampling_factor=1, kernel_point_source_init=None)

  Bases: `object`

  Point Spread Function class. This class describes and manages products used to perform the PSF modeling (convolution for extended surface brightness and painting of PSF’s for point sources).

  property fwhm
    Returns

      full width at half maximum of kernel (in units of pixel)

  property kernel_pixel

    returns the convolution kernel for a uniform surface brightness on a pixel size

    Returns

      2d numpy array

  property kernel_point_source
  kernel_point_source_supersampled(supersampling_factor, updata_cache=True)

    generates (if not already available) a supersampled PSF with ood numbers of pixels centered

    Parameters

      - supersampling_factor – int >=1, supersampling factor relative to pixel resolution

      - updata_cache – boolean, if True, updates the cached supersampling PSF if generated. Attention, this will overwrite a previously used supersampled PSF if the resolution is changing.

    Returns

      super-sampled PSF as 2d numpy array

  property psf_error_map
  set_pixel_size(deltaPix)

    update pixel size

    Parameters

      deltaPix – pixel size in angular units (arc seconds)

    Returns

      None

## Module contents