Utilities Documentation
parameter docu
- class helpr.utilities.parameter.Parameter(name, values, lower_bound=0, upper_bound=np.inf, size=False, dtype=float, error_function=ValueError)
Class to enable checking and enforcing parameter bounds.
- static check_size(obj, size, dtype)
Ensures object is of desired size.
- static ensure_array(obj, size, dtype)
Checks that object is an array and converts it otherwise.
- static parameter_bounds_check(name, parameter_values, lower_bound, upper_bound, error_function)
Checks that parameter values are within specified bounds.
- helpr.utilities.parameter.divide_by_dataframe(numerator, denominator)
Calculate division of a numpy array by a pandas DataFrame.
- helpr.utilities.parameter.subtract_dataframe(minuend, subtrahend)
Calculate subtraction of a numpy array by a pandas DataFrame.
plots docu
- helpr.utilities.plots.ecdf(sample)
Calculates empirical distribution function for dataset.
- Parameters:
sample – samples to be represented as an empirical cdf
- helpr.utilities.plots.failure_assessment_diagram_equation(load_ratio)
Calculates line from FAD equation.
- helpr.utilities.plots.filter_failure_assessment_data(data)
Filters out data for failure assessment diagram.
- helpr.utilities.plots.generate_crack_growth_rate_plot(life_assessment, save_fig=False)
Creates a crack growth rate plot.
- Parameters:
life_assessment (dict or DataFrame) – Single life assessment results.
save_fig (bool, optional) – Flag to save plot to a png file.
- helpr.utilities.plots.generate_pipe_life_assessment_plot(life_assessment, life_criteria, pipe_name='', save_fig=False)
Generates deterministic plot life assessment plot.
- Parameters:
life_assessment (dict or DataFrame) – Single pipe life assessment results.
life_criteria (dict or DataFrame) – Life criteria results.
pipe_name (str, optional) – Name of pipe to specify as title, defaults to no title.
save_fig (bool, optional) – Flag to save plot to a png file.
- helpr.utilities.plots.plot_cycle_life_cdf_ci(analysis_results, criteria='Cycles to a(crit)')
Creates a plot of confidence intervals around cdfs of analysis results.
- Parameters:
analysis_results (CrackEvolutionAnalysis) – Ensemble life assessment results.
criteria (str) – Life criteria to plot, defaults to ‘Cycles to a (crit)’.
- helpr.utilities.plots.plot_cycle_life_cdfs(analysis_results, criteria='Cycles to a(crit)', save_fig=False)
Creates a plot with cdfs of analysis results.
- Parameters:
analysis_results (CrackEvolutionAnalysis) – Ensemble life assessment results.
criteria (str) – Life criteria to plot, defaults to ‘Cycles to a (crit)’.
save_fig (bool, optional) – Flag to save plot to a png file.
- helpr.utilities.plots.plot_cycle_life_criteria_scatter(analysis_results, criteria='Cycles to a(crit)', color_by_variable=False, save_fig=False)
Creates scatter plots of cycle life QOI results. If save_fig is True, will return filepath str (if not color_by_variable) or list of filepaths if colored by variable.
- Parameters:
analysis_results (CrackEvolutionAnalysis) – Ensemble life assessment results.
criteria (str, optional) – Life criteria to plot, defaults to ‘Cycles to a (crit)’.
color_by_variable (bool, optional) – Flag to change colors by variable.
save_fig (bool, optional) – Flag to save plot to a png file.
- helpr.utilities.plots.plot_cycle_life_pdfs(analysis_results, criteria='Cycles to a(crit)', save_fig=False)
Creates pdfs of life cycle analysis results.
- Parameters:
analysis_results (CrackEvolutionAnalysis) – Ensemble life assessment results.
criteria (str) – Life criteria to plot, defaults to ‘Cycles to a (crit)’.
save_fig (bool, optional) – Flag to save plot to a png file.
- helpr.utilities.plots.plot_det_design_curve(dk, da_dn, save_fig=False)
Creates a plot of design curve values exercised in an analysis.
- Parameters:
dk (pandas.DataFrame) – Change in stress intensity factor.
da_dn (pandas.DataFrame) – Change of crack size over change in cycles (da/dn).
save_fig (bool, optional) – Flag to save plot to a png file.
- helpr.utilities.plots.plot_failure_assessment_diagram(life_assessment, nominal=False, save_fig=False)
Creates a failure assessment diagram (FAD).
- Parameters:
life_assessment (dict) – Single or Ensemble life assessment results.
nominal (bool, optional) – Flag for nominal or probabilistic results.
save_fig (bool, optional) – Flag to save plot to a png file.
- helpr.utilities.plots.plot_log_hist(data, label, logbins=None)
Create a log10-scale histogram of the given data.
- Parameters:
data (np.ndarray) – Data to bin and plot.
label (str) – Legend label for data.
logbins (np.ndarray, optional) – Option to pass in log spaced bins if already computed.
- Returns:
logbins – Bin locations in log10 spacing.
- Return type:
np.array
- helpr.utilities.plots.plot_mitigation_histograms(analysis_results, mitigated, inspection_interval)
Create histogram plots showing cracks failing over time and the impact of inspection.
- Parameters:
analysis_results (dict) – Life criteria data from fatigue analysis.
mitigated (list) – Indication of which cracks were mitigated through inspection.
inspection_interval (float) – Frequency of inspections.
- helpr.utilities.plots.plot_pipe_life_ensemble(life_assessment, criteria='Cycles to a(crit)', save_fig=False)
Creates plot of ensemble pipe life assessment results.
- Parameters:
life_assessment (CrackEvolutionAnalysis) – Ensemble life assessment results.
life_criteria (dict) – Life criteria results.
save_fig (bool, optional) – Flag to save plot to a png file.
- helpr.utilities.plots.plot_sensitivity_results(analysis_results, criteria='Cycles to a(crit)', save_fig=False)
Creates a plot of sensitivity results.
- Parameters:
analysis_results (CrackEvolutionAnalysis) – Ensemble life assessment results.
criteria (str, optional) – Life criteria to plot, defaults to ‘Cycles to a (crit)’.
save_fig (bool, optional) – Flag to save plot to a png file.
- helpr.utilities.plots.plot_unscaled_mitigation_cdf(analysis_results, mitigated, inspection_interval)
Creates a plot of unscaled cdfs showing impact of inspection/mitigation.
- Parameters:
analysis_results (dict) – Life criteria data from fatigue analysis.
mitigated (list) – Indication of which cracks were mitigated through inspection.
inspection_interval (float) – Frequency of inspections.
postprocessing docu
- helpr.utilities.postprocessing.calc_a_over_t_criterion_0(pipe_specification, a_crit)
Calculates ‘a critical’ life criteria.
- helpr.utilities.postprocessing.calc_a_over_t_criterion_1(pipe_specification, a_crit)
Calculates ‘25% a critical’ life criteria.
- helpr.utilities.postprocessing.calc_a_over_t_criterion_2(cycle_sheet, cycles_to_half_a_crit_cycles)
Calculates ‘half a critical cycles’ life criteria.
- helpr.utilities.postprocessing.calc_pipe_life_criteria(cycle_results, pipe, stress_state)
Calculates overall pipe life criteria.
- Parameters:
cycle_results (dict) – Complete load cycling results.
pipe_index (int) – Index of single pipe instance.
stress_state (GenericStressState) – Stress state specification.
- Returns:
life_criteria – Collected life criteria results.
- Return type:
dict
- helpr.utilities.postprocessing.calculate_failure_assessment(parameters, fatigue_results, stress_state)
Calculates failure assessment values for load cycling results.
- Parameters:
parameters (dict) – Analysis input parameters.
fatigue_results (dict) – Analysis load cycling results.
stress_state (GenericStressState) – Stress state specification.
- helpr.utilities.postprocessing.parallel_interpolation_list_pts(interpolation_points, x_vals, y_vals)
Interpolates a list of points in parallel.
- Parameters:
interpolation_points (list) – List of a critical values.
x_vals (pandas.Series) – Series of x values for interpolated data.
y_vals (pandas.Series) – Series of y values for interpolated data.
- Returns:
interpolation_results
- Return type:
numpy.ndarray
- helpr.utilities.postprocessing.parallel_interpolation_single_pt(interpolation_points, x_vals, y_vals)
Interpolates single points in parallel.
- Parameters:
interpolation_points (list) – List of a critical values.
x_vals (pandas.Series) – Series of x values for interpolated data.
y_vals (pandas.Series) – Series of y values for interpolated data.
- Returns:
interpolation_results
- Return type:
numpy.ndarray
- helpr.utilities.postprocessing.report_single_cycle_evolution(all_results, pipe_index)
Creates a DataFrame object for plotting a single crack cycle evolution.
- Parameters:
all_results (dict) – All load cycling results.
pipe_index (int) – Index of single pipe instance.
- Returns:
single_cycle_evolution – DataFrame for plotting of single instance.
- Return type:
pd.DataFrame
- helpr.utilities.postprocessing.report_single_pipe_life_criteria_results(life_results, pipe_index)
Reports pipe life criteria results for single instance.
- Parameters:
life_results (dict) – Complete load cycling results.
pipe_index (int) – Index of single pipe instance.
- Returns:
pipe_life – Collected life criteria results.
- Return type:
pandas.DataFrame
unit_conversion docu
Common unit conversion functions.
- helpr.utilities.unit_conversion.convert_in_to_m(inch_value: float) float
Converts inches to meters.
- helpr.utilities.unit_conversion.convert_ksi_to_mpa(ksi_value: float) float
Converts KSI to MPa.
- helpr.utilities.unit_conversion.convert_psi_to_mpa(psi_value: float) float
Converts PSI to MPa.
- helpr.utilities.unit_conversion.get_variable_units(variable_name: str, for_plotting: bool = True) str
Specifies units used for analysis variables