Extract metadata from start and stop document. Metadata extracted from other document in the scan are beamline specific and added to dictionary at later time.
(hdr)
| 539 | |
| 540 | |
| 541 | def _extract_metadata_from_header(hdr): |
| 542 | """ |
| 543 | Extract metadata from start and stop document. Metadata extracted from other document |
| 544 | in the scan are beamline specific and added to dictionary at later time. |
| 545 | """ |
| 546 | start_document = hdr.start |
| 547 | |
| 548 | mdata = ScanMetadataXRF() |
| 549 | |
| 550 | data_locations = { |
| 551 | "scan_id": ["scan_id"], |
| 552 | "scan_uid": ["uid"], |
| 553 | "scan_instrument_id": ["beamline_id"], |
| 554 | "scan_instrument_name": [], |
| 555 | "scan_end_station": [], |
| 556 | "scan_time_start": ["time"], |
| 557 | "scan_time_start_utc": ["time"], |
| 558 | "instrument_mono_incident_energy": ["beamline_status/energy", "scan/energy"], |
| 559 | "instrument_beam_current": [], |
| 560 | "instrument_detectors": ["detectors", "scan/detectors"], |
| 561 | "sample_name": ["sample/name", "sample", "scan/sample_name"], |
| 562 | "experiment_plan_name": ["plan_name"], |
| 563 | "experiment_plan_type": ["plan_type"], |
| 564 | "proposal_num": ["proposal/proposal_num"], |
| 565 | "proposal_title": ["proposal/proposal_title"], |
| 566 | "proposal_PI_lastname": ["proposal/PI_lastname"], |
| 567 | "proposal_saf_num": ["proposal/saf_num"], |
| 568 | "proposal_cycle": ["proposal/cycle"], |
| 569 | # Scan parameters |
| 570 | "param_type": ["scan/type"], |
| 571 | "param_input": ["scan/scan_input"], |
| 572 | "param_dwell": ["scan/dwell", "exposure_time"], |
| 573 | "param_snake": ["scan/snake"], |
| 574 | "param_shape": ["scan/shape", "shape"], |
| 575 | "param_theta": ["scan/theta/val"], |
| 576 | "param_theta_units": ["scan/theta/units"], |
| 577 | "param_delta": ["scan/delta/val"], |
| 578 | "param_delta_units": ["scan/delta/units"], |
| 579 | "param_fast_axis": ["scaninfo/fast_axis", "scan/fast_axis/motor_name"], |
| 580 | "param_fast_axis_units": ["scan/fast_axis/units"], |
| 581 | "param_slow_axis": ["scaninfo/slow_axis", "scan/slow_axis/motor_name"], |
| 582 | "param_slow_axis_units": ["scan/slow_axis/units"], |
| 583 | } |
| 584 | |
| 585 | for key, locations in data_locations.items(): |
| 586 | # Go to the next key if no location is defined for the current key. |
| 587 | # No locations means that the data is not yet defined in start document on any beamline |
| 588 | # Multiple locations point to locations at different beamlines |
| 589 | if not locations: |
| 590 | continue |
| 591 | |
| 592 | # For each metadata key there could be none, one or multiple locations in the start document |
| 593 | for loc in locations: |
| 594 | path = loc.split("/") # |
| 595 | ref = start_document |
| 596 | for n, p in enumerate(path): |
| 597 | if n >= len(path) - 1: |
| 598 | break |
no test coverage detected