Configuration
pyngb.PatternConfig
dataclass
Configuration for metadata and column patterns.
This class defines the binary patterns used to locate and extract specific metadata fields, temperature program data, calibration constants, and data columns from NGB files.
The patterns are defined as tuples of (category_bytes, field_bytes) that are used to construct regex patterns for finding specific data fields in the binary stream.
Attributes:
Name | Type | Description |
---|---|---|
metadata_patterns |
dict[str, tuple[bytes, bytes]]
|
Maps field names to (category, field) byte patterns |
temp_prog_patterns |
dict[str, bytes]
|
Patterns for temperature program extraction |
cal_constants_patterns |
dict[str, bytes]
|
Patterns for calibration constant extraction |
column_map |
dict[str, str]
|
Maps hex column IDs to human-readable column names |
Example
config = PatternConfig() config.column_map["8d"] = "time" config.metadata_patterns["sample_id"] = (b"\x30\x75", b"\x98\x08")
Note
Modifying these patterns may break compatibility with certain NGB file versions. Use caution when customizing.
Source code in src/pyngb/constants.py
120 121 122 123 124 125 126 127 128 129 130 131 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 |
|
pyngb.BinaryMarkers
dataclass
Binary markers for parsing NGB files.
These byte sequences mark important boundaries and structures within the binary NGB file format. They are used to locate data sections, separate tables, and identify data types.
Attributes:
Name | Type | Description |
---|---|---|
END_FIELD |
bytes
|
Marks the end of a data field |
TYPE_PREFIX |
bytes
|
Precedes data type identifier |
TYPE_SEPARATOR |
bytes
|
Separates type from value data |
END_TABLE |
bytes
|
Marks the end of a table |
TABLE_SEPARATOR |
bytes
|
Separates individual tables in a stream |
START_DATA |
bytes
|
Marks the beginning of data payload |
END_DATA |
bytes
|
Marks the end of data payload |