finesse.utilities.storage module

Methods for saving outputs to files.

Currently just uses pickles until HDF is working.

finesse.utilities.storage.create_object_dataset(grp, key, obj)[source]
finesse.utilities.storage.dict_to_json(d)[source]
finesse.utilities.storage.dump_solution_hdf(sol, filename)[source]
finesse.utilities.storage.load(filename, format=None)[source]
finesse.utilities.storage.load_solution_hdf(filename)[source]
finesse.utilities.storage.np_dtype_from_json(data)[source]
finesse.utilities.storage.np_dtype_to_json(dtype)[source]

Converts a numpy dtype into a json string format.

finesse.utilities.storage.object_to_hdf(obj)[source]
finesse.utilities.storage.save(obj, filename, format=None)[source]

Saves a Finesse solution object to a file. Two options are available: HDF5 and Pickle.

Parameters

objSolution

Solution object generated by a Finesse simulation

filenamestr

A path and filename to save the output. If the path does not exist it will be created.

formatstr, optional

For HDF files use one of “.h5”, “.hdf5”, “.hdf” or pickle files use one of “.pkl”, “.pickle”. If None then the extension of the filename is used.

finesse.utilities.storage.str_array_to_hdf(s)[source]
finesse.utilities.storage.to_generic_hdf(obj, grp)[source]

Used to convert a generic Python class into a HDF group.

Scalar values (as determined by np.isscalar) are added as HDF group attributes. This includes class attributes that are int, float, strings, etc. Attributes that are representable with a numpy array are written as datasets within the group. Any attribute that does not fit in the above will be pickled and added as a byte stream dataset.

finesse.utilities.storage.type_from_json(data)[source]
finesse.utilities.storage.type_to_json(_type)[source]