Sample Logger¶
rfsoc_rfdc.sample_logger
¶
Classes¶
HDF5Logger
¶
logging using HDF5 format for efficient storage of large arrays.
Advantages: - Automatic chunking and compression - Partial read/write without loading entire file - Stores metadata alongside data - Industry standard format
Requires: h5py (pip install h5py)
Source code in rfsoc_rfdc/sample_logger.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
Functions¶
save(data, filename, add_timestamp=True, dataset_name='iq_samples', metadata=None)
¶
Save numpy array to HDF5 file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
Numpy array to save |
required |
filename
|
str
|
Output filename (without extension) |
required |
add_timestamp
|
bool
|
Whether to append timestamp to filename |
True
|
dataset_name
|
str
|
Name of dataset within HDF5 file |
'iq_samples'
|
metadata
|
Optional[dict]
|
Optional dictionary of metadata to store |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Path to saved HDF5 file |
Source code in rfsoc_rfdc/sample_logger.py
load(filename, dataset_name='iq_samples')
¶
Load numpy array from HDF5 file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
HDF5 file path |
required |
dataset_name
|
str
|
Name of dataset to load |
'iq_samples'
|
Returns:
| Type | Description |
|---|---|
tuple
|
Tuple of (data, metadata) |
Source code in rfsoc_rfdc/sample_logger.py
load_partial(filename, start, end, dataset_name='iq_samples')
¶
Load partial data from HDF5 file without loading entire array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
HDF5 file path |
required |
start
|
int
|
Start index |
required |
end
|
int
|
End index |
required |
dataset_name
|
str
|
Name of dataset to load |
'iq_samples'
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Partial numpy array |
Source code in rfsoc_rfdc/sample_logger.py
SampleLogger
¶
High-level interface for logging large IQ sample datasets using HDF5.
Supports async logging to avoid blocking data acquisition.
Source code in rfsoc_rfdc/sample_logger.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | |
Functions¶
save(data, filename, metadata=None, add_timestamp=True)
¶
Save IQ samples to disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
Numpy array of IQ samples |
required |
filename
|
str
|
Base filename or path (include channel ID in the name if needed) |
required |
metadata
|
Optional[dict]
|
Optional metadata dictionary |
None
|
add_timestamp
|
bool
|
Whether to append timestamp |
True
|
Returns:
| Type | Description |
|---|---|
str
|
Path to saved file/directory |
Source code in rfsoc_rfdc/sample_logger.py
wait_for_writes()
¶
Wait for all async write operations to complete.
Source code in rfsoc_rfdc/sample_logger.py
load(path, dataset_name='iq_samples')
¶
Load IQ samples from disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
File or directory path |
required |
dataset_name
|
str
|
Dataset name (HDF5 only) |
'iq_samples'
|
Returns:
| Type | Description |
|---|---|
|
Numpy array or tuple of (data, metadata) for HDF5 |
Source code in rfsoc_rfdc/sample_logger.py
Functions¶
save_to_file_chunked(data, filename)
¶
Convenience function to save large IQ samples using the HDF5 backend.
Kept for backward compatibility with older code that expected chunked numpy output, but now always writes HDF5 files for better performance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
Numpy array to save |
required |
filename
|
str
|
Base filename (without extension, include channel ID in name if needed) |
required |
Returns:
| Type | Description |
|---|---|
str
|
Path to saved file |