-
Notifications
You must be signed in to change notification settings - Fork 21
change kwargs in read4stem #166
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
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -30,7 +30,7 @@ def read_4dstem( | |||||||
| Index of the dataset to load if file contains multiple datasets. | ||||||||
| If None, automatically selects the first 4D dataset found. | ||||||||
| **kwargs: dict | ||||||||
| Additional keyword arguments to pass to the Dataset4dstem constructor. | ||||||||
| Additional keyword arguments to pass to the file reader. | ||||||||
|
|
||||||||
| Returns | ||||||||
| -------- | ||||||||
|
|
@@ -39,8 +39,12 @@ def read_4dstem( | |||||||
| if file_type is None: | ||||||||
| file_type = Path(file_path).suffix.lower().lstrip(".") | ||||||||
|
|
||||||||
| sampling_override = kwargs.pop("sampling", None) | ||||||||
| origin_override = kwargs.pop("origin", None) | ||||||||
| units_override = kwargs.pop("units", None) | ||||||||
|
|
||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| file_reader = importlib.import_module(f"rsciio.{file_type}").file_reader | ||||||||
| data_list = file_reader(file_path) | ||||||||
| data_list = file_reader(file_path, **kwargs) | ||||||||
|
|
||||||||
| # If specific index provided, use it | ||||||||
| if dataset_index is not None: | ||||||||
|
|
@@ -69,25 +73,25 @@ def read_4dstem( | |||||||
|
|
||||||||
| imported_axes = imported_data["axes"] | ||||||||
|
|
||||||||
| sampling = kwargs.pop( | ||||||||
| "sampling", | ||||||||
| [ax["scale"] for ax in imported_axes], | ||||||||
| sampling = ( | ||||||||
| sampling_override | ||||||||
| if sampling_override is not None | ||||||||
| else [ax["scale"] for ax in imported_axes] | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not all axes have
Suggested change
|
||||||||
| ) | ||||||||
| origin = kwargs.pop( | ||||||||
| "origin", | ||||||||
| [ax["offset"] for ax in imported_axes], | ||||||||
| origin = ( | ||||||||
| origin_override if origin_override is not None else [ax["offset"] for ax in imported_axes] | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above: Not sure the policy on logging but you could output a warning that the scale is non-linear.
Suggested change
|
||||||||
| ) | ||||||||
| units = kwargs.pop( | ||||||||
| "units", | ||||||||
| ["pixels" if ax["units"] == "1" else ax["units"] for ax in imported_axes], | ||||||||
| units = ( | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All axes will have units :) and a name. That is the minimal definition. |
||||||||
| units_override | ||||||||
| if units_override is not None | ||||||||
| else ["pixels" if ax["units"] == "1" else ax["units"] for ax in imported_axes] | ||||||||
| ) | ||||||||
|
|
||||||||
| dataset = Dataset4dstem.from_array( | ||||||||
| array=imported_data["data"], | ||||||||
| sampling=sampling, | ||||||||
| origin=origin, | ||||||||
| units=units, | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| **kwargs, | ||||||||
| ) | ||||||||
|
|
||||||||
| return dataset | ||||||||
|
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd add sampling, Orgin and Units as Other Parameters: