Results Saving
Manage data saving.
- mdacli.save.get_1D_arrays(results)[source]
Get items from dict which correspond to np.ndarrays one dim.
- mdacli.save.is_1d_array(arr, *, ndim=1)
Assert value is array and of certain dimension.
- mdacli.save.is_2d_array(arr, *, ndim=2)
Assert value is array and of certain dimension.
- mdacli.save.is_3d_array(arr, *, ndim=3)
Assert value is array and of certain dimension.
- mdacli.save.is_higher_dimension_array(arr, ndim)[source]
Assert value is array and of certain dimension.
- mdacli.save.return_with_remove(ddict, keys, remove)[source]
Serve all saving functions.
If remove is true, Returns subset of keys from dict. Removes keys subset from original dict.
Else, return None.
- mdacli.save.save(results, fprefix='mdacli_results')[source]
Save the attributes of a results instance to disk.
1D, 2D and 3D numpy arrays are saved to csv files. 1D arrays of the same length are vertically stacked to create a table. 2D arrays are saved directly. 3D arrays are split into 2D arrays along the shortest dimension and one CSV is saved for each 2D array created, and resulting CSVs are stored together in a ZIP file. Note: higher dimensional arrays are ignored.
We try to save everything else in a JSON file. Non-serializable types are ignored.
- Parameters:
fprefix (str) – prefix for all files saved
results (~MDAnalysis.analysis.base.Results) – A Results instance from which the stored data is taken.
- mdacli.save.save_1D_arrays(results, fprefix='1darray', remove=True)[source]
Save 1D arrays from results.
- Parameters:
results (dict-like) – Dictionary containing results.
remove (bool) – If true remove keys mapping to 1D numpy arrays.
- mdacli.save.save_3D_array_to_2D_csv(item, arr_name='arr', zipit=True)[source]
Save 3D array to 2D CSVs.
Has option to store all in a ZIP file.
- mdacli.save.save_Results_object(results, fprefix='results', remove=True)[source]
Save results if they are Results objects.
- mdacli.save.save_files_to_zip(files, zipname='thezip', remove=True)[source]
Compress all files into a single zip archive.
- Parameters:
files (list-like) – File names to save to the ZIP archive.
zipname (str) – The name of the zip file without extension.
remove (bool, option, default True) – Removes the original files.
- mdacli.save.save_higher_dim_arrays(results, fprefix='XDarr', remove=True, min_ndim=4)[source]
Save items of multidimensional arrays to CSV.
- mdacli.save.save_json_serializables(results, remove=True, **jsonargs)[source]
Save serializable items to a JSON.
- mdacli.save.save_result_array(arr, fprefix='prefix')[source]
Save array to disk accoring to num of dimensions.
- mdacli.save.save_to_json(json_dict, fname='jdict', indent=4, sort_keys=True)[source]
Save dictionary to JSON file.
- mdacli.save.savetxt_w_command(fname, X, header='', fsuffix='.csv', **kwargs)[source]
Save CSV data with info about execution command.
Adds the command line input to the header and checks for a doubled defined filesuffix.
- mdacli.save.stack_1d_arrays_list(list_1D, extra_list=None)[source]
Stack a list of 1D numpy arrays of the same length vertically together.
The result is a list containing 2D arrays where each array got the same number of rows.
- Parameters:
list_1d (list) – list of 1 dimensional numpy arrays
extra_list (list) – additional list of numpy arrays on which the operations are executed as for
list_1d
- Returns:
out_list (list) – list of stacked 2D numpy arrays organized by their length
out_extra (list) – list of stacked 2D numpy applied applied to the same operations as out_list