nomad_camels_hdf5 package
Subpackages
Module contents
- class suitcase.nomad_camels_hdf5.FileManager(directory, new_file_each=True, file_extension=None)
Bases:
object
Class taken from suitcase-nxsas!
A class that manages multiple files.
- Parameters:
directory (str or Path) – The directory (as a string or as a Path) to create the files inside.
allowed_modes (Iterable) – Modes accepted by
MultiFileManager.open
. By default this is restricted to “exclusive creation” modes (‘x’, ‘xt’, ‘xb’) which raise an error if the file already exists. This choice of defaults is meant to protect the user for unintentionally overwriting old files. In situations where overwrite (‘w’, ‘wb’) or append (‘a’, ‘r+b’) are needed, they can be added here.libraries. (This design is inspired by Python's zipfile and tarfile)
- property artifacts
- close()
close all files opened by the manager
- open(relative_file_path, entry_name, mode, **open_file_kwargs)
- reserve_name(entry_name, relative_file_path)
- class suitcase.nomad_camels_hdf5.Serializer(directory, file_prefix='{uid}-', plot_data=None, new_file_each=True, do_nexus_output=False, **kwargs)
Bases:
DocumentRouter
Serialize a stream of documents to nomad_camels_hdf5.
Note
This can alternatively be used to write data to generic buffers rather than creating files on disk. See the documentation for the
directory
parameter below.- Parameters:
directory (string, Path, or Manager) –
For basic uses, this should be the path to the output directory given as a string or Path object. Use an empty string
''
to place files in the current working directory.In advanced applications, this may direct the serialized output to a memory buffer, network socket, or other writable buffer. It should be an instance of
suitcase.utils.MemoryBufferManager
andsuitcase.utils.MultiFileManager
or any object implementing that interface. See the suitcase documentation at https://nsls-ii.github.io/suitcase for details.file_prefix (str, optional) – The first part of the filename of the generated output files. This string may include templates as in
{proposal_id}-{sample_name}-
, which are populated from the RunStart document. The default value is{uid}-
which is guaranteed to be present and unique. A more descriptive value depends on the application and is therefore left to the user.**kwargs (kwargs) – Keyword arugments to be passed through to the underlying I/O library.
- artifacts
dict mapping the ‘labels’ to lists of file names (or, in general, whatever resources are produced by the Manager)
- property artifacts
- close()
Close all of the resources (e.g. files) allocated.
- descriptor(doc)
- event_page(doc)
- get_length_of_stream(stream_id)
- make_nexus_structure()
- start(doc)
- stop(doc)
- suitcase.nomad_camels_hdf5.clean_filename(filename)
cleans the filename from characters that are not allowed
- Parameters:
filename (str) – The filename to clean.
- suitcase.nomad_camels_hdf5.export(gen, directory, file_prefix='{uid}-', new_file_each=True, plot_data=None, **kwargs)
Export a stream of documents to nomad_camels_hdf5.
Note
This can alternatively be used to write data to generic buffers rather than creating files on disk. See the documentation for the
directory
parameter below.- Parameters:
gen (generator) – expected to yield
(name, document)
pairsdirectory (string, Path or Manager.) –
For basic uses, this should be the path to the output directory given as a string or Path object. Use an empty string
''
to place files in the current working directory.In advanced applications, this may direct the serialized output to a memory buffer, network socket, or other writable buffer. It should be an instance of
suitcase.utils.MemoryBufferManager
andsuitcase.utils.MultiFileManager
or any object implementing that interface. See the suitcase documentation at https://nsls-ii.github.io/suitcase for details.file_prefix (str, optional) – The first part of the filename of the generated output files. This string may include templates as in
{proposal_id}-{sample_name}-
, which are populated from the RunStart document. The default value is{uid}-
which is guaranteed to be present and unique. A more descriptive value depends on the application and is therefore left to the user.**kwargs (kwargs) – Keyword arugments to be passed through to the underlying I/O library.
- Returns:
artifacts – dict mapping the ‘labels’ to lists of file names (or, in general, whatever resources are produced by the Manager)
- Return type:
dict
Examples
Generate files with unique-identifier names in the current directory.
>>> export(gen, '')
Generate files with more readable metadata in the file names.
>>> export(gen, '', '{plan_name}-{motors}-')
Include the measurement’s start time formatted as YYYY-MM-DD_HH-MM.
>>> export(gen, '', '{time:%Y-%m-%d_%H:%M}-')
Place the files in a different directory, such as on a mounted USB stick.
>>> export(gen, '/path/to/my_usb_stick')
- suitcase.nomad_camels_hdf5.get_param_dict(param_values)
- Parameters:
param_values
- suitcase.nomad_camels_hdf5.recourse_entry_dict(entry, metadata)
Recoursively makes the metadata to a dictionary.
- Parameters:
entry
metadata
- suitcase.nomad_camels_hdf5.sort_by_list(sort_list, other_lists)
- Parameters:
sort_list
other_lists
- suitcase.nomad_camels_hdf5.timestamp_to_ISO8601(timestamp)
- Parameters:
timestamp