MCPcopy Create free account
hub / github.com/NSLS2/PyXRF / calculate_profile

Function calculate_profile

pyxrf/model/parameters.py:1282–1334  ·  view source on GitHub ↗

Calculate the spectrum profile based on given parameters. Use function construct_linear_model from xrf_model. Parameters ---------- x : array channel array y : array spectrum intensity param : dict parameters elemental_lines : list su

(x, y, param, elemental_lines, default_area=1e5)

Source from the content-addressed store, hash-verified

1280
1281
1282def calculate_profile(x, y, param, elemental_lines, default_area=1e5):
1283 """
1284 Calculate the spectrum profile based on given parameters. Use function
1285 construct_linear_model from xrf_model.
1286
1287 Parameters
1288 ----------
1289 x : array
1290 channel array
1291 y : array
1292 spectrum intensity
1293 param : dict
1294 parameters
1295 elemental_lines : list
1296 such as Si_K, Pt_M
1297 default_area : float
1298 default value for the gaussian area of each element
1299
1300 Returns
1301 -------
1302 x : array
1303 trimmed energy range
1304 temp_d : dict
1305 dict of array
1306 area_dict : dict
1307 dict of area for elements and other peaks
1308 """
1309 # Need to use deepcopy here to avoid unexpected change on parameter dict
1310 fitting_parameters = copy.deepcopy(param)
1311
1312 total_list, matv, area_dict = construct_linear_model(
1313 x, fitting_parameters, elemental_lines, default_area=default_area
1314 )
1315
1316 temp_d = {k: v for (k, v) in zip(total_list, matv.transpose())}
1317
1318 # add background
1319 bg = snip_method_numba(
1320 y,
1321 fitting_parameters["e_offset"]["value"],
1322 fitting_parameters["e_linear"]["value"],
1323 fitting_parameters["e_quadratic"]["value"],
1324 width=fitting_parameters["non_fitting_values"]["background_width"],
1325 )
1326 temp_d["background"] = bg
1327
1328 x_energy = (
1329 fitting_parameters["e_offset"]["value"]
1330 + fitting_parameters["e_linear"]["value"] * x
1331 + fitting_parameters["e_quadratic"]["value"] * x**2
1332 )
1333
1334 return x_energy, temp_d, area_dict
1335
1336
1337def trim_escape_peak(data, param_dict, y_size):

Callers 4

_manual_inputMethod · 0.85
get_profileMethod · 0.85

Calls 1

snip_method_numbaFunction · 0.85

Tested by

no test coverage detected