srxraylib.metrology package
Submodules
srxraylib.metrology.dabam module
- dabam: (dataBase for metrology)
python module for processing remote files containing the results of metrology measurements on X-ray mirrors
- classes:
dabam
- main functions:
cdf (calculate antiderivative function)
psd (calculate power spectral density)
write_shadowSurface (writes file with a mesh for SHADOW)
func_ellipse_slopes evaluates the ellipse slopes profile equation
- MODIFICATION HISTORY:
20130902 srio@esrf.eu, written
20131109 srio@esrf.eu, added command line arguments, access metadata
20151103 srio@esrf.eu, restructured to OO
20151118 srio@esrf.eu, cleaned and tested
20190731 srio@lbl.gov, updated version, allows reading external files, change server, etc.
- srxraylib.metrology.dabam.autocorrelationfunction(x1, f1)[source]
A function that calculates the autocovariance function and correlation length of a 1-d profile f(x).
- Parameters:
x1 (numpy array) – the abscissas array (profile points).
f1 (numpy array) – array with the funcion value (profile heights).
- Returns:
(lags,acf,cl) lags=lag length vector (abscissas of acf), acf=autocovariance function, and cl=correlation length
- Return type:
tuple
- srxraylib.metrology.dabam.cdf(sy, sz, method=1)[source]
A function that calculates the profile from the slope by simple integration (antiderivative)
- Parameters:
sy (numpy array) – 1D array of (equally-spaced) lengths.
sz (numpy array) – 1D array of slopes.
method (int, optional) – 0 use simple sum as integration method 1 use trapezoidal rule (default)
- Returns:
1D array with cdf
- Return type:
numpy array
Note
The abscissas must be sorted, but the step may not be constant.
- class srxraylib.metrology.dabam.dabam[source]
Bases:
objectConstructor.
- autocorrelation_heights()[source]
return the autocorrelation of the heights profile.
- Return type:
float
- autocorrelation_slopes()[source]
return the autocorrelation of the slopes profile.
- Return type:
float
- csd_heights()[source]
Gets the heights profile from the calculated PSD with phase.
- Return type:
numpy array
- csd_slopes()[source]
Gets the slopes profile from the calculated PSD with phase.
- Return type:
numpy array
- dabam_summary_dictionary_from_json_indexation(surface=None, slp_err_from=None, slp_err_to=None, length_from=None, length_to=None)[source]
Returns a list with the dictionaries of the profiles matching some requirements. It uses the json summary for scanning the profiles.
- Parameters:
surface (str, default) – The ‘surface’ key in the metadata. Default=None means that any value if taken.
slp_err_from (float, optional) – Minimum slope error RMS in rad.
slp_err_to (float, optional) – Maximum slope error RMS in rad.
length_from (float, optional) – Minimum mirror length in m.
length_to (float, optional) – Maximum mirror length in m.
- Return type:
list
- dabam_summary_dictionary_from_scratch(surface=None, slp_err_from=None, slp_err_to=None, length_from=None, length_to=None, nmax=1000000, verbose=True)[source]
Creates a json summary file with several profiles matching some requirements.
- Parameters:
surface (str, default) – The ‘surface’ key in the metadata. Default=None means that any value if taken.
slp_err_from (float, optional) – Minimum slope error RMS in rad.
slp_err_to (float, optional) – Maximum slope error RMS in rad.
length_from (float, optional) – Minimum mirror length in m.
length_to (float, optional) – Maximum mirror length in m.
nmax (int, optional) – Profile number of the last profile to consider.
verbose (boolean, optional) – Set True for verbose output.
- Returns:
dictionaries of the consideted profiles.
- Return type:
list
- file_metadata()[source]
- Returns:
The name of the metadata file (with the extension .txt).
- Return type:
str
- classmethod get_default_server()[source]
gets the address of the default server.
- Returns:
Server address.
- Return type:
str
- get_input_value(key)[source]
- Parameters:
key (str) – key value
- Return type:
The input corresponding to that key.
- get_input_value_short_name(key)[source]
- Parameters:
key (str) – The input key value.
- Returns:
The short name (e.g. key=’entryNumber’, it returns ‘N’)
- Return type:
str
- get_server(directory)[source]
Returns the address of the current server.
- Parameters:
directory (? [todo: fix code]) –
- Returns:
Setver address.
- Return type:
str
- classmethod initialize_from_entry_number(entry_number)[source]
Initialize dabax instance with a given profile number.
- Parameters:
entry_number (int) – The dabax profile number.
- Return type:
a dabax instance
- classmethod initialize_from_external_data(input, column_index_abscissas=0, column_index_ordinates=1, skiprows=1, useHeightsOrSlopes=0, to_SI_abscissas=1.0, to_SI_ordinates=1.0, detrending_flag=-1, detrending_window_factor=1.0, reset_zero_height=0)[source]
Returns a dabax instance initialized with external data.
- Parameters:
input (numpy array) – The numpy array with the abscissas and profile heights or slopes.
column_index_abscissas (int, optional) – Index of the column with the abscissas.
column_index_ordinates (int, optional) – Index of the column with the ordinates.
skiprows (int, optional) – Number of rows to skip.
useHeightsOrSlopes (int, optional) – The ordinates are: 0=Heights, or 1=Slopes.
to_SI_abscissas (float, optional) – The conversion factor from abscissas’ units to SI units.
to_SI_ordinates (float, optional) – The conversion factor from ordinates’ units to SI units.
detrending_flag (int, optional) – if >0 is the polynomial degree, -1=skip, -2=read from metadata DETRENDING, -3=ellipse(optimized) -4=ellipse(design).
detrending_window_factor (float, optional) – if detrending_flag>0, this is the window covering for the fit (1.0 is full window).
reset_zero_height (int, optional) – if 1, resets the minimum value of the height profile to zero.
- Return type:
instance of dabax.
- classmethod initialize_from_local_server(entry, server=None)[source]
Initialize dabax instance with a given profile number in given server.
- Parameters:
entry (int) – The dabax profile number.
server (str) – The server URL or file name.
- Return type:
a dabax instance.
- load(entry=None)[source]
- Parameters:
entry (int, optional) – sets the current entry to this value before loading (default=None, using current set number).
- load_json_summary(filename=None)[source]
returns the text in a json summary file.
- Parameters:
filename (str, optional) – The file name. Default=None, meaning that the remote dabam-summary.json is loaded.
- Returns:
The JSON object that contains data in the form of key/value pairs
- Return type:
json object
- make_calculations()[source]
Once the inputs are set, use thos method to perform calculations (detrending, histograms, osd, etc.).
- metadata_set_info(YEAR_FABRICATION=None, SURFACE_SHAPE=None, FUNCTION=None, LENGTH=None, WIDTH=None, THICK=None, LENGTH_OPTICAL=None, SUBSTRATE=None, COATING=None, FACILITY=None, INSTRUMENT=None, POLISHING=None, ENVIRONMENT=None, SCAN_DATE=None, CALC_HEIGHT_RMS=None, CALC_HEIGHT_RMS_FACTOR=None, CALC_SLOPE_RMS=None, CALC_SLOPE_RMS_FACTOR=None, USER_EXAMPLE=None, USER_REFERENCE=None, USER_ADDED_BY=None)[source]
Sets the metadata info.
- Parameters:
YEAR_FABRICATION – the user value to be set.
SURFACE_SHAPE – the user value to be set.
FUNCTION – the user value to be set.
LENGTH – the user value to be set.
WIDTH – the user value to be set.
THICK – the user value to be set.
LENGTH_OPTICAL – the user value to be set.
SUBSTRATE – the user value to be set.
COATING – the user value to be set.
FACILITY – the user value to be set.
INSTRUMENT – the user value to be set.
POLISHING – the user value to be set.
ENVIRONMENT – the user value to be set.
SCAN_DATE – the user value to be set.
CALC_HEIGHT_RMS – the user value to be set.
CALC_HEIGHT_RMS_FACTOR – the user value to be set.
CALC_SLOPE_RMS – the user value to be set.
CALC_SLOPE_RMS_FACTOR – the user value to be set.
USER_EXAMPLE – the user value to be set.
USER_REFERENCE – the user value to be set.
USER_ADDED_BY – the user value to be set.
- plot(what=None)[source]
Makes a single or multiple plot (using matplotlib).
- Parameters:
what (str or list, optional) – possible options: “all”, “heights”, “slopes”, “psd_h”, “psd_s”, “csd_h”, “cds_s”, “histo_s”, “histo_h”
- set_entry(value)[source]
Sets the input “entryNumber” key to a given value.
- Parameters:
value – The value.
- set_input_detrendingWindowFactor(value)[source]
Sets the input “detrendingWindowFactor” key to a given value.
- Parameters:
value – The value.
- set_input_entryNumber(value)[source]
Sets the current profile number.
- Parameters:
value (int) – The profile number.
- set_input_localFileRoot(value)[source]
Sets the input “localFileRoot” key to a given value.
- Parameters:
value – The value.
- set_input_multiply(value)[source]
Sets the input “multiply” key to a given value.
- Parameters:
value – The value.
- set_input_nbinH(value)[source]
Sets the input “nbinH” key to a given value.
- Parameters:
value – The value.
- set_input_nbinS(value)[source]
Sets the input “nbinS” key to a given value.
- Parameters:
value – The value.
- set_input_outputFileRoot(value)[source]
Sets the input “outputFileRoot” key to a given value.
- Parameters:
value – The value.
- set_input_oversample(value)[source]
Sets the input “oversample” key to a given value.
- Parameters:
value – The value.
- set_input_plot(value)[source]
Sets the input “plot” key to a given value.
- Parameters:
value – The value.
- set_input_resetZeroHeight(value)[source]
Sets the input “resetZeroHeight” key to a given value.
- Parameters:
value – The value.
- set_input_setDetrending(value)[source]
Sets the input “setDetrending” key to a given value.
- Parameters:
value – The value.
- set_input_shadowCalc(value)[source]
Sets the input “shadowCalc” key to a given value.
- Parameters:
value – The value.
- set_input_shadowFactor(value)[source]
Sets the input “shadowFactor” key to a given value.
- Parameters:
value – The value.
- set_input_shadowNx(value)[source]
Sets the input “shadowNx” key to a given value.
- Parameters:
value – The value.
- set_input_shadowNy(value)[source]
Sets the input “shadowNy” key to a given value.
- Parameters:
value – The value.
- set_input_shadowWidth(value)[source]
Sets the input “shadowWidth” key to a given value.
- Parameters:
value – The value.
- set_input_silent(value)[source]
Sets the input “silent” key to a given value.
- Parameters:
value – The value.
- set_input_summary(value)[source]
Sets the input “summary” key to a given value.
- Parameters:
value – The value.
- set_input_useAbscissasColumn(value)[source]
Sets the input “useAbscissasColumn” key to a given value.
- Parameters:
value – The value.
- set_input_useHeightsOrSlopes(value)[source]
Sets the input “useHeightsOrSlopes” key to a given value.
- Parameters:
value – The value.
- set_input_useOrdinatesColumn(value)[source]
Sets the input “useOrdinatesColumn” key to a given value.
- Parameters:
value – The value.
- set_inputs_from_dictionary(dict)[source]
Sets the input keys to given values.
- Parameters:
dict (dictionary) – A dictionary with the values to change.
- set_server(server)[source]
Sets current server tyo a given address.
- Parameters:
server (str) – The server address.
- statistics_summary()[source]
returns a summary of the statistics of the heights and slopes profiles.
- Return type:
str
- stdev_profile_heights()[source]
Gets the standard deviation of the heights profile
- Return type:
float
- stdev_profile_slopes()[source]
Gets the standard deviation of the slopes profile
- Return type:
float
- stdev_psd_heights()[source]
Gets the standard deviation of the heights profile by integration of the PSD.
- Return type:
float
- stdev_psd_slopes()[source]
Gets the standard deviation of the slopes profile by integration of the PSD.
- Return type:
float
- stdev_user_heights()[source]
Gets the standard deviation of the heights profile by retrieving the value stored in the metadata.
- Return type:
float
- stdev_user_slopes()[source]
Gets the standard deviation of the slopes profile by retrieving the value stored in the metadata.
- Return type:
float
- write_output_dabam_files(filename_root='dabam-XXX', loaded_from_file=None)[source]
Writes a local copy of the dabam files and data of the of current profile.
- Parameters:
filename_root (str, optional) – The root of the file name (.txt and .dat will be created).
boolean (loaded_from_file =) – If the current data is not loaded from a remote server, it may come from local files or from arrays. Set this to 1 if the local file exists, so data will be copied from there. Default=None, use data in arrays.
optional – If the current data is not loaded from a remote server, it may come from local files or from arrays. Set this to 1 if the local file exists, so data will be copied from there. Default=None, use data in arrays.
- write_template(number_string='000', FILE_FORMAT=1)[source]
Writes the dabam files (e.g. dabam-000.dat and dabam-000.txt) with the current data. This can be used to prepare a new profile to be uploaded to the server.
- Parameters:
number_string (str, optional) – the profile number.
FILE_FORMAT (int, optional) – 1 = slopes in Col2 2 = heights in Col2 3 = slopes in Col2, file X1 Y1 X2 Y2 4 = heights in Col2, file X1 Y1 X2 Y2
- srxraylib.metrology.dabam.dabam_summary(nmax=None, latex=0)[source]
creates a text with the summary of all dabam entries.
- Parameters:
nmax (int, optional) – Profile number of the last profile to consider.
latex (int, optional) – Set to 1 for latex output.
- Return type:
str
- srxraylib.metrology.dabam.dabam_summary_dictionary(surface=None, slp_err_from=None, slp_err_to=None, length_from=None, length_to=None, verbose=True, server=None, force_from_scratch=False)[source]
Obsolete. This is kept for back compatibility. Use dabam.dabam_summary_dictionary_from_scratch() instead.
- srxraylib.metrology.dabam.func_ellipse_slopes(x, p, q, theta, shift)[source]
A function that calculates the derivative (y’(x) i.e., slopes) of a ellipse y(x) defined by its distance to focii (p,q) and grazing angle theta at coordinate x=0
- Parameters:
x (numpy array) – the length coordinate for the ellipse (x=0 is the center).
p (float) – the distance from source to mirror center.
q (float) – the distance from mirror center to image.
theta (float) – the grazing incidence angle in rad.
shift (float) – a vertical shift to be added to the ellipse y’ coordinate.
- Returns:
The ellipse slopes y’.
- Return type:
numpy array
- srxraylib.metrology.dabam.main()[source]
Main program to run dabam from command line.
Example
>>> python -m srxraylib.metrology.dabam -h # get help >>> python -m srxraylib.metrology.dabam 10 -P all # retrieve and plot profile number 10
- srxraylib.metrology.dabam.make_json_summary(nmax=100000, force_from_scratch=False, server=None)[source]
Obsolete. This is kept for back compatibility. Use dabam methods instead.
- srxraylib.metrology.dabam.moment(array, substract_one_in_variance_n=True)[source]
Calculate the first four statistical moments of a 1D array.
- Parameters:
array (numpy array) – theinput array.
substract_one_in_variance_n (boolean, optional) – if True calculate variance as Sum[(x_i-x_mean)**2]/(N-1), otherwise the variance is Sum[(x_i-x_mean)**2]/N.
- Returns:
(m0,m1,m2,m3) with m0 (mean) m1 (variance) m2 (skewness) m3 (kurtosis).
- Return type:
tuple
- srxraylib.metrology.dabam.psd(xx, yy, onlyrange=None)[source]
A function that calculates the PSD (power spectral density) from a profile.
- Parameters:
xx (numpy array) – 1D array of (equally-spaced) lengths.
yy (numpy array) – 1D array of heights.
onlyrange (list or tuple, optional) – 2-element array specifying the min and max spatial frequencies to be considered. Default is from 1/(length) to 1/(2*interval) (i.e., the Nyquist frequency), where length is the length of the scan, and interval is the spacing between points.
- Returns:
(psd,f) arrays with the PSD and frequencies (abscissas).
- Return type:
tuple
- srxraylib.metrology.dabam.write_shadowSurface(s, xx, yy, outFile='presurface.dat')[source]
A function that writes a mesh surface in SHADOW format.
- Parameters:
s (numpy array) – A 2D array (Nx,Ny) with heights.
xx (numpy array) – An array of dimension Nx with coordinates along X (width).
yy (numpy array) – An array of dimension Ny with coordinates along Y (width).
outFile (str, optional) – The file name. Default: “presurface.dat”.
srxraylib.metrology.dabam_tests module
Tests for the dabam metrology module.
- srxraylib.metrology.dabam_tests.test_dabam_names()[source]
Tests that the I/O methods work well for the list of input values :return:
srxraylib.metrology.error_profile_calculator module
Error profile calculator for mirror surface metrology.
- class srxraylib.metrology.error_profile_calculator.DabamInputParameters(dabam_server, widget=None)[source]
Bases:
object
srxraylib.metrology.make_json_summary module
This program makes a summary file pf the dabam contents to accelerate the search.
Example
>>> python -m srxraylib.metrology.make_json_summary
srxraylib.metrology.profiles_simulation module
This is a collection of functions to simulate profiles that can be used for describing surface errors in optical surfaces
Note that all the functions are dimensionless: therefore use always the same unit in horizontal, vertical, and RMS inputs. Angles are in rad.
- Functions:
combine_two_transversal_profiles(): combine two profiles into a mesh
simulate_gaussian_profile_1D():
simulate_fractal_profile_1D():
simulate_profile_2D
simulate_profile_2D_from_1D
create_random_rough_surface_1D(): binding to simulate_gaussian_profile_1D and simulate_fractal_profile_1D
create_simulated_1D_file_APS
create_simulated_2D_profile_APS
create_2D_profile_from_1D
- Authors and main contributors:
Luca Rebuffi, Ruben Reininger, Manuel Sanchez del Rio, Xianbo Shi
- srxraylib.metrology.profiles_simulation.combine_two_transversal_profiles(WW_x, WW, SF_x, SF)[source]
Combine two profiles into a mesh.
- Parameters:
WW_x (numpy array) – abscissas of profile along width.
WW (numpy array) – profile along width.
SF_x (numpy array) – abscissas of profile along length.
SF (numpy array) – profile along length.
- Returns:
the combined mesh s(index_length,index_width).
- Return type:
tuple
Note
the returned array las LENGTH in zeroth order and WIDTH in first order, so shadow coordinates (Y,X).
- srxraylib.metrology.profiles_simulation.create_2D_profile_from_1D(profile_1D_x, profile_1D_y, mirror_width=20.0, step_w=1.0, random_seed_w=8787, error_type_w=0, rms_w=1e-06)[source]
generates a 2-dimensional random rough surface z(x,y) with PSD following a power law. The surface has a power law PSD |f|**(-beta) in both y and x directions
- Parameters:
profile_1D_x (numpy array) – The array with abscissas.
profile_1D_y (numpy array) – The array with heights.
mirror_width (float, optional) – The mesh width.
step_w (float, optional) – The step along the width dorection.
random_seed_w (int, optional) – A seed to initialize the numpy random generator.
error_type_w (int, optional) – FIGURE_ERROR = 0, SLOPE_ERROR = 1.
rms_w (float, optional) – The RMS value for the heights aling the width direction.
- Returns:
(abscissas of transversal profile, profile_1D_x, profile_2D).
- Return type:
tuple
- srxraylib.metrology.profiles_simulation.create_simulated_1D_file_APS(mirror_length=200.0, step=1.0, random_seed=8787, error_type=0, rms=1e-06, power_law_exponent_beta=1.5, power_law_exponent_beta_two=1.5, frequency_power_law_match=0.001)[source]
Generates a 1-dimensional random rough surface z(x) with n_surface_points surface points. The surface has a power law PSD |f|**(-beta) where:
beta=power_law_exponent_beta for frequencies < frequency_power_law_match
beta=power_law_exponent_beta for frequencies > frequency_power_law_match.
It is a fractal profile if 1<beta<3.
- Parameters:
mirror_length (float, optional) – the mirror length (mm or any user unit) (default=200.0)
step (float, optional) – the mirror step (mm or user units) (default=1.0)
random_seed (int, optional) – a random seed to initialize numpy.seed(). Use zero to avoid initialization (default=8787)
error_type (float, optional) – define where normalize the output profile to height error (0, default) or slope error (1)
rms (float, optional) – either the height error in user units (if error_type=0) or the slope error in rad (error_type=1) (default=1e-6)
power_law_exponent_beta (float, optional) – the beta value of the first interval of frequencies (default=1.5)
power_law_exponent_beta_two (float, optional) – the beta value of the second interval of frequencies (default=1.5)
frequency_power_law_match (float, optional) – the frequency (in 1/(user units) to match frequency intervals (default=0.001)
- Returns:
(x coords, y values)
- Return type:
tuple
- srxraylib.metrology.profiles_simulation.create_simulated_2D_profile_APS(mirror_length=200.0, step_l=1.0, random_seed_l=8787, error_type_l=0, rms_l=1e-06, mirror_width=20.0, step_w=1.0, random_seed_w=8788, error_type_w=0, rms_w=1e-06, power_law_exponent_beta_l=1.5, power_law_exponent_beta_w=1.5)[source]
generates a 2-dimensional random rough surface z(x,y) with PSDs following a power law. The surface has a power law PSD |f|**(-beta) in both y and x directions
- Parameters:
mirror_length (float, optional) – the mirror length (mm or any user unit) (default=200.0).
mirror_width (float, optional) – the mirror width (mm or any user unit) (default=200.0).
step_l (float, optional) – the step for mirror length (mm or user units) (default=1.0).
step_w (float, optional) – the step for mirror width (mm or user units) (default=1.0).
random_seed_l (int, optional) – a random seed to initialize numpy.seed() when creating the longitudinal profiles.
random_seed_w (int, optional) – a random seed to initialize numpy.seed() when creating the transversal profiles.
error_type_l (int, optional) – normalize the output longitudinal profile to height error (0, default) or slope error (1).
error_type_w (int, optional) – normalize the output transversal profile to height error (0, default) or slope error (1).
rms_l (float, optional) – either the heigh error in user units (if error_type_l=0) or the slope error in rad (error_type_l=1).
rms_w (float, optional) – either the heigh error in user units (if error_type_w=0) or the slope error in rad (error_type_w=1).
power_law_exponent_beta_l (float) – The beta value (exponent).
power_law_exponent_beta_w (float) – The beta value (exponent).
- Returns:
(x, y, z) arrays for width direction x, longitudinal direction y, and heights z(x,y).
- Return type:
tuple
- srxraylib.metrology.profiles_simulation.simulate_profile_1D(step=1.0, mirror_length=200.0, random_seed=8787, error_type=0, rms=3e-09, profile_type=0, rms_heights=3e-09, correlation_length=30.0, power_law_exponent_beta=0.9)[source]
Create a simulated 1D profile.
- Parameters:
step (float, optional) – The abscissas step/
mirror_length (float, optional) – The profile length.
random_seed (int, optional) – A seed to initialize the numpy random generator.
error_type (float, optional) – FIGURE_ERROR = 0, SLOPE_ERROR = 1.
rms (float, optional) – the RMS of the height profile.
profile_type (float, optional) – GAUSSIAN = 0, FRACTAL = 1.
rms_heights (float, optional) – The rms height. Specific inputs for profile_type=GAUSSIAN.
correlation_length (float, optional) – The value for the correlation length. Specific inputs for profile_type=GAUSSIAN.
power_law_exponent_beta (float, optional) – The value for the exponent of the power law (beta). Specific inputs for profile_type=FRACTAL.
- Returns:
(x_coords, y_values) numpy arrays.
- Return type:
tuple
- srxraylib.metrology.profiles_simulation.simulate_profile_1D_fractal(step=1.0, npoints=None, mirror_length=200.0, power_law_exponent_beta=1.5, npoints_ratio_f_over_x=1.0, random_seed=8787, renormalize_to_heights_sd=None, renormalize_to_slopes_sd=None, frequency_max=None, frequency_min=None)[source]
Generates a 1-dimensional random rough surface f(x) with ‘npoint’ surface points. The surface has a Fractal profile.
- Parameters:
step (float, optional) – step in mirror length (default=0.2).
npoints (int, optional) – number of points in mirror length (default=None, i.e., undefined so use step and mirror_length to calculate it. If defined, use npoints and step is irrelevant).
mirror_length (float, optional) – profile length.
power_law_exponent_beta (float, optional) – beta value.
npoints_ratio_f_over_x (float, optional) – ratio of the number of points in frequency domain over real space (default=1.0).
random_seed (int, optional) – a random seed to initialize numpy.seed(). Use zero to avoid initialization (default=8787).
renormalize_to_heights_sd (float, optional) – set to a value to renormalize the profile to this height stdev value (default=None).
renormalize_to_slopes_sd (float, optional) – set to a value to renormalize the profile to this slope stdev value (default=None).
frequency_max (float, optional) – max of f.
frequency_min (float, optional) – min of f.
- Returns:
(x,prof) where x = profile abscissas, prof = profile heights.
- Return type:
tuple
- srxraylib.metrology.profiles_simulation.simulate_profile_1D_gaussian(step=1.0, npoints=None, mirror_length=200.0, rms_heights=3e-09, correlation_length=30.0, random_seed=8787, renormalize_to_heights_sd=None, renormalize_to_slopes_sd=None)[source]
Generates a 1-dimensional random rough surface f(x) with ‘npoint’ surface points. The surface has a Gaussian height distribution function and a Gaussian autocovariance function, where rL is the length of the surface, h is the RMS height and cl is the correlation length.
- Parameters:
step (float, optional) – step in mirror length (default=0.2)
npoints (int, optional) – number of points in mirror length (default=None, i.e., undefined so use step and mirror_length to calculate it. If defined, use npoints and step is irrelevant)
mirror_length (float, optional) – profile length
rms_heights (float, optional) – rms height for the Gaussian. It is usually not important if normalize_to_{heights,slopes_sd is used}
correlation_length (float, optional) – correlation length
random_seed (int, optional) – a random seed to initialize numpy.seed(). Use zero to avoid initialization (default=8787)
renormalize_to_heights_sd (float, optional) – set to a value to renormalize the profile to this height stdev value (default=None)
renormalize_to_slopes_sd (float, optional) – set to a value to renormalize the profile to this slope stdev value (default=None)
- Returns:
(x,f) where x = profile abscissas, f = profile heights
- Return type:
tuple
Note
this is based on a translation to python of the matlab function rsgeng1d from David Bergström see: http://www.mysimlabs.com/surface_generation.html
- srxraylib.metrology.profiles_simulation.simulate_profile_2D(combination='FF', mirror_length=200.0, step_l=1.0, random_seed_l=8787, error_type_l=0, rms_l=1e-06, power_law_exponent_beta_l=1.5, correlation_length_l=30.0, x_l=None, y_l=None, mirror_width=20.0, step_w=1.0, random_seed_w=8788, error_type_w=0, rms_w=1e-06, power_law_exponent_beta_w=1.5, correlation_length_w=30.0, x_w=None, y_w=None)[source]
Combines two 1D simulated (GAUSSIAN or FRACTAL) or EXPERIMENTAL simulated profiles into a single 2D profile or surface.
- Parameters:
combination (str, optional) – two character string with the comination of profile type (F-fractal, G=gaussian, E=experimental) The first character is for mirror length direction (Y, subscript _l) and the second character is for mirror width direction (X, subscript _w). Example: “FF” (fractal in Y, fractal in X), “EG” (Experimental in Y, Gaussian in X”
mirror_length (float, optional) – the mirror length (along Y).
step_l (float, optional) – step size.
random_seed_l (float, optional) – seed to initialize random seed for Y simulation.
error_type_l (float, optional) – normalize to heights error (0) or slopes error (1).
rms_l (float, optional) – the vealue of eithe height error (if error_type_l=0) or slope error (if error_type_l=1).
power_law_exponent_beta_l (float, optional) – if Fractal, the beta value.
correlation_length_l (float, optional) – if Gaussian, the correlation length.
x_l (float, optional) – if Experimental, the abscissas (Y coordinales).
y_l (float, optional) – if Experimental, the ordinates (heights).
mirror_width (float, optional) – the mirror width (along X).
step_w (float, optional) – step size.
random_seed_w (float, optional) – seed to initialize random seed for X simulation.
error_type_w (float, optional) – normalize to heights error (0) or slopes error (1).
rms_w (float, optional) – the vealue of eithe height error (if error_type_w=0) or slope error (if error_type_w=1).
power_law_exponent_beta_w (float, optional) – if Fractal, the beta value.
correlation_length_w (float, optional) – if Gaussian, the correlation length.
x_w (float, optional) – if Experimental, the abscissas (X coordinales).
y_w (float, optional) – if Experimental, the ordinates (heights).
- Returns:
(WW_x, SF_x, s) arrays along width (X), length (Y) and heights(SF_x.size,WW_x.size).
- Return type:
tuple
- srxraylib.metrology.profiles_simulation.slopes(z, x, y, silent=1, return_only_rms=0)[source]
This function calculates the slope errors of a surface along the mirror length y and mirror width x.
- Parameters:
z (numpy array) – the width array of dimensions (Nx).
x (numpy array) – the length array of dimensions (Ny).
y (numpy array) – the surface array of dimensions (Nx,Ny).
silent (int, optional) – 1 for silent output.
return_only_rms (int, optional) – 1 for returning only the rms value.
- Returns:
if return_only_rms=0 return slopesrms: a 2-dim array with (in rad): [slopeErrorRMS_X,slopeErrorRMS_Y] if return_only_rms=1 return (slope,slopesrms), with slope an array of dimension (2,Nx,Ny) with the slopes errors in rad along X in slope[0,:,:] and along Y in slope[1,:,:]
- Return type:
tuple