Skip to content

polarisation 'pc' not recognised on i06 #30

@DanPorter

Description

@DanPorter

Scan file

/dls/i06/data/2026/cm44142-2/i06-369334.nxs

Notebook

/dls/i06/data/2026/cm44142-2/processed/notebooks/i06-369334_xas_notebook.ipynb

Code

xas_scan = scan.xas_spectra(dls_loader=True)

Error

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[7], line 2
      1 # Load scan as Spectra object
----> 2 xas_scan = scan.xas_spectra(dls_loader=True)
      3 scan_title = f"#{xas_scan.metadata.scan_no} {edge_label} T={xas_scan.metadata.temp:.0f}K B={xas_scan.metadata.mag_field:.3g}T {xas_scan.metadata.pol}"
      4 print(scan_title)

File /dls_sw/apps/mmg_toolbox/latest/mmg_toolbox/mmg_toolbox/nexus/nexus_scan.py:353, in NexusScan.xas_spectra(self, sample_name, element_edge, mode, dls_loader)
    341 def xas_spectra(self, sample_name: str | None = None, element_edge: str | None = None, mode: str | list[str] = 'all',
    342                 dls_loader: bool = False) -> SpectraContainer:
    343     """
    344     Load XAS Spectra from the scan file
    345 
   (...)
    351     :return: SpectraContainer
    352     """
--> 353     return load_xas_scans(self.filename, sample_name=sample_name, element_edge=element_edge,
    354                           mode=mode, dls_loader=dls_loader)[0]

File /dls_sw/apps/mmg_toolbox/latest/mmg_toolbox/mmg_toolbox/xas/nxxas_loader.py:323, in load_xas_scans(sample_name, element_edge, mode, dls_loader, *filenames)
    305 def load_xas_scans(*filenames: str, sample_name: str | None = None, element_edge: str | None = None,
    306                    mode: str | list[str] = 'all', dls_loader: bool = False) -> list[SpectraContainer]:
    307     """
    308     Load XAS Spectra from a list of scan files
    309 
   (...)
    316     :return: SpectraContainer
    317     """
    318     scans = [
    319         load_from_dat(filename, sample_name=sample_name, element_edge=element_edge, mode=mode)
    320         if filename.endswith('.dat')
    321         else load_from_nxs(filename, sample_name=sample_name, element_edge=element_edge, mode=mode)
    322         if not dls_loader and is_nxxas(filename)
--> 323         else load_from_nxs_using_hdfmap(filename, sample_name=sample_name, element_edge=element_edge, mode=mode)
    324         for filename in filenames
    325     ]
    326     return scans

File /dls_sw/apps/mmg_toolbox/latest/mmg_toolbox/mmg_toolbox/xas/nxxas_loader.py:276, in load_from_nxs_using_hdfmap(filename, sample_name, element_edge, mode)
    274 end_date_iso = m.eval(hdf, 'str(end_time)')
    275 cmd = m.eval(hdf, Md.cmd)
--> 276 pol = get_polarisation(hdf)
    277 pol_angle = m.eval(hdf, Md.pol_angle)
    278 if sample_name is None:

File /dls_sw/apps/mmg_toolbox/latest/mmg_toolbox/mmg_toolbox/utils/polarisation.py:141, in get_polarisation(pol)
    139         dataset = nx_find(pol, label)
    140         if dataset:  # DLS specific polarisation mode
--> 141             return get_polarisation(dataset)
    142     raise KeyError(f"{pol} contains no polarisation fields")
    143 if np.issubdtype(pol.dtype, np.number):

File /dls_sw/apps/mmg_toolbox/latest/mmg_toolbox/mmg_toolbox/utils/polarisation.py:147, in get_polarisation(pol)
    145         return polarisation_label_from_stokes(pol[...])
    146     return polarisation_label_from_stokes(*pol)
--> 147 return check_polarisation(pol[()])

File /dls_sw/apps/mmg_toolbox/latest/mmg_toolbox/mmg_toolbox/utils/polarisation.py:98, in check_polarisation(label, arbitrary_angle)
     96 if label is None and arbitrary_angle is not None:
     97     return polarisation_label_from_stokes(*stokes_from_vector(arbitrary_angle))
---> 98 raise ValueError(f"Polarisation parameters not recognized: {label}")

ValueError: Polarisation parameters not recognized: b'pc'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions