Skip to content

hertzforge.core.run_log_model

run_log_model

The run log read as tests, axes and runs: their states, the holds and owed lists, the views a report reads, and the projection to full level.

A RunLog (core.run_log) is a list of entries, each with plain test, axis and run references. RunLogModel reads a log's corrected view and builds the rest from it, every time it is made: nothing here is stored in the file, so a hold, an owed line or a credited duration is always what the entries say now, and a correction changes it at once.

Tests. A test is opened by a test_opened entry, which carries its kind (one of TEST_KINDS: the project types plus Functional and Other) and its header (run_log.HEADER_FIELDS): what the test is, the article, the documents and revisions, and the plan's numbers the log checks against. A header_change changes one header field. A test has three states: open (it takes runs), closed to runs (when it is closed, or when the next test opens) and released (its release entry, a post-test step 'release'). A test closed to runs still takes findings, post-test steps and dispositions; a released test takes no new runs, findings or header changes.

The roll (roll) closes the current test to runs and opens the next with its header carried from the last. Every carried field is marked carried until it is confirmed (confirm) or changed.

Runs are numbered within a test, and each sits on one axis. What a run holds depends on the test's kind: random level rows ending at full level with the counter, sine sweeps with their direction and count, shock shots with their four checks and the pulse count against the budget, and for a survey or functional run its result and who ran it.

Holds are what the log asks to be answered before the test goes on: an abort with no cause, an over-test question unanswered, a restart with no cause, a "not explained" answer with no later answer, a notch not in the header's planned list with no deviation, a limit, tolerance or abort-band change with no deviation, and a go at a hold-point level with no customer agreement logged. They are shown, never enforced: the log never drives the controller.

Owed lists are checklists with a line each, done by an entry (who and when) or still owed: the setup before the first low level, the axis change, the release checklist, an abort's first-minute fields, a shot's four checks, and a day with no clock check.

The projection (project) takes readings at a level L in dB relative to full level (negative) to full level by the factor 10^(-L/20), exactly, and judges the drive fraction against its window, the peak current at the plan's sigma against the peak rating and the peak voltage against the rail. A check that cannot be made reads "not judged", with why, and is never a pass.

Classes:

Name Description
Check

One headroom number at full level: what it is, its value at full

Projection

Readings at a level projected to full level, and the headroom

Comparison

A level row compared with an earlier one: the earlier entry, what

LevelReading

A level row read against its test's header: the projection to full

TestHeader

A test's header as it stands at some entry: the value of each

Run

One run of a test: its number, its axis, what its kind of test

Test

One test as the log holds it: its number and kind, the entries

Hold

A hold: its rule (a key of HOLD_RULES), its test, the entry that

OwedLine

One line of an owed list: its key, what it asks, the entry that

OwedList

An owed list: its name, its title, its test and axis, its lines in

Interruption

A stop the test did not plan to run through, or a scheduled one:

Credit

The time credited on one axis of a test, from the counters, against

PulseCount

The pulses a shock test has given, by axis and in all, against the

Finding

A deviation or anomaly: its number, kind ('deviation' or

FileRow

A file an entry names: the entry and the file.

ChronologyRow

An entry in the order of events, with its time on the recorders'

RunLogModel

A run log read as tests, axes and runs, with its holds, owed lists

Functions:

Name Description
notch_in_plan

Whether a notch with fields (its band, and its depth_db where

full_level_factor

The factor that takes a reading at level_db to full level:

parse_counter

A controller's counter as seconds: '750', '750 s', '12:30' (minutes

clock_text

Seconds as the counter reads them: m:ss, or h:mm:ss from an hour,

project

Readings at a level projected to full level, with the headroom

judge_pulses

The pulses counted by axis (by_axis) judged against budget, a

admit

Refuse an entry of kind for test that the test's state does not

append

RunLog.append, refused first when the test's state does not take

open_test

Open the log's next test, when no test is open to runs.

roll

Close the current test to runs and open the next, its header

close_test

Close test test to runs without opening another. It still takes

change_header

Change one field of test test's header, the value it had

confirm

Confirm carried fields of test test as they stand (every carried

release

Write test test's release, the release checklist's 'release'

Classes

Check dataclass

Check(name: str, at_full: float | None, limit: float | tuple[float, float] | None, verdict: str, message: str)

One headroom number at full level: what it is, its value at full level, the limit it is judged against, and the verdict ('within', 'over', 'under' or 'not judged') with words that say why.

Attributes:

Name Type Description
judged bool

Whether the check was made; one that was not is never a

Attributes
judged property
judged: bool

Whether the check was made; one that was not is never a pass.

Projection dataclass

Projection(level_db: float, factor: float, voltage: float | None, current: float | None, drive_fraction: float | None, checks: tuple[Check, ...])

Readings at a level projected to full level, and the headroom checks. verdict is 'within' only when every check was judged within; 'outside' when any is over or under; otherwise 'not judged'.

Methods:

Name Description
check

The check named name ('drive fraction', 'peak current',

Attributes:

Name Type Description
verdict str

'within', 'outside' or 'not judged', as the class says.

Attributes
verdict property
verdict: str

'within', 'outside' or 'not judged', as the class says.

Methods:
check
check(name: str) -> Check

The check named name ('drive fraction', 'peak current', 'rms current', 'peak voltage').

Comparison dataclass

Comparison(against: Entry, what: str, ratios: Mapping[str, float | None], flagged: tuple[str, ...])

A level row compared with an earlier one: the earlier entry, what it is (the previous level, or the last run of the same setup), and the ratios of the readings now to then, each None where either reading is missing or zero. flagged names each ratio that moved more than VA_CHANGE.

LevelReading dataclass

LevelReading(entry: Entry, projection: Projection | None, message: str, previous: Comparison | None, last_run: Comparison | None)

A level row read against its test's header: the projection to full level (None when it cannot be made, message saying why), the volts-per-amp ratio against the previous level, and the comparison with the last run of the same setup when the log holds one.

Attributes:

Name Type Description
verdict str

The projection's verdict, or 'not judged' without one.

Attributes
verdict property
verdict: str

The projection's verdict, or 'not judged' without one.

TestHeader dataclass

TestHeader(values: Mapping[str, Any], set_by: Mapping[str, int], carried: tuple[str, ...])

A test's header as it stands at some entry: the value of each field, the entry that set it, and the fields carried from the last test and not yet confirmed or changed.

Methods:

Name Description
get

The value of header field name, or default.

is_carried

Whether field name is carried and not yet confirmed.

Methods:
get
get(name: str, default: Any = None) -> Any

The value of header field name, or default.

is_carried
is_carried(name: str) -> bool

Whether field name is carried and not yet confirmed.

Run dataclass

Run(test: int, number: int, axis: str | None, shape: str, entries: tuple[Entry, ...])

One run of a test: its number, its axis, what its kind of test makes it hold (shape), and its entries in the order written.

Attributes:

Name Type Description
levels tuple[Entry, ...]

The level rows, in the order written.

sweeps tuple[Entry, ...]

The sweeps, in the order written.

shots tuple[Entry, ...]

The shots, in the order written.

start Entry | None

The run's first start entry, or None.

stop Entry | None

The run's last stop or abort, or None.

outcome str

'aborted' (an abort since its last start or restart, whether or

reached_full bool

Whether any entry of the run gives full level (0 dB).

counter str | None

The counter at the run's last stop, as written, or None.

result str | None

A survey or functional run's result, from its last stop.

by str | None

Who ran a survey or functional run, from its last stop.

Attributes
levels property
levels: tuple[Entry, ...]

The level rows, in the order written.

sweeps property
sweeps: tuple[Entry, ...]

The sweeps, in the order written.

shots property
shots: tuple[Entry, ...]

The shots, in the order written.

start property
start: Entry | None

The run's first start entry, or None.

stop property
stop: Entry | None

The run's last stop or abort, or None.

outcome property
outcome: str

'aborted' (an abort since its last start or restart, whether or not a run stop was written beside it), 'stopped' (a scheduled stop), 'completed', or 'running' when no stop follows its last start or restart.

reached_full property
reached_full: bool

Whether any entry of the run gives full level (0 dB).

counter property
counter: str | None

The counter at the run's last stop, as written, or None.

result property
result: str | None

A survey or functional run's result, from its last stop.

by property
by: str | None

Who ran a survey or functional run, from its last stop.

Test dataclass

Test(number: int, kind: str, opened: Entry | None, closed: Entry | None, released: Entry | None, header: TestHeader, axes: tuple[str, ...], runs: tuple[Run, ...], entries: tuple[Entry, ...], problems: tuple[str, ...])

One test as the log holds it: its number and kind, the entries that opened, closed and released it, its header as it stands, its axes in the order first named, its runs, its entries in the order written, and what in them does not fit its states (problems).

Methods:

Name Description
run

Run number of the test.

Attributes:

Name Type Description
title str

The header's title, or 'Test N'.

state str

'open', 'closed to runs' or 'released' (STATES).

shape str

What its runs hold (RUN_SHAPES).

Attributes
title property
title: str

The header's title, or 'Test N'.

state property
state: str

'open', 'closed to runs' or 'released' (STATES).

shape property
shape: str

What its runs hold (RUN_SHAPES).

Methods:
run
run(number: int) -> Run

Run number of the test.

Hold dataclass

Hold(rule: str, test: int | None, entry: Entry, message: str)

A hold: its rule (a key of HOLD_RULES), its test, the entry that raised it and what it asks.

OwedLine dataclass

OwedLine(key: str, label: str, done: Entry | None = None, late: bool = False)

One line of an owed list: its key, what it asks, the entry that did it (None while owed), and whether it was done after the list was due.

Attributes:

Name Type Description
owed bool

Whether the line is still owed.

Attributes
owed property
owed: bool

Whether the line is still owed.

OwedList dataclass

OwedList(name: str, title: str, test: int | None, axis: str | None, lines: tuple[OwedLine, ...], due: Entry | None = None)

An owed list: its name, its title, its test and axis, its lines in order, and the entry it was due before (None when it has no due point).

Attributes:

Name Type Description
owed tuple[OwedLine, ...]

The lines still owed.

complete bool

Whether every line is done.

Attributes
owed property
owed: tuple[OwedLine, ...]

The lines still owed.

complete property
complete: bool

Whether every line is done.

Interruption dataclass

Interruption(entry: Entry, kind: str, cause: Entry | None, path: Entry | None, restart: Entry | None)

A stop the test did not plan to run through, or a scheduled one: the entry (an abort, or a scheduled run stop), its kind ('abort', 'trip' or 'scheduled'), and the cause, path and restart that answer it, each None until logged.

Credit dataclass

Credit(test: int, axis: str | None, seconds: float, complete: bool, notes: tuple[str, ...], duration: float | None, lower: float | None, upper: float | None, verdict: str, message: str)

The time credited on one axis of a test, from the counters, against the header's duration and its tolerance: the seconds credited, whether every segment could be read (complete), why not (notes), the duration and its bounds, and the verdict ('within', 'short', 'over' or 'not judged') with words that say why.

PulseCount dataclass

PulseCount(test: int, count: int, by_axis: Mapping[str | None, int], budget: int | None, verdict: str, message: str)

The pulses a shock test has given, by axis and in all, against the header's budget: 'within', 'over' or 'not judged', with words.

Finding dataclass

Finding(number: str, kind: str, entry: Entry, test: int | None, dispositions: tuple[Entry, ...])

A deviation or anomaly: its number, kind ('deviation' or 'anomaly'), the entry that opened it (corrected), its test, and the dispositions written against it.

Attributes:

Name Type Description
open bool

Whether an anomaly is still open (no disposition); a deviation

owner str | None

An anomaly's owner, as typed.

fact str | None

The finding's fact, as typed at the console.

Attributes
open property
open: bool

Whether an anomaly is still open (no disposition); a deviation is never held open waiting for an approval.

owner property
owner: str | None

An anomaly's owner, as typed.

fact property
fact: str | None

The finding's fact, as typed at the console.

FileRow dataclass

FileRow(entry: Entry, file: FileRef)

A file an entry names: the entry and the file.

ChronologyRow dataclass

ChronologyRow(entry: Entry, recorder_time: datetime | None, late: bool)

An entry in the order of events, with its time on the recorders' clock (None with no clock check before it) and whether it is late.

RunLogModel

RunLogModel(log: RunLog)

A run log read as tests, axes and runs, with its holds, owed lists and views. Built from the log's corrected view when made, and never stored: make a new one after the log changes.

Parameters:

Name Type Description Default
log RunLog

The log, open for writing or read-only.

required

Methods:

Name Description
tests

Every test, in the order first opened (or first named).

test

Test number; RunLogError when the log has none.

next_test

The number the next test opened takes.

next_run

The number the next run of test test takes.

header_at

The header of entry's test as it stood when entry was

runs

The runs of one test (test its number) or of every test

notch_planned

Whether notch entry is in its test's planned list as the

holds

The holds of one test or every test, in the order of the

owed

Every list with a line still owed, for one test or the whole

checklist

One checklist of test test, every line with who did it and

abort_fields

Each abort's first-minute fields, done by the abort or by the

shot_checks

Each shot's four checks, a line done when the shot (as

clock_days

A line for every day the selected entries fall on (by each

interruptions

The aborts, trips and scheduled stops, each with the cause, the

credited

The time credited on each axis of one test or every test, from

pulses

The pulses test test has given (each shot one, or its

findings

The deviations and anomalies, by number, each with the

open_anomalies

The anomalies with no disposition, with their owners.

files

Every file the selected entries name, in the order written.

late

The selected entries written down late (Entry.is_late).

chronology

The selected entries in the order of their events (by event

reading

Level row entry read against its test's header as it stood

Attributes:

Name Type Description
current Test | None

The test open to runs, the latest opened; None when none is.

Attributes
current property
current: Test | None

The test open to runs, the latest opened; None when none is.

Methods:
tests
tests() -> list[Test]

Every test, in the order first opened (or first named).

test
test(number: int) -> Test

Test number; RunLogError when the log has none.

next_test
next_test() -> int

The number the next test opened takes.

next_run
next_run(test: int) -> int

The number the next run of test test takes.

header_at
header_at(entry: Entry) -> TestHeader

The header of entry's test as it stood when entry was written: what a notch, a go or a reading is judged against, so a header changed later does not change the judgment.

runs
runs(test: Any = ALL) -> list[Run]

The runs of one test (test its number) or of every test (ALL), test by test.

notch_planned
notch_planned(entry: Entry) -> tuple[bool, str]

Whether notch entry is in its test's planned list as the header stood when it was written, and why: on its axis (a planned notch with no axis is on every axis), its band inside the planned band, and its depth no deeper than the planned depth where the plan gives one. The typed planned mark is not what decides it.

holds
holds(test: Any = ALL) -> list[Hold]

The holds of one test or every test, in the order of the entries that raised them (HOLD_RULES).

owed
owed(test: Any = ALL) -> list[OwedList]

Every list with a line still owed, for one test or the whole log: the setup before the first low level, each axis change, the release checklist once the test is closed to runs, each abort's first-minute fields, each shot's four checks, and the days with no clock check.

checklist
checklist(test: int, name: str, axis: str | None = None) -> OwedList

One checklist of test test, every line with who did it and when or still owed: 'before low level' (the test's first axis), 'axis change' (to axis, an axis after the first) or 'release'. A line is done by a setup step (a post-test step for the release checklist) naming it by its key or its words; an axis change's steps are on the new axis, and its first line may name the axis it closes.

abort_fields
abort_fields(test: Any = ALL) -> list[OwedList]

Each abort's first-minute fields, done by the abort or by the correction that added the field: the level, the channel, the line or band, the panel fault, the counter, who called it, what was heard, the records read and the over-test answer. A partial abort is accepted; what it lacks is owed here.

shot_checks
shot_checks(test: Any = ALL) -> list[OwedList]

Each shot's four checks, a line done when the shot (as corrected) carries every field of the check.

clock_days
clock_days(test: Any = ALL) -> OwedList

A line for every day the selected entries fall on (by each entry's own date), done by that day's first clock check, which may be anywhere in the log.

interruptions
interruptions(test: Any = ALL) -> list[Interruption]

The aborts, trips and scheduled stops, each with the cause, the path and the restart that answer it (by refers_to, or the next written in the same test).

credited
credited(test: Any = ALL) -> list[Credit]

The time credited on each axis of one test or every test, from the counters, against the header's duration and tolerance.

A run's time counts once it reaches full level (an entry giving 0 dB). A segment runs from its start (a run start's counter, 0 when not given, or a restart's counter) to the counter at its stop or abort. A restart that resumes continues the count; one that starts the test again discards what was credited before it on the axis. A segment whose counter is missing or unreadable leaves the total a lower bound, and the verdict not judged.

pulses
pulses(test: int) -> PulseCount

The pulses test test has given (each shot one, or its pulses), by axis and in all, against the header's budget. Every shot entry counts, a missed one too: a missed pulse spends the budget.

findings
findings(test: Any = ALL) -> list[Finding]

The deviations and anomalies, by number, each with the dispositions written against it anywhere in the log.

open_anomalies
open_anomalies(test: Any = ALL) -> list[Finding]

The anomalies with no disposition, with their owners.

files
files(test: Any = ALL) -> list[FileRow]

Every file the selected entries name, in the order written.

late
late(test: Any = ALL) -> list[Entry]

The selected entries written down late (Entry.is_late).

chronology
chronology(test: Any = ALL) -> list[ChronologyRow]

The selected entries in the order of their events (by event time, then by id), each with its time on the recorders' clock.

reading
reading(entry: Entry | int) -> LevelReading

Level row entry read against its test's header as it stood when the row was written: projected to full level (project), its volts per amp against the previous level of the run, and its readings against the last run of the same setup (the same level on the same axis, in an earlier run of the test or of a test of the same kind and configuration). What cannot be read reads not judged, with why.

Functions:

notch_in_plan

notch_in_plan(planned: Sequence[Mapping[str, Any]] | None, axis: str | None, fields: Mapping[str, Any]) -> tuple[bool, str]

Whether a notch with fields (its band, and its depth_db where given) on axis is in the planned list planned (a header's notches_planned), and why: on its axis (a planned notch with no axis is on every axis), its band inside the planned band, and its depth no deeper than the planned depth where the plan gives one. What RunLogModel.notch_planned judges a written notch by, and what an entry form shows before the notch is written. A typed planned mark is not what decides it.

full_level_factor

full_level_factor(level_db: float) -> float

The factor that takes a reading at level_db to full level: 10^(-L/20), with L in dB relative to full level (-12 for twelve below, which gives 3.98).

Refused with RunLogError: a level that is not a finite number, and a level above full (positive), which is not projected down.

parse_counter

parse_counter(text: Any) -> float

A controller's counter as seconds: '750', '750 s', '12:30' (minutes and seconds) or '1:02:30' (hours, minutes and seconds), with decimals on the seconds.

Refused with RunLogError naming the text: anything else, and minutes or seconds of 60 or more after the first part.

clock_text

clock_text(seconds: float) -> str

Seconds as the counter reads them: m:ss, or h:mm:ss from an hour, to the second.

project

project(level_db: float, *, voltage: float | None = None, current: float | None = None, drive_fraction: float | None = None, sigma: float | None = None, rated_current_peak: float | None = None, rated_current_rms: float | None = None, rail_voltage: float | None = None, drive_window: Sequence[float] | None = None) -> Projection

Readings at a level projected to full level, with the headroom checks.

Each reading is multiplied by full_level_factor (10^(-L/20), exactly). The drive fraction at full level is judged against its window; the rms current times sigma (the peak a random drive reaches, at the plan's sigma) against the peak current rating; the rms voltage times sigma against the rail; and, when the header gives a continuous rating, the rms current against it, which is what a sine test budgets.

Parameters:

Name Type Description Default
level_db float

The level the readings were taken at, in dB relative to full level: -12 for twelve below. Not above 0.

required
voltage float

The amplifier's rms voltage (V) and current (A) at the level.

None
current float

The amplifier's rms voltage (V) and current (A) at the level.

None
drive_fraction float

The drive as a fraction of its range, 0 to 1.

None
sigma float

The plan's peak-to-rms ratio of the drive.

None
rated_current_peak float

The amplifier's peak and continuous current ratings (A).

None
rated_current_rms float

The amplifier's peak and continuous current ratings (A).

None
rail_voltage float

The amplifier's rail, the peak voltage it can give (V).

None
drive_window (float, float)

The drive fraction's window at full level; DRIVE_WINDOW when not given.

None

Returns:

Type Description
Projection

The factor, the readings, and each check with its verdict. A check that cannot be made (a reading or a rating missing, or a reading of zero) reads "not judged", with why.

Raises:

Type Description
RunLogError

A level above full or not finite, a reading that is negative or not finite, a drive fraction above 1, a sigma or rating that is zero, and a window that is not two fractions low then high.

judge_pulses

judge_pulses(test: int, by_axis: Mapping[str | None, int], budget: int | None) -> PulseCount

The pulses counted by axis (by_axis) judged against budget, a test header's pulse_budget: what RunLogModel.pulses reports, and what a shot form shows with the shot being typed counted in.

admit

admit(log: RunLog | RunLogModel, kind: str, test: int | None) -> None

Refuse an entry of kind for test that the test's state does not take, with RunLogError naming the test and its state: a run entry with no test, any entry for a test never opened, a run entry for a test closed to runs, and a run, finding or header change for a released test. A test is opened with open_test or roll, and closed with close_test.

append

append(log: RunLog, kind: str, *, author: str, test: int | None = None, **kwargs: Any) -> Entry

RunLog.append, refused first when the test's state does not take the entry (admit).

open_test

open_test(log: RunLog, *, author: str, test_kind: str, header: Mapping[str, Any] | None = None, text: str = '', event_time: datetime | None = None, files: Iterable[Any] = ()) -> Entry

Open the log's next test, when no test is open to runs.

Parameters:

Name Type Description Default
log RunLog

The log, open for writing.

required
author str

The author's typed initials.

required
test_kind str

One of TEST_KINDS.

required
header mapping

The header's fields (run_log.HEADER_FIELDS).

None
text str

Free text.

''
event_time datetime

When it was opened, with its zone; now, if not given.

None
files iterable

Files the header attaches (the plan, the procedure, the profile), each a path or a FileRef.

()

Returns:

Type Description
Entry

The test opened entry.

Raises:

Type Description
RunLogError

When a test is open (roll to the next instead), the kind is not one of TEST_KINDS, or a header field is refused.

roll

roll(log: RunLog, *, author: str, test_kind: str | None = None, header: Mapping[str, Any] | None = None, reason: str = '', text: str = '', event_time: datetime | None = None, files: Iterable[Any] = ()) -> tuple[Entry, Entry]

Close the current test to runs and open the next, its header carried from the current one.

Every field of the current header not given in header (nor the kind, when test_kind is given) is carried, and marked carried until it is confirmed (confirm) or changed (change_header). The current test still takes findings, post-test steps and dispositions until its release entry; its release checklist is owed.

Parameters:

Name Type Description Default
log RunLog

The log, open for writing.

required
author str

The author's typed initials.

required
test_kind str

The next test's kind; carried when not given.

None
header mapping

The next test's header fields that differ, or are confirmed.

None
reason str

Why the current test closes; 'rolled to test N' when not given.

''
text str

Free text on the next test's opening.

''
event_time datetime

When, with its zone; now, if not given.

None
files iterable

Files the next test's header attaches.

()

Returns:

Type Description
(Entry, Entry)

The current test's closing and the next test's opening.

Raises:

Type Description
RunLogError

When no test is open, the kind is not one of TEST_KINDS, or a header field is refused; nothing is written then.

close_test

close_test(log: RunLog, test: int, *, author: str, reason: str = '', event_time: datetime | None = None) -> Entry

Close test test to runs without opening another. It still takes findings, post-test steps and dispositions until its release.

change_header

change_header(log: RunLog, test: int, field: str, value: Any, *, author: str, text: str = '', event_time: datetime | None = None) -> Entry

Change one field of test test's header, the value it had recorded beside the new one. A carried field changed is confirmed. Once the test is running, a change of a limit, tolerance, abort band, planned notch or hold point raises a hold until a deviation names it.

confirm

confirm(log: RunLog, test: int, names: Iterable[str] | None = None, *, author: str, event_time: datetime | None = None) -> list[Entry]

Confirm carried fields of test test as they stand (every carried field when names is None): a header change of each to its own value, which is a confirmation, not a change. Refused for a field that is not carried.

release

release(log: RunLog, test: int, *, author: str, text: str = '', event_time: datetime | None = None) -> Entry

Write test test's release, the release checklist's 'release' line: the article and facility released and the setup free to be broken. The names typed are recorded; the log tracks no signatures. Refused while the test is open to runs.