levisim.multiphysics.utils.comparison¶
Checks that different calculation methods agree, with the plotting and labelling helpers they use
- levisim.multiphysics.utils.comparison.thresholds_for_difficulty_level(difficulty_level)[source]¶
Returns tuple of
( errant_pixel_allowed_percentage, relative_diff_threshold, relative_diff_allowed_failed_points_percentage, )
- exception levisim.multiphysics.utils.comparison.TooManyErrantPixelsInImageDiff[source]¶
Bases:
ExceptionRaised when the greyscale diff of two plots has too many errant pixels
- exception levisim.multiphysics.utils.comparison.RelativeDifferenceTooHigh[source]¶
Bases:
ExceptionRaised when two calculations differ by more than the allowed relative difference
- levisim.multiphysics.utils.comparison.verify_equivalence_of_spectrum_calculation_methods(mtrap, spectrum_types, methods, **kwargs)[source]¶
Calculate all spectrum_types via all methods
Verify their equivalnece by
checking for sufficently few errant pixels in a greyscale image diff
checking the relative absolute difference is sufficiently low
- levisim.multiphysics.utils.comparison.verify_equivalence_of_spectral_functions(mtrap, func_dict, **kwargs)[source]¶
Calculate all functions in func_dict across the given mtrap.ω_range
Verify their equivalnece by
checking for sufficently few errant pixels in a greyscale image diff of their plots
checking the relative absolute difference is sufficiently low
- levisim.multiphysics.utils.comparison.assert_images_agree_within_errant_pixels(image_dict, **kwargs)[source]¶
Test the greyscale diff of all pairs of images in image_dict for errant pixels
- levisim.multiphysics.utils.comparison.assert_arrays_agree_within_threshold(mtrap, array_dict, **kwargs)[source]¶
Test the relative difference of all pairs of arrays in array_dict is below threshold
A pair passes if its mean relative absolute difference is below the threshold for difficulty_level (default ‘very hard’), or if the percentage of points above it is below that level’s allowance, or - only if allowed_failed_points_per_resonance = k is given - if at most k·num_dimensions points per spectrum are above it (the failures sit on resonances). Raises RelativeDifferenceTooHigh otherwise, unless fail_quietly.
- levisim.multiphysics.utils.comparison.visualise_two_spectrum_calculation_methods(mtrap, spectrum_type, method_A, method_B, **kwargs)[source]¶
Visualise a given spectrum_type calculated via method_A vs. method_B
- levisim.multiphysics.utils.comparison.visualise_two_noise_component_calculation_methods(mtrap, noise_vector_type, dim_index, noise_index, vals_A, vals_B, method_A, method_B, **kwargs)[source]¶
Visualise a given noise_vector_type’s component (determined by dim_index and noise_index) calculated via method_A vs. method_B
For efficiency, vals_A and vals_B are pre-calculated from the full noise vector functions and passed in as arguments directly here
- levisim.multiphysics.utils.comparison.visualise_two_noise_component_calculation_methods_over_entire_spectrum(mtrap, noise_vector_type, HD_ω_range, SD_ω_range, HD_minus_vals_A, HD_minus_vals_B, SD_vals_A, SD_vals_B, HD_plus_vals_A, HD_plus_vals_B, dim_index, noise_index, method_A, method_B, **kwargs)[source]¶
Visualise a given noise_vector_type’s component (determined by dim_index and noise_index) calculated via method_A vs. method_B, across 3 different spectral ranges: - -HD_ω_range: negative high resolution range, around the negative resonances - SD_ω_range: lower resolution range, between positive and negative resonances - HD_ω_range: positive high definition range, around the positive resonances
For efficiency, all the values are pre-calculated from the full noise vector functions and passed in as arguments directly here
- levisim.multiphysics.utils.comparison.visualise_relative_difference_of_two_arrays(mtrap, array_A, array_B, name_A, name_B, **kwargs)[source]¶
Visualise the relative difference of array_A vs. array_B
- levisim.multiphysics.utils.comparison.plot_pass_fail_matrix(matrix, names, **kwargs)[source]¶
Plots the PASS/FAIL matrix for the pair-wise comparison of named items (e.g. images, arrays)
- levisim.multiphysics.utils.comparison.plot_mean_abs_relative_diffs_matrix(matrix, names, **kwargs)[source]¶
Plots the matrix for the pair-wise comparison of the mean absolute difference
- levisim.multiphysics.utils.comparison.greyscale_diff(image_A, image_B)[source]¶
Convert the diff of two images into greyscale
- levisim.multiphysics.utils.comparison.calculate_temperature_from_position_PSD(mtrap, vals, ii, label)[source]¶
Calculates the temperature from the PSD via two methods:
phonons
variance
- levisim.multiphysics.utils.comparison.get_latex_labels(mtrap, hat=False, PSD=False)[source]¶
Returns a list of latex strings of dimension labels e.g.
$x_1$or$\hat{x}_1$
- levisim.multiphysics.utils.comparison.noise_vector_string(mtrap, noise_vector_type, dim_index, noise_index)[source]¶
Returns a string representing the noise vector and component
- levisim.multiphysics.utils.comparison.noise_vector_latex(mtrap, noise_vector_type, dim_index, noise_index)[source]¶
Returns a latex string representing the noise vector and component
- levisim.multiphysics.utils.comparison.phase_per_tweezer_string(mtrap, latex=False, uppercase=False, unit=0.017453292519943295, unit_symbol='°')[source]¶
Returns string of the values of the tweezer phases with lowercase φ