Skip to content

Commit

Permalink
add metadata support for pump2
Browse files Browse the repository at this point in the history
  • Loading branch information
rettigl committed Jan 23, 2025
1 parent 504678b commit 9f6fba7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
16 changes: 4 additions & 12 deletions src/specsscan/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ def load_scan(
if k in res_xarray.dims
}

# store data for resolved axis coordinates
for axis in res_xarray.dims:
self._scan_info[axis] = res_xarray.coords[axis].data

res_xarray = res_xarray.rename(rename_dict)
for k, v in coordinate_mapping.items():
if k in fast_axes:
Expand All @@ -264,18 +268,6 @@ def load_scan(
slow_axes.add(v)
self._scan_info["coordinate_depends"] = depends_dict

axis_dict = {
"/entry/sample/transformations/sample_polar": "Polar",
"/entry/sample/transformations/sample_tilt": "Tilt",
"/entry/sample/transformations/sample_azimuth": "Azimuth",
"/entry/instrument/beam_pump/pulse_delay": "delay",
}

# store data for resolved axis coordinates
for k, v in depends_dict.items():
if v in axis_dict:
self._scan_info[axis_dict[v]] = res_xarray.coords[k].data

for name in res_xarray.dims:
try:
res_xarray[name].attrs["unit"] = self._config["units"][name]
Expand Down
25 changes: 24 additions & 1 deletion src/specsscan/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,15 @@ def fetch_elab_metadata(self, scan: int, metadata: dict) -> dict:
float(metadata["elabFTW"]["laser_status"]["probe_profile_x"]),
float(metadata["elabFTW"]["laser_status"]["probe_profile_y"]),
]
if (
"laser_status" in metadata["elabFTW"]
and "pump2_profile_x" in metadata["elabFTW"]["laser_status"]
and "pump2_profile_y" in metadata["elabFTW"]["laser_status"]
):
metadata["elabFTW"]["laser_status"]["pump2_profile"] = [
float(metadata["elabFTW"]["laser_status"]["pump2_profile_x"]),
float(metadata["elabFTW"]["laser_status"]["pump2_profile_y"]),
]

# fix preparation date
if "sample" in metadata["elabFTW"] and "preparation_date" in metadata["elabFTW"]["sample"]:
Expand Down Expand Up @@ -249,11 +258,25 @@ def fetch_elab_metadata(self, scan: int, metadata: dict) -> dict:
elif metadata["elabFTW"]["scan"]["probe_polarization"] == "p":
metadata["elabFTW"]["scan"]["probe_polarization"] = 0

if (
"scan" in metadata["elabFTW"]
and "pump2_polarization" in metadata["elabFTW"]["scan"]
and isinstance(metadata["elabFTW"]["scan"]["pump2_polarization"], str)
):
if metadata["elabFTW"]["scan"]["pump2_polarization"] == "s":
metadata["elabFTW"]["scan"]["pump2_polarization"] = 90
elif metadata["elabFTW"]["scan"]["pump2_polarization"] == "p":
metadata["elabFTW"]["scan"]["pump2_polarization"] = 0

# remove pump information if pump not applied:
if not metadata["elabFTW"]["scan"].get("pump_status", 1):
if metadata["elabFTW"]["scan"].get("pump_status", "closed") == "closed":
if "pump_photon_energy" in metadata["elabFTW"].get("laser_status", {}):
del metadata["elabFTW"]["laser_status"]["pump_photon_energy"]

if metadata["elabFTW"]["scan"].get("pump2_status", "closed") == "closed":
if "pump2_photon_energy" in metadata["elabFTW"].get("laser_status", {}):
del metadata["elabFTW"]["laser_status"]["pump2_photon_energy"]

return metadata


Expand Down

0 comments on commit 9f6fba7

Please sign in to comment.