PyOPIA 2.4.4__tar.gz → 2.4.6__tar.gz

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.
Files changed (26) hide show
  1. {pyopia-2.4.4 → pyopia-2.4.6}/PKG-INFO +5 -1
  2. {pyopia-2.4.4 → pyopia-2.4.6}/README.md +4 -0
  3. pyopia-2.4.6/pyopia/__init__.py +1 -0
  4. {pyopia-2.4.4 → pyopia-2.4.6}/pyopia/instrument/silcam.py +81 -9
  5. {pyopia-2.4.4 → pyopia-2.4.6}/pyopia/io.py +1 -1
  6. pyopia-2.4.4/pyopia/__init__.py +0 -1
  7. {pyopia-2.4.4 → pyopia-2.4.6}/LICENSE +0 -0
  8. {pyopia-2.4.4 → pyopia-2.4.6}/pyopia/background.py +0 -0
  9. {pyopia-2.4.4 → pyopia-2.4.6}/pyopia/classify.py +0 -0
  10. {pyopia-2.4.4 → pyopia-2.4.6}/pyopia/cli.py +0 -0
  11. {pyopia-2.4.4 → pyopia-2.4.6}/pyopia/exampledata.py +0 -0
  12. {pyopia-2.4.4 → pyopia-2.4.6}/pyopia/instrument/__init__.py +0 -0
  13. {pyopia-2.4.4 → pyopia-2.4.6}/pyopia/instrument/common.py +0 -0
  14. {pyopia-2.4.4 → pyopia-2.4.6}/pyopia/instrument/holo.py +0 -0
  15. {pyopia-2.4.4 → pyopia-2.4.6}/pyopia/instrument/uvp.py +0 -0
  16. {pyopia-2.4.4 → pyopia-2.4.6}/pyopia/pipeline.py +0 -0
  17. {pyopia-2.4.4 → pyopia-2.4.6}/pyopia/plotting.py +0 -0
  18. {pyopia-2.4.4 → pyopia-2.4.6}/pyopia/process.py +0 -0
  19. {pyopia-2.4.4 → pyopia-2.4.6}/pyopia/simulator/__init__.py +0 -0
  20. {pyopia-2.4.4 → pyopia-2.4.6}/pyopia/simulator/silcam.py +0 -0
  21. {pyopia-2.4.4 → pyopia-2.4.6}/pyopia/statistics.py +0 -0
  22. {pyopia-2.4.4 → pyopia-2.4.6}/pyopia/tests/__init__.py +0 -0
  23. {pyopia-2.4.4 → pyopia-2.4.6}/pyopia/tests/test_classify.py +0 -0
  24. {pyopia-2.4.4 → pyopia-2.4.6}/pyopia/tests/test_notebooks.py +0 -0
  25. {pyopia-2.4.4 → pyopia-2.4.6}/pyopia/tests/test_pipeline.py +0 -0
  26. {pyopia-2.4.4 → pyopia-2.4.6}/pyproject.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyOPIA
3
- Version: 2.4.4
3
+ Version: 2.4.6
4
4
  Summary: A Python Ocean Particle Image Analysis toolbox.
5
5
  Home-page: https://github.com/sintef/pyopia
6
6
  Keywords: Ocean,Particles,Imaging,Measurement,Size distribution
@@ -91,6 +91,10 @@ We welcome additions and improvements to the code! We request that you follow a
91
91
  4. All pull requests must be reviewed by a person. The benefits from code review are plenty, but we like to emphasise that code reviews help spreading the awarenes of code changes. Please note that code reviews should be a pleasant experience, so be plesant, polite and remember that there is a human being with good intentions on the other side of the screen.
92
92
  5. All contributions are linted with flake8. We recommend that you run flake8 on your code while developing to fix any issues as you go. We recommend using autopep8 to autoformat your Python code (but please check the code behaviour is not affected by autoformatting before pushing). This makes flake8 happy, and makes it easier for us all to maintain a consistent and readable code base.
93
93
 
94
+ ## Docstrings
95
+
96
+ Use the NumPy style in docstrings. See style guide [here](https://numpydoc.readthedocs.io/en/latest/format.html#documenting-classes)
97
+
94
98
  # Installing
95
99
 
96
100
  ## For users
@@ -41,6 +41,10 @@ We welcome additions and improvements to the code! We request that you follow a
41
41
  4. All pull requests must be reviewed by a person. The benefits from code review are plenty, but we like to emphasise that code reviews help spreading the awarenes of code changes. Please note that code reviews should be a pleasant experience, so be plesant, polite and remember that there is a human being with good intentions on the other side of the screen.
42
42
  5. All contributions are linted with flake8. We recommend that you run flake8 on your code while developing to fix any issues as you go. We recommend using autopep8 to autoformat your Python code (but please check the code behaviour is not affected by autoformatting before pushing). This makes flake8 happy, and makes it easier for us all to maintain a consistent and readable code base.
43
43
 
44
+ ## Docstrings
45
+
46
+ Use the NumPy style in docstrings. See style guide [here](https://numpydoc.readthedocs.io/en/latest/format.html#documenting-classes)
47
+
44
48
  # Installing
45
49
 
46
50
  ## For users
@@ -0,0 +1 @@
1
+ __version__ = '2.4.6'
@@ -6,6 +6,7 @@ import os
6
6
  import numpy as np
7
7
  import pandas as pd
8
8
  from skimage.exposure import rescale_intensity
9
+ import skimage.io
9
10
 
10
11
 
11
12
  def timestamp_from_filename(filename):
@@ -25,8 +26,35 @@ def timestamp_from_filename(filename):
25
26
  return timestamp
26
27
 
27
28
 
28
- def load_image(filename):
29
- '''load a .silc file from disc
29
+ def load_mono8(filename):
30
+ '''load a mono8 .msilc file from disc
31
+
32
+ Assumes 8-bit mono image in range 0-255
33
+
34
+ Parameters
35
+ ----------
36
+ filename : string
37
+ filename to load
38
+
39
+ Returns
40
+ -------
41
+ array
42
+ raw image float between 0-1
43
+ '''
44
+ im_mono = np.load(filename, allow_pickle=False).astype(np.float64) / 255
45
+ image_shape = np.shape(im_mono)
46
+ if len(image_shape) > 2:
47
+ if image_shape[2] == 1:
48
+ img = im_mono[:, :, 0]
49
+ else:
50
+ raise RuntimeError('Invalid image dimension')
51
+ return img
52
+
53
+
54
+ def load_rgb8(filename):
55
+ '''load an RGB .silc file from disc
56
+
57
+ Assumes 8-bit RGB image in range 0-255
30
58
 
31
59
  Parameters
32
60
  ----------
@@ -42,15 +70,47 @@ def load_image(filename):
42
70
  return img
43
71
 
44
72
 
73
+ def load_image(filename):
74
+ '''.. deprecated:: 2.4.6
75
+ :func:`pyopia.instrument.silcam.load_image` will be removed in version 3.0.0, it is replaced by
76
+ :func:`pyopia.instrument.silcam.load_rgb8` because this is more explicit to that image type.
77
+
78
+ Load an RGB .silc file from disc
79
+
80
+ Parameters
81
+ ----------
82
+ filename : string
83
+ filename to load
84
+
85
+ Returns
86
+ -------
87
+ array
88
+ raw image float between 0-1
89
+ '''
90
+
91
+ return load_rgb8(filename)
92
+
93
+
45
94
  class SilCamLoad():
46
95
  '''PyOpia pipline-compatible class for loading a single silcam image
47
- using :func:`pyopia.instrument.silcam.load_image`
48
96
  and extracting the timestamp using
49
97
  :func:`pyopia.instrument.silcam.timestamp_from_filename`
50
98
 
51
99
  Required keys in :class:`pyopia.pipeline.Data`:
52
100
  - :attr:`pyopia.pipeline.Data.filename`
53
101
 
102
+ Parameters
103
+ ----------
104
+ image_format : str, optional
105
+ Image file format. Can be either 'infer', 'rgb8' or 'mono8', by default 'infer'.
106
+
107
+ Note
108
+ ----
109
+ 'infer' uses the file extension to determine the image format using the following convention:
110
+ - '.silc' for RGB8
111
+ - '.msilc' for MONO8
112
+ - '.bmp' for using skimage.io.imread
113
+
54
114
  Returns
55
115
  -------
56
116
  data : :class:`pyopia.pipeline.Data`
@@ -61,16 +121,28 @@ class SilCamLoad():
61
121
  :attr:`pyopia.pipeline.Data.img`
62
122
  '''
63
123
 
64
- def __init__(self):
65
- pass
124
+ def __init__(self, image_format='infer'):
125
+ self.image_format = image_format
126
+ self.extension_load = {'.silc': load_rgb8,
127
+ '.msilc': load_mono8,
128
+ '.bmp': skimage.io.imread}
129
+ self.format_load = {'RGB8': load_rgb8,
130
+ 'MONO8': load_mono8}
66
131
 
67
132
  def __call__(self, data):
68
- timestamp = timestamp_from_filename(data['filename'])
69
- img = load_image(data['filename'])
70
- data['timestamp'] = timestamp
71
- data['imraw'] = img
133
+ data['timestamp'] = timestamp_from_filename(data['filename'])
134
+ data['imraw'] = self.load_image(data['filename'])
72
135
  return data
73
136
 
137
+ def load_image(self, filename):
138
+ if self.image_format == 'infer':
139
+ file_extension = os.path.splitext(os.path.basename(filename))[-1]
140
+ load_function = self.extension_load[file_extension]
141
+ else:
142
+ load_function = self.format_load[self.image_format]
143
+ img = load_function(filename)
144
+ return img
145
+
74
146
 
75
147
  class ImagePrep():
76
148
  '''PyOpia pipline-compatible class for preparing silcam images for further analysis
@@ -184,7 +184,7 @@ def combine_stats_netcdf_files(path_to_data, prefix='*'):
184
184
 
185
185
  sorted_filelist = sorted(glob(os.path.join(path_to_data, prefix + 'Image-D*-STATS.nc')))
186
186
  with xarray.open_mfdataset(sorted_filelist, combine='nested', concat_dim='index',
187
- decode_cf=False, parallel=False,
187
+ decode_cf=True, parallel=False,
188
188
  coords='minimal', compat='override') as ds:
189
189
  xstats = ds.load()
190
190
 
@@ -1 +0,0 @@
1
- __version__ = '2.4.4'
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes