coconut_tools.magnetogram.NLD_implicit_method¶
Preprocess magnetograms with nonlinear diffusion filtering.
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
Perona-Malik nonlinear diffusion filter implemented in
nonlinear_diffusion_filter.
Author: Jose Murteira Cleaned and modularized by: Luis
Functions
|
Apply optional Gaussian smoothing and nonlinear diffusion to Br. |
|
Process all target times described by one nonlinear diffusion config. |
|
Process one target time with the nonlinear diffusion pipeline. |
- coconut_tools.magnetogram.NLD_implicit_method.filter_radial_field(Br, phi, theta, iterations=3, apply_gaussian=True, gaussian_sigma=1.0, dx_override=1.0, dy_override=1.0, tau=1.0)[source]¶
Apply optional Gaussian smoothing and nonlinear diffusion to Br.
phiandthetaare kept in the signature for consistency with the other filters; the numerical spacing used by the nonlinear diffusion solver comes fromdx_overrideanddy_override.- Parameters:
Br (np.ndarray) – 2D array of the radial magnetic field.
phi (np.ndarray) – 1D longitude grid in radians.
theta (np.ndarray) – 1D colatitude grid in radians.
iterations (int) – Number of iterations for nonlinear diffusion.
apply_gaussian (bool) – Whether to apply Gaussian filtering before diffusion.
gaussian_sigma (float) – Sigma used in Gaussian smoothing.
dx_override (float) – Spatial resolution in x-direction (default: 1.0).
dy_override (float) – Spatial resolution in y-direction (default: 1.0).
tau (float) – Time step for the nonlinear diffusion.
- Returns:
Filtered Br field and final time step.
- Return type:
tuple[np.ndarray, float]
- coconut_tools.magnetogram.NLD_implicit_method.process_config(config, method_used='NLD')[source]¶
Process all target times described by one nonlinear diffusion config.
With only
dateset, one target time is processed. Withcadence_hoursandtotal_hours, the function builds a time sequence and processes each target independently. Whenoutput_path_figis 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.NLD_implicit_method.process_magnetogram_date(config, target_date, method_used='NLD', output_path_fig=None)[source]¶
Process one target time with the nonlinear diffusion 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 nonlinear diffusion 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,interpolation_order,interpolation,rotate_to_stonyhurst,flux_correct,flux_correction_method,drms_emailorjsoc_email,tau,iterations,apply_gaussian,gaussian_sigma,dx_override, anddy_override.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, optionalBr_linear, final diffusion timestep, and rotation angle.- Return type:
dict[str, Any]