Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add xarray backend for Igor Pro files #60

Merged
merged 58 commits into from
Oct 8, 2024
Merged

Add xarray backend for Igor Pro files #60

merged 58 commits into from
Oct 8, 2024

Conversation

kmnhan
Copy link
Owner

@kmnhan kmnhan commented Sep 4, 2024

Add a backend so that igor pro files (.pxp, .pxt, .ibw) can be opened with xr.open_dataarray and xr.open_dataset.

Links:
https://docs.xarray.dev/en/stable/internals/how-to-add-new-backend.html

  • Implement backend entry point
  • Change io functions to use xarray methods like xr.open_mfdataset
    After testing with dask, joblib-based parallelization seems to work better (at least for igor files)
  • Update documentation on working with igor
  • Update documentation with changes to data loader
    Postpone change to 3.0
  • Drop support returning list of items, it was prone to breaking anyways, replace with DataTree
    This breaks too many things, better split

`.pxt`, `.pxp`, and `.ibw` files can now be opened with xarray methods such as `xr.open_dataset` and `xr.open_dataarray`. See the updated user guide for more information.
@kmnhan kmnhan added enhancement New feature or request docs Documentation related labels Sep 4, 2024
@kmnhan kmnhan self-assigned this Sep 4, 2024
Copy link

codecov bot commented Sep 4, 2024

Codecov Report

Attention: Patch coverage is 82.14286% with 80 lines in your changes missing coverage. Please review.

Project coverage is 77.46%. Comparing base (6fcc4a8) to head (3094678).
Report is 516 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/erlab/io/dataloader.py 80.00% 25 Missing ⚠️
src/erlab/io/plugins/maestro.py 30.00% 7 Missing ⚠️
src/erlab/plotting/annotations.py 22.22% 7 Missing ⚠️
src/erlab/io/__init__.py 25.00% 6 Missing ⚠️
src/erlab/io/igor.py 80.64% 6 Missing ⚠️
src/erlab/utils/formatting.py 90.76% 6 Missing ⚠️
src/erlab/io/plugins/merlin.py 78.26% 5 Missing ⚠️
src/erlab/io/plugins/da30.py 69.23% 4 Missing ⚠️
src/erlab/io/plugins/esm.py 81.81% 4 Missing ⚠️
src/erlab/interactive/fermiedge.py 90.90% 2 Missing ⚠️
... and 7 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #60      +/-   ##
==========================================
+ Coverage   75.94%   77.46%   +1.51%     
==========================================
  Files          64       66       +2     
  Lines       10543    10697     +154     
==========================================
+ Hits         8007     8286     +279     
+ Misses       2536     2411     -125     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Calling `erlab.io.load_wave` and `erlab.io.load_experiment` is deprecated. When writing new code, use `xarray.load_dataarray` and `xarray.load_dataset` instead.
Whenever the `identify()` method failed to find any files, subclasses had to explicitly raise `FileNotFoundError`. This resulted in a lot of boilerplate code and ambiguous error messages. Now, all subclasses can just return `None` in `identify()` when no files are found. The appropriate error is automatically raised.
Memmapping seemed to interfere loading multiple files when called through ipywidgets.
@kmnhan kmnhan force-pushed the dev-io branch 5 times, most recently from 4141c42 to 08930bb Compare September 11, 2024 04:59
kmnhan and others added 26 commits September 23, 2024 14:44
When accessing the data of a single slice from the right-click menu of `ImageTool`, the attributes of the original data are now kept. This allows saved slices or data opened in other tools to retain their attributes.
This commit adds a new data loader for beamline ID21 ESM at NSLS-II, Brookhaven National Laboratory.
The DA30 loader now tries to return a dataset from `.zip` files only when there are no coordinate conflicts. In the case of conflicts, the loader will return a `DataTree`.

Also, single region DA30 `.pxt` files will now return a `DataArray` consistent with the equivalent `.ibw` file.
Coordinate order was broken for loaders which assign coordinates in inherited `post_process`. This is now fixed, and returned data will be consistently ordered with respect to the mapping, with the dimension coordinates coming first.
@kmnhan kmnhan marked this pull request as ready for review October 8, 2024 06:27
@kmnhan kmnhan merged commit 1f646d2 into main Oct 8, 2024
11 checks passed
@kmnhan kmnhan deleted the dev-io branch October 8, 2024 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation related enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant