Skip to content

Commit 0450b43

Browse files
committed
update general loader, Readme and examples
1 parent 7c22382 commit 0450b43

3 files changed

Lines changed: 47 additions & 3 deletions

File tree

AFMReader/general_loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def load(self) -> tuple[npt.NDArray | str, float | None]: # noqa: C901
6565
elif self.suffix == ".spm":
6666
image, pixel_to_nanometre_scaling_factor = spm.load_spm(self.filepath, self.channel)
6767
elif self.suffix == ".h5-jpk":
68-
image, pixel_to_nanometre_scaling_factor = h5_jpk.load_h5jpk(self.filepath, self.channel)
68+
image, pixel_to_nanometre_scaling_factor, _ = h5_jpk.load_h5jpk(self.filepath, self.channel)
6969
elif self.suffix == ".stp":
7070
image, pixel_to_nanometre_scaling_factor = stp.load_stp(self.filepath)
7171
elif self.suffix == ".top":

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,15 @@ image, pixel_to_nanometre_scaling_factor = load_jpk(file_path="./my_jpk_file.jpk
129129
### .h5-jpk
130130

131131
You can open `.h5-jpk` files using the `load_h5jpk` function. Just pass in the path
132-
to the file, the channel name you want to use and the frame number to access.
132+
to the file and the channel name you want to use.
133133
(If in doubt, use `height_trace` or `measuredHeight_trace`).
134134

135+
Note: Since `.h5-jpk` stores timeseries AFM data a dictionary of timestamps for each frame is also returned.
136+
135137
```python
136138
from AFMReader.h5_jpk import load_h5jpk
137139

138-
image, pixel_to_nanometre_scaling_factor = load_h5jpk(file_path="./my_jpk_file.jpk", channel="height_trace", frame = 0)
140+
frames, pixel_to_nanometre_scaling_factor, timestamp_dict = load_h5jpk(file_path="./my_jpk_file.jpk", channel="height_trace")
139141
```
140142

141143
### .stp

examples/example_01.ipynb

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,48 @@
188188
"plt.show()"
189189
]
190190
},
191+
{
192+
"cell_type": "markdown",
193+
"metadata": {},
194+
"source": [
195+
"# H5-JPK Files"
196+
]
197+
},
198+
{
199+
"cell_type": "code",
200+
"execution_count": null,
201+
"metadata": {},
202+
"outputs": [],
203+
"source": [
204+
"# Import the load_jpk function from AFMReader\n",
205+
"from AFMReader.h5_jpk import load_h5jpk"
206+
]
207+
},
208+
{
209+
"cell_type": "code",
210+
"execution_count": null,
211+
"metadata": {},
212+
"outputs": [],
213+
"source": [
214+
"# Load the JPK file as an image and pixel to nm scaling factor\n",
215+
"FILE = \"../tests/resources/sample_0.h5-jpk\"\n",
216+
"frames, pixel_to_nm_scaling, timestamps = load_h5jpk(file_path=FILE, channel=\"height_trace\", flip_image=True)\n",
217+
"logger.info(f\"Loaded {len(frames)} frames from {FILE}\")"
218+
]
219+
},
220+
{
221+
"cell_type": "code",
222+
"execution_count": null,
223+
"metadata": {},
224+
"outputs": [],
225+
"source": [
226+
"# Plot the image\n",
227+
"import matplotlib.pyplot as plt\n",
228+
"\n",
229+
"plt.imshow(image, cmap=\"afmhot\")\n",
230+
"plt.show()"
231+
]
232+
},
191233
{
192234
"cell_type": "markdown",
193235
"metadata": {},

0 commit comments

Comments
 (0)