punchbowl.level3.f_corona_model#

Functions#

solve_qp_cube(input_vals, cube, n_nonnan_required, ...)

Fast solver for the quadratic programming problem.

model_fcorona_for_cube(→ tuple[numpy.ndarray, ...)

Model the F corona given a list of times and a corresponding data cube.

_model_fcorona_for_cube_inner(→ tuple[numpy.ndarray, ...)

fill_nans_with_interpolation(→ numpy.ndarray)

Fill NaN values in an image using interpolation.

_load_one_file(→ ndcube.NDCube)

Support for loading files in parallel via multiprocessing.

construct_f_corona_model(→ list[ndcube.NDCube])

Construct a full F corona model.

subtract_f_corona_background(→ ndcube.NDCube)

Subtract f corona background.

subtract_f_corona_background_task(→ ndcube.NDCube)

Subtracts a background f corona model from an observation.

create_empty_f_background_model(→ numpy.ndarray)

Create an empty background model.

Module Contents#

punchbowl.level3.f_corona_model.solve_qp_cube(input_vals: numpy.ndarray, cube: numpy.ndarray, n_nonnan_required: int = 7)#

Fast solver for the quadratic programming problem.

Parameters:
  • input_vals (np.ndarray) – array of times

  • cube (np.ndarray) – array of data

  • n_nonnan_required (int) – The number of non-nan values that must be present in each pixel’s time series. Any pixels with fewer will not be fit, with zeros returned instead.

Returns:

Array of coefficients for solving polynomial

Return type:

np.ndarray

punchbowl.level3.f_corona_model.model_fcorona_for_cube(xt: numpy.ndarray, reference_xt: float, cube: numpy.ndarray, min_brightness: float = 1e-18, clip_factor: float | None = 1, return_full_curves: bool = False, num_workers: int | None = 8, detrend: bool = True) tuple[numpy.ndarray, numpy.ndarray] | tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]#

Model the F corona given a list of times and a corresponding data cube.

Parameters:
  • xt (np.ndarray) – time array

  • reference_xt (float) – timestamp to evaluate the model for

  • cube (np.ndarray) – observation array

  • min_brightness (float) – pixels dimmer than this value are set to nan and considered empty

  • clip_factor (float | None) – If None, no smoothing is applied. Otherwise, the difference between the 25th and 75th percentile is computed and values that vary from the median by more than clip_factor times the difference data are rejected.

  • return_full_curves (bool) – If True, this function returns the full curve fitted to the time series at each pixel and the smoothed data cube. If False (default), only the curve’s value at the central frame is returned, producing a model at one instant in time.

  • num_workers (int | None) – Work is parallelized over this many worker processes. If None, this matches the number of cores.

  • detrend (bool) – Whether to detrend each time series before outlier rejection

Returns:

  • np.ndarray – The F-corona model at the central point in time. If return_full_curves is True, this is instead the F-corona model at all points in time covered by the data cube

  • np.ndarray – The number of data points used in solving the F-corona model for each pixel of the output

  • np.ndarray – The smoothed data cube. Returned only if return_full_curves is True.

punchbowl.level3.f_corona_model._model_fcorona_for_cube_inner(xt: numpy.ndarray, reference_xt: float, cube: numpy.ndarray, min_brightness: float = 1e-18, clip_factor: float | None = 1, return_full_curves: bool = False, detrend: bool = True) tuple[numpy.ndarray, numpy.ndarray] | tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]#
punchbowl.level3.f_corona_model.fill_nans_with_interpolation(image: numpy.ndarray) numpy.ndarray#

Fill NaN values in an image using interpolation.

punchbowl.level3.f_corona_model._load_one_file(filename: str) ndcube.NDCube#

Support for loading files in parallel via multiprocessing.

Parameters:

filename (str) – The file to load

Returns:

data_object – The loaded data

Return type:

NDCube

punchbowl.level3.f_corona_model.construct_f_corona_model(filenames: list[str], clip_factor: float = 3.0, reference_time: str | None = None, num_workers: int = 8, fill_nans: bool = True, polarized: bool = False) list[ndcube.NDCube]#

Construct a full F corona model.

punchbowl.level3.f_corona_model.subtract_f_corona_background(data_object: ndcube.NDCube, before_f_background_model: ndcube.NDCube, after_f_background_model: ndcube.NDCube) ndcube.NDCube#

Subtract f corona background.

punchbowl.level3.f_corona_model.subtract_f_corona_background_task(observation: ndcube.NDCube, before_f_background_model_path: str, after_f_background_model_path: str) ndcube.NDCube#

Subtracts a background f corona model from an observation.

This algorithm linearly interpolates between the before and after models.

Parameters:
  • observation (NDCube) – an observation to subtract an f corona model from

  • before_f_background_model_path (str) – path to a NDCube f corona background map before the observation

  • after_f_background_model_path (str) – path to a NDCube f corona background map after the observation

Returns:

A background subtracted data frame

Return type:

NDCube

punchbowl.level3.f_corona_model.create_empty_f_background_model(data_object: ndcube.NDCube) numpy.ndarray#

Create an empty background model.