Extrapolations#
NF2 extrapolations are usually run from YAML configuration files. The YAML file describes the run directory, input data, geometry, model, training settings, losses, callbacks, and export/evaluation datasets. The command-line tools load that YAML file, fill any placeholders, normalize the public schema, and then start the same Python training API used by scripts.
Choose the page that matches the geometry or run type:
Cartesian extrapolations cover local active-region boxes and multi-height Cartesian inputs.
Spherical extrapolations cover full-disk and synoptic-map runs.
Analytical NLFF cases provide fast benchmark and smoke-test runs.
Series runs run time sequences after an initial single extrapolation has produced the starting NF2 state.
YAML Configuration Files#
A YAML configuration has a small set of top-level sections:
path: ./runs/case
work_path: ./runs/case/work
logging:
project: nf2
name: "My extrapolation"
data:
geometry: cartesian
boundaries: []
training:
epochs: 30
losses: []
callbacks: []
The required section is data. It must set data.geometry to cartesian or spherical and provide one or more boundary datasets. Everything else can be explicit or left to defaults. For a complete list of accepted keys, see the Full YAML Reference and Dataset and Sampler Reference.
The command-line tools accept only --config as a named argument, then treat any additional --name value pairs as placeholder replacements. This is what lets one example YAML file run on different data files without editing the file each time.
path: "<<run_path>>"
data:
geometry: cartesian
boundaries:
- type: fits
load_map: false
files:
Br: "<<Br>>"
Bt: "<<Bt>>"
Bp: "<<Bp>>"
Run it with custom files:
nf2-extrapolate \
--config nf2/cartesian/minimal_fits.yaml \
--run_path ./runs/ar377 \
--Br ./data/ar377/Br.fits \
--Bt ./data/ar377/Bt.fits \
--Bp ./data/ar377/Bp.fits
You can also write literal paths directly in the YAML instead of placeholders:
path: ./runs/ar377
data:
geometry: cartesian
boundaries:
- type: fits
load_map: false
files:
Br: ./data/ar377/Br.fits
Bt: ./data/ar377/Bt.fits
Bp: ./data/ar377/Bp.fits
Use placeholders for reusable example configs and literal paths for one-off local configs.
What NF2 Does With The YAML#
When a run starts, NF2 performs these steps:
Reads the YAML file.
Replaces
<<placeholder>>values with matching command-line arguments.Normalizes the public YAML schema into the internal runtime configuration.
Builds boundary, sampler, and validation datasets from
data.Builds the SIREN field model and configured losses.
Trains the model and writes
path/extrapolation_result.nf2.
The .nf2 result stores the trained model state and the normalized metadata needed by output helpers, exporters, and metrics.
Python API#
The command-line tools are thin wrappers around the Python API. Use nf2.run(...) when you want to create configurations programmatically:
import nf2
nf2.run(
path="./runs/case1",
data={
"geometry": "cartesian",
"boundaries": [
{
"type": "fits",
"load_map": False,
"files": {
"Br": "./data/Br.fits",
"Bt": "./data/Bt.fits",
"Bp": "./data/Bp.fits",
},
}
],
"z_range": [0, 80],
},
training={"epochs": 30},
)
After training, load the result with nf2.load(...). NF2 chooses CartesianOutput or SphericalOutput from the checkpoint metadata:
import nf2
out = nf2.load("./runs/case1/extrapolation_result.nf2")
cube = out.load_cube(height_range=[0, 80], Mm_per_pixel=1.0, metrics=["j", "alpha"])
Use nf2.run_series(...) for time series, nf2.export_file(...) for programmatic exports, and from nf2.metrics import compute_metrics for custom evaluation procedures.