MeasurementConfig#
Describing a measurement stream by what it is, rather than by wiring it up. A stream is identified by its tracking file, its measurement type and its station; the type supplies the model class, the data block and the units, and the config supplies what every stream in a scenario shares.
MeasurementRegistry#
- class MeasurementRegistry#
Bases:
objectThe table of measurement types a scenario can be built from.
Maps a short type name such as
"SeqRange"onto theMeasurementTypedescribing it, so a stream can be written as(file, meas_type, station)and everything else looked up.Every method is a static method: there is one table per process, not one per instance, and
get()andregister()both work on it.Methods
all()The whole table, keyed by type name.
assign_dataset_names(streams[, registry])Name every stream, keeping the names unique.
get(name)Look up one measurement type.
register(name, spec)Add a measurement type, or replace one of the same name.
See also
scarabaeus.MeasurementConfigSettings shared across streams.
scarabaeus.MeasurementStreamOne stream, named by type.
scarabaeus.MeasurementSpecConsumes the registry to build a filter-ready spec.
Notes
The table is built on first use rather than at import, because building it means importing every model class and this module is imported during package initialisation.
Examples
import scarabaeus as scb scb.MeasurementRegistry.register( "MyRange", scb.MeasurementType(MyRangeModel, "meas_sim", km, "Range", real=False), ) spec = scb.MeasurementSpec.build([(file, "MyRange", station)])
- static all() dict#
The whole table, keyed by type name.
- Returns:
- dict
The live table, not a copy: mutating it changes what later lookups see. Prefer
register()for that.
- static assign_dataset_names(streams, registry: dict = None) list#
Name every stream, keeping the names unique.
Streams that share a station and a type would otherwise collide, which matters because solutions are keyed by dataset name. Repeats get a counter appended, added after the label so that the substrings
Plottingclassifies on stay intact.- Parameters:
- streamssequence of MeasurementStream
The streams to name. A stream that already carries a
namekeeps it, and is still checked against the generated names for collisions.- registrydict, optional
Table to resolve each stream’s type against. Defaults to
all().
- Returns:
- list of str
One name per stream, in the order given.
- static get(name: str) MeasurementType#
Look up one measurement type.
- Parameters:
- namestr
A registered type name.
- Returns:
- MeasurementType
The specification registered under name.
- Raises:
- KeyError
If name is not registered. The message lists the names that are, since a typo here is otherwise reported much later as a missing model.
- static register(name: str, spec: MeasurementType) None#
Add a measurement type, or replace one of the same name.
Lets a new measurement type be used by
build()without editing this module.- Parameters:
- namestr
Short name streams will refer to the type by.
- specMeasurementType
What the name implies: model class, data block, units, label.
MeasurementType#
- class MeasurementType(model_class: Any, meas_name: str, units: Any, label: str, real: bool = True)#
Bases:
objectWhat a measurement type implies.
- Attributes:
- model_classtype
Measurement model to build.
- meas_namestr
Block within the tracking json holding this measurement.
- unitsUnits
Units the observations are read in. Keeping these with the type is what stops a sigma being built in one unit and the observations in another, which is easy to do when both are written out by hand.
- labelstr
Human-readable suffix used when naming datasets. Must keep the substrings Plotting classifies on (“Range Rate” before “Range”).
- realbool
True for real tracking data, False for simulated.
MeasurementConfig#
- class MeasurementConfig(media_folder: str | None = None, tropo_seasonal_file_path: str | None = None, sc_transponder_delay_RU: float = 0.0, frame: Any = None, sigma: dict = <factory>, bias: dict = <factory>, extra: dict = <factory>)#
Bases:
objectSettings shared by every stream in a scenario.
Anything here can also be overridden per stream. Extra keys can be carried in
extraso this can grow without changing the signature.- Attributes:
- media_folderstr, optional
Folder holding the tropospheric and ionospheric correction files.
- tropo_seasonal_file_pathstr, optional
Seasonal troposphere file.
- sc_transponder_delay_RUfloat
Spacecraft transponder delay in range units (RU), applied to the real radiometric reads (DopplerReal, SequentialRangingReal). Defaults to
0.0, which takes the delay each tracking block carries, or no delay when it has none.A plain float on purpose, not an ArrayWUnits: a range unit is not a fixed unit of time. One RU lasts
1 / (range_unit * reference_frequency)seconds, which depends on the band and on the exciter scalars of each pass, so it is only known once a pass is read and is not somethingUnitscan convert. The reader converts it per pass withtransponder_delay_seconds(). RU is also how missions quote the delay.- frameFrame, optional
Frame the observations are expressed in.
Noneleaves each model on its own default, which is J2000. Set it andbuild()passes it to every stream’s read.- sigmadict, optional
Default measurement sigma per type name or per dataset name, used for any stream that does not carry its own.
A value is needed for every stream, including real data. The sigma refit during outlier rejection runs on the residuals, which come from the dataset, which cannot be built without a sigma to weight them – so the refit revises an initial value rather than standing in for one. A stream left without one reports what is missing (see
_require_sigma()).- biasdict, optional
Measurement bias per type name or dataset name. Defaults to 0.
- extradict
Anything further, offered to every model constructor.
Offered, not passed:
build()filters each model’s keyword arguments against its signature, so a key that only one model accepts reaches only that model instead of raising TypeError on the others. The cost is that a key no model accepts – a typo, or one meant for a different scenario – would simply do nothing, sobuildwarns about any key it could not give to at least one model.
Methods
get_bias(type_name[, dataset_name])Return the bias of a stream.
get_sigma(type_name[, dataset_name])Return the sigma of a stream.
See also
scarabaeus.MeasurementRegistryThe measurement types a stream can name.
scarabaeus.MeasurementStreamOne stream, which can override these settings.
- get_bias(type_name: str, dataset_name: str = None)#
Return the bias of a stream.
- Parameters:
- type_namestr
Measurement type of the stream, a key of the registry.
- dataset_namestr, optional
Dataset name of the stream, looked up before
type_name. Defaults toNone.
- Returns:
- object
The bias given for
dataset_name, else the one given fortype_name, else0.0.
- get_sigma(type_name: str, dataset_name: str = None)#
Return the sigma of a stream.
- Parameters:
- type_namestr
Measurement type of the stream, a key of the registry.
- dataset_namestr, optional
Dataset name of the stream, looked up before
type_name. Defaults toNone.
- Returns:
- object or None
The sigma given for
dataset_name, else the one given fortype_name, elseNone.
MeasurementStream#
- class MeasurementStream(file: str, meas_type: str, station: Any, name: str | None = None, sigma: Any = None, bias: Any = None, media: Any = None)#
Bases:
objectOne measurement stream.
Normally written as a plain
(file, meas_type, station)tuple and normalised into this; use the class directly when a stream needs something the defaults do not cover.Methods
coerce(item)Return
itemas a MeasurementStream.default_name(type_spec)Return the default dataset name of this stream.
See also
scarabaeus.MeasurementRegistryThe measurement types
meas_typenames.scarabaeus.MeasurementConfigSettings shared across streams.
- classmethod coerce(item) MeasurementStream#
Return
itemas a MeasurementStream.- Parameters:
- itemMeasurementStream or tuple or list
A stream, returned unchanged, or a
(file, meas_type, station)sequence of exactly three elements.
- Returns:
- MeasurementStream
The stream.
- Raises:
- ValueError
If a tuple or list does not have exactly three elements.
- TypeError
If
itemis neither a stream nor a tuple or list.
Notes
Fields after
stationmust be passed by name, because their order is not one anyone would guess:(file, type, station, 0.5)written for a sigma would otherwise name the dataset “0.5” and set no sigma.
- default_name(type_spec: MeasurementType) str#
Return the default dataset name of this stream.
- Parameters:
- type_specMeasurementType
Type of the stream, whose
labelis appended.
- Returns:
- str
"<station name> <label>".