grdb
A Python library for creating and managing SQLite databases of THz pulse measurement data.
Installation
pip install grdb
Examples
Loading Pulses
Stream every pulse in bounded batches:
from pathlib import Path
from grdb import iter_pulse_batches
db_path = Path("raster.grf")
batches = iter_pulse_batches(db_path, batch_size=256)
first_batch = next(batches)
iter_pulse_batches returns final pulses in persisted insertion order, excludes
source-only composition rows, and reconstructs stitched and averaged lineage.
Use it instead of repeated load_pulses calls when traversing a complete file.
Load sample pulses:
from pathlib import Path
from grdb import load_pulses
db_path = Path("raster.grf")
# Load first 100 sample pulses
samples = load_pulses(db_path, offset=0, limit=100, variant="sample")
Load reference pulses:
from pathlib import Path
from grdb import load_pulses
db_path = Path("raster.grf")
# Load first 50 reference pulses
references = load_pulses(db_path, offset=0, limit=50, variant="reference")
Load all pulses (both samples and references):
from pathlib import Path
from grdb import load_pulses
db_path = Path("raster.grf")
# Load all pulse types (variant=None)
all_pulses = load_pulses(db_path, offset=0, limit=1000, variant=None)
Loading Metadata
from pathlib import Path
from grdb import load_metadata
db_path = Path("raster.grf")
raster_config, device_metadata, raster_metadata, n_refs, n_samples = load_metadata(db_path)
raster_config: Acquisition settings such as rasterpatterns, scanstepsize, optionalreference_point, how often toacquire_ref_every, and any multi-passrepetitions_config.device_metadata: Instrument identifiers including the serial number and firmware version captured at acquisition time.raster_metadata: Session-level context like the GRDB app version, optionalraster_id, acquisitiontimestamp, user-suppliedannotations, rawdevice_configuration, and any saved coordinate transform inuser_coordinates.user_coordinates(withinraster_metadata): ACoordinateTransformthat captures how user coordinates map to machine space, including the UUID andnameof the transform, the XYZoffsetapplied, the axis/sign remapping inmapping, thelast_usedtimestamp, and optional operatornotes.n_refsandn_samples: Counts of final reference and sample pulses stored in the database (stitched sources are excluded so the numbers reflect the user-facing traces).
Understanding the Measurement Data Structure
The load_pulses function returns a list of Measurement objects. Each Measurement represents a single pulse measurement with its associated metadata and spatial information.
Measurement Fields
A Measurement object contains the following fields:
-
pulse(Trace): The actual pulse data containing:time(list[float]): Time values for the pulse waveformsignal(list[float]): Signal amplitude values corresponding to each time pointuuid(UUID): Unique identifier for this pulsetimestamp(int): Unix timestamp in milliseconds when the pulse was acquiredderived_from(list[PulseComposition] | None): If this pulse was created by stitching multiple pulses together, this contains information about the source pulsesaveraged_from(list[Trace] | None): If this pulse was created by averaging multiple pulses, this lists the contributing source traces (which may themselves be stitched)
-
point(Point3D): The 3D spatial coordinates where this pulse was measured:x(float | None): X coordinatey(float | None): Y coordinatez(float | None): Z coordinate
-
variant(str): The type of measurement, one of:"reference": Reference measurement taken at a known location"sample": Sample measurement taken on the object being scanned"noise": Noise measurement for baseline correction"other": Other types of measurements
-
reference(UUID | None): If this is a sample measurement, this field may contain the UUID of the associated reference pulse -
annotations(list[KVPair] | None): Optional key-value pairs for additional metadata
Example: Accessing Measurement Data
from pathlib import Path
from grdb import load_pulses
db_path = Path("raster.grf")
# Load sample pulses
samples = load_pulses(db_path, offset=0, limit=10, variant="sample")
# Access the first measurement
first_measurement = samples[0]
# Access pulse waveform data
time_values = first_measurement.pulse.time
signal_values = first_measurement.pulse.signal
# Access spatial coordinates
x_position = first_measurement.point.x
y_position = first_measurement.point.y
z_position = first_measurement.point.z
# Check the measurement type
measurement_type = first_measurement.variant
# Get the pulse UUID
pulse_id = first_measurement.pulse.uuid
Metadata
Release files for grdb 0.12.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| grdb-0.12.0.tar.gz | 28.1 kB | Without provenance | Details for grdb-0.12.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| grdb-0.12.0-py3-none-any.whl | Python 3 | none | any | Details for grdb-0.12.0-py3-none-any.whl |
Total release size: 48.9 kB
Release files / grdb-0.12.0.tar.gz
| Download URL | grdb-0.12.0.tar.gz |
|---|---|
| Size | 28.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e262dc36d2d9084c59c6635e3abab1a33e5eaa4c28192f14b2fa12d66c7de197
|
|
BLAKE2b-256 checksum How to use checksums |
ab38f3574ec3f75ff6fc00a291d4747a97bb3297529ecb38750103bfa3569782
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.19
|
Release files / grdb-0.12.0-py3-none-any.whl
| Download URL | grdb-0.12.0-py3-none-any.whl |
|---|---|
| Size | 20.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ac9e82e2f09dd9afd45ff2593447507b12c9c27af55f82fffb93e99ede3aab7b
|
|
BLAKE2b-256 checksum How to use checksums |
ef8609b114172cca24c9421cc13a26287e5421330cb6a0fe88b511d78245a182
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.19
|
Security for grdb 0.12.0
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.