adamspy.postprocess package¶
Subpackages¶
Submodules¶
adamspy.postprocess.animation module¶
Code for generating animations automatically in Adams View
- 
adamspy.postprocess.animation.create_animation(model_file: str, res_file: str, model_name: str, analysis_name: str, timeout=60)[source]¶
- Creates an animation from the given model. - Parameters: - model_file (str) – Adams View model (.cmd) file
- res_file (str) – Adams results (.res) file
- model_name (str) – Name of the model
- analysis_name (str) – Name of the analysis
- wait (bool, optional) – If True, code execution will freeze until the animation script completes and the postprocessor closes. (the default is True)
 
adamspy.postprocess.exported module¶
- 
adamspy.postprocess.exported.import_spreadsheet(filename, output_type='dict')[source]¶
- Reads data from a file generated in Adams View using File>Export>Spreadsheet. - Parameters: - Returns: - Pandas :obj:Dataframe if output_type is ‘DataFrame’ or :obj:dict if output_type is ‘dict’ - Return type: - DataFrame or dict 
adamspy.postprocess.mode_tables module¶
- 
class adamspy.postprocess.mode_tables.Modal(modes: Dict[int, adamspy.postprocess.mode_tables.Mode])[source]¶
- Bases: - object- 
get_modes_where_parts_participate(part_suffix, table, column, threshold=0.9, sum_or_max='max')[source]¶
- Returns a dictionary where the keys are mode numbers and the values are :obj:Mode objects in which any part with the suffix part_suffix has at least threshold percent of the total. - Parameters: - part_suffix (str) – Suffix of parts to check for
- table (str) – Table type. Options are ‘coords’, ‘kinetic_energy’, ‘strain_energy’, ‘dissipative_energy’
- column (str) – Column name from the table
- threshold (float) – Part’s value must be greater than threshold multiplied the sum or max (depending on sum_or_max value) of the column in the table to be considered participating
- sum_or_max (str) – Must be ‘sum’ or ‘max’
 - Returns: - Dictionary where the keys are mode numbers and the values are :obj:Mode objects - Return type: 
 
- 
adamspy.postprocess.msg module¶
This module contains tools for extracing data from the message file.
- 
adamspy.postprocess.msg.get_modes(filename, output_type='dict', i_analysis=0, underdamped_only=True, sort_by_wn=True)[source]¶
- Gets the modes from an Adams Solver message file. - Parameters: - filename (str) – Name of Adams Solver message (.msg) file.
- output_type (str, optional) – If ‘DataFrame’, returns a pandas :obj:pd.DataFrame if ‘dict’, returns a :obj:dict. (Default is ‘dict’)
- i_analysis (int, (optional)) – If the Adams Solver message (.msg) file contains multiple eigensolutions, this specifies which one to get. (Default is 0 which takes the first analysis)
 - Returns: - ` – Table of modes - Return type: - obj:pd.DataFrame` or :obj:dict 
- 
adamspy.postprocess.msg.get_process_id(filename: pathlib.Path)[source]¶
- Returns the process ID of the Adams job that generated the given message file. - Parameters: - filename (Path) – Path to the message file. - Returns: - Process ID of the Adams job that generated the given message file. - Return type: - int 
- 
adamspy.postprocess.msg.get_runtime_summary(filename)[source]¶
- Returns a list of timestamps from the Adams message (.msg) file. Each timestamp in the list is a list as follows [elapsed time, cpu time, percent speedup] - Parameters: - filename (str) – Filename of message file - Returns: - List of timestamps where each timestamp in the list is a list as follows [elapsed time, cpu time, percent speedup]. - Return type: - list 
- 
adamspy.postprocess.msg.get_timestamps(filename)[source]¶
- Returns a list of timestamps from the Adams message (.msg) file. Each timestamp in the list is a list as follows [simulation time, step size, Function evaluations, cumulative steps taken, integration order, simulation time] - Parameters: - filename (str) – Filename of message file - Returns: - List of timestamps where each timestamp in the list is a list as follows [simulation time, step size, Function evaluations, cumulative steps taken, integration order, simulation time]. - Return type: - list 
adamspy.postprocess.ppt module¶
This module is for sending scripts through Adams/PPT
- 
adamspy.postprocess.ppt.edit_results(res_file, input_dict, new_res_file=None, _just_write_script=False, timeout=300)[source]¶
- 
adamspy.postprocess.ppt.filter_results(res_file, reqs_to_clean, freq_cutoff, N_filter=5, reqs_to_check=None, t_min=None, t_max=None, _just_write_script=False, timeout=300, _inplace=False, return_raw=False)[source]¶
- Similar to manually_remove_spikes, but allows user to plot the signals in batches. Instead of passing a dictionary for the reqs_to_check argument, pass a list of dictionaries and the results in each dictionary in the list will be plotted together. - Parameters: - res_file (str) – Adams Results (.res) filename
- reqs_to_clean (dict) – Nested dictionary of result sets and result components to clean
- freq_cutoff (float) – Cutoff freqency of filter in Hz
- N_filter (int) – Order of filter
- reqs_to_check (list of dicts) – list of nested dictionary of result sets and result components to check for spikes, by default same as reqs_to_clean
- t_min (float, optional) – Minumum simulation time to clean, by default None
- t_max (float, optional) – Maximum simulation time to clean, by default None
- timeout (float, optional) – Number of seconds to wait for results to load before timing out, by default _TIMEOUT
 - Returns: - Nested dictionary of cleaned results - Return type: 
- 
adamspy.postprocess.ppt.get_lunar_results(res_files, reqs_to_get, t_min, t_max, output_file, _just_write_script=False, timeout=300)[source]¶
- 
adamspy.postprocess.ppt.get_results(res_file, reqs_to_get, t_min=None, t_max=None, _just_write_script=False, timeout=300)[source]¶
- Gets results from an Adams results (.res) file. - Example - >>> result_file = 'example.res' >>> t_min = 70 >>> t_max = 80 >>> reqs_to_get = {} >>> reqs_to_get['MSE'] = ['Instantaneous_Bottom_MSE', 'Filtered_Surface_MSE'] >>> reqs_to_get['ROP_controls'] = ['Command_ROP', 'True_WOB'] >>> requests, units = get_results(result_file, reqs_to_get, t_min, t_max) - Note - This funciton only works with Requests. It does not work with Result Sets. - Note - This function only works with xml results files. - Parameters: - result_file (str) – Filename of an Adams results (.res) file
- reqs_to_get (dict) – Dictionary of requests to extract (the default is None, which gets all results)
- t_min (float, optional) – Minimum time for which to extract results (the default is None)
- t_max (float, optional) – Maximum time for which to extract results (the default is None)
 - Returns: - Dictionary of request data - Return type: 
- 
adamspy.postprocess.ppt.manually_remove_spikes(res_file, reqs_to_clean, reqs_to_check=None, t_min=None, t_max=None, _just_write_script=False, timeout=300, _inplace=False)[source]¶
- Allows the user to manually scan through the result sets to pick out points to eliminate. - Parameters: - res_file (str) – Adams Results (.res) filename
- reqs_to_clean (dict, optional) – Nested dictionary of result sets and result components to clean
- reqs_to_check (dict) – Nested dictionary of result sets and result components to check for spikes, by default same as reqs_to_clean
- t_min (float, optional) – Minumum simulation time to clean, by default None
- t_max (float, optional) – Maximum simulation time to clean, by default None
- timeout (float, optional) – Number of seconds to wait for results to load before timing out, by default _TIMEOUT
 - Returns: - Nested dictionary of cleaned results - Return type: 
- 
adamspy.postprocess.ppt.manually_remove_spikes_batch(res_file, reqs_to_clean, reqs_to_check=None, t_min=None, t_max=None, _just_write_script=False, timeout=300, _inplace=False)[source]¶
- Similar to manually_remove_spikes, but allows user to plot the signals in batches. Instead of passing a dictionary for the reqs_to_check argument, pass a list of dictionaries and the results in each dictionary in the list will be plotted together. - Parameters: - res_file (str) – Adams Results (.res) filename
- reqs_to_clean (dict) – Nested dictionary of result sets and result components to clean
- reqs_to_check (list of dicts) – list of nested dictionary of result sets and result components to check for spikes, by default same as reqs_to_clean
- t_min (float, optional) – Minumum simulation time to clean, by default None
- t_max (float, optional) – Maximum simulation time to clean, by default None
- timeout (float, optional) – Number of seconds to wait for results to load before timing out, by default _TIMEOUT
 - Returns: - Nested dictionary of cleaned results - Return type: 
adamspy.postprocess.xml module¶
- 
adamspy.postprocess.xml.get_component(res_file, comp_name)[source]¶
- Returns the numeric data in res_file associated with the result component comp_name. - Parameters: - Returns: - List of values from the result (.res) file. - Return type: - Raises: - ValueError– Raised if comp_name not found in res_file.
- 
adamspy.postprocess.xml.get_results(result_file, reqs_to_get=None, t_min=None, t_max=None, return_units=False, overwrite_pickle=True, use_iterparse=False)[source]¶
- Gets results from an Adams results (.res) file. - Example - >>> result_file = 'example.res' >>> t_min = 70 >>> t_max = 80 >>> reqs_to_get = {} >>> reqs_to_get['MSE'] = ['Instantaneous_Bottom_MSE', 'Filtered_Surface_MSE'] >>> reqs_to_get['ROP_controls'] = ['Command_ROP', 'True_WOB'] >>> requests, units = get_results(result_file, reqs_to_get, t_min, t_max) - Note - This funciton only works with Requests. It does not work with Result Sets. - Note - This function only works with xml results files. - Parameters: - result_file (str) – Filename of an Adams results (.res) file
- reqs_to_get (dict) – Dictionary of requests to extract (the default is None, which gets all results)
- t_min (float, optional) – Minimum time for which to extract results (the default is None)
- t_max (float, optional) – Maximum time for which to extract results (the default is None)
 - Returns: - dict – Dictionary of request data
- dict – Dictionary defining units for each request. NOTE: This is only returned if return_units=True
 
- 
adamspy.postprocess.xml.get_stepmap_dictionary(file_name)[source]¶
- Create dictionary where keys are result names and values are indices of components. - Note - Res names must be full, like: * time.time * part_2_xform.fx * part_3_xform.accy - Parameters: - file_name (str) – Results (.res) file - Returns: - Step map - Return type: - dict 
- 
adamspy.postprocess.xml.shrink_results(result_file, reqs_to_keep=None, t_min=None, t_max=None, new_result_file=None, in_place=False)[source]¶
- Shrinks a results file by eliminating unwanted data. - Example - >>> result_file = 'example.res' >>> t_min = 70 >>> t_max = 80 >>> reqs_to_keep = {} >>> reqs_to_keep['MSE'] = ['Instantaneous_Bottom_MSE', 'Filtered_Surface_MSE'] >>> reqs_to_keep['ROP_controls'] = ['Command_ROP', 'True_WOB'] >>> shrink_results(result_file, reqs_to_keep, t_min, t_max) - Note - This funciton only works with Requests. It does not work with Result Sets. - Parameters: - result_file (str) – Filename of the results file
- reqs_to_keep (dict) – Dictionary of requests and request components that should be saved.
- t_min (float, optional) – Start time of period of interest (default is None which uses the first time step)
- t_max (float, optional) – End time of period of interest (default is None which uses the last time step)
- new_result_file (str) – Name that will be given to the new results file. (Default is None which adds a ‘_shrunk’ suffix to result_file if in_place=False or uses result_file if in_place=True.)
- in_place (bool, optional) – If True, existing file will be deleted.
 
Module contents¶
Package for working with Adams Results
- 
adamspy.postprocess.get_log_errors(log_file: pathlib.Path)[source]¶
- Checks the log file for errors of the type AviewError. - Parameters: - log_file (str) – Filename of aview log file (usulally aview.log) 
- 
adamspy.postprocess.launch_ppt(res_file, cmd_file=None, wait=False, timeout=30, _terminate=False)[source]¶
- Launches the Adams PostProcessor and reads in the specified results file. - Parameters: - res_file (str) – Filepath to an Adams Results file.
- cmd_file (str, optional) – Adams View command (.cmd) file. If given, this will be loaded before the results file. This is necessary to view animations.
- wait (bool, optional) – If True, code execution will freeze until the postprocessor is closed. (the default is False)
- timeout (float, optional) – If wait`=`False, code execution will freeze until the postprocessor has started loading the results file or until timeout secodns have elapsed.
- _terminate (bool, optional) – If True, the PostProcessor will close immediately. This is for testing purposes.