API Reference#
The top-level nf2 package exposes the stable public access points. Lower-level modules remain available for advanced use cases, but user code should prefer these helpers.
Public access points for the NF2 framework.
The top-level package intentionally avoids importing heavy astronomy and deep learning dependencies until a caller asks for the matching helper.
- nf2.download_hmi_full_disk(*args, **kwargs)[source]#
Download HMI full-disk vector data through JSOC/DRMS.
- nf2.download_hmi_synoptic(*args, **kwargs)[source]#
Download HMI synoptic vector maps through JSOC/DRMS.
- nf2.export_series(*args, **kwargs)[source]#
Export multiple NF2 result files matched by one or more glob patterns.
- nf2.load(path, device=None)[source]#
Load an NF2 result and return the matching output helper.
- Parameters:
path – Path to a
.nf2checkpoint.device – Optional PyTorch device used for evaluation.
- Returns:
Geometry-specific output helper selected from checkpoint metadata.
- Return type:
- nf2.run(*args, **kwargs)[source]#
Run a single NF2 extrapolation.
The function accepts either the normalized runtime configuration used by
nf2.extrapolateor the public v0.4 YAML-style schema. When the public schema is passed, it is normalized before training starts.
- nf2.run_series(*args, **kwargs)[source]#
Run an NF2 extrapolation series.
Accepts the same public configuration schema as
run(), with series placeholders expanded before the data module is built.
- class nf2.CartesianOutput(*args, **kwargs)[source]#
Evaluate Cartesian NF2 extrapolation checkpoints.
- load_cube(height_range=None, x_range=None, y_range=None, Mm_per_pixel=None, **kwargs)[source]#
Load a regularly sampled Cartesian volume.
Ranges are specified in megameters. Additional keyword arguments are forwarded to
BaseOutput.load_coords().
- class nf2.SphericalOutput(*args, **kwargs)[source]#
Evaluate spherical NF2 extrapolation checkpoints.
- load_spherical(radius_range=None, latitude_range=<Quantity [-1.57079633, 1.57079633] rad>, longitude_range=<Quantity [0. , 6.28318531] rad>, sampling=[100, 180, 360], **kwargs)[source]#
Load a regularly sampled spherical volume.
samplingis ordered as radius, latitude, longitude. Ranges should use Astropy units.- Parameters:
radius_range (Quantity)
latitude_range (Quantity)
longitude_range (Quantity)
- load(radius_range=None, latitude_range=<Quantity [-1.57079633, 1.57079633] rad>, longitude_range=(0, 6.283185307179586), resolution=<Quantity 64. pix / solRad>, nan_value=0, **kwargs)[source]#
Load a Cartesian cube covering a spherical shell selection.
- Parameters:
radius_range (Quantity)
latitude_range (Quantity)
longitude_range (Quantity)
resolution (Quantity)
Unified export command for NF2 result files.
- nf2.export.export_file(nf2_path, out_path=None, *, fmt='vtk', Mm_per_pixel=None, height_range=None, metrics=None, x_range=None, y_range=None, radius_range=None, latitude_range=None, longitude_range=None, pixels_per_solRad=64, progress=True)[source]#
Export one NF2 file to a supported exchange format.
- Parameters:
nf2_path (
str) – Path to anextrapolation_result.nf2checkpoint.out_path (
str|None) – Optional output path. Converter defaults are used when omitted.fmt (
str) – Export format:vtk,npz,hdf5/h5,fits, orheightfor multi-height surface mappings.Mm_per_pixel (
float|None) – Cartesian sampling controls in megameters.height_range (
list[float] |None) – Cartesian sampling controls in megameters.x_range (
list[float] |None) – Cartesian sampling controls in megameters.y_range (
list[float] |None) – Cartesian sampling controls in megameters.radius_range (
list[float] |None) – Spherical VTK sampling controls. Radius is in solar radii; angles are in degrees.latitude_range (
list[float] |None) – Spherical VTK sampling controls. Radius is in solar radii; angles are in degrees.longitude_range (
list[float] |None) – Spherical VTK sampling controls. Radius is in solar radii; angles are in degrees.pixels_per_solRad (
int) – Spherical VTK sampling controls. Radius is in solar radii; angles are in degrees.metrics (
list[str] |None) – Derived quantities to include, such asj,alpha, orfree_energy_fft.progress (
bool) – Show converter progress where supported.
- nf2.export.export_series(patterns, out_dir, *, fmt='vtk', overwrite=False, **kwargs)[source]#
Export all NF2 files matched by one or more glob patterns.
Existing files are skipped unless
overwriteis true.- Parameters:
patterns (list[str])
out_dir (str)
fmt (str)
overwrite (bool)
Command-line quality metrics for NF2 extrapolation results.
- nf2.metrics.compute_metrics(nf2_path, *, device=None, progress=False, **kwargs)[source]#
Compute standard NLFF quality metrics for an NF2 result.
- Parameters:
nf2_path – Path to an
extrapolation_result.nf2file.device – Optional PyTorch device for evaluation.
progress – Show progress while sampling the model.
**kwargs – Geometry-specific sampling options. Cartesian output accepts
Mm_per_pixel,height_range,x_range, andy_range. Spherical output acceptsspherical_sampling,radius_range,latitude_range, andlongitude_range.
- Returns:
Metric names and scalar values ready for printing or downstream use.
- Return type:
dict
Unified download command for NF2 example data sources.
- nf2.data.download.download_hmi_sharp(download_dir, email, t_start, t_end=None, noaa_num=None, sharp_num=None, cadence='720s', segments='Br,Bp,Bt,Br_err,Bp_err,Bt_err', series='sharp_cea_720s')[source]#
Download an HMI SHARP or SHARP CEA vector magnetogram series.
Parameters mirror the
nf2-download --source hmi_sharpcommand. Provide eithersharp_numornoaa_num.
- nf2.data.download.download_hmi_synoptic(download_dir, email, carrington_rotation=None, carrington_rotation_end=None, t_start=None, t_end=None, segments='Br,Bt,Bp', series='b_synoptic', include_mr_polfil=False, synoptic_product='vector')[source]#
Download HMI synoptic maps for one or more Carrington rotations.
Rotations can be provided explicitly or inferred from
t_startand optionalt_end.
- nf2.data.download.download_hmi_full_disk(download_dir, email, t_start, t_end=None, cadence='720s', series='B_720s', segments='field,inclination,azimuth,disambig', convert_ptr=True, keep_coordinates=False)[source]#
Download HMI full-disk vector data, optionally converted to Br/Bt/Bp.
Conversion uses the JSOC
HmiB2ptrexport process by default.