photometry#

Methods for performing photometry / measuring fluxes.

hsr4hci.photometry._gaussian_integral(amplitude, sigma, radius=0.5)[source]#

This function compute the following integral:

\[\int_{0}^{R} dr \int_{0}^{2\pi} d\phi \ r\ A e^{-\frac{r^2}{2\sigma^2}} = 2 \pi A \sigma^2 (1 - e^{-\frac{R^2}{2\sigma^2}})\]

This function can be used to turn the results of the fit of a 2D Gaussian into units that are compatible with aperture photometry.

Parameters:
  • amplitude (float) – Amplitude of a (symmetric) 2D Gaussian.

  • sigma (float) – Standard deviation of a (symmetric) 2D Gaussian.

  • radius (float) – The maximum radius \(R\) for the integral.

Returns:

The value of the above integral as a float.

Return type:

float

hsr4hci.photometry._get_flux__as(frame, position, aperture_radius)[source]#

Auxiliary function to measure the flux using the β€œAS” mode. See get_flux() for more details.

Parameters:
Return type:

Tuple[Tuple[float, float], float]

hsr4hci.photometry._get_flux__ass(frame, position, aperture_radius, search_radius)[source]#

Auxiliary function to measure the flux using the β€œASS” mode. See get_flux() for more details.

Parameters:
Return type:

Tuple[Tuple[float, float], float]

hsr4hci.photometry._get_flux__f(frame, position, mask_frame_radius=5.0)[source]#

Auxiliary function to measure the flux using the β€œF” mode. See get_flux() for more details.

Parameters:
Return type:

Tuple[Tuple[float, float], float]

hsr4hci.photometry._get_flux__fs(frame, position, search_radius, mask_frame_radius=5.0)[source]#

Auxiliary function to measure the flux using the β€œFS” mode. See get_flux() for more details.

Parameters:
Return type:

Tuple[Tuple[float, float], float]

hsr4hci.photometry._get_flux__p(frame, position)[source]#

Auxiliary function to measure the flux using the β€œP” mode. See get_flux() for more details.

Parameters:
Return type:

Tuple[Tuple[float, float], float]

hsr4hci.photometry.get_flux(frame, position, mode='AS', aperture_radius=None, search_radius=None, mask_frame_radius=5.0)[source]#

This function estimates the flux at or around a given position in a frame. There are five different modes for how to do this:

  1. β€œAS” (aperture sum):

    Compute the integrated flux over a circular aperture with radius aperture_radius at the given position. This is perhaps the most β€œintuitive” way to compute the flux.

  2. β€œASS” (aperture sum + search):

    Similar to β€œAS”, except the position of the circular aperture is varied in a circular region with radius search_radius to find the position with the highest flux.

  3. β€œP” (pixel):

    Compute or interpolate the value of a single pixel at the given position. (Internally, this simply uses an aperture with a diameter of 1 pixel.)

  4. β€œF” (fit):

    Compute the flux by fitting a 2D Gaussian to the given position and returning its amplitude.

  5. β€œFS” (fit + search):

    Similar to β€œF”, except the position of the 2D Gaussian is also optimized within the given search_radius.

Parameters:
  • frame (ndarray) – A 2D numpy array of shape (width, height) containing the data on which to run the aperture photometry.

  • position (Tuple[float, float]) – A tuple (x, y) specifying the position at which to estimate the flux.

  • mode (str) – Either β€œAS”, β€œASS”, β€œP”, β€œF”, or β€œFS” (see above for a detailed explanation).

  • aperture_radius (Optional[Quantity]) – Required for modes β€œAS” and β€œASS”. Defines the radius of the circular aperture over the flux is summed up / integrated.

  • search_radius (Optional[Quantity]) – Required for modes β€œASS” and β€œFS”. Defines the size of the region within which we vary the position to find the β€œoptimal” (= highest) flux.

  • mask_frame_radius (float) –

    For modes β€œF” and β€œFS” (i.e., the modes that are based on fitting a 2D Gaussian to the data), we use a mask to set pixels to zero that are further away from the position (plus search_radius) than the given mask_frame_radius. This is useful to avoid that other signals or speckles β€œin the distance” affect the result of the fit. Modes β€œP”, β€œAS”, and β€œASS” ignore this parameter.

    Caution

    For measuring the stellar flux, this parameter should be set to a larger value than for planets; otherwise, the stellar flux will be under-estimated.

Returns:

A tuple (final_position, flux), where the final_position is a 2-tuple of floats (i.e., the Cartesian position using the photutils coordinate convention).

Return type:

Tuple[Tuple[float, float], float]

hsr4hci.photometry.get_fluxes_for_polar_positions(polar_positions, frame, mode='AS', aperture_radius=None, search_radius=None)[source]#

Auxiliary function for applying to get_flux() to a list of positions that are given in (β€œastronomical”) polar coordinates.

Parameters:
  • polar_positions (List[Tuple[Quantity, Quantity]]) – A list of positions in polar coordinates, that is, every position is a tuple (separation, angle), where for the angle, 0 degrees is β€œup”, not β€œright”.

  • frame (ndarray) – The frame / image on which to perform the photometry.

  • mode (str) – The mode parameter for get_flux(); see there for more details.

  • aperture_radius (Optional[Quantity]) – The aperture_radius parameter for get_flux(); see there for more details.

  • search_radius (Optional[Quantity]) – The search_radius parameter for get_flux(); see there for more details.

Returns:

A list of the fluxes for each given polar position.

Return type:

List[float]

hsr4hci.photometry.get_stellar_flux(psf_template, dit_stack, dit_psf_template, mode='FS', scaling_factor=1.0, aperture_radius=None, search_radius=Quantity(1, 'pixel'))[source]#

This function takes the unsaturated PSF template and computes the flux of the star, normalized relative to the integration time of the stack.

Parameters:
  • psf_template (ndarray) – 2D numpy array with the unsaturated PSF template.

  • dit_stack (float) – Integration time of the frames in the stack (in seconds).

  • dit_psf_template (float) – Integration time of the unsaturated PSF template (in seconds).

  • scaling_factor (float) – A scaling factor to account for neutral density (ND) filters. Example: If the transmission is 2%, use a value of 0.02 for the scaling_factor.

  • mode (str) – See get_aperture_flux() for more details. For the stellar flux, mode β€œFS” is recommended.

  • aperture_radius (Optional[Quantity]) – See get_aperture_flux() for details.

  • search_radius (Optional[Quantity]) – See get_aperture_flux() for details.

Returns:

The stellar flux, normalized relative to the DIT of the stack.

Return type:

float