calamari.io#
File input for calamari: content-sniffing loader dispatch.
Public entry points:
load()– parse a file into aMeasurement, auto-detecting the dialect by content (or forced withfmt=). Raises rather than guessing when nothing recognises the file.sniff_format()– report the detected dialect without parsing.is_supported_file()– boolean probe that parses and validates the export.
The built-in MPMS3 loader registers
themselves when calamari.io.quantum_design is imported, which
happens here at package import, so they are available as soon as
calamari.io is imported. New instrument formats register the same
way; nothing here is MPMS-specific beyond that import.
Strictness (IO-5)#
load() returns a Measurement only for a
file some registered loader actually claims. There is no best-effort
“parse it anyway” fallback and no data_format='unknown' outcome: a file
calamari does not recognise is an error, not a half-parsed object that
downstream code has to keep re-checking. The four ways a file can fail to
load are kept distinct, because they call for different fixes:
OSError(FileNotFoundError,IsADirectoryError,PermissionError)The file could not be read at all – wrong path, a directory, no permission.
UnsupportedFileErrorRead fine; no loader’s signature matched. Register a loader for the format, or fix the file.
UnknownFormatErrorfmt=named a loader that is not registered. A caller typo; the file was never read.FileParseErrorA recognised export has malformed structure. Re-export the complete file.
To test for supportedness instead of handling an exception – the right
shape for a directory walk over mixed content – use
is_supported_file(), which never raises. Catalogue discovery uses signature
recognition so that malformed recognised exports can be recorded as parse errors.
Functions
Test whether an export can be loaded, including structural validation. |
|
Parse a magnetometry file into a |
|
Return the detected dialect name for |
Modules
Loader abstract base class and content-sniffing registry. |
|
Parse Quantum Design MPMS3 measurement exports. |