kmnhan / erlabpy

Complete python workflow for Angle-Resolved Photoemission Spectroscopy (ARPES)
https://erlabpy.readthedocs.io
GNU General Public License v3.0
6 stars 7 forks source link

A universal attribute accessor #27

Closed kmnhan closed 2 weeks ago

kmnhan commented 7 months ago

Description

Currently, the data loader adds new keys to the data attributes to store common metadata like sample temperature.

For instance, if an endstation stores the sample temperature in the "TB" attribute, we would add a new key "temp_sample" to the attributes and copy the value. This results in duplicate attributes with same value but different name, which can be confusing.

Possible solution

We could try to preserve the original attributes.

The steps are:

  1. Add a mapping to the loader.
  2. Upon loading the data, just add one attribute that stores the name of the loader the data was loaded with.
  3. Write an accessor that can get the mapping from the loader, and return the corresponding value dynamically.

Some expected problems with this approach:

Alternatives

No response

Additional context

No response

kmnhan commented 2 months ago

In this approach, major changes to the loader may break existing code and saved data. It would be better to retain the current way of storing the data, and just add an accessor for convenience.

Things to consider:

  1. What do we need in the accessor?

    • Hard to generalize, must provide per-loader customization
    • Similar to creating a summary dataset, although this currently requires manual effort
  2. Are we OK with current attribute names? They may be confusing, i.e., temperature is temp_sample but work function is sample_workfunction...