r""" Create the dictionary used for storage of data on XRF reference sample. The field ``element_lines`` is the dictionary, which stores data on density density of the element (in the sample) and fluorescence of the emission line (computed later during processing of the reference sca
(quant_param_dict, incident_energy)
| 425 | |
| 426 | |
| 427 | def get_quant_fluor_data_dict(quant_param_dict, incident_energy): |
| 428 | r""" |
| 429 | Create the dictionary used for storage of data on XRF reference sample. The field |
| 430 | ``element_lines`` is the dictionary, which stores data on density density of the |
| 431 | element (in the sample) and fluorescence of the emission line (computed later |
| 432 | during processing of the reference scan. |
| 433 | |
| 434 | Parameters |
| 435 | ---------- |
| 436 | |
| 437 | quant_param_dict: dict |
| 438 | Dictionary with the information on reference sample (loaded from YAML configuration |
| 439 | file). The dictionary should satifsfy the ``_xrf_standard_schema`` schema. |
| 440 | |
| 441 | incident_energy: float |
| 442 | Incident beam energy |
| 443 | |
| 444 | Returns |
| 445 | ------- |
| 446 | |
| 447 | quant_fluor_data_dict: dict |
| 448 | Dictionary that contains data on XRF reference sample, including the field |
| 449 | ``element_lines``, which relates the emission lines (active at ``incident_energy``) |
| 450 | with respective fluorescence (area under the line spectra) and density of the element. |
| 451 | The fluorescence is set to None and needs to be computed later. The dictionary |
| 452 | should satisfy the ``_xrf_quant_fluor_schema`` schema. |
| 453 | """ |
| 454 | if incident_energy is not None: |
| 455 | # Make sure that it is 'float', not 'float64', since 'float64' is not supported by 'yaml' package |
| 456 | incident_energy = float(max(incident_energy, 0)) |
| 457 | |
| 458 | quant_fluor_data_dict = {} |
| 459 | quant_fluor_data_dict["name"] = quant_param_dict["name"] |
| 460 | quant_fluor_data_dict["serial"] = quant_param_dict["serial"] |
| 461 | quant_fluor_data_dict["description"] = quant_param_dict["description"] |
| 462 | |
| 463 | # Find the density (mass) of each element in the mis of compounds. |
| 464 | # Note, that the sample may contain the same element as a component of multiple compounds. |
| 465 | element_dict = {} |
| 466 | for compound, mass in quant_param_dict["compounds"].items(): |
| 467 | # Split compound/compound_density into elements/element_density |
| 468 | el_and_mass = split_compound_mass(compound, mass) |
| 469 | for el, ms in el_and_mass.items(): |
| 470 | if el in element_dict: |
| 471 | element_dict[el] += ms |
| 472 | else: |
| 473 | element_dict[el] = ms |
| 474 | |
| 475 | # Create the dictionary of element lines. Fluorescence is unknown at this point, |
| 476 | # so it is always None. |
| 477 | element_lines = {} |
| 478 | for el, ms in element_dict.items(): |
| 479 | lines = generate_eline_list([el], incident_energy=incident_energy) |
| 480 | e = {_: {"density": ms, "fluorescence": None} for _ in lines} |
| 481 | element_lines.update(e) |
| 482 | |
| 483 | quant_fluor_data_dict["element_lines"] = element_lines |
| 484 |