coconut_tools.magnetogram.Yaroslavsky_filter

Preprocess magnetograms with a local weighted Yaroslavsky-style filter.

This module shares the magnetogram download, reading, temporal interpolation, effective-time handling, Stonyhurst rotation, flux correction, plotting, and COCONUT boundary writing utilities from sph_filtering. Its specific processing step applies optional Gaussian smoothing followed by the local weighted filter implemented in local_weigh_filter.filter3.

Author: Jose Murteira Cleaned and modularized by: Luis

Functions

filter_radial_field_weighted(Br, phi, theta, ...)

Apply optional Gaussian smoothing and local weighted filtering to Br.

process_config(config[, method_used])

Process all target times described by one Yaroslavsky configuration.

process_magnetogram_date(config, target_date)

Process one target time with the local weighted filter pipeline.

coconut_tools.magnetogram.Yaroslavsky_filter.filter_radial_field_weighted(Br, phi, theta, alpha_factor, Rn, sig=0.0, write_gaussian_prepass=False)[source]

Apply optional Gaussian smoothing and local weighted filtering to Br.

Grid spacing is estimated from the supplied longitude and colatitude vectors in radians. Following the article implementation, a single isotropic physical spacing R_sun * max(delta_theta, delta_phi) is passed to the local weighted filter.

Parameters:
  • Br (np.ndarray) – Input magnetic field map.

  • phi (np.ndarray) – 1D array of longitudes in radians.

  • theta (np.ndarray) – 1D array of colatitudes in radians.

  • alpha_factor (float) – Alpha controlling kernel sharpness.

  • Rn (float) – Neighborhood radius in grid-spacing units.

  • sig (float) – Sigma of optional Gaussian smoothing.

  • write_gaussian_prepass (bool) – Whether to export Gaussian-smoothed version.

Returns:

Filtered Br field.

Return type:

np.ndarray

coconut_tools.magnetogram.Yaroslavsky_filter.process_config(config, method_used='Yaroslavsky')[source]

Process all target times described by one Yaroslavsky configuration.

With only date set, one target time is processed. With cadence_hours and total_hours, the function builds a time sequence and processes each target independently. When output_path_fig is omitted each figure is named from the effective magnetogram time.

Parameters:
  • config (dict[str, Any]) – Processing configuration.

  • method_used (str) – Method label used in output filenames.

Returns:

Per-date processing results.

Return type:

list[dict[str, Any]]

coconut_tools.magnetogram.Yaroslavsky_filter.process_magnetogram_date(config, target_date, method_used='Yaroslavsky', output_path_fig=None)[source]

Process one target time with the local weighted filter pipeline.

The function downloads or reuses a magnetogram, optionally interpolates a four-map stencil, computes and logs the effective magnetogram time, optionally rotates to Stonyhurst, optionally balances net flux, applies the local weighted filter, writes the boundary file, and optionally saves a diagnostic figure.

Parameters:
  • config (dict[str, Any]) – Processing configuration. Common keys are map_type, output_dir, download_dir, r_st, amp, adapt_map, write_map, show_map, visu_type, alpha, Rn, sig, interpolation_order, interpolation, rotate_to_stonyhurst, flux_correct, flux_correction_method, drms_email or jsoc_email, and write_gaussian_prepass.

  • target_date – Requested processing time.

  • method_used (str) – Method label used in output filenames.

  • output_path_fig (str | None) – Explicit diagnostic figure path. If omitted, the figure name is built from the effective time.

Returns:

Processing metadata, including target date, effective_date, output paths, selected local file or interpolation stencil, optional Br_linear, and rotation angle.

Return type:

dict[str, Any]