Skip to content

Commit

Permalink
Merge branch 'developer' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
erikfrojdh authored Feb 9, 2024
2 parents 7e9d97f + be41dec commit 2146f3d
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 11 deletions.
1 change: 1 addition & 0 deletions .github/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ dependencies:
- build
- conda-build
- conda-verify
- boa
- numpy
2 changes: 1 addition & 1 deletion .github/workflows/build_conda_pkgs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Build conda pkg
shell: bash -l {0}
run: |
conda build .
conda mambabuild .
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,5 @@ FILE_CONTENTS {
We aim to follow NEP 29 regarding supported Python and Numpy versions https://numpy.org/neps/nep-0029-deprecation_policy.html#nep29

At the moment this means:
* Python 3.8-3.10
* Numpy 1.19-1.21
* Python 3.9-3.11
* Numpy 1.22-1.24
2 changes: 1 addition & 1 deletion conda-recepie/conda_build_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ python:
- 3.11
- 3.11
- 3.11


numpy:
- 1.20
Expand All @@ -22,7 +23,6 @@ numpy:
- 1.25
- 1.26


zip_keys:
- python
- numpy
Expand Down
2 changes: 1 addition & 1 deletion hdf5maker/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from .hdf5_file import write_data_file, write_master_file, get_output_fname, Hdf5File
from .hdf5_file import write_data_file, write_master_file, get_output_fname, Hdf5File, write_simple_master_file
from .io import read_bad_pixels, read_bad_channels

#Imports related to raw files
Expand Down
21 changes: 18 additions & 3 deletions hdf5maker/hdf5_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,15 @@ def write_data_file(
fname,
data,
image_nr_low=1,
compression=hdf5plugin.Bitshuffle(nelems=0, lz4=True),
compression=hdf5plugin.Bitshuffle(nelems=0, cname='lz4'),
):
print(color.info(f"Writing: {fname}"))
f = h5py.File(fname, "w")
try:
f = h5py.File(fname, "w")
except Exception as inst:
print(color.error(f"Writing of: {fname} failed could not open file"))
raise inst

nxentry, nxdata = create_entry_and_data(f)
ds = nxdata.create_dataset(
"data",
Expand All @@ -76,14 +81,24 @@ def write_data_file(
ds.attrs["image_nr_high"] = np.int32(image_nr_low + data.shape[0] - 1)
f.close()

def write_simple_master_file(fname, data_files):
print(color.info(f"Writing: {fname}"))
f = h5py.File(fname, "w")
nxentry, nxdata = create_entry_and_data(f)

# Link written data sets:
for i, fname in enumerate(data_files, start=1):
f[f"entry/data/data_{i:06d}"] = h5py.ExternalLink(fname, "entry/data/data")

f.close()

def write_master_file(
fname,
data_files,
pixel_mask=None,
raw_master_file = None,
i0 = None,
compression=hdf5plugin.Bitshuffle(nelems=0, lz4=True),
compression=hdf5plugin.Bitshuffle(nelems=0, cname='lz4'),
):
print(color.info(f"Writing: {fname}"))
f = h5py.File(fname, "w")
Expand Down
8 changes: 7 additions & 1 deletion hdf5maker/raw_file_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,13 @@ def __init__(self, fname, redistribute=None, lazy=False, fastquad=False):
self.redistribute = True
self.dt = to_dtype(self.master["Dynamic Range"])
self.dr = self.master["Dynamic Range"]
self.total_frames = self.master["Frames in File"]
#Look for the new field Frames in File and if this is not present
#fall back to Total Frames
try:
self.total_frames = self.master["Frames in File"]
except:
self.total_frames = self.master["Total Frames"]

self.max_frames_per_file = self.master["Max Frames Per File"]
self.file_geometry = self.master["Pixels"][::-1]
self.frames_per_file = get_frames_per_file(
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

setuptools.setup(
name="hdf5maker",
version= '2023.9.21.dev0',
version= '2024.2.9.dev0',
author="Erik Frojdh",
author_email="[email protected]",
description="Eiger raw file to hdf5 converter",
Expand All @@ -36,5 +36,5 @@
"Operating System :: OS Independent",
],
ext_modules=[c_ext],
python_requires='>=3.8',
python_requires='>=3.9',
)

0 comments on commit 2146f3d

Please sign in to comment.