README.md
Project description
grdb
A Python library for creating and managing SQLite databases of THz pulse measurement data.
Installation
pip install grdb
Examples
Loading Pulses
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file grdb-0.10.0.tar.gz.
File metadata
- Download URL: grdb-0.10.0.tar.gz
- Upload date:
- Size: 24.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8294940df87e90142f7a67b6ef55ef0612d74bc9701cb23bca2362e98b97a1d6
|
|
| MD5 |
7b60f9c1228c6222f64a7d5fe2148f89
|
|
| BLAKE2b-256 |
e6e0e2f6e66a2eee0228c9f5305b90daeea5320f02176a2787cbdb62e456b1b4
|
File details
Details for the file grdb-0.10.0-py3-none-any.whl.
File metadata
- Download URL: grdb-0.10.0-py3-none-any.whl
- Upload date:
- Size: 19.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70ef60ff72387a9873c4a512f687b0caccd0d60198296e688596e87f2d465d66
|
|
| MD5 |
5efb6e8beaa6d025b326208c4dc6f036
|
|
| BLAKE2b-256 |
cc37011947faf4effc1a39a0e2c9b9a969b6ebab2373990e95d8bc7904f1ef07
|