calamari.io#

File input for calamari: content-sniffing loader dispatch.

Public entry points:

  • load() – parse a file into a Measurement, auto-detecting the dialect by content (or forced with fmt=). 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.

UnsupportedFileError

Read fine; no loader’s signature matched. Register a loader for the format, or fix the file.

UnknownFormatError

fmt= named a loader that is not registered. A caller typo; the file was never read.

FileParseError

A 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

is_supported_file

Test whether an export can be loaded, including structural validation.

load

Parse a magnetometry file into a Measurement.

sniff_format

Return the detected dialect name for path, or None.

Modules

base

Loader abstract base class and content-sniffing registry.

quantum_design

Parse Quantum Design MPMS3 measurement exports.