Skip to content

Commit

Permalink
Merge pull request #700 from hakonanes/690-oxford-ebsp-aztec-6.1
Browse files Browse the repository at this point in the history
Fix reading of Oxford Instrument's *.ebsp files with format version 6
  • Loading branch information
hakonanes authored Nov 20, 2024
2 parents 8d60a69 + 96fb621 commit b17755b
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 77 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ its best to adhere to `Semantic Versioning <https://semver.org/spec/v2.0.0.html>
List entries are sorted in descending chronological order. Contributors to each release
were listed in alphabetical order by first name until version 0.7.0.

0.11.1 (2024-11-24)
===================

Fixed
-----
- Reading of Oxford binary `*.ebsp` files with version 6.
(`#700 <https://github.com/pyxem/kikuchipy/pull/700>`_)

0.11.0 (2024-11-10)
===================

Expand Down
4 changes: 4 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@


DATA_PATH = Path(__file__).parent / "src/kikuchipy/data"
DATA_PATH = DATA_PATH.resolve()

# ------------------------------ Setup ------------------------------ #

Expand Down Expand Up @@ -511,6 +512,9 @@ def oxford_binary_file(tmpdir, request) -> Generator[TextIOWrapper, None, None]:

for i in new_order:
r, c = np.unravel_index(i, (nr, nc))
if ver > 4:
extra_pattern_header = np.array([c, r], dtype=np.int32)
extra_pattern_header.tofile(f)
pattern_header.tofile(f)
data[r, c].tofile(f)
if ver > 1:
Expand Down
29 changes: 18 additions & 11 deletions doc/tutorials/load_save_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,13 @@
"Here, the Oxford Instruments binary [file_reader()](../reference/generated/kikuchipy.io.plugins.oxford_binary.file_reader.rst) is called.\n",
"\n",
"Every pattern's flattened index into the 2D navigation map, as well as their entry in the file (map order isn't always the same as file order) can be retrieved from `s_oxford.original_metadata.map1d_id` and `s_oxford.original_metadata.file_order`, respectively.\n",
"If available in the file, every pattern's row and column beam position in microns can be retrieved from `s_oxford.original_metadata.beam_y` and `s_oxford.original_metadata.beam_x`, respectively.\n",
"The following data may be read as well, depending on their presence in the file:\n",
"\n",
"* `s_oxford.original_metadata.beam_x`: Every pattern's column in microns\n",
"* `s_oxford.original_metadata.beam_y`: Every pattern's row in microns\n",
"* `s_oxford.original_metadata.map_x`: Every pattern's column\n",
"* `s_oxford.original_metadata.map_y`: Every pattern's row\n",
"\n",
"All these are 1D arrays."
]
},
Expand Down Expand Up @@ -1100,10 +1106,11 @@
"## Load and save virtual BSE images\n",
"\n",
"One or more virtual backscatter electron (BSE) images in a [VirtualBSEImage](../reference/generated/kikuchipy.signals.VirtualBSEImage.rst) signal can be read and written to file using one of HyperSpy's many readers and writers.\n",
"If they are only to be used internally in HyperSpy, they can be written to and read back from HyperSpy's HDF5/zarr specification [as explained above for EBSD master patterns](#Save-patterns).\n",
"\n",
"If they are only to be used internally in HyperSpy, they can be written to and read back from HyperSpy's HDF5/zarr specification [as explained above for EBSD master patterns](#Save-patterns).\n",
"If we want to write the images to image files, HyperSpy also provides a series of image readers/writers, as explained in their [IO user guide](https://hyperspy.org/hyperspy-doc/v1.7/user_guide/io.html#images).\n",
"If we wanted to write them as a stack of TIFF images"
"\n",
"Writing as a stack of TIFF images"
]
},
{
Expand Down Expand Up @@ -1146,7 +1153,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We can also write them to e.g. `png` or `bmp` files with `Matplotlib`"
"Read the TIFF stack back into a `VirtualBSEImage` signal"
]
},
{
Expand All @@ -1155,16 +1162,15 @@
"metadata": {},
"outputs": [],
"source": [
"nav_size = vbse.axes_manager.navigation_size\n",
"for i in range(nav_size):\n",
" plt.imsave(temp_dir / f\"vbse{i}.png\", vbse.inav[i].data)"
"vbse2 = hs.load(temp_dir / vbse_fname, signal_type=\"VirtualBSEImage\")\n",
"vbse2"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Read the TIFF stack back into a `VirtualBSEImage` signal"
"We can also write them to e.g. `png` or `bmp` files with `Matplotlib`"
]
},
{
Expand All @@ -1173,8 +1179,9 @@
"metadata": {},
"outputs": [],
"source": [
"vbse2 = hs.load(temp_dir / vbse_fname, signal_type=\"VirtualBSEImage\")\n",
"vbse2"
"nav_size = vbse.axes_manager.navigation_size\n",
"for i in range(nav_size):\n",
" plt.imsave(temp_dir / f\"vbse{i}.png\", vbse.inav[i].data)"
]
},
{
Expand Down Expand Up @@ -1211,7 +1218,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.6"
"version": "3.12.7"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
Expand Down
2 changes: 1 addition & 1 deletion src/kikuchipy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"Carter Francis",
"Magnus Nord",
]
__version__ = "0.11.0"
__version__ = "0.11.1"

__getattr__, __dir__, __all__ = lazy_loader.attach_stub(__name__, __file__)

Expand Down
4 changes: 3 additions & 1 deletion src/kikuchipy/data/_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,9 @@ def fetch_file_path(
) -> str:
if show_progressbar is None:
show_progressbar = hs.preferences.General.show_progressbar
downloader = pooch.HTTPDownloader(progressbar=show_progressbar)
downloader = pooch.HTTPDownloader(
progressbar=show_progressbar, headers={"User-Agent": "agent"}
)

if self.is_in_package:
if self.has_correct_hash:
Expand Down
Loading

0 comments on commit b17755b

Please sign in to comment.