Skip to content

Soil-profile application and GUI API

neptoon.soil_profile.application is the orchestration boundary for interactive applications. It composes the existing preflight planner, stable sparse-profile service, optional CRNS-constrained runner, diagnostics and parameter-estimation contracts without changing model physics.

Use this layer when a GUI or service needs structured state instead of parsing logs or private DataFrames.

Typical workflow

from neptoon.soil_profile import (
    ProfileInputColumns,
    SoilProfileCancellationToken,
    SoilProfileController,
    SparseProfileRequest,
)

controller = SoilProfileController()
request = SparseProfileRequest(
    latitude_deg=50.8,
    sensor_columns={10.0: "sm10"},
    input_columns=ProfileInputColumns(
        temperature_mean="temperature",
        precipitation="precipitation_mm",
    ),
)

session = controller.prepare(frame, request)
issues = controller.validate(session)
capabilities = controller.capabilities(session)
preview = controller.preview(session)
estimate = controller.estimate_run(session)

cancel = SoilProfileCancellationToken()
outcome = controller.run(
    session,
    cancellation_token=cancel,
    progress_callback=lambda event: print(event.stage, event.fraction),
    output_directory="outputs/run-001",
)

prepare() does not run the model. It exposes planner blockers/warnings, capabilities and pending scientific decisions first. The default session uses the planner-recommended physically complete window; a caller can explicitly select the full record with session.select_window("full_record"). That choice is recorded in the run manifest.

Stable application contracts

Application facade for planning, validation, execution and GUI diagnostics.

The controller never changes model physics or silently accepts diagnostic recommendations. It composes existing public soil-profile contracts, records planner decisions in a manifest, translates progress dictionaries into stable events, and converts expected failures/cancellation into structured outcomes. Unexpected :class:NeptoonInternalError instances still propagate with their original chained traceback so application adapters do not hide programming defects.

prepare

prepare(data, request, *, execution_mode='auto', crns_options=None, planning_options=None, dwd_catalog=None, window_mode='recommended')

Prepare one run without executing the scientific reconstruction.

Planning remains non-mutating. The returned session contains structured issues, capabilities and pending decisions suitable for GUI controls. window_mode='recommended' selects the planner's longest physically complete window; callers can switch to full_record explicitly before execution and that choice is captured in the run manifest.

validate

validate(session)

Return the structured validation issues captured during preparation.

capabilities

capabilities(session)

Return feature availability for enabling/disabling GUI controls.

preview

preview(session)

Return a JSON-safe preview of data coverage, layers and observations.

estimate_run

estimate_run(session)

Return a cheap, explicitly lower-bound resource estimate for UI warnings.

run

run(session, *, progress_callback=None, status_callback=None, cancellation_token=None, output_directory=None)

Execute one soil-profile run inside a stable user-status operation.

plot_data

plot_data(outcome)

Return frontend-neutral tables for a completed application outcome.

configuration_schema staticmethod

configuration_schema()

Return high-level request metadata suitable for generated GUI forms.

Prepared, mutable application state for one prospective reconstruction.

run_id instance-attribute

run_id

data instance-attribute

data

request instance-attribute

request

plan instance-attribute

plan

execution_mode instance-attribute

execution_mode

capabilities instance-attribute

capabilities

issues instance-attribute

issues

pending_decisions instance-attribute

pending_decisions

crns_options class-attribute instance-attribute

crns_options = None

window_mode class-attribute instance-attribute

window_mode = 'recommended'

status class-attribute instance-attribute

status = PREPARED

created_at class-attribute instance-attribute

created_at = field(default_factory=lambda: _utc_now_iso())

selected_start property

selected_start

selected_end property

selected_end

select_window

select_window(mode)

Choose whether execution uses the planner window or the full record.

to_dict

to_dict()

Structured outcome returned by the GUI/application controller.

run_id instance-attribute

run_id

status instance-attribute

status

result instance-attribute

result

summary instance-attribute

summary

manifest instance-attribute

manifest

issues class-attribute instance-attribute

issues = ()

error class-attribute instance-attribute

error = None

manifest_path class-attribute instance-attribute

manifest_path = None

succeeded property

succeeded

to_dict

to_dict()

Machine-readable validation or execution issue for an application UI.

code instance-attribute

code

severity instance-attribute

severity

message instance-attribute

message

stage instance-attribute

stage

recommended_action class-attribute instance-attribute

recommended_action = None

details class-attribute instance-attribute

details = field(default_factory=dict)

to_dict

to_dict()

Capabilities discovered from the prepared data, request and run plan.

can_run instance-attribute

can_run

can_run_sparse_profile instance-attribute

can_run_sparse_profile

can_run_crns_constrained instance-attribute

can_run_crns_constrained

can_assimilate_in_situ instance-attribute

can_assimilate_in_situ

can_use_auto_crns_uncertainty instance-attribute

can_use_auto_crns_uncertainty

can_estimate_process_parameters instance-attribute

can_estimate_process_parameters

can_estimate_hydraulic_parameters instance-attribute

can_estimate_hydraulic_parameters

can_characterize_site instance-attribute

can_characterize_site

can_cancel class-attribute instance-attribute

can_cancel = True

can_preview class-attribute instance-attribute

can_preview = True

to_dict

to_dict()

One explicit user decision suggested by the application layer.

code instance-attribute

code

title instance-attribute

title

description instance-attribute

description

recommended_choice instance-attribute

recommended_choice

scientific_effect instance-attribute

scientific_effect

current_value class-attribute instance-attribute

current_value = None

proposed_value class-attribute instance-attribute

proposed_value = None

to_dict

to_dict()

Structured progress event emitted by :class:SoilProfileController.

stage instance-attribute

stage

status instance-attribute

status

message instance-attribute

message

completed class-attribute instance-attribute

completed = None

total class-attribute instance-attribute

total = None

fraction class-attribute instance-attribute

fraction = None

timestamp class-attribute instance-attribute

timestamp = None

to_dict

to_dict()

Thread-safe cooperative cancellation token for GUI-managed model runs.

is_cancelled property

is_cancelled

cancel

cancel()

raise_if_cancelled

raise_if_cancelled(*, stage='soil-profile application')

Cheap pre-run size estimate for interactive resource warnings.

raw_state_memory_mb estimates only the dense daily ensemble state array (days × layers × ensemble members × float64). It is intentionally labelled as a lower bound and is not a runtime or peak-memory promise.

model_days instance-attribute

model_days

hydraulic_layers instance-attribute

hydraulic_layers

reported_layers instance-attribute

reported_layers

ensemble_size instance-attribute

ensemble_size

raw_state_memory_mb instance-attribute

raw_state_memory_mb

large_run instance-attribute

large_run

note instance-attribute

note

to_dict

to_dict()

Frontend-neutral plot-data facade over a completed profile result.

profile

profile()

Return long-form reported/forecast profile data when available.

storage

storage(intervals=((0.0, 5.0), (0.0, 25.0), (0.0, 50.0)), *, state='reported', uncertainty_method='auto')

Return depth-integrated VWC/storage plus uncertainty for plotting.

crns

crns()

Return the best available CRNS response/assimilation diagnostic table.

innovations

innovations()

Return CRNS innovation, uncertainty and NIS columns for diagnostic plots.

High-level optional controls for an experimental CRNS-constrained GUI run.

The application layer keeps the experimental objects opaque so importing the stable application API does not enable or initialise experimental soil-model access. They are passed through only when execution_mode resolves to crns_constrained.

crns_soil_moisture_column instance-attribute

crns_soil_moisture_column

corrected_neutron_column class-attribute instance-attribute

corrected_neutron_column = None

constraint class-attribute instance-attribute

constraint = None

forward_operator_config class-attribute instance-attribute

forward_operator_config = None

Progress and cancellation

The controller translates the model's committed-day progress dictionaries into SoilProfileProgressEvent. It can additionally publish the same progress through the common status_callback as operation soil_profile.reconstruction, so a GUI can use one status contract for stationary, roving, download, and soil-profile work. The fraction remains local to the reconstruction operation.

controller = SoilProfileController(status_callback=on_status)

A broken GUI callback is logged and ignored so UI state cannot corrupt a scientific run. Cooperative cancellation is checked before execution and after model progress events and returns a structured CANCELLED outcome.

Cancellation is not a hard thread/process kill. It stops at model-safe callback boundaries and therefore preserves the scientific error boundary.

Run manifest

When output_directory is supplied, every completed, blocked, failed or cancelled application run writes soil_profile_run_manifest.json. The manifest contains:

  • Neptoon version and application schema version;
  • run ID and lifecycle timestamps;
  • selected execution mode and run window;
  • an SHA-256 content fingerprint plus input columns/row count, but not raw data;
  • the high-level request and planner audit;
  • capabilities, issues, pending decisions and automatic orchestration choices;
  • compact result metadata or the structured public error.

A separate soil_profile_application_summary.json contains the latest depth, water-balance, CRNS, parameter-estimation and diagnostic summary available from the completed result.

GUI-generated forms

SoilProfileController.configuration_schema() exposes durable high-level fields such as coordinates, profile depth, texture/bulk-density priors, adaptation window and sensor mappings. It intentionally does not promote every private numerical ProfileModelConfig field into a GUI compatibility promise. Expert settings remain available through model_overrides.

Experimental CRNS runs

A GUI can opt into CRNS-constrained execution with CRNSProfileApplicationOptions. Experimental modules are imported lazily only when that execution path is actually run. The application layer does not silently convert unsupported top-level Rosetta fraction priors; it blocks and asks the caller to use depth-resolved hydraulic priors or a supported texture prior.