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

Method create_spectrum_from_param_dict

pyxrf/model/parameters.py:395–505  ·  view source on GitHub ↗

Create spectrum profile with based on the current set of parameters. (``self.param_new`` -> ``self.EC`` and ``self.element_list``). Typical use: update self.param_new, then call this function. Set ``reset=False`` to keep selection status of the elemental lines.

(self, reset=True)

Source from the content-addressed store, hash-verified

393 )
394
395 def create_spectrum_from_param_dict(self, reset=True):
396 """
397 Create spectrum profile with based on the current set of parameters.
398 (``self.param_new`` -> ``self.EC`` and ``self.element_list``).
399 Typical use: update self.param_new, then call this function.
400 Set ``reset=False`` to keep selection status of the elemental lines.
401
402 Parameters
403 ----------
404 reset : boolean
405 clear or keep status of the elemental lines (in ``self.EC``).
406 """
407 param_dict = self.param_new
408 self.element_list = get_element_list(param_dict)
409
410 self.define_range()
411 self.prefit_x, pre_dict, area_dict = calculate_profile(self.x0, self.y0, param_dict, self.element_list)
412 # add escape peak
413 if param_dict["non_fitting_values"]["escape_ratio"] > 0:
414 pre_dict["escape"] = trim_escape_peak(self.io_model.data, param_dict, len(self.y0))
415
416 temp_dict = OrderedDict()
417 for e in pre_dict.keys():
418 if e in ["background", "escape"]:
419 spectrum = pre_dict[e]
420
421 # summed spectrum here is not correct,
422 # as the interval is assumed as 1, not energy interval
423 # however area of background and escape is not used elsewhere, not important
424 area = np.sum(spectrum)
425
426 ps = PreFitStatus(
427 z=get_Z(e),
428 energy=get_energy(e),
429 area=float(area),
430 spectrum=spectrum,
431 maxv=float(np.around(np.max(spectrum), self.max_area_dig)),
432 norm=-1,
433 status=True,
434 lbd_stat=False,
435 )
436 temp_dict[e] = ps
437
438 elif "-" in e: # pileup peaks
439 energy = self.get_pileup_peak_energy(e)
440 energy = f"{energy:.4f}"
441 spectrum = pre_dict[e]
442 area = area_dict[e]
443
444 ps = PreFitStatus(
445 z=get_Z(e),
446 energy=str(energy),
447 area=area,
448 spectrum=spectrum,
449 maxv=np.around(np.max(spectrum), self.max_area_dig),
450 norm=-1,
451 status=True,
452 lbd_stat=False,

Calls 13

define_rangeMethod · 0.95
get_element_listFunction · 0.85
calculate_profileFunction · 0.85
trim_escape_peakFunction · 0.85
PreFitStatusClass · 0.85
get_ZFunction · 0.85
get_energyFunction · 0.85
keysMethod · 0.80
itemsMethod · 0.80
delete_allMethod · 0.80

Tested by

no test coverage detected