micress-micpy 0.3.1b1__py3-none-any.whl → 0.3.2b0__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 +54 -33
- micpy/version.py +1 -1
- {micress_micpy-0.3.1b1.dist-info → micress_micpy-0.3.2b0.dist-info}/METADATA +1 -1
- micress_micpy-0.3.2b0.dist-info/RECORD +12 -0
- micress_micpy-0.3.1b1.dist-info/RECORD +0 -12
- {micress_micpy-0.3.1b1.dist-info → micress_micpy-0.3.2b0.dist-info}/LICENSE +0 -0
- {micress_micpy-0.3.1b1.dist-info → micress_micpy-0.3.2b0.dist-info}/WHEEL +0 -0
- {micress_micpy-0.3.1b1.dist-info → micress_micpy-0.3.2b0.dist-info}/top_level.txt +0 -0
micpy/bin.py
CHANGED
|
@@ -403,32 +403,42 @@ class Series(np.ndarray):
|
|
|
403
403
|
self.times = getattr(obj, "times", None)
|
|
404
404
|
self.spacings = getattr(obj, "spacings", None)
|
|
405
405
|
|
|
406
|
-
def
|
|
406
|
+
def iter_field(self):
|
|
407
|
+
"""Iterate over fields in the series.
|
|
408
|
+
|
|
409
|
+
Yields:
|
|
410
|
+
Field.
|
|
411
|
+
"""
|
|
407
412
|
for item, time, spacing in zip(self, self.times, self.spacings):
|
|
408
413
|
yield Field(item, time, spacing)
|
|
409
414
|
|
|
410
|
-
def
|
|
411
|
-
"""Get
|
|
415
|
+
def get_field(self, index: int) -> Field:
|
|
416
|
+
"""Get a field from the series.
|
|
412
417
|
|
|
413
418
|
Args:
|
|
414
|
-
index (
|
|
419
|
+
index (int): Index of the field.
|
|
415
420
|
|
|
416
421
|
Returns:
|
|
417
422
|
Field.
|
|
418
423
|
"""
|
|
424
|
+
return Field(self[index], self.times[index], self.spacings[index])
|
|
425
|
+
|
|
426
|
+
def get_series(self, key: Union[int, slice, list]) -> "Series":
|
|
427
|
+
"""Get a series of fields.
|
|
419
428
|
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
429
|
+
Args:
|
|
430
|
+
key (Union[int, slice, list]): Key to list of field IDs, a slice object, or a
|
|
431
|
+
list of field IDs.
|
|
432
|
+
|
|
433
|
+
Returns:
|
|
434
|
+
Series of fields.
|
|
435
|
+
"""
|
|
436
|
+
if isinstance(key, int):
|
|
437
|
+
return Series([self.get_field(key)])
|
|
438
|
+
if isinstance(key, slice):
|
|
439
|
+
return Series([self.get_field(i) for i in range(*key.indices(len(self)))])
|
|
440
|
+
if isinstance(key, list):
|
|
441
|
+
return Series([self.get_field(i) for i in key])
|
|
432
442
|
raise TypeError("Invalid argument type")
|
|
433
443
|
|
|
434
444
|
def write(self, filename: str, compressed: bool = True, geometry: bool = True):
|
|
@@ -444,7 +454,7 @@ class Series(np.ndarray):
|
|
|
444
454
|
|
|
445
455
|
file_open = gzip.open if compressed else open
|
|
446
456
|
with file_open(filename, "wb") as file:
|
|
447
|
-
for field in self:
|
|
457
|
+
for field in self.iter_field():
|
|
448
458
|
field.to_file(file, geometry)
|
|
449
459
|
geometry = False
|
|
450
460
|
|
|
@@ -655,24 +665,34 @@ class File:
|
|
|
655
665
|
for position in self.index():
|
|
656
666
|
yield Field.read(position, shape=self.shape, spacing=self.spacing)
|
|
657
667
|
|
|
668
|
+
def read_field(self, field_id: int) -> Field:
|
|
669
|
+
"""Read a field from the file.
|
|
670
|
+
|
|
671
|
+
Args:
|
|
672
|
+
field_id (int): Field ID.
|
|
673
|
+
|
|
674
|
+
Returns:
|
|
675
|
+
Field.
|
|
676
|
+
"""
|
|
677
|
+
self.index()
|
|
678
|
+
|
|
679
|
+
position = self._index[field_id]
|
|
680
|
+
return Field.read(position, shape=self.shape, spacing=self.spacing)
|
|
681
|
+
|
|
658
682
|
def read(
|
|
659
683
|
self, key: Optional[Union[int, slice, list, Callable[[Field], bool]]] = None
|
|
660
684
|
) -> Series:
|
|
661
|
-
"""Read
|
|
685
|
+
"""Read a series of fields from the file.
|
|
662
686
|
|
|
663
687
|
Args:
|
|
664
|
-
key (Union[int, slice, list, Callable[[Field], bool]
|
|
665
|
-
|
|
666
|
-
|
|
688
|
+
key (Union[int, slice, list, Callable[[Field], bool]]): Key to list of
|
|
689
|
+
field IDs, a slice object, a list of field IDs, or a function that filters
|
|
690
|
+
fields. Defaults to `None`.
|
|
667
691
|
|
|
668
692
|
Returns:
|
|
669
|
-
|
|
693
|
+
Series of fields.
|
|
670
694
|
"""
|
|
671
695
|
|
|
672
|
-
def read_field(self, field_id: Union[int, slice, list]):
|
|
673
|
-
position = self._index[field_id]
|
|
674
|
-
return Field.read(position, shape=self.shape, spacing=self.spacing)
|
|
675
|
-
|
|
676
696
|
def iterable(iterable):
|
|
677
697
|
if self._verbose:
|
|
678
698
|
return utils.progress_indicator(
|
|
@@ -685,17 +705,16 @@ class File:
|
|
|
685
705
|
if key is None:
|
|
686
706
|
fields = list(field for field in iterable(self.iterate()))
|
|
687
707
|
elif isinstance(key, int):
|
|
688
|
-
fields = [read_field(
|
|
708
|
+
fields = [self.read_field(key)]
|
|
689
709
|
elif isinstance(key, slice):
|
|
690
710
|
indices = range(*key.indices(len(self._index)))
|
|
691
|
-
fields = [read_field(
|
|
711
|
+
fields = [self.read_field(i) for i in iterable(indices)]
|
|
692
712
|
elif isinstance(key, list):
|
|
693
|
-
fields = [read_field(
|
|
713
|
+
fields = [self.read_field(i) for i in iterable(key)]
|
|
694
714
|
elif isinstance(key, Callable):
|
|
695
715
|
fields = [field for field in iterable(self.iterate()) if key(field)]
|
|
696
716
|
else:
|
|
697
717
|
raise TypeError("Invalid argument type")
|
|
698
|
-
|
|
699
718
|
return Series(fields)
|
|
700
719
|
|
|
701
720
|
|
|
@@ -746,7 +765,7 @@ def plot(
|
|
|
746
765
|
args (PlotArgs, optional): Arguments for plotting. Defaults to `None`.
|
|
747
766
|
|
|
748
767
|
Returns:
|
|
749
|
-
Matplotlib figure
|
|
768
|
+
Matplotlib figure, axes, and color bar.
|
|
750
769
|
"""
|
|
751
770
|
|
|
752
771
|
if matplotlib is None:
|
|
@@ -794,7 +813,9 @@ def plot(
|
|
|
794
813
|
ax.set_aspect(args.aspect)
|
|
795
814
|
ax.set_frame_on(False)
|
|
796
815
|
|
|
797
|
-
mesh = ax.
|
|
816
|
+
mesh = ax.imshow(
|
|
817
|
+
slice_2d, cmap=args.cmap, vmin=args.vmin, vmax=args.vmax, origin="lower"
|
|
818
|
+
)
|
|
798
819
|
|
|
799
820
|
bar = pyplot.colorbar(mesh, ax=ax, cax=args.cax)
|
|
800
821
|
bar.locator = matplotlib.ticker.MaxNLocator(
|
|
@@ -803,4 +824,4 @@ def plot(
|
|
|
803
824
|
bar.outline.set_visible(False)
|
|
804
825
|
bar.update_ticks()
|
|
805
826
|
|
|
806
|
-
return fig, ax
|
|
827
|
+
return fig, ax, bar
|
micpy/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.3.
|
|
1
|
+
__version__ = "0.3.2b0"
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
micpy/__init__.py,sha256=7wQUaseppjQYZW1iAVNm2WSDjvBLlqtY8tiHsfDaW5Q,148
|
|
2
|
+
micpy/bin.py,sha256=5_VjciuoY7MGgbsYGD4YEBsGIRtN1UHEu1bF4c84KoU,26150
|
|
3
|
+
micpy/geo.py,sha256=z7dP3hC2Fhed4N5eRrlWlC4jtIXiYPIx2BYNhn10dfw,7447
|
|
4
|
+
micpy/matplotlib.py,sha256=GF2ghyBORC5RRjW00DdsHu5aSkpMFdI9wqg6d_psPsI,1198
|
|
5
|
+
micpy/tab.py,sha256=QCnfggxRWkKgS9-zGj8kyCjhfUw7QeTgGZWedHh4MTw,3548
|
|
6
|
+
micpy/utils.py,sha256=Kt1AvhMvWer9uftbb88X7N27aXtQdJl26grHmmm2vOQ,859
|
|
7
|
+
micpy/version.py,sha256=cmRz06nS65Gsdx46NbGK09hWYOtmDwCXP9-XRCvNvUc,25
|
|
8
|
+
micress_micpy-0.3.2b0.dist-info/LICENSE,sha256=seHdCiArizUoWZ6bEFg6N3K2ZtfPK35wvOwg0kH-f6o,1488
|
|
9
|
+
micress_micpy-0.3.2b0.dist-info/METADATA,sha256=iJ3JJYKKdZzkdnCkfYstoSu4NDaYJMX0aIAuMKIFoQs,1229
|
|
10
|
+
micress_micpy-0.3.2b0.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
|
11
|
+
micress_micpy-0.3.2b0.dist-info/top_level.txt,sha256=RiopkpW0AGNYdtOW2eQUWgm3yHGC13q9pWlHb2alhiE,6
|
|
12
|
+
micress_micpy-0.3.2b0.dist-info/RECORD,,
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
micpy/__init__.py,sha256=7wQUaseppjQYZW1iAVNm2WSDjvBLlqtY8tiHsfDaW5Q,148
|
|
2
|
-
micpy/bin.py,sha256=LQiaAxLCyBw_7kfimFbZtqqMoP3iAYFVKDc4Ohvyxm8,25729
|
|
3
|
-
micpy/geo.py,sha256=z7dP3hC2Fhed4N5eRrlWlC4jtIXiYPIx2BYNhn10dfw,7447
|
|
4
|
-
micpy/matplotlib.py,sha256=GF2ghyBORC5RRjW00DdsHu5aSkpMFdI9wqg6d_psPsI,1198
|
|
5
|
-
micpy/tab.py,sha256=QCnfggxRWkKgS9-zGj8kyCjhfUw7QeTgGZWedHh4MTw,3548
|
|
6
|
-
micpy/utils.py,sha256=Kt1AvhMvWer9uftbb88X7N27aXtQdJl26grHmmm2vOQ,859
|
|
7
|
-
micpy/version.py,sha256=zKEPT4cdwsCB_uCEMo5TXBcz3hseWXYp71mYqedQBds,25
|
|
8
|
-
micress_micpy-0.3.1b1.dist-info/LICENSE,sha256=seHdCiArizUoWZ6bEFg6N3K2ZtfPK35wvOwg0kH-f6o,1488
|
|
9
|
-
micress_micpy-0.3.1b1.dist-info/METADATA,sha256=5oK-n39nupCZmnR1PNSesTpWkYhTFREiJFGAuY_mZ7g,1229
|
|
10
|
-
micress_micpy-0.3.1b1.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
|
11
|
-
micress_micpy-0.3.1b1.dist-info/top_level.txt,sha256=RiopkpW0AGNYdtOW2eQUWgm3yHGC13q9pWlHb2alhiE,6
|
|
12
|
-
micress_micpy-0.3.1b1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|