micress-micpy 0.2.14b0__py3-none-any.whl → 0.2.16b0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- micpy/bin.py +51 -47
- micpy/utils.py +11 -0
- micpy/version.py +1 -1
- {micress_micpy-0.2.14b0.dist-info → micress_micpy-0.2.16b0.dist-info}/METADATA +1 -1
- micress_micpy-0.2.16b0.dist-info/RECORD +12 -0
- micress_micpy-0.2.14b0.dist-info/RECORD +0 -12
- {micress_micpy-0.2.14b0.dist-info → micress_micpy-0.2.16b0.dist-info}/LICENSE +0 -0
- {micress_micpy-0.2.14b0.dist-info → micress_micpy-0.2.16b0.dist-info}/WHEEL +0 -0
- {micress_micpy-0.2.14b0.dist-info → micress_micpy-0.2.16b0.dist-info}/top_level.txt +0 -0
micpy/bin.py
CHANGED
|
@@ -631,67 +631,67 @@ class File:
|
|
|
631
631
|
if self._verbose:
|
|
632
632
|
print(*args, file=sys.stderr)
|
|
633
633
|
|
|
634
|
-
def
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
self._file = open(self._filename, "rb")
|
|
638
|
-
self._compressed = utils.is_compressed(self._filename)
|
|
639
|
-
|
|
640
|
-
return self
|
|
634
|
+
def _open_file(self):
|
|
635
|
+
self._file = open(self._filename, "rb")
|
|
636
|
+
self._compressed = utils.is_compressed(self._filename)
|
|
641
637
|
|
|
642
|
-
def
|
|
643
|
-
"""Close the file."""
|
|
638
|
+
def _close_file(self):
|
|
644
639
|
if self._file:
|
|
645
640
|
self._file.close()
|
|
641
|
+
self._reset()
|
|
646
642
|
|
|
643
|
+
def _reset(self):
|
|
647
644
|
self._file = None
|
|
648
645
|
self._compressed = None
|
|
649
646
|
self._created = None
|
|
650
647
|
self._modified = None
|
|
651
648
|
self._index = None
|
|
652
649
|
|
|
653
|
-
def
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
Args:
|
|
657
|
-
create (bool, optional): Create the index. Defaults to None (auto).
|
|
658
|
-
update (bool, optional): Update the index. Defaults to None (auto).
|
|
650
|
+
def _update_timestamps(self):
|
|
651
|
+
self._created = os.path.getctime(self._filename)
|
|
652
|
+
self._modified = os.path.getmtime(self._filename)
|
|
659
653
|
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
return self._created != os.path.getctime(self._filename)
|
|
666
|
-
|
|
667
|
-
def file_modified():
|
|
668
|
-
return self._modified != os.path.getmtime(self._filename)
|
|
669
|
-
|
|
670
|
-
create = create if create is not None else file_created()
|
|
671
|
-
update = update if update is not None else file_modified()
|
|
672
|
-
|
|
673
|
-
if create:
|
|
674
|
-
self.close()
|
|
675
|
-
self.open()
|
|
654
|
+
def open(self):
|
|
655
|
+
"""Open the file."""
|
|
656
|
+
if not self._file:
|
|
657
|
+
self.create_index()
|
|
658
|
+
return self
|
|
676
659
|
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
660
|
+
def close(self):
|
|
661
|
+
"""Close the file."""
|
|
662
|
+
self._close_file()
|
|
663
|
+
|
|
664
|
+
def index(self):
|
|
665
|
+
"""Get the index of the file."""
|
|
666
|
+
if self._created != os.path.getctime(self._filename):
|
|
667
|
+
self.create_index()
|
|
668
|
+
elif self._modified != os.path.getmtime(self._filename):
|
|
669
|
+
self.update_index()
|
|
670
|
+
return self._index
|
|
680
671
|
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
672
|
+
def create_index(self):
|
|
673
|
+
"""Create an index of the file."""
|
|
674
|
+
self._close_file()
|
|
675
|
+
self._open_file()
|
|
676
|
+
self._update_timestamps()
|
|
677
|
+
self._index = Index.from_file(
|
|
678
|
+
self._file,
|
|
685
679
|
verbose=self._verbose,
|
|
680
|
+
chunk_size=self._chunk_size,
|
|
681
|
+
compressed=self._compressed,
|
|
686
682
|
)
|
|
687
683
|
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
self.
|
|
693
|
-
|
|
694
|
-
|
|
684
|
+
def update_index(self):
|
|
685
|
+
"""Update the index of the file."""
|
|
686
|
+
self._update_timestamps()
|
|
687
|
+
index = Index.from_file(
|
|
688
|
+
self._file,
|
|
689
|
+
verbose=self._verbose,
|
|
690
|
+
chunk_size=self._chunk_size,
|
|
691
|
+
compressed=self._compressed,
|
|
692
|
+
position=self._index[-1],
|
|
693
|
+
)
|
|
694
|
+
self._index.extend(index)
|
|
695
695
|
|
|
696
696
|
def times(self) -> List[float]:
|
|
697
697
|
"""Get the times of the fields in the file.
|
|
@@ -706,7 +706,7 @@ class File:
|
|
|
706
706
|
|
|
707
707
|
Args:
|
|
708
708
|
shape (Tuple[int, int, int]): Shape of the geometry.
|
|
709
|
-
spacing (Tuple[float, float, float]): Spacing of the geometry
|
|
709
|
+
spacing (Tuple[float, float, float]): Spacing of the geometry in μm³.
|
|
710
710
|
"""
|
|
711
711
|
|
|
712
712
|
self.shape = np.array(shape)
|
|
@@ -726,7 +726,11 @@ class File:
|
|
|
726
726
|
Defaults to True.
|
|
727
727
|
"""
|
|
728
728
|
geo_dict = geo.read(filename, type=type, compressed=compressed)
|
|
729
|
-
|
|
729
|
+
|
|
730
|
+
shape = geo_dict["shape"]
|
|
731
|
+
spacing = utils.convert_si(geo_dict["spacing"], "cm", "μm")
|
|
732
|
+
|
|
733
|
+
self.set_geo(shape, spacing)
|
|
730
734
|
|
|
731
735
|
def find_geo(self, type: geo.Type = geo.Type.EXTENDED, compressed: bool = None):
|
|
732
736
|
"""Find geometry file and read it.
|
micpy/utils.py
CHANGED
|
@@ -4,6 +4,17 @@ import sys
|
|
|
4
4
|
import time
|
|
5
5
|
|
|
6
6
|
|
|
7
|
+
def convert_si(value, unit_in, unit_out):
|
|
8
|
+
"""Convert value from one SI unit to another SI unit."""
|
|
9
|
+
SI = {"μm": 0.000001, "mm": 0.001, "cm": 0.01, "m": 1.0}
|
|
10
|
+
|
|
11
|
+
if isinstance(value, (float, int)):
|
|
12
|
+
return value * SI[unit_in] / SI[unit_out]
|
|
13
|
+
elif isinstance(value, (tuple, list)):
|
|
14
|
+
return [v * SI[unit_in] / SI[unit_out] for v in value]
|
|
15
|
+
raise ValueError("Unsupported value type.")
|
|
16
|
+
|
|
17
|
+
|
|
7
18
|
def progress_indicator(iterable, description="Progress", unit="Iteration", start=1):
|
|
8
19
|
"""Progress indicator for iterable."""
|
|
9
20
|
|
micpy/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.2.
|
|
1
|
+
__version__ = "0.2.16b0"
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
micpy/__init__.py,sha256=7wQUaseppjQYZW1iAVNm2WSDjvBLlqtY8tiHsfDaW5Q,148
|
|
2
|
+
micpy/bin.py,sha256=1eO8nv3j3CNFFx35W2I-MdOTgelxVwOf3AzIv5-cnXY,26586
|
|
3
|
+
micpy/geo.py,sha256=dcXcxvAxPpe4Rrs1ImYs8H67c2228brabdefJMoLn0g,7354
|
|
4
|
+
micpy/matplotlib.py,sha256=toxFTtTaA-usuWUltMp0XufQee4-n68XH7SN2In2NZY,1845
|
|
5
|
+
micpy/tab.py,sha256=ZXhL6bg17W3jqFFX28htCOAV9W_W3op_-GD7iU5a_wY,3547
|
|
6
|
+
micpy/utils.py,sha256=-JS5SRqH4QMD6_pXBKPVw5zPNTbaqkcOUu9ej5Gi0QU,1282
|
|
7
|
+
micpy/version.py,sha256=MwwJ3Tq2WyMrlg5ARuI934Sn37GJtLQJ8y2GpYXfdw4,26
|
|
8
|
+
micress_micpy-0.2.16b0.dist-info/LICENSE,sha256=seHdCiArizUoWZ6bEFg6N3K2ZtfPK35wvOwg0kH-f6o,1488
|
|
9
|
+
micress_micpy-0.2.16b0.dist-info/METADATA,sha256=ZtkZWKBm6rCf4Bgwq8hKzO-sEdNkSpCBe7XDC5sF6EY,3824
|
|
10
|
+
micress_micpy-0.2.16b0.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
|
11
|
+
micress_micpy-0.2.16b0.dist-info/top_level.txt,sha256=RiopkpW0AGNYdtOW2eQUWgm3yHGC13q9pWlHb2alhiE,6
|
|
12
|
+
micress_micpy-0.2.16b0.dist-info/RECORD,,
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
micpy/__init__.py,sha256=7wQUaseppjQYZW1iAVNm2WSDjvBLlqtY8tiHsfDaW5Q,148
|
|
2
|
-
micpy/bin.py,sha256=VHh9JPJAr0jjFJnyPLO-kIO1AdEuQgBun8oakLOpaoM,26534
|
|
3
|
-
micpy/geo.py,sha256=dcXcxvAxPpe4Rrs1ImYs8H67c2228brabdefJMoLn0g,7354
|
|
4
|
-
micpy/matplotlib.py,sha256=toxFTtTaA-usuWUltMp0XufQee4-n68XH7SN2In2NZY,1845
|
|
5
|
-
micpy/tab.py,sha256=ZXhL6bg17W3jqFFX28htCOAV9W_W3op_-GD7iU5a_wY,3547
|
|
6
|
-
micpy/utils.py,sha256=Kt1AvhMvWer9uftbb88X7N27aXtQdJl26grHmmm2vOQ,859
|
|
7
|
-
micpy/version.py,sha256=hNVzjX1MyH60RwPXe8_zwZd7WsxPBh2PKFtmqeYKn_Y,26
|
|
8
|
-
micress_micpy-0.2.14b0.dist-info/LICENSE,sha256=seHdCiArizUoWZ6bEFg6N3K2ZtfPK35wvOwg0kH-f6o,1488
|
|
9
|
-
micress_micpy-0.2.14b0.dist-info/METADATA,sha256=2kD96oel2I-27Of19SvAh6kKYTpKrNInKrR9pw0nwtY,3824
|
|
10
|
-
micress_micpy-0.2.14b0.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
|
11
|
-
micress_micpy-0.2.14b0.dist-info/top_level.txt,sha256=RiopkpW0AGNYdtOW2eQUWgm3yHGC13q9pWlHb2alhiE,6
|
|
12
|
-
micress_micpy-0.2.14b0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|