virgil.pipeline
Provisional
May change in any 0.4.x release without a deprecation cycle.
The classes and functions of the pipelines. For what a pipeline does, the run folder, the checks and the stability policy, see Pipelines and their stability.
Bases: _Pipeline
Search for a companion, set contrast limits, fit and sample a binary.
Provisional
May change in any 0.4.x release without a deprecation cycle.
Stages: load, overview, search (point-companion grid,
detection_statistics),
limits (absil_limits), fit,
posterior (NUTS, same prior as the fit) and quicklook.
res.summary["companion"] has sep_mas and pa_deg for either
template. Settings:
pipeline settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
OIData
|
The data. |
required |
model
|
BinaryModelAngular or BinaryModelCartesian
|
An instance of |
None
|
output
|
str or PathLike
|
Run folder (default |
'run'
|
**settings
|
Overrides of |
{}
|
Examples:
>>> import virgil as vg
>>> from virgil.pipeline import BinaryPipeline
>>> res = BinaryPipeline(vg.OIData("hd1234.oifits"), output="runs/binary").run()
>>> res.summary["companion"]["sep_mas"]
NAME = 'binary'
class-attribute
instance-attribute
STABILITY = 'provisional'
class-attribute
instance-attribute
STAGES = ('load', 'overview', 'search', 'limits', 'fit', 'posterior', 'quicklook')
class-attribute
instance-attribute
__init__(data, model=None, *, output='run', **settings)
Bases: _Pipeline
Measure a star's angular diameter, with and without limb darkening.
Provisional
May change in any 0.4.x release without a deprecation cycle.
Stages: load, overview, fit (a scan of the uniform-disk
diameter, then fit of each other model from the
scanned diameter), posterior (NUTS) and quicklook. The default
models are compared on −2 log L against a BIC penalty.
res.summary["star"]["diam_mas"] is the preferred model's. All settings:
pipeline settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
OIData
|
The data. |
required |
model
|
str or SourceModel
|
|
None
|
output
|
str or PathLike
|
Run folder (default |
'run'
|
**settings
|
Overrides of |
{}
|
Examples:
>>> import virgil as vg
>>> from virgil.pipeline import StarPipeline
>>> res = StarPipeline(vg.OIData("star.oifits"), output="runs/star").run()
>>> res.summary["star"]["diam_mas"]
NAME = 'star'
class-attribute
instance-attribute
STABILITY = 'provisional'
class-attribute
instance-attribute
STAGES = ('load', 'overview', 'fit', 'posterior', 'quicklook')
class-attribute
instance-attribute
names = names
instance-attribute
__init__(data, model=None, *, output='run', **settings)
Bases: _Pipeline
Fit a disk, ring or halo with a MultipoleDisk.
Provisional
May change in any 0.4.x release without a deprecation cycle.
The star is a grey point source unless star_diameter_mas, star_temperature_k or
star_index says otherwise; the disk's spectral index is relative to it. Stages: load
(wavel_range [min, max] in metres; error_floor a dict of absolute floors),
overview (plots; sets the half-fringe λ/2B of the longest baseline), geometry (χ²
grid over cos inc and pa, then a single-ring fit), profile, compare,
posterior (NUTS, with posterior=True) and quicklook. model="gp" fits a
RadialGP profile at each length scale and keeps the largest Laplace evidence;
"rings" adds Gaussian rings until the BIC stops improving. run() returns a
Result: res.summary["disk"] (n_rings and rings for "rings"),
res.model() (the best fit), res.checks. All settings, with defaults:
pipeline settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
OIData
|
The data. |
required |
model
|
('gp', 'rings')
|
What to fit (default |
"gp"
|
output
|
str or PathLike
|
Run folder (default |
'run'
|
**settings
|
Overrides of |
{}
|
Examples:
>>> import virgil as vg
>>> from virgil.pipeline import DiskPipeline
>>> res = DiskPipeline(vg.OIData("disk.oifits"), "rings", output="runs/disk").run()
>>> res.summary["disk"]["n_rings"], res.model()
NAME = 'disk'
class-attribute
instance-attribute
STABILITY = 'provisional'
class-attribute
instance-attribute
STAGES = ('load', 'overview', 'geometry', 'profile', 'compare', 'posterior', 'quicklook')
class-attribute
instance-attribute
name = name
instance-attribute
error_mode
property
"quoted", "fit" or "rescale": error_scale with
"auto" resolved ("rescale" for "gp", else "quoted").
processed
property
The data after wavel_range and error_floor, and (with
error_scale="rescale", once the profile stage has estimated
it) the MacKay error scale: every fit and evidence after that point
is on these data.
__init__(data, model=None, *, output='run', **settings)
__repr__()
Bases: _Pipeline
Fit the orbit of a binary seen on several nights, blind to its period.
Provisional
May change in any 0.4.x release without a deprecation cycle.
The data must be prepared already (the instrument's channel, band and
noise handling). Stages: load (group into nights), epochs
(epoch_positions), search
(fit_orbit_aliases with no published
period, window or prior),
modes (rank the bands; compare with a single star), posterior
(NUTS per significant band) and quicklook. summary["modes"]["winner"]
is the winning alias band, ["delta_log_z"] its margin (nats) over the
runner-up. All settings: pipeline settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
epochs
|
Epochs or dict
|
An |
required |
output
|
str or PathLike
|
Run folder (default |
'run'
|
**settings
|
Overrides of |
{}
|
Examples:
>>> from virgil.pipeline import OrbitPipeline
>>> res = OrbitPipeline.from_oifits(files, output="runs/orbit").run()
>>> res.summary["modes"]["winner"]["period"]
NAME = 'orbit'
class-attribute
instance-attribute
STABILITY = 'provisional'
class-attribute
instance-attribute
STAGES = ('load', 'epochs', 'search', 'modes', 'posterior', 'quicklook')
class-attribute
instance-attribute
data = Epochs(mapping, times=keep or None)
instance-attribute
__init__(epochs, *, output='run', **settings)
from_oifits(paths, metadata=None, *, output='run', **settings)
classmethod
Build a pipeline from OIFITS files, grouped into nights.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paths
|
str, os.PathLike or list of them
|
OIFITS files, each split into nights at gaps of |
required |
metadata
|
dict
|
|
None
|
output
|
str or PathLike
|
Run folder. |
'run'
|
**settings
|
Settings overriding the defaults. |
{}
|
__repr__()
Bases: _Pipeline
Image the source from V², closure phases or complex visibilities.
Provisional
May change in any 0.4.x release without a deprecation cycle.
A Gaussian-process image on the quoted errors; a good fit does not
promise that the morphology is right. Multi-channel data give one grey
image. Stages: load, overview (the grid), star (with or
without a point source, by log evidence), hyperparameters (σ and ℓ by
Laplace evidence), members (members fits at those shared
hyperparameters), combine (images/mean.fits and sigma.fits)
and quicklook. To spread the members over tasks, call
pipeline.run(through="hyperparameters"), then pipeline.run_member(k)
for k in range(members), then pipeline.run(), which returns the
Result (res.image()). All settings, with defaults:
pipeline settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
OIData
|
The data. |
required |
model
|
'gp'
|
The image prior (the only one in this version). |
"gp"
|
output
|
str or PathLike
|
Run folder (default |
'run'
|
**settings
|
Overrides of |
{}
|
Examples:
>>> from virgil.pipeline import ImagingPipeline
>>> res = ImagingPipeline(data, output="runs/image").run()
>>> res.image().pixels.shape
NAME = 'image'
class-attribute
instance-attribute
STABILITY = 'provisional'
class-attribute
instance-attribute
STAGES = ('load', 'overview', 'star', 'hyperparameters', 'members', 'combine', 'quicklook')
class-attribute
instance-attribute
__init__(data, model=None, *, output='run', **settings)
run_member(k)
Fit member k unless it is saved (after the hyperparameters
stage); the members stage runs every one that is missing.
An image from Result.image:
pixels (row 0 North, column 0 East), the centre offset dra,
ddec (mas) and the FITS header (STARFRAC: star's flux share).
pixels
instance-attribute
pixel_scale_mas
instance-attribute
dra
instance-attribute
ddec
instance-attribute
header
instance-attribute
__init__(pixels, pixel_scale_mas, dra, ddec, header)
The result of OrbitPipeline.run() is a Result: Result.aliases() returns the engine's AliasResult (every alias band, its evidence and the best orbit), Result.samples() the posterior draws of the winning band, and Result.summary the numbers and checks. The orbit tutorial reads one.
A model DiskPipeline can fit, registered under a short name.
Entries of MODELS are parallel options, not a chain: each runs the
profile and compare stages on its own settings and checks. Adding an
entry (say a cone) is adding a row to MODELS, with no new stage.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The short name accepted by |
label |
str
|
Human-readable name, for plots and messages. |
disk |
str
|
What the disk is, in one line. |
profile |
callable
|
|
compare |
callable
|
|
checks |
tuple of str
|
The names of the checks that apply (from |
candidate |
str
|
Prefix of the names of the candidate models under |
name
instance-attribute
label
instance-attribute
disk
instance-attribute
profile
instance-attribute
compare
instance-attribute
checks
instance-attribute
candidate
instance-attribute
__init__(name, label, disk, profile, compare, checks, candidate)
The registry of short names to DiskModel.
The fitted disk: images, profile, colour, lopsidedness and residuals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
System
|
The fitted model ( |
required |
data
|
OIData
|
The data ( |
required |
r_out_mas
|
float
|
Outer radius of the radial range (mas); the images span ±1.2 times this. |
required |
r_in_mas
|
float
|
Inner radius of the radial range (mas); the curves start there. |
0.0
|
npix
|
int
|
Pixels of each image. |
200
|
Returns:
| Type | Description |
|---|---|
Figure
|
|
Reload a pipeline run from its folder, without recomputing anything.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or PathLike
|
The run folder (the pipeline's |
required |
Returns:
| Type | Description |
|---|---|
Result
|
|
The outputs of a pipeline run, reloaded from its folder.
Nothing is recomputed: every accessor reads the files the run wrote, and returns plain numbers, numpy arrays or real virgil objects that can be refined by hand.
Attributes:
| Name | Type | Description |
|---|---|---|
path |
Path
|
The run folder. |
run |
dict
|
The contents of |
summary |
dict
|
The contents of |
path = Path(path)
instance-attribute
run = read_json(run_file)
instance-attribute
summary = read_json(summary_file) if summary_file.exists() else {}
instance-attribute
status
property
Run status: "running", "partial", "complete" or "failed".
checks
property
The quality checks, as a list of Check.
plots
property
Paths of the plots the run wrote, sorted by name.
__init__(path)
__repr__()
describe()
The key numbers of the summary as short text, one per line.
data()
The data actually fitted, as an OIData, from data/processed.oifits.
image(which='mean')
The combined image of an imaging run (which="sigma": the
spread of its members), a SkyImage.
model(name=None)
A fitted model, a real virgil object with its values set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
For a run that fitted several models ( |
None
|
model_values(name=None)
The fitted parameter values, as path → numpy array (see model).
samples(group_by_chain=True, name=None)
Posterior samples by site, shaped (chain, draw) (or flat).
name selects one of several fitted models, as in model.
aliases()
The alias search of an orbit run, as an
AliasResult (every band's modes,
evidences and best orbit), from stages/search/aliases.json.
sample_stats(name=None)
NUTS diagnostics per transition, shaped (chain, draw).
grid()
Grid results: "axes" (usable as grid=) plus one map per name.
fit_result(name=None)
The MAP fit as a virgil FitResult, e.g. to continue with fit.
name selects one of several fitted models, as in model.
One quality check of a pipeline run.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Stable identifier, e.g. |
status |
{'pass', 'warn', 'fail'}
|
Outcome. |
value |
(float, list or None)
|
The quantity tested. |
threshold |
(float, list or None)
|
The threshold it was compared with. |
message |
str
|
One templated sentence saying what the outcome means. |
name
instance-attribute
status
instance-attribute
value
instance-attribute
threshold
instance-attribute
message
instance-attribute
__post_init__()
to_dict()
The check as a JSON-ready dict.
from_dict(record)
classmethod
Rebuild a check from :meth:to_dict.