API Reference
GravityToolsNext.AbstractGridRule
— TypeAbstractGridRule
A discretization rule for a 1D grid axis. Implementations:
LinRule
— uniform spacing in the physical domain.LogRule
— uniform spacing in log10(|x|); sign can be auto-detected.ExplicitRule
— use a user-provided set of values verbatim.
GravityToolsNext.AbstractTempoSettings
— TypeAbstractTempoSettings
Abstract base type for all TEMPO settings structures. Used for dispatching and type hierarchies.
GravityToolsNext.AbstractTempoVersion
— TypeAbstractTempoVersion
Abstract base for different TEMPO flavors (Tempo / Tempo2). Implementations must provide:
tempo_data_dir(v) :: String
— data directory path (TEMPO* env target)tempo_cmd_path(v) :: String
— resolved executable path (or bare name)tempo_cmd(v) :: Cmd
— ready-to-run commandtempo_env(v) :: Dict{String,String}
— env vars to pass to the process
GravityToolsNext.AdaptiveRefinement2DGrid
— TypeAdaptiveRefinement2DGrid
Structure representing a 2D adaptive refinement grid with variables, parameters, axes, refinement settings, and refinement status.
GravityToolsNext.AdaptiveRefinement2DGrid
— MethodAdaptiveRefinement2DGrid(x::GridAxis, y::GridAxis, ref_sets)
Construct a new AdaptiveRefinement2DGrid from grid axes and refinement settings.
GravityToolsNext.BasicResidualStats
— TypeBasicResidualStats
Summary for raw (non-normalized) residuals.
Fields
n
: number of pointsmin,max
: rangemean
: arithmetic meanwmean
: weighted mean (if weights given; else = mean)median
: sample medianrms
: √(mean(x^2)) — uncenteredwrms
: √(∑w x^2 / ∑w) — uncentered, weightedstd
: √(mean((x-mean)^2)) — centeredwstd
: √(∑w (x-wmean)^2 / ∑w) — centered, weightedmad
: median(|x - median(x)|) — robust spread
GravityToolsNext.BasicTempoOutput
— TypeBasicTempoOutput
Basic statistical metrics from a single TEMPO2 fit iteration.
Fields:
rms_pre_fit_residual_us::Float64
: RMS of pre-fit residuals (µs)rms_post_fit_residual_us::Float64
: RMS of post-fit residuals (µs)rms_tn_post_fit_residual_us::Float64
: RMS of post-fit residuals after TN plugin (µs), if present (NaN otherwise)chisqr::Float64
: Total chi-squarenfree::Int
: Degrees of freedomchisqr_red::Float64
: Reduced chi-square (chisqr / nfree
)pre_post::Float64
:pre-fit RMS / post-fit RMS
number_of_fit_parameters::Int
: Number of fitted parametersnumber_of_points_in_fit::Int
: Number of TOAs in fitoffset_value::Float64
: Best-fit offset valueoffset_error::Float64
: Uncertainty of the offsetoffset_e_sqrt_n::Float64
:offset_error * sqrt(n)
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.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.ClenshawCurtisNodes
— TypeClenshawCurtisNodes(n; eps=1e-6)
Chebyshev–Clenshaw–Curtis nodes on u ∈ (0,1) with optional trimming eps
to avoid exact endpoints {0,1}. These u-nodes are later mapped to parameter values via prior_invcdf(prior, u)
.
GravityToolsNext.CombinedTOAEntry
— TypeCombinedTOAEntry
Merged view of one TOA with corresponding residual entries.
Fields:
index::Int
: sequential index after header removal (from.tim
)timfile_line::Int
: original line number in the.tim
filein_fit::Bool
: whether this TOA is within the requested time windowtoa::Float64
: MJDfreq::Float64
: frequency (MHz)signal::Float64
: residualssignal
column (µs)red_noise::Float64
:residual - residual_tn
(µs)residual::Float64
: residual with red noise (µs)residual_tn::Float64
: residual with TN removed (µs)uncertainty_orig::Float64
: original TOA uncertainty from.tim
(µs)uncertainty::Float64
: transformed uncertainty from residuals file (µs)backend::String
: backend labelweight::Float64
:1 / uncertainty^2
(or0
if uncertainty ≤ 0 or non-finite)
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.ConvergenceInfo
— TypeConvergenceInfo
Summary of convergence diagnostics.
wrms
,wrms_tn
,chisqr
— time series with last-step deltas.pre_post_final
— value taken strictly from the last iteration (NaN if unavailable).worst_parameter
—WorstParam
from the last successful iteration providing a fit-parameter table;nothing
otherwise.thresholds
— dictionary of limits used byis_converged
.converged
— final decision under the given thresholds.
GravityToolsNext.ConvergenceInfo
— MethodConvergenceInfo(wrms, wrms_tn, chisqr, pre_post_final, worst_parameter, thresholds)
Builds a ConvergenceInfo
and computes converged
. For sequences with fewer than two points, convergence falls back to the :pre_post_final
criterion.
GravityToolsNext.ConvergenceSeries
— TypeConvergenceSeries
Holds a metric's values across iterations together with absolute/relative last-step deltas. If fewer than two points are available, final_*_delta = NaN
.
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.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.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.ExplicitRule
— TypeExplicitRule(vals)
Explicit set of coordinates for the axis. The rule carries the values; the axis keeps min/max/N
for convenience.
GravityToolsNext.ExplicitThetaNodes
— TypeExplicitThetaNodes(theta)
Explicit parameter values; used as-is (no inverse-CDF mapping).
GravityToolsNext.FitParameter
— TypeFitParameter
Represents a single model parameter reported in the TEMPO2 fit table.
Fields:
name::String
: parameter name (e.g., "F0", "PB", ...)name_symbol::Symbol
: cached symbol for fast lookuppre_fit::Float64
: pre-fit valuepost_fit::Float64
: post-fit valueuncertainty::Float64
: 1σ uncertaintydifference::Float64
:post_fit - pre_fit
fit_flag::Bool
: whether the parameter was fitted (true
) or held fixed (false
)
GravityToolsNext.FullUnit
— TypeFullUnit(name; min=-Inf, max=Inf)
Always refine over the whole range [min, max]
of variable name
.
GravityToolsNext.GeneralTempoResult
— TypeGeneralTempoResult
Top-level container with everything you usually want after a run.
Fields (stored)
iterations
: all internal iterationsfinal_index
: index of the last iteration (==length(iterations)
)last_successful_index
: 0 if there were no successful iterationssuccess
: quick boolean flag; true iff the run is considered successfulstatus
: low-level run status (:ok | :engine_failed | :parse_failed | :files_missing | :unknown
)convergence
: convergence summary across iterationsmetrics
: compact scalar metrics for quick ranking/comparisonparam_estimates
: map:NAME => (value, uncertainty)
extracted from the final iterationpar_file_final
: written output par-file (if available)subresults
: optional nested results (e.g., per-epoch, per-band, grid cells)subresult_type
: tag describing whatsubresults
mean (e.g.,:epoch
,:band
,:grid
)metadata
: extra info (paths, timings, seeds, etc.)
Virtual properties (accessible via res.final
/ res.last_successful
):
final
: alias forres.iterations[res.final_index]
last_successful
:nothing
iflast_successful_index == 0
, otherwiseres.iterations[res.last_successful_index]
residual_stats
: alias forres.final.stats
white_noise
: alias forres.final.white_noise_fit
(white_noise_fit
is also available)
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.GridAxis
— MethodGridAxis(name::Symbol, vals::AbstractVector)
Construct an explicit axis that uses the provided vals
verbatim.
GravityToolsNext.GridAxis
— MethodGridAxis(name::Symbol; min, max, N, rule::AbstractGridRule=LinRule())
Construct an axis on [min, max]
with N
nodes, using the provided rule
. Supported rules: LinRule()
, LogRule([sign])
, or ExplicitRule(vals)
(via the positional constructor GridAxis(name, vals)
).
GravityToolsNext.GridPrior
— TypeGridPrior
Tabulated prior on a single parameter.
Fields
x
: strictly increasing parameter grid (e.g., θ-values)pdf
: prior density onx
(non-negative; integrates to 1 w.r.t. x)cdf
: cumulative prior onx
(strictly increasing, ~[0,1])
GravityToolsNext.GridPrior
— MethodGridPrior(x::AbstractVector{<:Real}, pdf::AbstractVector{<:Real})
Build a normalized GridPrior
from tabulated x
and (possibly unnormalized) pdf
.
- Sorts by
x
if needed; - Clamps negative
pdf
to 0; - Computes CDF via cumulative trapezoid;
- Normalizes both
pdf
andcdf
to unit mass; - Validates the result.
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.InternalIterationOutput
— TypeInternalIterationOutput
Container for one internal fit iteration (or pre-iteration preamble if the first iteration did not actually run but produced logs/errors).
Fields:
basic::Union{BasicTempoOutput,Nothing}
: basic fit metrics, ornothing
if unavailablefit_parameters::Union{Vector{FitParameter},Nothing}
: parameter table, ornothing
error::TempoOutputError
: error status
GravityToolsNext.InternalIterationResult
— TypeInternalIterationResult
A single TEMPO iteration snapshot:
Fields
output
: parsed TEMPO output blocks (incl. basic/error/parameters)residuals
: raw residual rows as read from disk (ornothing
if not kept)stats
: residual statistics group (in-fit / in-tim), if availablewhite_noise_fit
: per-backend white-noise fit result (optional)metadata
: extra info (paths, counts, flags, time window, etc.)
GravityToolsNext.LinRule
— TypeLinRule <: AbstractGridRule
Linear spacing rule in the physical coordinate: values(ax)
is an evenly spaced LinRange(min, max, N)
.
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.LogRule
— TypeLogRule(sign)
LogRule()
Logarithmic spacing rule: uniformly spaced in log10(|x|)
.
Arguments
sign::Int
:+1
or-1
. Controls the sign of returned physical values. UseLogRule()
(no args) to enable auto sign — inferred from the axismin
at sampling time.
Notes
- Physical values are computed as sign * 10 .^ linspace(ax), where linspace(ax) is uniform in log10(|x|).
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.MaterializedJob
— TypeMaterializedJob
Concrete, self-contained description of a single run workspace. It keeps the original TempoRunSettings
(never mutated) and records the realized filesystem layout (job_root, input/output/tmp) and resolved paths to staged inputs/outputs. Internal to TempoRun; not exported. Do not construct manually.
Fields
settings
: the original settings used to materialize the jobjob_root
: absolute job root directoryinput_dir
: directory where input files live for this joboutput_dir
: directory where final outputs are writtentmp_dir
: working CWD for the engine (may equaljob_root
)run_cwd
: actual CWD for the engine processpar_in_path
: resolved path to the input par file used to create_init.par
tim_in_path
: resolved path to the staged TIM inside the jobpar_out_path
: absolute path where the final.par
is placedcreated_paths
: a list of paths created during materializationnotes
: assorted flags (e.g.,:snapshot_par
,:linked_tim
)
GravityToolsNext.PriorExecutionOptions
— TypePriorExecutionOptions
Execution policy for running prior-marginalization nodes.
Fields
mode
: node chaining policy (:independent
|:chained
)chain_direction
: traversal order when chaining (:forward
|:backward
)chain_snapshot_par
: force snapshot of per-node input par when chaining (true/false)scheduler
: how to schedule nodes (:serial
|:distributed
)max_workers
: cap for distributed workers (ignored for:serial
;0
means "all available")workdir_layout
: directory layout policy (currently only:per_node
)node_dir_prefix
: subdirectory prefix under the base task's work dir (e.g."nodes/node_"
)keep_node_dirs
: keep (true) or delete (false) per-node directories after runon_error
: error handling (:stop
|:skip
|:collect
)
Directory naming:
dir_name_mode
: directory name style (:index_only
|:with_value
)index_pad
: zero-padding width for node indexvalue_sig
: significant digits used when embedding the parameter value into the name
GravityToolsNext.PriorMarginalizationSettings
— TypePriorMarginalizationSettings{P,N}
Settings describing prior-based marginalization over a single parameter.
Fields
parameter
: TEMPO parameter name (e.g.,:GAMMA
,:XPBDOT
)pin_mode
: how to set the parameter per node (:force
|:fixed
|:fit
)prior
: prior specification (analytic / grid / sampled)nodes
: rule to generate θ-nodes (mapped via prior inverse CDF, if applicable)likelihood_source
: metric key used to build likelihood (a key inresult.metrics
)ref_strategy
: reference choice for Δ (e.g.,:prior_median
|:grid_argmin
|:spline_argmin
|:custom_value
)ref_value
: custom reference value (required iffref_strategy == :custom_value
)representative
: which θ to report at top-level (e.g.,:prior_median
)save_node_results
: whether to keepsubresults
(per-nodeGeneralTempoResult
)exec_options
: execution policy (chaining, scheduler, dirs, error handling, naming)metrics_hook
: optional callback to extend the metrics dictionary
Notes
metrics_hook
is expected to have signature like:(final_it::InternalIterationResult, conv::ConvergenceInfo, metrics::Dict{Symbol,Float64}) -> Nothing
and can mutatemetrics
in-place to add custom scalars.
GravityToolsNext.PriorMarginalizedTempoTask
— TypePriorMarginalizedTempoTask{T,P,N} <: SingleTempoTask
A task wrapper that evaluates a base single-tempo task over a grid of prior values θ
and aggregates node results into one posterior-aware result.
Type parameters
T
— a concreteSingleTempoTask
(e.g.BasicTempoTask
)P
— a prior specification implementing theAbstractPriorSpec
APIN
— a node rule implementing theAbstractNodeRule
API
Fields
base_task
— the underlying single task to run at each grid nodesettings
— prior definition, node grid rule, execution options, etc.
GravityToolsNext.QuantileNodes
— TypeQuantileNodes(q)
Explicit quantiles q ⊂ (0,1)
; they will be clamped into (ε, 1-ε) and mapped by prior_invcdf
.
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.RelDiffUnit
— TypeRelDiffUnit(name; min=-Inf, max=Inf, rel_diff, from_min=true)
Refine where the relative change exceeds rel_diff
within [min, max]
.
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.RunArtifacts
— TypeRunArtifacts
Filesystem view of a concrete run. All paths are absolute and can be used by task-level code to read, archive, or prune artifacts. Constructed by run_tempo_parsed
.
Fields
job_root
: job root directoryrun_cwd
: actual engine CWD (tmp/
for split layout by default)input_dir
: directory with staged inputs for the runoutput_dir
: directory where final outputs residetim_path
: the staged TIM used by the runpar_out_path
: final.par
path (may or may not exist on failure)out_path
: stdout capture file path (when enabled), otherwisenothing
residual_paths
: per-iteration residual file paths (nothing
if absent)
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.SampledPrior
— MethodSampledPrior(path::AbstractString;
column::Union{Int,Symbol}=1,
comment::AbstractString="#",
delim=nothing,
transform::Function=identity,
bandwidth::Union{Nothing,Real}=nothing) -> SampledPrior
Convenience constructor: read numeric samples from path
and build a SampledPrior
.
column
: 1-based column index or:auto
(first parseable number per line).comment
: lines starting with this string are skipped.delim
: custom delimiter forsplit
(default: regex for commas/whitespace).transform
: applied to each parsed value (e.g. unit conversion).bandwidth
: optional KDE bandwidth override used at materialization time.
GravityToolsNext.TempoOutputError
— TypeTempoOutputError
Describes an error encountered while parsing one iteration section.
Fields:
error_type::Symbol
::none
if no error; otherwise a specific error tag (e.g.,:missing_rms
,:crash
, ...)message::String
: diagnostic message
GravityToolsNext.TempoParFile
— TypeTempoParFile
A representation of a TEMPO .par
file, containing:
name
: file name (e.g.,"B1937.par"
)dir
: directory pathpath
: full path (joinpath(dir, name)
)params
: dictionary of parameters (Symbol => TempoParameter
)order
: ordered list of parameter symbols to preserve file layout
GravityToolsNext.TempoParameter
— TypeConvenient constructor. Accepts AbstractString
for name (e.g. SubString
), stores as String
. Promotes any Real
value/uncertainty to BigFloat
.
GravityToolsNext.TempoParameter
— TypeTempoParameter
Parameter from a TEMPO/TEMPO2 .par
file.
Fields
name::String
— canonical parameter name (may include spaces, e.g. "JUMP -be SCAMP")name_symbol::Symbol
— cached symbol version ofname
value::Union{Int64, BigFloat, String, Nothing}
flag::Union{Int64, Nothing}
— fit flag (typically -1, 0, 1), optionaluncertainty::Union{BigFloat, Nothing}
— 1σ uncertainty, optional
GravityToolsNext.TempoResidualEntry
— TypeTempoResidualEntry
One line from residuals.dat
(TEMPO/TEMPO2). Values are converted to microseconds where appropriate (signal, residual, residual_tn, uncertainty).
GravityToolsNext.TempoRunOutput
— TypeTempoRunOutput
Low-level result of invoking TEMPO/TEMPO2 for a single settings bundle. This is not the scientific analysis; it only captures parsed iterations, file artifacts and a coarse success/status for the engine run.
Fields
parsed
:Vector{InternalIterationOutput}
parsed from stdoutartifacts
:RunArtifacts
with absolute paths to all on-disk productssuccess
:true
whenengine_ok ∧ parse_ok ∧ files_ok
status
::ok | :engine_failed | :parse_failed | :files_missing
n_iter
: number of parsed iterationsexit_code
: engine exit code (0
ok,1
exception)stderr_tail
: last ~1000 characters of stderr, ornothing
started_at
,finished_at
,duration_s
: coarse timing info
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.TempoRunSettings
— MethodTempoRunSettings(; kwargs...) -> TempoRunSettings
Keyword-style construction with sensible defaults. Raises an error if nits < 1
.
Keyword arguments
- Paths:
work_dir
,par_input
,par_output
,tim_input
- Execution:
tempo_version
,flags
,nits
,gain
- Modifiers:
override_params
,time_start
,time_finish
,couple_f1_to_ddot
- Capture:
write_output
,write_residuals
- Retention:
save_internal_iterations
,save_residuals
- White-noise analysis (convenience):
white_noise_enabled
,white_noise_scope
(:final
|:all
) or passanalysis::WhiteNoiseOptions
- Workspace (convenience):
work_mode
,job_name
,overwrite
(:error|:reuse|:unique|:clean
),layout
,temp_dir
,link_tim
,snapshot_par
,cleanup_before_run
,keep_tmp_on_success
,keep_tmp_on_error
,timeout_s
,write_manifest
,manifest_style
or passworkspace::WorkspaceOptions
- Logging (convenience):
verbosity
,with_timestamps
or passlogging::LoggingOptions
GravityToolsNext.TimTOAEntry
— TypeTimTOAEntry
Single TOA from a .tim
file, after removing comments and headers.
Fields:
index::Int
: sequential index after removing comments/headers (1-based)timfile_line::Int
: original line number in the.tim
file (1-based)toa::Float64
: MJDfreq::Float64
: observing frequency (MHz)uncertainty::Float64
: TOA uncertainty (microseconds)backend::String
: backend label (extracted from-be <name>
if present, otherwise"unknown"
)
GravityToolsNext.WhiteNoiseBackendFitResult
— TypeWhiteNoiseBackendFitResult
Per-backend white-noise fit result.
Fields
backend
: backend id asSymbol
efac
,equad
: white-noise parameters used to scale uncertaintiesoffset
: constant offset applied before normalizationad_objective
: value of the optimized objective (e.g., AD A²)stats
: normalized residual stats with fitted efac/equad/offsetsuccess
: parameters are finite/usable; diagnostics/stats computedconverged
: optimizer reported convergence (useful even ifsuccess=true
)
Notes
- When
success == false
,stats
contains a neutral placeholder (from_empty_norm_stats()
), and the pretty-printer skips printing the stats block for this backend.
GravityToolsNext.WhiteNoiseFitResult
— TypeWhiteNoiseFitResult
White-noise fit for all backends + global summary over concatenated normalized residuals.
Fields
by_backend
: mapbackend => WhiteNoiseBackendFitResult
global_stats
: summary over successful backends onlyfailed_backends
: vector of backend ids that did not produce usable parameters (success=false
)
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.WorstParam
— TypeWorstParam
Named tuple describing the least stable fitted parameter: (name::Symbol, delta::Float64, uncertainty::Float64, ratio::Float64)
where ratio = delta / uncertainty
.
GravityToolsNext._PriorNodeResult
— Type_PriorNodeResult
Internal container holding data for a single grid node.
Fields
index
— 1-based node position on the gridtheta
— θ value at the nodeworkdir
— absolute path to the node's working directorylike_metric
— scalar metric used as a likelihood proxy (e.g.metrics[:chi2_fit]
)prior_density
— prior pdf value π(θ) at this noderesult
— node'sGeneralTempoResult
GravityToolsNext._PriorNodeResult
— MethodConvenience constructor that computes like_metric
and prior_density
.
Base.getindex
— Methodgetindex(output::InternalIterationOutput, key::Union{String,Symbol})
Convenience lookup. If key
matches a field in BasicTempoOutput
, returns it. Otherwise, if it matches a parameter name, returns the corresponding FitParameter
. Throws KeyError
if nothing matches.
Base.show
— MethodPretty-print Tempo
/Tempo2
. Supports inline one-liner via IOContext key :inline => true
.
Base.show
— MethodBase.show(io::IO, ::MIME"text/plain", grid::AdaptiveRefinement2DGrid)
Pretty-print the AdaptiveRefinement2DGrid with variable, parameter, axis, and refinement information.
Base.show
— MethodBase.show(io::IO, par_file::TempoParFile)
Pretty-prints the .par
file name, directory, and all parameters in order.
GravityToolsNext._apply_coupling_f1_to_ddot!
— Method_apply_coupling_f1_to_ddot!(pf, overrides) -> TempoParFile
If DDOT
(or F2
) is present in overrides
and F1
is not overridden, adjust F1
according to the heuristic ΔF1 = - F0 * (DDOTnew - DDOTbase) / D, using values from pf
:
F0
,F1
read from the currentpf
(pre-override state),DDOT_base
frompf[:DDOT]
if present, otherwisepf[:F2]
, else 0,D
frompf[:D]
if present, else 1.
The new F1
is upserted into pf
.
GravityToolsNext._assemble_prior_result
— Method_assemble_prior_result(task, thetas, nodes) -> GeneralTempoResult
Assemble the top-level prior-marginalized result:
- choose a reference (θref, mref) and convert node metrics into log-likelihoods;
- compute discrete posterior weights on the node grid and summarize them;
- integrate a continuous (spline-based) posterior for moments/evidence/χ² summaries;
- select a representative node result for the structural fields;
- marginalize model parameter estimates across nodes using posterior weights;
- merge metrics/extras and metadata; optionally attach node subresults.
GravityToolsNext._bad_prior_result
— Method_bad_prior_result(task, bad_node, nodes_done) -> GeneralTempoResult
Return the GeneralTempoResult
of a failing node augmented with prior/marginalization context in metadata. Used when on_error == :stop
.
GravityToolsNext._build_thetas
— Method_build_thetas(s) -> Vector{Float64}
Construct the θ grid according to s.nodes
using the given prior.
GravityToolsNext._check_nodes_for_error
— Method_check_nodes_for_error(nodes, on_error) -> Union{Nothing, Int}
Return the 1-based index of the first failing node according to the policy, or nothing
if execution should proceed. Currently supports on_error == :stop
.
GravityToolsNext._choose_representative
— Method_choose_representative(s, thetas, metrics) -> θ
Select a representative θ for reporting/subresult extraction (e.g. prior median or grid argmin).
GravityToolsNext._empty_norm_stats
— Method_empty_norm_stats() -> NormalizedResidualStats
Return a neutral/empty NormalizedResidualStats
so downstream code doesn't crash on empty groups. Internal helper.
GravityToolsNext._extract_metric
— Method_extract_metric(res::GeneralTempoResult, key::Symbol) -> Float64
Fetch a scalar metric from res.metrics
, with a friendly error if missing.
GravityToolsNext._group_by_backend
— Method_group_by_backend(entries; in_fit=nothing) -> Dict{Symbol, Vector{CombinedTOAEntry}}
Group entries by backend (Symbol). Optionally filter by in_fit
:
nothing
: no filteringtrue
: only in-fitfalse
: only not in-fit
Internal helper.
GravityToolsNext._header_length
— Method_header_length(clean_lines)
Internal: returns the number of initial non-comment lines to treat as header. Backward-compatible default: first 2 non-comment lines.
GravityToolsNext._integrate_posterior
— Method_integrate_posterior(thetas, metrics, prior; kwargs...) -> NamedTuple
Spline-approximate χ²(θ) from node metrics, combine with the prior to form a continuous posterior p(θ) ∝ exp(logL(θ))·π(θ), and evaluate evidence (log-domain), posterior moments, and χ² summaries.
Returns a named tuple with fields:
logZ
(log-evidence),evidence
(may beInf
ifexp(logZ)
overflows),mean
,var
,std
,median
,mode
,quad_error
,θgrid
,pgrid
(normalized density on the returned grid),chi2_post_mean_spline
,chi2_at_post_mean_spline
,chi2_marginalized
.
Notes
- Numerical stabilization uses
c = max(Lgrid)
and integratesZ0 = ∫ exp(L(θ)−c) dθ
. Then:logZ = log(Z0) + c
. We avoid formingZ = Z0*exp(c)
directly. - Moments are computed as ratios in the stabilized domain:
E[θ] = m1/Z0
,E[θ²] = m2/Z0
,Var[θ] = E[θ²] − E[θ]²
. chi2_marginalized = −2*logZ + mref
is stable even whenexp(logZ)
would overflow.
GravityToolsNext._is_comment_or_blank
— Method_is_comment_or_blank(s)
Internal: returns true
if the line is blank or looks like a comment in a .tim
file.
GravityToolsNext._load_final_par_file
— Method_load_final_par_file(par_out_path::AbstractString) :: Union{TempoParFile,Nothing}
Attempt to read the final output .par
file produced by TEMPO/TEMPO2. Returns a TempoParFile
on success or nothing
when the file is absent or cannot be parsed.
GravityToolsNext._make_node_task
— Method_make_node_task(base_task, s, i, θ) -> (node_task, node_tag, node_dir, par_out)
Construct a per-node task by:
- deriving a leaf
node_dir
name (no leading "nodes/"), - deriving
node_tag
= basename(node_dir), - deriving per-node
par_output
name, - cloning
base_task
with updatedtemp_dir
,par_output
,io_mirror
, and an upserted parameter(s.parameter => θ)
with pin-mode flag.
GravityToolsNext._marginalize_param_estimates
— Method_marginalize_param_estimates(nodes, w) -> Dict{Symbol, ParamEstimate}
Compute posterior-marginalized parameter estimates across nodes using weights w
. For each parameter name seen in any node, compute the pooled mean and the total uncertainty via the law of total variance.
GravityToolsNext._normalized_shifted_residuals_for_backend
— Method_normalized_shifted_residuals_for_backend(residuals, uncertainties_orig, efac, equad, offset)
-> Vector{Float64}
Transform uncertainties (σ' = sqrt((efac·σ)^2 + equad^2)) and compute shifted, normalized residuals (residuals - offset) ./ σ'
for a single backend. Returns a vector aligned with the inputs (no filtering performed here). Inputs are assumed to be in microseconds (µs); the result is unitless.
GravityToolsNext._posterior_summary
— Method_posterior_summary(thetas, w) -> Dict{Symbol,Float64}
Return basic discrete summaries on the node grid: posterior mean, median, mode, and a normalization check.
GravityToolsNext._posterior_weights
— Method_posterior_weights(thetas, loglikes, prior) -> Vector{Float64}
Compute normalized posterior weights on the node grid: wi ∝ exp(logLi) * π(θ_i), normalized with log-sum-exp stabilization.
GravityToolsNext._prepare_node_workdir
— Method_prepare_node_workdir(base_dir, exec, idx, param, theta) -> String
Create (if needed) and return the node working directory under base_dir
. Also writes a small node_meta.txt
with index/parameter/θ for traceability.
GravityToolsNext._resolve_reference
— Method_resolve_reference(s, thetas, metrics) -> (θref, mref)
Choose a reference θ and its metric value used for χ² shifting and reporting. Supported strategies:
:grid_argmin
— θ at argmin of node metrics:spline_argmin
— currently uses node argmin (spline argmin may be added later):prior_median
— θ at prior median (nearest node):custom_value
— user-provideds.ref_value
GravityToolsNext._rule_linvals
— Method_rule_linvals(rule::ExplicitRule, min::Float64, max::Float64, N::Int)
For an explicit axis, the linear parameterization equals the stored values.
GravityToolsNext._rule_linvals
— Method_rule_linvals(rule::LinRule, min::Float64, max::Float64, N::Int)
Return linear parameterization for a linear axis.
GravityToolsNext._rule_linvals
— Method_rule_linvals(rule::LogRule, min::Float64, max::Float64, N::Int)
Return uniformly spaced samples in log10(|x|) for a logarithmic axis. Throws if min/max are zero or have different signs.
GravityToolsNext._rule_values
— Method_rule_values(rule::ExplicitRule, lin::Vector{Float64}; min_hint::Float64=NaN)
For an explicit axis, physical values equal the stored values. min_hint
is accepted for a uniform API and ignored.
GravityToolsNext._rule_values
— Method_rule_values(rule::LinRule, lin::Vector{Float64}; min_hint::Float64=NaN)
For a linear axis, physical values coincide with the linear parameterization. min_hint
is accepted for a uniform API and ignored.
GravityToolsNext._rule_values
— Method_rule_values(rule::LogRule, lin::Vector{Float64}; min_hint::Float64=1.0)
Map logarithmic linear samples back to physical space, using the rule sign if provided or the sign inferred from min_hint
(axis min) for auto-sign.
GravityToolsNext._run_nodes_serial!
— Method_run_nodes_serial!(task, thetas) -> Vector{_PriorNodeResult}
Run node tasks sequentially (optionally in chained mode) and collect node results. Handles per-node task derivation, execution, metric extraction, and chaining source updates. Implements on_error == :stop
policy for early stopping on node failure.
GravityToolsNext._split_iterations
— Method_split_iterations(output::AbstractString) -> Vector{SubString{String}}
Split the full output into iteration sections by anchor lines, BUT keep any preamble BEFORE the first anchor as part of the FIRST section (so early errors are captured). Anchors supported: lines starting with Complete fit
, RMS pre-fit residual
, or ss/fs
.
GravityToolsNext._wn_mask
— Method_wn_mask(niter::Int, scope::Symbol) :: BitVector
Construct a boolean mask that selects which iterations will undergo white-noise analysis:
:all
— all iterations are selected:final
— only the last iteration is selected
Unknown scopes are treated defensively as :final
.
GravityToolsNext.ad_objective_function!
— Methodad_objective_function!(residuals_norm, residuals, uncertainties_tr) -> A²
Fill residuals_norm .= residuals ./ uncertainties_tr
and return Anderson–Darling A². Mutates residuals_norm
as a working buffer.
GravityToolsNext.ad_objective_function
— MethodAD objective from precomputed normalized residuals.
GravityToolsNext.ad_objective_function_fit_offset!
— Methodad_objective_function_fit_offset!(residuals_shifted_norm, residuals, uncertainties_tr)
-> (A²_min, offset*)
1D minimize A² over offset
, given fixed uncertainties_tr
. Uses Optim.optimize
. Mutates residuals_shifted_norm
as a working buffer.
GravityToolsNext.ad_objective_function_with_offset!
— Methodad_objective_function_with_offset!(residuals_shifted_norm, residuals, uncertainties_tr, offset) -> A²
Fill residuals_shifted_norm .= (residuals .- offset) ./ uncertainties_tr
and return A². Mutates residuals_shifted_norm
as a working buffer.
GravityToolsNext.axisvalues
— Methodaxisvalues(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.build_convergence_info
— Methodbuild_convergence_info(iterations; thresholds=default_convergence_thresholds())
-> ConvergenceInfo
Constructs convergence time series from iterations that have residual statistics. pre_post_final
is taken strictly from the last iteration; if unavailable there, it is NaN
. The worst_parameter
is taken from the last successful iteration that provides a fit-parameter table.
When only one valid point is available, the decision converged
falls back to pre_post_final
.
GravityToolsNext.build_convergence_series
— Methodbuild_convergence_series(values) -> ConvergenceSeries
Constructs absolute and relative last-step deltas for a numeric sequence. Relative delta uses a stable denominator max(abs(prev), eps())
.
GravityToolsNext.build_core_metrics
— Methodbuild_core_metrics(final_it::InternalIterationResult, conv::ConvergenceInfo;
include_tim::Bool=true,
include_tim_even_if_same::Bool=false)
-> Dict{Symbol,Float64}
Produce a compact, task-agnostic set of scalar metrics from the final iteration and convergence info. Missing pieces are filled with NaN
.
Included keys (always):
- :chi2fit, :chi2rfit, :wrmsfit, :wrmstn_fit
- :prepostfinal
- :deltawrmstn, :delta_chi2
- :adwhitefit (global AD after white-noise fit; NaN if not available)
Additionally (only if include_tim == true
and either the in-fit and in-tim sets differ or include_tim_even_if_same == true
):
- :chi2tim, :chi2rtim, :wrmstim, :wrmstn_tim
GravityToolsNext.build_general_tempo_result
— Methodbuild_general_tempo_result(
iterations;
par_file_final=nothing,
subresults=GeneralTempoResult[],
subresult_type=nothing,
metadata=Dict(),
metrics_hook=nothing
)
Build a GeneralTempoResult
from a list of InternalIterationResult
s.
- Uses the last iteration as
final
(indexfinal_index = length(iterations)
). - Computes
last_successful_index
(last iteration with no error and with stats); 0 if none. - Computes convergence across all iterations with available stats.
- Extracts parameter estimates from the final iteration.
- Computes
metrics
viabuild_core_metrics(final, convergence)
and optionally merges a user-suppliedmetrics_hook(final, convergence)
dictionary (values must beReal
).
GravityToolsNext.build_internal_iteration_result
— Methodbuild_internal_iteration_result(output, residual_path, tim_entries; kwargs...) -> InternalIterationResult
Build a single-iteration result from parsed TEMPO output and (optionally) residuals on disk.
Behavior
- Does not return early on TEMPO errors; instead records the error and proceeds to attempt residual loading/combination guardedly.
- Reads residuals via a safe wrapper; if the file is missing or unreadable, residuals are
nothing
. - Combines TIM entries with residuals using a safe combiner; on length mismatch or missing inputs, combination yields
nothing
. - Optionally performs white-noise fitting (
analyze_white_noise=true
) on combined in-fit data when available. - Records per-stage flags in
metadata
for downstream diagnostics.
Keywords
save_residuals::Bool=false
— keep raw residual rows inside the resultanalyze_white_noise::Bool=false
— run per-backend white-noise fittime_start::Union{Nothing,Float64}=nothing
— lower MJD bound for combiningtime_finish::Union{Nothing,Float64}=nothing
— upper MJD bound for combining
GravityToolsNext.build_node_dirname
— Methodbuild_node_dirname(prefix, idx; pad=3, param=:θ, theta=nothing, mode=:index_only, sig=6) -> String
Build a per-node directory name according to the selected naming mode.
:index_only
→ uses only an index with zero-padding.:with_value
→ additionally appends__<PARAM>=<VALUE>
where<VALUE>
is compact-formatted.
GravityToolsNext.build_residual_statistics_group
— Methodbuild_residual_statistics_group(entries) -> ResidualStatisticsGroup
Build statistics for in-fit and in-tim sets. If there is no time window (i.e. all entries are in-fit), the same ResidualStatisticsEntry
object is reused (aliased) for both fields to avoid duplicate computation/memory. You can detect this via group.in_fit === group.in_tim
.
GravityToolsNext.build_white_noise_fit
— Methodbuild_white_noise_fit(entries::Vector{CombinedTOAEntry}) -> WhiteNoiseFitResult
Per-backend estimation of (efac, equad, offset) on in-fit TOAs. Robust to empty groups and solver failures. Produces per-backend normalized residual stats and a global summary. Inputs are expected in microseconds (µs) for residuals and TOA uncertainties; normalized residuals are unitless.
Behavior
- If a backend fails (throws) or yields non-finite parameters, it is marked
success=false
and added tofailed_backends
. Its stats are set to a neutral placeholder and its contribution is excluded fromglobal_stats
. global_stats
are computed by concatenating normalized residuals from successful backends only.
GravityToolsNext.calculate_2DGrid
— Methodcalculate_2DGrid(grid, target_function, params_function!)
Calculate and adaptively refine the grid up to the desired refinement level.
GravityToolsNext.calculate_cell!
— Methodcalculate_cell!(i_cell, j_cell, grid, grid_refined, target_function)
Calculate values for all new points introduced by refining a cell.
GravityToolsNext.calculate_point!
— Methodcalculate_point!(p, i_ref, j_ref, grid, grid_refined, target_function, lock_obj)
Remotely calculate the value at a point in the refined grid and update both grids with locking.
GravityToolsNext.cell_selector
— Methodcell_selector(i_cell, j_cell, grid, ref_unit::ContourUnit)
Selects cells where the cell crosses a specified contour value.
GravityToolsNext.cell_selector
— Methodcell_selector(i_cell, j_cell, grid, ref_unit::DiffContourUnit)
Selects cells where the cell crosses a contour and the difference exceeds a threshold.
GravityToolsNext.cell_selector
— Methodcell_selector(i_cell, j_cell, grid, ref_unit::DiffUnit)
Selects cells where the difference across the cell exceeds a threshold.
GravityToolsNext.cell_selector
— Methodcell_selector(i_cell, j_cell, grid, ref_unit::FullUnit)
Selects cells where the min/max value is within specified bounds.
GravityToolsNext.cell_selector
— Methodcell_selector(i_cell, j_cell, grid, ref_unit::LocalMinimaUnit; at_corner=false)
Selects cells containing a unique local minimum within a specified range.
GravityToolsNext.cell_selector
— Methodcell_selector(i_cell, j_cell, grid, ref_unit::RelDiffUnit)
Selects cells where the relative difference across the cell exceeds a threshold.
GravityToolsNext.cell_selector
— Methodcell_selector(i_cell, j_cell, grid)
Determine if the cell at (icell, jcell) should be refined according to the refinement settings.
GravityToolsNext.chisq_stats
— Methodchisq_stats(res, unc; dof=length(res)) -> (χ², χ²_red)
For raw residuals with transformed uncertainties unc
.
GravityToolsNext.chisq_stats
— Methodchisq_stats(res_norm; dof=length(res_norm)) -> (χ², χ²_red)
For already normalized residuals (σ'=1 scale), χ² = ∑ r².
GravityToolsNext.cleanup_old_tempo_files
— Methodcleanup_old_tempo_files(job::MaterializedJob) -> Nothing
Remove common TEMPO/TEMPO2 byproducts in job.job_root
(and the resolved par_out_path
). This is a pre-run hygiene step and never touches user inputs or previous persisted results outside the known byproduct set.
GravityToolsNext.cleanup_run!
— Methodcleanup_run!(output::TempoRunOutput, settings::TempoRunSettings; success::Bool=output.success) -> Nothing
Ergonomic overload that accepts a TempoRunOutput
. Delegates to the RunArtifacts
-based method. Override success
if your task-level success criterion differs from the engine-level one.
GravityToolsNext.cleanup_run!
— Methodcleanup_run!(artifacts::RunArtifacts, settings::TempoRunSettings; success::Bool=true) -> Nothing
Remove the working directory (run_cwd
) when it is a dedicated subdirectory (e.g., tmp/
). This is a post-run hygiene step controlled by keep_tmp_on_success
/ keep_tmp_on_error
. It never touches input_dir
or output_dir
and is safe to call multiple times.
GravityToolsNext.combine_tim_and_residuals
— Methodcombine_tim_and_residuals(tim_entries, residuals; time_start=nothing, time_finish=nothing)
-> Vector{CombinedTOAEntry}
Combine .tim
entries and residuals 1:1 (by index). Optional time window (MJD
) marks in_fit
for each entry. Lengths must match; this function throws a DimensionMismatch
exception on mismatch. Use combine_tim_and_residuals_safe
for a non-throwing variant.
Notes:
weight = 1 / uncertainty^2
ifuncertainty
is positive and finite; otherwise0.0
.- Time window is inclusive:
time_start ≤ toa ≤ time_finish
when both are provided.
GravityToolsNext.combine_tim_and_residuals_safe
— Methodcombine_tim_and_residuals_safe(
tim_entries::Union{Nothing,Vector{TimTOAEntry}},
residuals::Union{Nothing,Vector{TempoResidualEntry}};
time_start::Union{Nothing,Float64}=nothing,
time_finish::Union{Nothing,Float64}=nothing,
) -> Union{Nothing, Vector{CombinedTOAEntry}}
Safe (non-throwing) wrapper around combine_tim_and_residuals
. Returns nothing
in any of the following cases (and logs a warning):
tim_entries === nothing
orresiduals === nothing
- either input is empty
- length mismatch between the two inputs
Otherwise, returns the combined vector.
GravityToolsNext.copy_par_file
— Methodcopy_par_file(par_file; new_name=nothing, suffix=nothing, new_dir=par_file.dir, deep_copy=false)
Return a (possibly shallow) copy of par_file
with optional file/dir changes.
Precedence for filename:
- if
new_name
is provided -> use it, - else if
suffix
is provided -> append_suffix
before ".par", - else -> keep original name.
Ensures the result ends with .par
.
GravityToolsNext.copy_with
— Methodcopy_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.cpad_display
— Methodcpad_display(s, w) -> String
Center-pad string s
to width w
(using display width). Left pad gets the floor, right pad the remainder. Returns a new String
.
GravityToolsNext.default_convergence_thresholds
— Methoddefault_convergence_thresholds() -> Dict{Symbol,Float64}
Default limits used by is_converged
:
:abs_wrms_tn
— absolute delta of TN-weighted WRMS:abs_chisqr
— absolute delta of χ²:pre_post_final
— |prepostfinal − 1|
GravityToolsNext.default_par_output
— Methoddefault_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.delete_param!
— Methoddelete_param!(pf, name) -> Bool
Delete by name from params
and remove from order
. Returns true
if deleted.
GravityToolsNext.delete_param!
— Methoddelete_param!(params, name) -> Bool
Delete parameter by name if present. Returns true
if deleted.
GravityToolsNext.delete_params!
— Methoddelete_params!(pf, names) -> Int
Delete all parameters listed in names
. Returns the number of deletions.
GravityToolsNext.delete_params!
— Methoddelete_params!(params, names) -> Int
Delete all parameters whose names are in names
. Returns count deleted. Preserves relative order of remaining items.
GravityToolsNext.estimate_white_noise_ad_with_offset
— Methodestimate_white_noise_ad_with_offset(residuals, uncertainties_orig; kwargs...)
-> (efac, equad, offset, ad_objective, converged)
Jointly estimate (efac, equad, offset) by minimizing AD A² of normalized residuals.
- If no initial guesses are provided, builds a small grid over
equad
and targetstd(res_norm)
, solvesefac
for each pair, fitsoffset
, and seedsOptim.optimize
. - Mutates working buffers internally for performance (documented below).
converged
is the boolean flag returned byOptim.converged(...)
for the outer 3D solve.
Notes
- Inputs are expected in µs for residuals and TOA uncertainties; the objective uses unitless normalized residuals.
- On severely degenerate inputs (e.g., zero variance or infeasible seeds), the optimizer may throw; callers are expected to guard with
try/catch
(as done inbuild_white_noise_fit
) and mark the backend as failed.
GravityToolsNext.eval_nodes
— Methodeval_nodes(prior, rule::ClenshawCurtisNodes) -> θ::Vector{Float64}
Chebyshev–Clenshaw–Curtis nodes on u∈(0,1), trimmed at max(rule.eps, PRIOR_U_EPS)
, then mapped to parameter space via prior_invcdf
.
GravityToolsNext.eval_nodes
— Methodeval_nodes(prior, rule::ExplicitThetaNodes) -> θ::Vector{Float64}
Return a sorted, deduplicated copy of the provided θ-values (no inv-CDF mapping).
GravityToolsNext.eval_nodes
— Methodeval_nodes(prior, rule::QuantileNodes) -> θ::Vector{Float64}
Clamp provided quantiles to (PRIORUEPS, 1-PRIORUEPS) and map via prior_invcdf
.
GravityToolsNext.extract_tempo_parameter_from_line
— Methodextract_tempo_parameter_from_line(line) -> TempoParameter
Parse one .par
line using a simple grammar:
name
is either 1 token, or 3 tokens if the first three tokens are non-numeric strings (e.g. "JUMP -be SCAMP", "TNEF -be SCAMP").- Then go:
value
(String/Int64/BigFloat), optionalflag
(Int64), optionaluncertainty
(BigFloat). - If there is one trailing token after value:
- Int64 → it's a flag
- BigFloat → it's an uncertainty
- If there are two trailing tokens after value and they look like
Int64
thenBigFloat
, treat them asflag
anduncertainty
respectively.
GravityToolsNext.find_efac_for_fixed_equad_and_std!
— Methodfind_efac_for_fixed_equad_and_std!(residuals_norm, uncertainties_tr, residuals, uncertainties_orig,
equad_fixed, std_res_norm_target) -> efac
Solve for efac
such that std(residuals ./ σ′(efac, equadfixed)) ≈ stdresnormtarget.
Notes:
- Monotone in
efac
(for fixedequad
), so we first try to bracket a root and useBisection()
. - Mutates
residuals_norm
anduncertainties_tr
as work buffers; no allocations. - Returns
NaN
if the target is infeasible or a robust root was not found.
GravityToolsNext.find_worst_parameter
— Methodfind_worst_parameter(fit_params) -> WorstParam | nothing
Finds the parameter with the largest absolute ratio |Δ/σ|
among parameters with fit_flag = true
and finite uncertainties (σ > 0
). Returns a named tuple WorstParam
or nothing
if no suitable parameters are present.
GravityToolsNext.format_short
— Methodformat_short(x; sig=6) -> String
Compact scientific formatting for real numbers. Preserves NaN
/Inf
in a readable form.
GravityToolsNext.generate_par_file_name
— Methodgenerate_par_file_name(base_name::String, suffix::String) -> String
Generates a new .par
filename by removing the existing extension (if any), appending _suffix
, and adding .par
.
GravityToolsNext.get_convergence_metric
— Methodget_convergence_metric(info, key) -> Float64
Maps a threshold key to the corresponding last-step delta (or |prepostfinal−1|). Returns NaN
if the metric is not available.
GravityToolsNext.get_in
— Methodget_in(obj, path::AbstractVector{Symbol})
Follow path
through nested getproperty
calls: e.g. get_in(x, [:stats, :std])
is equivalent to x.stats.std
.
GravityToolsNext.get_par_file_representation
— Methodget_par_file_representation(param) -> String
Return a fixed-width .par
line: name, value, optional flag, optional uncertainty. Format numerics with up to 21 significant digits; increase if needed.
GravityToolsNext.get_param
— Methodget_param(params, name; default=nothing) -> Union{TempoParameter,Nothing}
Return a parameter by name or default
if missing.
GravityToolsNext.get_param
— Methodget_param(pf, name; default=nothing) -> Union{TempoParameter,Nothing}
GravityToolsNext.has_param
— Methodhas_param(params, name) -> Bool
GravityToolsNext.has_param
— Methodhas_param(pf, name) -> Bool
GravityToolsNext.in_fit_equals_in_tim
— Methodin_fit_equals_in_tim(group::ResidualStatisticsGroup) -> Bool
Returns true
if the group used a single aliased entry for both fields (no time window), i.e. group.in_fit === group.in_tim
.
GravityToolsNext.interpolate_cell!
— Methodinterpolate_cell!(i, j, grid, grid_refined)
Interpolate values for new points in the refined grid that were not directly calculated.
GravityToolsNext.is_converged
— Methodis_converged(info) -> Bool
Checks all keys present in info.thresholds
. If a required metric is NaN
, convergence fails.
GravityToolsNext.is_converged_by
— Methodis_converged_by(info, keys...) -> Bool
Checks convergence only for the specified keys. Metrics that are not finite are ignored for the decision.
GravityToolsNext.is_debug
— Methodis_debug(l::LoggingOptions) -> Bool
GravityToolsNext.is_info
— Methodis_info(l::LoggingOptions) -> Bool
Treats :debug
as informational as well (superset).
GravityToolsNext.is_silent
— Methodis_silent(l::LoggingOptions) -> Bool
GravityToolsNext.is_warn
— Methodis_warn(l::LoggingOptions) -> Bool
GravityToolsNext.linspace
— Methodlinspace(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.lpad_display
— Methodlpad_display(s, w) -> String
Pad string s
on the left (using display width via Unicode.textwidth
) to width w
. Returns a new String
. If s
already fits, returns String(s)
unchanged.
GravityToolsNext.make_accessor
— Methodmake_accessor(spec) -> (label::String, getter::Function, key)
Create an accessor triple from a column spec. Supported forms:
:field
— direct field access, label"field"
, key:field
"a.b"
— nested path by dots, label"a.b"
, key"a.b"
(:a, :b)
/Vector{Symbol}
— nested path, label"a.b"
, key"a.b"
label => path_or_function
— custom header; right side can be a function(row)->val
or a path-like spec as above.key
is thelabel
.Function
— use function both as getter and askey
, label"(f)"
.
Throws ArgumentError
for unsupported types.
GravityToolsNext.materialize
— Methodmaterialize(pr::SampledPrior; n_max=4096) -> GridPrior
Build (and cache) a GridPrior
via KDE of the samples. Subsequent calls reuse the cache. n_max
is an upper bound on the KDE output grid size (the actual size is controlled by KernelDensity.jl).
GravityToolsNext.materialize_job
— Methodmaterialize_job(s::TempoRunSettings) -> MaterializedJob
Create a reproducible run workspace according to s.workspace
and stage inputs. The returned MaterializedJob
stores the original settings and the realized filesystem layout and paths.
Semantics
work_mode
::inplace
— usepaths.work_dir
asjob_root
.:jobdir
— create or reuse a subdirectory insidepaths.work_dir
.
overwrite
(when the target jobdir already exists)::error
— throw;:reuse
— use as-is (no cleanup here; seecleanup_before_run
);:unique
— create a suffixed sibling (…-001, …-002);:clean
— purge contents and use the same directory.
layout
::flat
—input_dir = output_dir = job_root
;:split
— createinput/
,output/
, andtmp/
(ortemp_dir
).
cleanup_before_run
:- if
tmp_dir != job_root
— empty onlytmp_dir
; - otherwise — remove typical TEMPO byproducts from
job_root
.
- if
Staging
- TIM: symlink when
link_tim=true
(fallback to copy); no-op if already in place. - PAR: copy snapshot when
snapshot_par=true
or the source is outsidejob_root
.
Note: engine will be invoked from the chosen CWD with relative file names.
GravityToolsNext.par_input_path
— Methodpar_input_path(s::TempoRunSettings) -> String
Absolute path to the input .par
file, resolving a relative name against s.paths.work_dir
.
GravityToolsNext.parallel_precalculate_2DGrid!
— Methodparallel_precalculate_2DGrid!(grid, target_function, params_function!)
Fill the grid with values using parallel processing.
GravityToolsNext.parallel_refine_2DGrid
— Methodparallel_refine_2DGrid(grid, target_function, params_function!)
Refine the grid by one level using parallel processing.
GravityToolsNext.param_index
— Methodparam_index(params, name) -> Union{Int,Nothing}
Find index of parameter by name (compared with p.name_symbol
). Returns nothing
if missing.
GravityToolsNext.params_as_vector
— Methodparams_as_vector(pf) -> Vector{TempoParameter}
Return parameters in the stored order; skips names that may have been removed from params
.
GravityToolsNext.parse_basic_tempo_output
— Methodparse_basic_tempo_output(section::String, ::Type{Tempo2})
-> (BasicTempoOutput | nothing, TempoOutputError)
Parse RMS, chi-square, number of points/params, and offset block.
GravityToolsNext.parse_fit_parameters
— Methodparse_fit_parameters(section::String, ::Type{Tempo2})
-> (Vector{FitParameter} | nothing, TempoOutputError)
Extract the parameter table between dashed lines. If dashed separators are missing, attempt a fallback search using a header-like line.
GravityToolsNext.parse_internal_iteration_tempo_output
— Methodparse_internal_iteration_tempo_output(section::String, ::Type{Tempo2}) -> InternalIterationOutput
Parse a single iteration section:
- detect known fatal errors;
- parse basic fit statistics;
- parse fit-parameter table.
If any step fails, returns an output with error
set, others nothing
.
GravityToolsNext.parse_tempo_output
— Methodparse_tempo_output(output::String, ::Type{Tempo2}) -> Vector{InternalIterationOutput}
Split full TEMPO2 output into iteration sections, keeping any preamble BEFORE the first anchor as part of the FIRST section, and parse each section.
GravityToolsNext.parse_tempo_output_error
— Methodparse_tempo_output_error(section::String, ::Type{Tempo2}) -> TempoOutputError
Scan a section for known error patterns (lost connection, segfaults, panic, etc.).
GravityToolsNext.parse_tempo_parameter_field
— Methodparse_tempo_parameter_field(str) -> Int64 | BigFloat | String
Try Int64
, then BigFloat
, otherwise return String
.
GravityToolsNext.pathlike_to_syms
— Methodpathlike_to_syms(x) -> Vector{Symbol}
Normalize a column/field path specification to a vector of symbols. Supported inputs:
Symbol
AbstractString
with dots (e.g."stats.std"
)Tuple
/Vector{Symbol}
Throws ArgumentError
otherwise.
GravityToolsNext.precalculate_2DGrid!
— Methodprecalculate_2DGrid!(grid, target_function, params_function!)
Populate the grid with initial values before refinement, using parallel or single-core as needed.
GravityToolsNext.print_aligned_table
— Methodprint_aligned_table(data; kwargs...)
Convenience overload that prints to stdout
.
GravityToolsNext.print_aligned_table
— Methodprint_aligned_table(io, d::AbstractDict; kwargs...)
Dictionary-friendly overload. Treats values as rows, and uses keys as the left-most "name" column. Keys are converted to strings. Supports the same options as the vector overload, plus:
name_label
: header text for the name column (default:"key"
).sort_by = :__key__
sorts by dictionary keys (name column). Usenothing
to keep insertion order, or any other validsort_by
(applied to values).
All other options (cols
, formats
, renderers
, aligns
, header_align
, order
) are forwarded.
GravityToolsNext.print_aligned_table
— Methodprint_aligned_table(io, rows;
namecol, cols;
indent=0, header=true,
formats=Dict(), renderers=Dict(), aligns=Dict(),
header_align=:auto,
sort_by=nothing, order=:asc,
names_override=nothing, name_label_override=nothing)
Flexible, allocation-friendly table printer for a vector of rows (typically structs).
Parameters
namecol
— how to obtain the left-most "name" column from each row. One of:Symbol
, dottedString
(e.g."stats.std"
), tuple(:stats,:std)
, or a function(row)->name
.cols
— collection of column specs (right-hand side of the table). Each element can be:Symbol
— field name- dotted
String
— nested path (e.g."stats.std"
) - tuple /
Vector{Symbol}
— nested path label => getter
— custom label with either a function or a path-like specFunction
— getter; label becomes"(f)"
formats::Dict
— optional number formats (Printf) per-column, keyed by the columnkey
(as returned bymake_accessor
). Defaults to"%10.6f"
.renderers::Dict
— optional custom cell renderers per-column:v -> AbstractString
. Takes precedence overformats
.aligns::Dict
— optional alignment per-column::left | :right | :center
. Defaults to:right
for numeric columns,:center
for Bool, otherwise:left
.header_align
— alignment for header labels::auto
(default): center for right/center columns, left for text columns:left
,:center
, or:match
(same as data alignment)
- Sorting:
sort_by
can benothing
(no sorting),:__name__
(sort by resolved names), any path-like spec, or a function.order
is:asc
or:desc
. - Name overrides:
names_override::Vector{String}
can be used to directly supply the row names (useful when the name is not obtainable from the row itself).name_label_override
sets the header text for the name column.
Examples
print_aligned_table(stdout, rows;
namecol = :backend,
cols = (
:efac, :equad, "stats.std", "chisqr" => (:stats, :chisqr),
:success, :converged,
),
formats = Dict(
:efac => "%10.6f", :equad => "%10.4f", "stats.std" => "%10.6f",
"chisqr" => "%10.4f"
),
renderers = Dict(
:success => x -> (x ? "✓" : "✗"),
:converged => x -> (x ? "✓" : "✗"),
),
aligns = Dict(:success=>:center, :converged=>:center),
header_align = :auto,
sort_by = :ad_objective, order = :asc,
)
GravityToolsNext.print_white_noise_fit_report!
— Methodprint_white_noise_fit_report!(
io::IO,
backend::AbstractString,
residuals::Vector{Float64},
uncertainties_orig::Vector{Float64},
uncertainties_tr::Vector{Float64},
residuals_norm::Vector{Float64},
residuals_shifted_norm::Vector{Float64},
efac::Float64, equad::Float64, offset::Float64, ad_objective::Float64;
n_toas::Int = length(residuals),
sections::AbstractSet{Symbol} = Set([
:header, :residuals, :uncertainties_orig, :uncertainties_tr, :normalized, :shifted_normalized, :chi2, :footer
]),
)
Mutating workspace variant:
- Overwrites
uncertainties_tr
,residuals_norm
,residuals_shifted_norm
. - Computes only what is required by
sections
.
GravityToolsNext.print_white_noise_fit_report
— Methodprint_white_noise_fit_report(
io::IO,
backend, residuals, uncertainties_orig,
efac, equad, offset, ad_objective;
sections=Set([...])
)
Non-mutating convenience: allocates local work buffers and calls print_white_noise_fit_report!
.
GravityToolsNext.prior_cdf
— Methodprior_cdf(pr, x::Real) -> Float64
Prior cumulative distribution function at x. Optional but recommended for diagnostics/plots.
GravityToolsNext.prior_cdf
— Methodprior_cdf(pr::GridPrior, x::Real) -> Float64
Evaluate the tabulated CDF with linear interpolation. Returns cdf[1]
if x < x[1]
and cdf[end]
if x > x[end]
.
GravityToolsNext.prior_invcdf
— Methodprior_invcdf(pr, u::Real) -> Float64
Inverse-CDF mapping u ∈ (0,1) to θ. Concrete prior types must implement this scalar method. The caller may clamp u into (0,1) if appropriate.
GravityToolsNext.prior_invcdf
— Methodprior_invcdf(pr::GridPrior, u::Real) -> Float64
Invert the tabulated CDF with linear interpolation. u
is clamped into [cdf[1], cdf[end]]
before inversion.
GravityToolsNext.prior_logpdf
— Methodprior_logpdf(pr, x::Real) -> Float64
Log prior density at x. Optional but recommended for diagnostics/plots.
GravityToolsNext.prior_pdf
— Methodprior_pdf(pr, x::Real) -> Float64
Prior density at x. Optional but recommended for diagnostics/plots.
GravityToolsNext.prior_support
— Methodprior_support(pr) -> (xmin::Float64, xmax::Float64)
Optional domain hint used for plotting/clamping; override when available.
GravityToolsNext.prior_tail_mass
— Methodprior_tail_mass(pr, lo, hi) -> Float64
Return prior mass outside [lo, hi]: CDF(lo) + (1 - CDF(hi)).
GravityToolsNext.read_par_file!
— Methodread_par_file!(par_file::TempoParFile) -> TempoParFile
Reads and parses the .par
file on disk.
- Ignores blank lines and comment lines beginning with
C
,c
, or#
(after trimming). - Clears and fills
params
andorder
in-place. - If a parameter appears multiple times, the first occurrence defines the position in
order
, subsequent occurrences update the value in-place.
GravityToolsNext.read_par_file
— Methodread_par_file(path::AbstractString) -> TempoParFile
Reads a .par file from the given path and returns a TempoParFile.
GravityToolsNext.read_prior_samples
— Methodread_prior_samples(path; column=1, comment="#", delim=nothing, transform=identity) -> Vector{Float64}
Read numeric samples from a text file to build an empirical prior.
- Skips empty lines and lines starting with
comment
. - Splits each line by
delim
(default: regex for commas/whitespace). column
can be anInt
(1-based) or:auto
to pick the first parseable number on each line.transform
is applied to each parsed value (e.g., to convert units or apply a sign flip).
Returns a vector of finite Float64 values. Errors if fewer than 2 values are found.
GravityToolsNext.read_residual_file
— Methodread_residual_file(path::AbstractString) -> Vector{TempoResidualEntry}
Reads residuals.dat
(or similar) with 5 columns: time signal residual residual_tn uncertainty
. Signal, residuals, and uncertainty are converted to microseconds (×1e6).
GravityToolsNext.read_tim_file
— Methodread_tim_file(path::AbstractString) -> Vector{TimTOAEntry}
Reads a .tim
file, skipping comment/blank lines, preserving original line numbers, and assuming the first two non-comment lines are header/meta.
Notes:
- Expects data lines with (at least) 4 tokens where the 2nd/3rd/4th tokens are
freq
,MJD
,uncertainty
respectively (compatible with your current format). - Backend is taken from the
-be <name>
flag if present; otherwise"unknown"
. - Unparseable lines are skipped with a warning.
GravityToolsNext.read_tim_file_safe
— Methodread_tim_file_safe(path::AbstractString) -> Union{Nothing, Vector{TimTOAEntry}}
Safe wrapper around read_tim_file
. Returns nothing
if the file does not exist or if any I/O/parsing exception is thrown while reading the file. Per-line parsing issues are still logged by read_tim_file
as warnings.
GravityToolsNext.refine
— Methodrefine(grid::AdaptiveRefinement2DGrid)
Return a refined version of the grid with doubled resolution.
GravityToolsNext.refine
— Methodrefine(ax::GridAxis, levels::Integer) -> GridAxis
Apply refine
repeatedly levels
times.
GravityToolsNext.refine
— Methodrefine(ax::GridAxis) -> GridAxis
Refine a 1D axis by inserting midpoints to reach 2N-1
nodes.
LinAxis
: midpoints in physical space on [min, max].LogAxis
: midpoints uniform in log10(|x|) (geometric means in physical space).ExplicitAxis
: midpoints in physical space between consecutive user nodes.
Returns a new axis; the original is unchanged.
GravityToolsNext.refine
— Methodrefine(dict::Dict{Symbol,Matrix})
Refine each matrix in a dictionary of matrices.
GravityToolsNext.refine
— Methodrefine(arr::Matrix)
Refine a matrix by doubling its resolution, inserting -1 in new positions.
GravityToolsNext.refine_2DGrid
— Methodrefine_2DGrid(grid, target_function, params_function!)
Refine the grid by one level, using parallel or single-core as requested.
GravityToolsNext.refined_index
— Methodrefined_index(i_cell)
Return the index of the refined grid corresponding to the coarse cell index.
GravityToolsNext.rpad_display
— Methodrpad_display(s, w) -> String
Pad string s
on the right (using display width via Unicode.textwidth
) to width w
. Returns a new String
. If s
already fits, returns String(s)
unchanged.
GravityToolsNext.run_task
— Methodrun_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
.
GravityToolsNext.run_task
— Methodrun_task(task::MultiPointTask)
Entry point for multi-point workflows. Define as needed for your project.
GravityToolsNext.run_task
— Methodrun_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.run_task
— Methodrun_task(task::SingleTempoTask) -> GeneralTempoResult
Execute the task and return a unified result. Every concrete SingleTempoTask
must provide a method.
GravityToolsNext.run_tempo_parsed
— Methodrun_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.run_tempo_raw
— Methodrun_tempo_raw(job::MaterializedJob) -> (stdout::String, stderr::String, exit_code::Int)
Invoke TEMPO/TEMPO2 from the job's working directory (CWD) using relative paths (-f <init.par> <tim> -outpar <name.par>
). Returns captured stdout/stderr and a coarse exit code: returns 0 on normal completion, 1 on Julia-side exception.
GravityToolsNext.run_tempo_raw
— Methodrun_tempo_raw(settings::TempoRunSettings)
ERROR: This method is disabled. Materialize first: job = materialize_job(settings)
and then call run_tempo_raw(job)
. Or use run_tempo_parsed(settings)
.
GravityToolsNext.sanitize_name
— Methodsanitize_name(s) -> String
Make a string safe for filesystem by keeping only alphanumerics plus ._=-+
, replacing the rest with _
.
GravityToolsNext.set_flag!
— Methodset_flag!(pf, name, flag) -> TempoParFile
Set the fit-flag for an existing parameter. Throws if missing.
GravityToolsNext.single_core_precalculate_2DGrid!
— Methodsingle_core_precalculate_2DGrid!(grid, target_function, params_function!)
Fill the grid with values using a single core.
GravityToolsNext.single_core_refine_2DGrid
— Methodsingle_core_refine_2DGrid(grid, target_function, params_function!)
Refine the grid by one level using a single core.
GravityToolsNext.task_stage_inputs!
— Methodtask_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
.
GravityToolsNext.task_with_overrides
— Methodtask_with_overrides(task::BasicTempoTask, overrides; work_dir) :: BasicTempoTask
Clone the task with a new work_dir
and a list of TempoParameter
overrides that will be upserted into the underlying TempoRunSettings
.
GravityToolsNext.task_with_overrides
— Methodtask_with_overrides(task::T, overrides::AbstractVector{TempoParameter};
work_dir::AbstractString) -> T where {T<:SingleTempoTask}
Return a copy of task
(same concrete type) with additional/overriding parameters overrides
and a reassigned working directory work_dir
.
Implementations must merge overrides
with any existing parameter overrides present in the task's settings, giving precedence to the new ones.
GravityToolsNext.task_with_param
— Methodtask_with_param(task::T, name::Symbol, value::Float64, flag::Int;
work_dir::AbstractString) -> T where {T<:SingleTempoTask}
Convenience wrapper over task_with_overrides
for a single parameter. By default constructs TP(String(name), value; flag=flag)
and delegates. Usually there is no need to override this method.
GravityToolsNext.task_workdir
— Methodtask_workdir(task::BasicTempoTask) :: AbstractString
Return the working directory where this BasicTempoTask
will execute.
GravityToolsNext.task_workdir
— Methodtask_workdir(task::SingleTempoTask) -> AbstractString
Return the working directory where the task runs / writes results. Used by higher-level wrappers to organize per-node subdirectories.
GravityToolsNext.tempo_flag
— Methodtempo_flag(pin_mode::Symbol) -> Int
Map a high-level pin mode to the TEMPO flag:
:force
→-1
(force this value; do not recompute even if derived):fixed
→0
(set, but do not fit):fit
→1
(fit this parameter)
GravityToolsNext.tim_input_path
— Methodtim_input_path(s::TempoRunSettings) -> String
Absolute path to the input .tim
file, resolving a relative name against s.paths.work_dir
.
GravityToolsNext.transform_uncertainties!
— Methodtransform_uncertainties!(uncertainties_tr, uncertainties_orig, efac, equad)
-> uncertainties_tr
In-place transformation: σ' = sqrt((efac * σ)^2 + equad^2). Mutates the first argument.
GravityToolsNext.transform_uncertainties
— MethodOut-of-place variant of transform_uncertainties!
.
GravityToolsNext.update_par_file!
— Methodupdate_par_file!(pf::TempoParFile; ...; prefer_overrides=true) -> TempoParFile
Apply overrides and optionally set NITS/GAIN/START/FINISH with a clear precedence rule.
couple_f1_to_ddot::Bool=false
— if true and DDOT is overridden (while F1 is not), auto-adjust F1 using ΔF1 ≈ -F0·ΔDDOT/D.
GravityToolsNext.update_points_to_calculate!
— Methodupdate_points_to_calculate!(points_to_calculate, grid, grid_refined, refined_points_status)
Update the list of points to calculate for refinement (parallel version).
GravityToolsNext.update_points_to_calculate!
— Methodupdate_points_to_calculate!(points_to_calculate, i_ref_init, j_ref_init, grid, grid_refined, refined_points_status)
Update the list of points to calculate for a given refined point (parallel version).
GravityToolsNext.upsert_param!
— Methodupsert_param!(pf, p) -> TempoParFile
Insert or replace parameter p
by name, and ensure it is present in order
.
GravityToolsNext.upsert_param!
— Methodupsert_param!(params, p) -> Vector{TempoParameter}
Update by name or append if not present. Keeps order. Mutates params
.
Rules:
- If parameter with this name is new → push
p
. - If exists → replace value/flag intelligently:
- If
p.value === nothing
, keep the old value. - If
p.flag === nothing
, keep the old flag. - Otherwise take the provided values.
- If
GravityToolsNext.upsert_params!
— Methodupsert_params!(pf, ps) -> TempoParFile
Apply upsert_param!
for each p in ps
. If p.value === nothing
, treat it as a flag-only update.
GravityToolsNext.upsert_params!
— Methodupsert_params!(params, new_params) -> Vector{TempoParameter}
Apply upsert_param!
for each element of new_params
. Order of new elements is preserved.
GravityToolsNext.validate
— Methodvalidate(v::AbstractTempoVersion) -> Bool
Check that data directory exists and the executable is available (or at least named). Returns true
if OK, otherwise throws.
GravityToolsNext.validate
— Methodvalidate(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.
GravityToolsNext.validate_inputs_exist
— Methodvalidate_inputs_exist(s::TempoRunSettings) -> Bool
Validate inputs before materialization:
- checks that
par_input
andtim_input
exist relative towork_dir
; - ensures
par_output
is a file name (no directories).
Does not create directories. Returns true if valid, otherwise throws.
GravityToolsNext.validate_prior
— Methodvalidate_prior(pr::GridPrior; atol_mass=1e-3) -> Bool
Validate monotonicity and normalization of a GridPrior
. Throws an error with a diagnostic message if invalid.
GravityToolsNext.weighted_kurtosis
— Methodweighted_kurtosis(res [, unc]) -> (excess_g2, se_g2)
GravityToolsNext.weighted_mean
— Methodweighted_mean(res) -> (μ, se_μ)
weighted_mean(res, unc) -> (μ_w, se_μ)
Unweighted fast path avoids allocating ones(N)
. Weighted uses w = 1/unc^2. Standard errors follow the same conventions as in the legacy printout.
GravityToolsNext.weighted_mean_invvar
— Methodweighted_mean_invvar(residuals, uncertainties_tr) -> (μ_w, se_μ)
Inverse-variance weighted mean with w = 1/σ′^2 without allocations. Skips entries with non-finite residuals/σ′ or σ′ ≤ 0. Returns (NaN, NaN) if no valid points.
GravityToolsNext.weighted_rms
— Methodweighted_rms(res [, unc]) -> (rms, se_rms)
GravityToolsNext.weighted_skewness
— Methodweighted_skewness(res [, unc]) -> (g1, se_g1)
GravityToolsNext.weighted_std
— Methodweighted_std(res) / weighted_std(res, unc) -> (σ, se_σ)
Centered at (weighted) mean. Unweighted uses population σ (divide by N), to match the diagnostic behavior you had.
GravityToolsNext.with_upserted_params
— Methodwith_upserted_params(params, new_params) -> Vector{TempoParameter}
Non-mutating version of upsert_params!
.
GravityToolsNext.without_params
— Methodwithout_params(params, names) -> Vector{TempoParameter}
Non-mutating bulk deletion.
GravityToolsNext.write_node_metadata
— Methodwrite_node_metadata(path; meta...) -> Nothing
Write a simple key: value
metadata file at path
(e.g., "node_meta.txt"
).
Real
values are formatted viaformat_short
.AbstractVector{<:Real}
values are comma-joined with each element formatted viaformat_short
.- Other vectors are comma-joined via
string
. - Other scalars are stringified.
GravityToolsNext.write_par_file!
— Methodwrite_par_file!(par_file::TempoParFile) -> TempoParFile
Writes parameters to par_file.path
, preserving the order defined in order
. If par_file.dir
does not exist, it will be created.
GravityToolsNext.AbstractGridRule
GravityToolsNext.AbstractTempoSettings
GravityToolsNext.AbstractTempoVersion
GravityToolsNext.AdaptiveRefinement2DGrid
GravityToolsNext.AdaptiveRefinement2DGrid
GravityToolsNext.BasicResidualStats
GravityToolsNext.BasicTempoOutput
GravityToolsNext.BasicTempoTask
GravityToolsNext.CaptureOptions
GravityToolsNext.ClenshawCurtisNodes
GravityToolsNext.CombinedTOAEntry
GravityToolsNext.ContourUnit
GravityToolsNext.ConvergenceInfo
GravityToolsNext.ConvergenceInfo
GravityToolsNext.ConvergenceSeries
GravityToolsNext.DiffContourUnit
GravityToolsNext.DiffUnit
GravityToolsNext.EngineOptions
GravityToolsNext.ExplicitRule
GravityToolsNext.ExplicitThetaNodes
GravityToolsNext.FitParameter
GravityToolsNext.FullUnit
GravityToolsNext.GeneralTempoResult
GravityToolsNext.GridAxis
GravityToolsNext.GridAxis
GravityToolsNext.GridAxis
GravityToolsNext.GridPrior
GravityToolsNext.GridPrior
GravityToolsNext.InputModifiers
GravityToolsNext.InternalIterationOutput
GravityToolsNext.InternalIterationResult
GravityToolsNext.LinRule
GravityToolsNext.LocalMinimaUnit
GravityToolsNext.LogRule
GravityToolsNext.LoggingOptions
GravityToolsNext.MaterializedJob
GravityToolsNext.PriorExecutionOptions
GravityToolsNext.PriorMarginalizationSettings
GravityToolsNext.PriorMarginalizedTempoTask
GravityToolsNext.QuantileNodes
GravityToolsNext.RefinementSettings
GravityToolsNext.RelDiffUnit
GravityToolsNext.RetentionOptions
GravityToolsNext.RunArtifacts
GravityToolsNext.RunPaths
GravityToolsNext.SampledPrior
GravityToolsNext.TempoOutputError
GravityToolsNext.TempoParFile
GravityToolsNext.TempoParameter
GravityToolsNext.TempoParameter
GravityToolsNext.TempoResidualEntry
GravityToolsNext.TempoRunOutput
GravityToolsNext.TempoRunSettings
GravityToolsNext.TempoRunSettings
GravityToolsNext.TimTOAEntry
GravityToolsNext.WhiteNoiseBackendFitResult
GravityToolsNext.WhiteNoiseFitResult
GravityToolsNext.WhiteNoiseOptions
GravityToolsNext.WorkspaceOptions
GravityToolsNext.WorstParam
GravityToolsNext._PriorNodeResult
GravityToolsNext._PriorNodeResult
Base.getindex
Base.show
Base.show
Base.show
GravityToolsNext._apply_coupling_f1_to_ddot!
GravityToolsNext._assemble_prior_result
GravityToolsNext._bad_prior_result
GravityToolsNext._build_thetas
GravityToolsNext._check_nodes_for_error
GravityToolsNext._choose_representative
GravityToolsNext._empty_norm_stats
GravityToolsNext._extract_metric
GravityToolsNext._group_by_backend
GravityToolsNext._header_length
GravityToolsNext._integrate_posterior
GravityToolsNext._is_comment_or_blank
GravityToolsNext._load_final_par_file
GravityToolsNext._make_node_task
GravityToolsNext._marginalize_param_estimates
GravityToolsNext._normalized_shifted_residuals_for_backend
GravityToolsNext._posterior_summary
GravityToolsNext._posterior_weights
GravityToolsNext._prepare_node_workdir
GravityToolsNext._resolve_reference
GravityToolsNext._rule_linvals
GravityToolsNext._rule_linvals
GravityToolsNext._rule_linvals
GravityToolsNext._rule_values
GravityToolsNext._rule_values
GravityToolsNext._rule_values
GravityToolsNext._run_nodes_serial!
GravityToolsNext._split_iterations
GravityToolsNext._wn_mask
GravityToolsNext.ad_objective_function
GravityToolsNext.ad_objective_function!
GravityToolsNext.ad_objective_function_fit_offset!
GravityToolsNext.ad_objective_function_with_offset!
GravityToolsNext.axisvalues
GravityToolsNext.build_convergence_info
GravityToolsNext.build_convergence_series
GravityToolsNext.build_core_metrics
GravityToolsNext.build_general_tempo_result
GravityToolsNext.build_internal_iteration_result
GravityToolsNext.build_node_dirname
GravityToolsNext.build_residual_statistics_group
GravityToolsNext.build_white_noise_fit
GravityToolsNext.calculate_2DGrid
GravityToolsNext.calculate_cell!
GravityToolsNext.calculate_point!
GravityToolsNext.cell_selector
GravityToolsNext.cell_selector
GravityToolsNext.cell_selector
GravityToolsNext.cell_selector
GravityToolsNext.cell_selector
GravityToolsNext.cell_selector
GravityToolsNext.cell_selector
GravityToolsNext.chisq_stats
GravityToolsNext.chisq_stats
GravityToolsNext.cleanup_old_tempo_files
GravityToolsNext.cleanup_run!
GravityToolsNext.cleanup_run!
GravityToolsNext.combine_tim_and_residuals
GravityToolsNext.combine_tim_and_residuals_safe
GravityToolsNext.copy_par_file
GravityToolsNext.copy_with
GravityToolsNext.cpad_display
GravityToolsNext.default_convergence_thresholds
GravityToolsNext.default_par_output
GravityToolsNext.delete_param!
GravityToolsNext.delete_param!
GravityToolsNext.delete_params!
GravityToolsNext.delete_params!
GravityToolsNext.estimate_white_noise_ad_with_offset
GravityToolsNext.eval_nodes
GravityToolsNext.eval_nodes
GravityToolsNext.eval_nodes
GravityToolsNext.extract_tempo_parameter_from_line
GravityToolsNext.find_efac_for_fixed_equad_and_std!
GravityToolsNext.find_worst_parameter
GravityToolsNext.format_short
GravityToolsNext.generate_par_file_name
GravityToolsNext.get_convergence_metric
GravityToolsNext.get_in
GravityToolsNext.get_par_file_representation
GravityToolsNext.get_param
GravityToolsNext.get_param
GravityToolsNext.has_param
GravityToolsNext.has_param
GravityToolsNext.in_fit_equals_in_tim
GravityToolsNext.interpolate_cell!
GravityToolsNext.is_converged
GravityToolsNext.is_converged_by
GravityToolsNext.is_debug
GravityToolsNext.is_info
GravityToolsNext.is_silent
GravityToolsNext.is_warn
GravityToolsNext.linspace
GravityToolsNext.lpad_display
GravityToolsNext.make_accessor
GravityToolsNext.materialize
GravityToolsNext.materialize_job
GravityToolsNext.par_input_path
GravityToolsNext.parallel_precalculate_2DGrid!
GravityToolsNext.parallel_refine_2DGrid
GravityToolsNext.param_index
GravityToolsNext.params_as_vector
GravityToolsNext.parse_basic_tempo_output
GravityToolsNext.parse_fit_parameters
GravityToolsNext.parse_internal_iteration_tempo_output
GravityToolsNext.parse_tempo_output
GravityToolsNext.parse_tempo_output_error
GravityToolsNext.parse_tempo_parameter_field
GravityToolsNext.pathlike_to_syms
GravityToolsNext.precalculate_2DGrid!
GravityToolsNext.print_aligned_table
GravityToolsNext.print_aligned_table
GravityToolsNext.print_aligned_table
GravityToolsNext.print_white_noise_fit_report
GravityToolsNext.print_white_noise_fit_report!
GravityToolsNext.prior_cdf
GravityToolsNext.prior_cdf
GravityToolsNext.prior_invcdf
GravityToolsNext.prior_invcdf
GravityToolsNext.prior_logpdf
GravityToolsNext.prior_pdf
GravityToolsNext.prior_support
GravityToolsNext.prior_tail_mass
GravityToolsNext.read_par_file
GravityToolsNext.read_par_file!
GravityToolsNext.read_prior_samples
GravityToolsNext.read_residual_file
GravityToolsNext.read_tim_file
GravityToolsNext.read_tim_file_safe
GravityToolsNext.refine
GravityToolsNext.refine
GravityToolsNext.refine
GravityToolsNext.refine
GravityToolsNext.refine
GravityToolsNext.refine_2DGrid
GravityToolsNext.refined_index
GravityToolsNext.rpad_display
GravityToolsNext.run_task
GravityToolsNext.run_task
GravityToolsNext.run_task
GravityToolsNext.run_task
GravityToolsNext.run_tempo_parsed
GravityToolsNext.run_tempo_raw
GravityToolsNext.run_tempo_raw
GravityToolsNext.sanitize_name
GravityToolsNext.set_flag!
GravityToolsNext.single_core_precalculate_2DGrid!
GravityToolsNext.single_core_refine_2DGrid
GravityToolsNext.task_stage_inputs!
GravityToolsNext.task_with_overrides
GravityToolsNext.task_with_overrides
GravityToolsNext.task_with_param
GravityToolsNext.task_workdir
GravityToolsNext.task_workdir
GravityToolsNext.tempo_flag
GravityToolsNext.tim_input_path
GravityToolsNext.transform_uncertainties
GravityToolsNext.transform_uncertainties!
GravityToolsNext.update_par_file!
GravityToolsNext.update_points_to_calculate!
GravityToolsNext.update_points_to_calculate!
GravityToolsNext.upsert_param!
GravityToolsNext.upsert_param!
GravityToolsNext.upsert_params!
GravityToolsNext.upsert_params!
GravityToolsNext.validate
GravityToolsNext.validate
GravityToolsNext.validate_inputs_exist
GravityToolsNext.validate_prior
GravityToolsNext.weighted_kurtosis
GravityToolsNext.weighted_mean
GravityToolsNext.weighted_mean_invvar
GravityToolsNext.weighted_rms
GravityToolsNext.weighted_skewness
GravityToolsNext.weighted_std
GravityToolsNext.with_upserted_params
GravityToolsNext.without_params
GravityToolsNext.write_node_metadata
GravityToolsNext.write_par_file!