File Handling Functions¶
- pycube.fileop.convert.par_convert()¶
Convert files to Cube h5 format.
Only equally spaced x axes are currently supported.
- Cube Parameters:
task_source (str): name of the source task with files to convert in the ‘results’ folder
task_target (str, optional): name of the target task, defaults to current task
filetype: type of input file, see log for supported types.
parallel (bool, optional): perform parallel file conversion, default True
Note
When running the conversion in parallel, no other Cube tasks should run in parallel: A divider should be inserted before and after the convert task.
Note
The signal names in the source files must not contain a ‘/’.
- pycube.fileop.h5.par_h5_merge()¶
Collect h5 from the results folders of the workflow and merge them into one final h5.
Default: if there are n files name1, name2, … per folder, files will be merged by name, creating n target files of name1, name2 etc.
- Copies all attributes and datasets
existing attributes will be overwritten
existing datasets will not be copied and generate a warning
- Cube Parameters:
h5_filename (str, optional): name of the resulting h5 file when merging all files within a folder. ‘.h5’ will be added automatically. If empty, the name of the first h5 to be merged will be used
task_target (str, optional): name of the target task, defaults to current task
task_source_list (list(str)): name(s) of the source task(s) with files to be merged
delete_source (bool, optional): delete source files after merge
h5_group_list (list(str), optional): when use_groups is active: list with group names whenmerging files of identical content from multiple folders, must be of the same length as task_source_list. If empty the task names are used as group names instead.
single_targetfile (bool, optional): merge all h5 from source task into a single target file. Within the target file, groups for each source will be created based on the file names of the source files
use_groups (bool): when merging over multiple folders, create a group for each source within the target file. Group names are either given by h5_group_list or if empty the source task names are used instead
- pycube.fileop.h5.par_h5_export()¶
- Export a list of signals from Cube h5 file
if signal list is empty, all channels are exported
if “csv” is selected each channel is stored into a separate file
mat conversion does not save unit information to the mat file
- Cube Parameters:
task_source (str): name of the source task, with h5 file with the pressure signals in the subfolder ‘results’
task_target (str, optional): name of the target task, defaults to current task, results are saved in a file of the same name as the source h5
signals (list(str), optional): List of signals to be converted. All signals of the source will be converted if empty or omitted.
filetype (str): type of export file (currently Cube ‘h5’, ‘csv’, ‘pkl’ and Matlab ‘mat’ only)
single_targetfile (bool, optional): determines whether signals are stored in separate files or in one possibly very large file. Default is False. (currently ‘pkl’ and ‘csv’ only)
explicit (str, optional): force explicit export by setting to ‘compound’. (Data are stored in numpy structured array style.)
x_interval (list(float), optional): export data only in the given x interval (e.g. time interval), defaults to empty list for no x interval limit. A third optional value defines the start value for x in the returned interval.
- pycube.fileop.tools.par_zip_results()¶
zip file of the results folders of the tasks listed in task_source_list to a zip file in the target task’s result folder
- Cube Parameters:
task_source_list (list[str]): list of the source tasks
task_target (str, optional): name of the target task, defaults to current task
target_filename (str, optional) = ‘results.zip’: name of the target zip file
- pycube.fileop.pivot_table.par_pivot_table()¶
Generate a pivot table from a pandas data frame that was previously stored as Excel file.
- Cube Parameters:
task_source (str): name of the source task with h5 files in the ‘results’ folder
task_target (str, optional): name of the target task, defaults to current task
row_names (list[str]): list with row names, pivot table will be created in that order
column_names (list[str]): list with column names, pivot table will be created in that order
sorting_value_names (list[str]): list with value names, that will be sorted as pivot table
aggregation_function (str, optional): Aggregate function in case there are more than one values for same inputs. Defaults to ‘max’
- Optional parameter to style the table image:
plot_png (bool, optional): determines whether a png image of the dataframe is generated. Default is False. If set True, but no other optional parameter is set, a png image with white background is generated
color_map (str, optional): name of the Python color map used. Set ‘’ for no background color
color_axis (str, optional): determines the type of color coding. None = global color coding, 0 = coding per column, 1 = coding per row
decimal_places (int, optional): number of visualized digits. Set -1 for no rounding
color_NaN (str, optional): color to highlight NaN values. Set ‘’ for no highlighting
color_min (str, optional): color to highlight minimum values. Set ‘’ for no highlighting
min_color_axis (str, optional): determines the type of color coding. None = global color coding, 0 = coding per column, 1 = coding per row
color_max (str, optional): color to highlight maximum values. Set ‘’ for no highlighting
max_color_axis (str, optional): determines the type of color coding. None = global color coding, 0 = coding per column, 1 = coding per row