necst.web.observation_log¶
Operator-facing observation CSV log for the NECST console.
This log is intentionally separate from the internal operator JSONL log. The CSV is compact and append-only for observers and later analysis; the JSON sidecar keeps session/environment metadata out of each CSV row.
- resolve_log_dir(configured_dir=None, *, site_configured_dir=None, record_roots=None)[source]¶
Return
(directory, source, record_root, warnings).Directory selection order: 1. explicit argument, usually CLI
--obslog-dir; 2.NECST_OBSLOG_DIR; 3. site TOML[console.observation_log].directory; 4.<record root>/obslogsfrom explicit/site/env record-root candidates; 5.~/.necst/observation_logs.- Parameters:
configured_dir (Optional[Union[PathLike[str], str]]) –
site_configured_dir (Optional[Union[PathLike[str], str]]) –
record_roots (Optional[List[os.PathLike[str] | str]]) –
- Return type:
Tuple[Path, str, Optional[str], List[str]]
- obsfile_name_for_csv(value)[source]¶
Return the observation-instruction filename to store in action_or_obsfile.
- Parameters:
value (Any) –
- Return type:
str
- record_dir_name_for_csv(value)[source]¶
Return the final record-directory component to store in record_dir.
- Parameters:
value (Any) –
- Return type:
str
- select_weather(weather)[source]¶
Return temp_C, humidity_pct, pressure_hPa, source.
Prefer outside weather. If outside data are unavailable, fall back to inside weather. NECST WeatherMsg humidity is normally a 0–1 fraction, but the CSV column is explicitly percent, so fractions are normalized here.
- Parameters:
weather (Mapping[str, Any]) –
- Return type:
Tuple[str, str, str, str]
- class ObservationLogManager(log_dir, log_dir_source, record_root=None, prefix='obslog', observer='User', telescope='NECST', directory_warnings=<factory>)[source]¶
Bases:
objectAppend-only observer CSV log with a JSON metadata sidecar.
- Parameters:
log_dir (Path) –
log_dir_source (str) –
record_root (Optional[str]) –
prefix (str) –
observer (str) –
telescope (str) –
directory_warnings (List[str]) –
- log_dir: Path¶
- log_dir_source: str¶
- record_root: Optional[str] = None¶
- prefix: str = 'obslog'¶
- observer: str = 'User'¶
- telescope: str = 'NECST'¶
- directory_warnings: List[str]¶
- session_id: str¶
- created_utc: str¶
- csv_path: Path¶
- meta_path: Path¶
- row_id: int = 0¶
- closed_utc: Optional[str] = None¶
- last_rows: List[Dict[str, Any]]¶
- last_error: str = ''¶
- classmethod create(*, configured_dir=None, site_configured_dir=None, record_roots=None, prefix='obslog', observer='User', telescope='NECST')[source]¶
- Parameters:
configured_dir (Optional[Union[PathLike[str], str]]) –
site_configured_dir (Optional[Union[PathLike[str], str]]) –
record_roots (Optional[List[os.PathLike[str] | str]]) –
prefix (Any) –
observer (Any) –
telescope (str) –
- Return type:
- open_new(*, prefix=None, observer=None, initial=False, created=None)[source]¶
- Parameters:
prefix (Any) –
observer (Any) –
initial (bool) –
created (Optional[datetime]) –
- Return type:
None
- open_existing(path_text, *, observer=None)[source]¶
- Parameters:
path_text (Any) –
observer (Any) –
- Return type:
None
- write_event(context, *, comment='', mode='Console', event='event', action_or_obsfile='', result='unknown', record_dir=None)[source]¶
- Parameters:
context (Mapping[str, Any]) –
comment (Any) –
mode (Any) –
event (Any) –
action_or_obsfile (Any) –
result (Any) –
record_dir (Optional[Any]) –
- Return type:
bool