API Reference
Settings
GravityToolsNext.RunPaths
— TypeRunPaths
Holds paths for a TEMPO run.
Fields
work_dir::String
: Absolute working directory for the runpar_input::String
: Input.par
file name or relative path (resolved againstwork_dir
; absolute paths are rejected)par_output::String
: Output.par
file name (filename only; no directories)tim_input::String
:.tim
file name or relative path (resolved againstwork_dir
; absolute paths are rejected)
Notes
- A keyword constructor
RunPaths(; work_dir, par_input, tim_input, par_output=default_par_output(par_input))
is available.
GravityToolsNext.default_par_output
— Functiondefault_par_output(par_input::AbstractString) -> String
Generate a default output file name (no directories) by taking basename(par_input)
and replacing its .par
extension with *_out.par
.
- Accepts either a bare filename or any path.
- Still enforces that the basename ends with
.par
(case‑insensitive).
GravityToolsNext.EngineOptions
— TypeEngineOptions
Defines low-level options for a TEMPO run.
Fields
tempo_version::AbstractTempoVersion
: Which TEMPO flavor to useflags::String
: Additional command-line flags (normalized string)nits::Int
: Number of internal iterations (must be ≥ 1)gain::Float64
: GAIN parameter controlling convergence damping (must be > 0)
Notes
flags
should be a single string; it is normalized (trimmed) and must not contain newlines.gain
is validated to be strictly positive.
GravityToolsNext.InputModifiers
— TypeInputModifiers
Describes transformations applied to the inputs of a TEMPO run.
Fields
override_params::Vector{TempoParameter}
: parameters to upsert into the.par
time_start::Union{Nothing,Float64}
: optional lower MJD bound (inclusive)time_finish::Union{Nothing,Float64}
: optional upper MJD bound (inclusive)couple_f1_to_ddot::Bool
: if true, auto-adjustF1
whenDDOT
is overridden (applied during materialization)
Notes
- If both
time_start
andtime_finish
are provided,time_start ≤ time_finish
is enforced.
GravityToolsNext.CaptureOptions
— TypeCaptureOptions
Controls what is captured/emitted by the TEMPO engine itself (flags / process I/O).
Fields
write_output::Bool
: capture stdout/stderr from the enginewrite_residuals::Bool
: for Tempo2 uses-write_residuals
(per internal iteration); for Tempo uses-residuals
(final only)
GravityToolsNext.RetentionOptions
— TypeRetentionOptions
Controls what data we keep in the in-memory/result structures after a run.
Fields
save_internal_iterations::Bool
: retain all intermediate iteration resultssave_residuals::Bool
: retain residuals arrays inside results (can be large)
GravityToolsNext.WhiteNoiseOptions
— TypeWhiteNoiseOptions(; enabled=false, scope=:final)
Options for white-noise analysis:
enabled
— toggle analysis;scope
—:final
(last internal iteration) or:all
(every internal iteration).
GravityToolsNext.WorkspaceOptions
— TypeWorkspaceOptions
Workspace/runtime controls for a single TEMPO run. The options are grouped by intent:
Lifecycle & isolation
work_mode::Symbol
::inplace
|:jobdir
:inplace
— run directly insidework_dir
(job root =work_dir
).:jobdir
— create/use a subdirectory ofwork_dir
as an isolated job root.
job_name::Union{Nothing,String}
: subdirectory name whenwork_mode=:jobdir
.- If
nothing
, an auto name likejob-YYYYmmdd-HHMMSS-<rand>
is generated.
- If
overwrite::Symbol
::error
|:reuse
|:unique
|:clean
- Behavior when the target job directory already exists (
:unique
appends-001
,-002
, ...). :error
— fail if exists;:reuse
— use as-is;:clean
— purge contents then use.:overwrite
is accepted for backward compatibility and treated as:clean
(a warning is emitted).
- Behavior when the target job directory already exists (
Layout of files (inside the job root)
layout::Symbol
::flat
|:split
:flat
— files live directly in the job root.:split
— createinput/
,output/
,tmp/
under the job root.
temp_dir::Union{Nothing,String}
- If
nothing
, the executioncwd
is the job root for:flat
, ortmp/
for:split
. - If non-
nothing
, use this subdirectory as the executioncwd
(created if missing).
- If
I/O mirroring
io_mirror::Union{Symbol,Int,Tuple{Symbol,Int}} = :none
- Controls how the
temp_dir
(or job root) directory structure is mirrored for I/O. :none
(flat),:full
(mirror fulltemp_dir
),Int
(first N segments),(:depth_minus, k)
(first depth-k segments).- Ignored when
layout = :flat
.
- Controls how the
Inputs capture into job root
link_tim::Bool
: symlink the.tim
file instead of copying (falls back to copy if symlink fails).snapshot_par::Bool
: copy the input.par
for reproducibility.
Cleanup & retention
cleanup_before_run::Bool
: remove engine artifacts in the run directory before launch.keep_tmp_on_success::Bool
: keeptmp/
after a successful run (useful for debugging).keep_tmp_on_error::Bool
: keeptmp/
if the run failed.
Runtime & manifest
timeout_s::Union{Nothing,Int}
: kill the run after this many seconds (nothing
= unlimited).write_manifest::Bool
: write a small manifest file in the job root.manifest_style::Symbol
::json
|:toml
.
GravityToolsNext.LoggingOptions
— TypeLoggingOptions
Lightweight logging verbosity controls for the runner.
verbosity
— one of:silent | :warn | :info | :debug
(also accepts0..3
in the constructor)with_timestamps
— include timestamps in log lines
GravityToolsNext.TempoRunSettings
— TypeTempoRunSettings
Top-level settings for a single TEMPO run. Composed from smaller structures:
paths::RunPaths
engine::EngineOptions
modifiers::InputModifiers
capture::CaptureOptions
retention::RetentionOptions
analysis::WhiteNoiseOptions
workspace::WorkspaceOptions
logging::LoggingOptions
GravityToolsNext.copy_with
— Functioncopy_with(s::TempoRunSettings; kwargs...) -> TempoRunSettings
Create a modified copy of s
with keyword overrides. You can override either whole sub-structs (analysis
, workspace
, logging
) or individual convenience keys (e.g. white_noise_enabled
, timeout_s
, verbosity
, ...).
Additional override-params controls:
override_params_clear::Bool=false
: start from an empty override list.override_params_delete
: names (Symbol/String or a collection of them) to remove from overrides.override_params_upsert::Vector{TempoParameter}=TP[]
: add/replace overrides by name.
If override_params
is provided, delete/upsert are applied on top of it.
GravityToolsNext.validate
— Functionvalidate(v::AbstractTempoVersion) -> Bool
Check that data directory exists and the executable is available (or at least named). Returns true
if OK, otherwise throws.
validate(s::TempoRunSettings) -> Bool
Alias for [validate_inputs_exist
] — quick pre-materialization check that input .par
/.tim
exist relative to work_dir
and that par_output
is a bare file name. Does not create directories.
Runner & Tasks
GravityToolsNext.run_tempo_parsed
— Functionrun_tempo_parsed(settings::TempoRunSettings) :: TempoRunOutput
Materialize the workspace, run TEMPO/TEMPO2 with relative paths, parse stdout into iteration records, and assemble RunArtifacts
. No post-run deletion is performed here; call cleanup_run!
from task-level code after reading the artifacts.
GravityToolsNext.BasicTempoTask
— TypeBasicTempoTask(settings::TempoRunSettings)
Single TEMPO/TEMPO2 task with parsed iterations, optional residual statistics, and optional white-noise analysis controlled by settings.analysis
.
GravityToolsNext.run_task
— Functionrun_task(task::SingleTempoTask) -> GeneralTempoResult
Execute the task and return a unified result. Every concrete SingleTempoTask
must provide a method.
run_task(task::MultiPointTask)
Entry point for multi-point workflows. Define as needed for your project.
run_task(task::BasicTempoTask) -> GeneralTempoResult
Run TEMPO/TEMPO2 using task.settings
, parse iteration-wise outputs, attach residual/TIM-derived statistics, optionally perform white-noise fitting, and return an aggregated GeneralTempoResult
.
run_task(task::PriorMarginalizedTempoTask) -> GeneralTempoResult
Execute the prior-marginalized task: build θ grid, run/supply node results, and assemble the aggregated GeneralTempoResult
.
If settings.exec_options.on_error == :stop
, the execution stops at the first failing node (detected by _check_nodes_for_error
) and returns that node's GeneralTempoResult
annotated by _bad_prior_result
with :prior_mode => :stopped_on_error
.
GravityToolsNext.task_stage_inputs!
— Functiontask_stage_inputs!(task::SingleTempoTask, dest_dir::AbstractString) -> Nothing
Stage/copy any task-specific input artifacts into dest_dir
so that the task can run there using name-only paths. Default implementation does nothing.
Wrappers like prior-marginalization should call this before cloning a task with a new work_dir
.
Adaptive Grid
GravityToolsNext.GridAxis
— TypeGridAxis(name; min, max, N, rule)
GridAxis(name, values::AbstractVector)
A typed grid axis with a chosen discretization rule. Call axisvalues
to obtain physical coordinates and linspace
to obtain the rule's linear parameterization.
Arguments
name::Symbol
: semantic axis name (e.g.:PBDOT
,:beta0
).min, max
: axis bounds (ignored forExplicitRule
).N::Integer
: number of grid points (must be ≥ 1).rule
: one ofLinRule()
,LogRule([sign])
, orExplicitRule
.- values : alternative constructor; makes an ExplicitRule from a supplied vector of nodes.
Examples
ax1 = GridAxis(:x; min=-1.0, max=1.0, N=21, rule=LinRule())
ax2 = GridAxis(:m; min=-1e-4, max=-1e-2, N=16, rule=LogRule()) # auto-sign (−)
ax3 = GridAxis(:θ, [-1.0, -0.5, 0.0, 0.5, 1.0]) # explicit nodes
GravityToolsNext.LinAxis
— TypeGridAxis(name; min, max, N, rule)
GridAxis(name, values::AbstractVector)
A typed grid axis with a chosen discretization rule. Call axisvalues
to obtain physical coordinates and linspace
to obtain the rule's linear parameterization.
Arguments
name::Symbol
: semantic axis name (e.g.:PBDOT
,:beta0
).min, max
: axis bounds (ignored forExplicitRule
).N::Integer
: number of grid points (must be ≥ 1).rule
: one ofLinRule()
,LogRule([sign])
, orExplicitRule
.- values : alternative constructor; makes an ExplicitRule from a supplied vector of nodes.
Examples
ax1 = GridAxis(:x; min=-1.0, max=1.0, N=21, rule=LinRule())
ax2 = GridAxis(:m; min=-1e-4, max=-1e-2, N=16, rule=LogRule()) # auto-sign (−)
ax3 = GridAxis(:θ, [-1.0, -0.5, 0.0, 0.5, 1.0]) # explicit nodes
GravityToolsNext.LogAxis
— TypeGridAxis(name; min, max, N, rule)
GridAxis(name, values::AbstractVector)
A typed grid axis with a chosen discretization rule. Call axisvalues
to obtain physical coordinates and linspace
to obtain the rule's linear parameterization.
Arguments
name::Symbol
: semantic axis name (e.g.:PBDOT
,:beta0
).min, max
: axis bounds (ignored forExplicitRule
).N::Integer
: number of grid points (must be ≥ 1).rule
: one ofLinRule()
,LogRule([sign])
, orExplicitRule
.- values : alternative constructor; makes an ExplicitRule from a supplied vector of nodes.
Examples
ax1 = GridAxis(:x; min=-1.0, max=1.0, N=21, rule=LinRule())
ax2 = GridAxis(:m; min=-1e-4, max=-1e-2, N=16, rule=LogRule()) # auto-sign (−)
ax3 = GridAxis(:θ, [-1.0, -0.5, 0.0, 0.5, 1.0]) # explicit nodes
GravityToolsNext.ExplicitAxis
— TypeGridAxis(name; min, max, N, rule)
GridAxis(name, values::AbstractVector)
A typed grid axis with a chosen discretization rule. Call axisvalues
to obtain physical coordinates and linspace
to obtain the rule's linear parameterization.
Arguments
name::Symbol
: semantic axis name (e.g.:PBDOT
,:beta0
).min, max
: axis bounds (ignored forExplicitRule
).N::Integer
: number of grid points (must be ≥ 1).rule
: one ofLinRule()
,LogRule([sign])
, orExplicitRule
.- values : alternative constructor; makes an ExplicitRule from a supplied vector of nodes.
Examples
ax1 = GridAxis(:x; min=-1.0, max=1.0, N=21, rule=LinRule())
ax2 = GridAxis(:m; min=-1e-4, max=-1e-2, N=16, rule=LogRule()) # auto-sign (−)
ax3 = GridAxis(:θ, [-1.0, -0.5, 0.0, 0.5, 1.0]) # explicit nodes
GravityToolsNext.linspace
— Functionlinspace(ax)
Return the linear parameterization for an axis:
- For
LinAxis
, this equals the physical coordinates. - For
LogAxis
, this is uniform inlog10(|x|)
. - For
ExplicitAxis
, returns a copy of the stored values.
The result is a copy (safe to mutate by the caller).
GravityToolsNext.axisvalues
— Functionaxisvalues(ax)
Return the physical coordinates for an axis. For LogAxis
, uses the rule sign (+1/−1
) or infers it from ax.min
when the rule is constructed with LogRule()
.
The result is a copy (safe to mutate by the caller).
GravityToolsNext.RefinementSettings
— TypeRefinementSettings(units...; desired_refinement_level, parallel=false, params_to_save=())
Container for adaptive‑grid refinement configuration.
Arguments
units...
: one or more refinement units (order matters).desired_refinement_level
: how many refinement rounds to perform (≥ 0).parallel
: whether the grid engine may run points in parallel.params_to_save
: tuple of metric names to extract at each point.
GravityToolsNext.LocalMinimaUnit
— TypeLocalMinimaUnit(name; min=-Inf, max=Inf, from_min=true)
Refine until a local minimum is detected along variable name
within the interval [min, max]
.
Arguments
name::Symbol
: the variable/axis identifier.min
,max
: bounds of the search interval.from_min
: iftrue
, sweep from the lower bound (otherwise from upper).
GravityToolsNext.FullUnit
— TypeFullUnit(name; min=-Inf, max=Inf)
Always refine over the whole range [min, max]
of variable name
.
GravityToolsNext.DiffUnit
— TypeDiffUnit(name; min=-Inf, max=Inf, diff, from_min=true)
Refine where the absolute change Δ(metric) exceeds diff
within [min, max]
. If from_min
is true
, scanning proceeds from the lower bound.
GravityToolsNext.RelDiffUnit
— TypeRelDiffUnit(name; min=-Inf, max=Inf, rel_diff, from_min=true)
Refine where the relative change exceeds rel_diff
within [min, max]
.
GravityToolsNext.ContourUnit
— TypeContourUnit(name; min=-Inf, max=Inf, contours, from_min=true)
Refine near specified contour levels (contours
) of the target metric within [min, max]
. contours
can be a number, a tuple, or a vector of levels.
GravityToolsNext.DiffContourUnit
— TypeDiffContourUnit(name; min=-Inf, max=Inf, diffs, contours, from_min=true)
Refine near combinations of absolute difference thresholds (diffs
) and contour levels (contours
) within [min, max]
. diffs
/contours
accept a number, tuple, or vector.
GravityToolsNext.AdaptiveRefinement2DGrid
— TypeAdaptiveRefinement2DGrid
Structure representing a 2D adaptive refinement grid with variables, parameters, axes, refinement settings, and refinement status.
GravityToolsNext.GridWorkspaceOptions
— TypeGridWorkspaceOptions
Workspace and tagging options for Adaptive2DGridTask
.
Fields
grid_root::String
: Root folder for all grid artifacts. If relative, it's resolved against the base taskwork_dir
.point_job_prefix::String
: Subdirectory undergrid_root
to hold per-point job folders (used as part ofjob_name
).results_dirname::String
: Subdirectory undergrid_root
where per-point results (e.g., JLD2 files) are saved.input_dirname::String
: Optional subdirectory name used when staging base inputs for the grid.
Tagging
tag_mode::Symbol
::with_value
to embed axis values into the tag,:hash
to use a stable hash instead.tag_value_sig::Int
: Significant digits when formatting values for:with_value
tags.tag_sep::String
: Separator between X and Y parts for:with_value
tags.sanitize::Bool
: Make tag filesystem-safe.hash_len::Int
: Number of hex characters to keep whentag_mode == :hash
.
Persistence & staging
save_results_jld2::Bool
: Save fullGeneralTempoResult
for each point intoresults_dirname
.stage_inputs::Bool
: Stage base task inputs into the grid root once before running.stage_inputs_mode::Symbol
: Where to stage inputs::root
(intogrid_root
) or:subdir
(intogrid_root/input_dirname
).
GravityToolsNext.Adaptive2DGridTask
— TypeAdaptive2DGridTask(; base_task, x, y, ref_settings, opts=GridWorkspaceOptions())
Run a SingleTempoTask
over an adaptively refined 2D grid defined by axes x
and y
.
Arguments
base_task::SingleTempoTask
: The task to clone and execute at each grid point.x::GridAxis
,y::GridAxis
: Grid axes (linear/log/explicit rules supported).ref_settings::RefinementSettings
: Refinement engine configuration (units and parameters to save).opts::GridWorkspaceOptions
: Workspace layout, tagging, and persistence options.
Behavior
- Each grid point is run in its own job directory (under
opts.grid_root
) with a uniquejob_name
andpar_output
stem. - The task is cloned via
task_copy_with
and parameter overridesTP(string(x.name), xv)
,TP(string(y.name), yv)
. - Selected result scalars are returned to the grid engine as a
NamedTuple
keyed byref_settings.params_to_save
.
GravityToolsNext.Adaptive2DGridTask
GravityToolsNext.AdaptiveRefinement2DGrid
GravityToolsNext.BasicTempoTask
GravityToolsNext.CaptureOptions
GravityToolsNext.ContourUnit
GravityToolsNext.DiffContourUnit
GravityToolsNext.DiffUnit
GravityToolsNext.EngineOptions
GravityToolsNext.ExplicitAxis
GravityToolsNext.FullUnit
GravityToolsNext.GridAxis
GravityToolsNext.GridWorkspaceOptions
GravityToolsNext.InputModifiers
GravityToolsNext.LinAxis
GravityToolsNext.LocalMinimaUnit
GravityToolsNext.LogAxis
GravityToolsNext.LoggingOptions
GravityToolsNext.RefinementSettings
GravityToolsNext.RelDiffUnit
GravityToolsNext.RetentionOptions
GravityToolsNext.RunPaths
GravityToolsNext.TempoRunSettings
GravityToolsNext.WhiteNoiseOptions
GravityToolsNext.WorkspaceOptions
GravityToolsNext.axisvalues
GravityToolsNext.copy_with
GravityToolsNext.default_par_output
GravityToolsNext.linspace
GravityToolsNext.run_task
GravityToolsNext.run_tempo_parsed
GravityToolsNext.task_stage_inputs!
GravityToolsNext.validate