Skip to main content

cosmic-metrics

Per-observation quality metrics for NenuFAR Cosmic Dawn data. Read QUALITY statistics, calibration solutions, power spectra, horizon-filtered variance and optional GNSS ionosphere maps; inspect the resulting table, reject poor blocks and compute pspipe weights.

Documentation: Read the Docs

Cosmic Metrics object and data flow

How the objects work together explains the diagram.

Install

Requires Python 3.10+ and the NenuFAR processing stack (aoquality, ps_eor, pspipe), installed with it from PyPI:

python -m pip install cosmic-metrics
python -m pip install 'cosmic-metrics[report]'  # Optional interactive HTML report
python -m pip install 'cosmic-metrics[iono]'  # Optional spinifex map reader

From a checkout, use python -m pip install -e . with the same extras.

Python workflow

A Dataset contains observation blocks, named source readers and a managed raw cache. Metric objects define calculations. compute_metrics() returns an independent MetricTable containing scalars and observation metadata.

import cosmic_metrics as cm
from cosmic_metrics import metrics as m

dataset = cm.Dataset.from_toml('metrics.toml')
noise = m.RegionPower('dt_V', **m.REG_B)
phase = m.PhaseChange(120, source='solutions_l2a')
table = dataset.compute_metrics([noise, phase], n_workers=1)
print(table.df)
print(table.missing_reasons)

# Example threshold only; choose science cuts for your dataset.
selection = table.select_blocks([
    cm.Rule(phase.name, '>', 3, scale='mad'),
], missing='reject')
weights = table.compute_weights(noise.name, selection=selection)
table.save('metrics.csv')
selection.save('selection.json', weights=weights)

print(dataset.cache.inspect())
preview = dataset.cache.clear(stale_only=True, dry_run=True)

Adapt examples/nt04_l3.toml to your input paths and save it as metrics.toml. QUALITY and calibration templates are resolved per block; source names choose which reader a metric uses. All block times are UTC MJD seconds. Cache validity uses exact time bounds and dependency signatures. For scripts with n_workers > 1, use a main guard.

Prepare the expensive raw arrays using only the dataset TOML, without defining metrics:

cosmic-metrics cache populate metrics.toml --dry-run
cosmic-metrics cache populate metrics.toml
cosmic-metrics cache status metrics.toml

The example uses Slurm/libpipe; set [worker].nodes="localhost" for local population, or use SSH host names/ranges. The CLI accepts the same host and worker overrides as nenucal, for example --hosts localhost --max-concurrent 4. It runs in the foreground; use a persistent terminal session for unattended work. Use --slurm-nodes 4 to override the Slurm allocation size for one run while retaining the account, partition and other Slurm options from the TOML. Valid cache entries are skipped; use --force to rebuild them explicitly. [cache].require=true makes later notebook computations raise on missing/stale PS or variance entries. QUALITY and calibration remain uncached. Run population before the Python example when using that configuration. See cache preparation for worker settings, progress logs and resuming interrupted jobs.

Command-line workflow

The dataset TOML can also define the metrics ([[metrics]]), selection stages ([[selection]]) and an output directory, so that no Python is needed:

cosmic-metrics compute metrics.toml --dry-run   # list blocks and metric columns
cosmic-metrics compute metrics.toml             # metrics.csv
cosmic-metrics select metrics.toml              # selection.json
cosmic-metrics report metrics.toml              # interactive report.html

The report shows every metric against LST or date, with linked selection across metric panels, the profile of a selected block in all metrics and a night × LST grid. See the command-line guide.

For RFI checks in a specific frequency band, configure a variance source and compute m.BandVariance((67, 68)) or m.BandVarianceRatio((67, 68)). These reduce the horizon-filtered channel variance around 67–68 MHz; the ratio uses dt_V as its noise reference. See the band-variance guide for units, filtering and interpretation.

Documentation

Start with the complete synthetic example, which needs no input data. The guide and generated API reference cover the current implementation:

The earlier metrics prototype is retained on the eric-prototype branch.

Validate and build docs

python -m pip install -e '.[test,docs,report]'
python -m pytest
python -m ruff check src tests docs/conf.py
python -m sphinx -W --keep-going -b html docs docs/_build/html

Metadata

Release files for cosmic-metrics 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cosmic-metrics 0.1.2
File Size Uploaded Provenance Actions
cosmic_metrics-0.1.2.tar.gz 54.8 kB Without provenance Details for cosmic_metrics-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cosmic-metrics 0.1.2
File Interpreter ABI Platform Actions
cosmic_metrics-0.1.2-py3-none-any.whl Python 3 none any Details for cosmic_metrics-0.1.2-py3-none-any.whl

Total release size: 118.0 kB

Release files / cosmic_metrics-0.1.2.tar.gz

Download URL cosmic_metrics-0.1.2.tar.gz
Size 54.8 kB
Tags Source
SHA-256 checksum
How to use checksums
52d9617cc4255b73e95ea72d9c4f6cb383a44a0df5a326def0a29b26dc4ed403
BLAKE2b-256 checksum
How to use checksums
81659e3e353203924ab6f274c0d08f8bffe5515553d7b41bd39d4bab9581f21c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.14.4 Linux/7.0.0-38-generic

Release files / cosmic_metrics-0.1.2-py3-none-any.whl

Download URL cosmic_metrics-0.1.2-py3-none-any.whl
Size 63.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c3e627c454441cb19551fb13a36e322c63d1a0dd5349b80aa49dfa36181f3f05
BLAKE2b-256 checksum
How to use checksums
0fdc804fc799f7a6692b4ee370a7ca3e77433dc560d8bc5182ac7110fab4e4e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.14.4 Linux/7.0.0-38-generic

Security for cosmic-metrics 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page