PyOPIA 2.6.2__tar.gz → 2.7.0__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.
- {pyopia-2.6.2 → pyopia-2.7.0}/PKG-INFO +1 -1
- pyopia-2.7.0/pyopia/__init__.py +1 -0
- {pyopia-2.6.2 → pyopia-2.7.0}/pyopia/background.py +25 -9
- {pyopia-2.6.2 → pyopia-2.7.0}/pyopia/statistics.py +1 -1
- pyopia-2.6.2/pyopia/__init__.py +0 -1
- {pyopia-2.6.2 → pyopia-2.7.0}/LICENSE +0 -0
- {pyopia-2.6.2 → pyopia-2.7.0}/README.md +0 -0
- {pyopia-2.6.2 → pyopia-2.7.0}/pyopia/classify.py +0 -0
- {pyopia-2.6.2 → pyopia-2.7.0}/pyopia/cli.py +0 -0
- {pyopia-2.6.2 → pyopia-2.7.0}/pyopia/exampledata.py +0 -0
- {pyopia-2.6.2 → pyopia-2.7.0}/pyopia/instrument/__init__.py +0 -0
- {pyopia-2.6.2 → pyopia-2.7.0}/pyopia/instrument/common.py +0 -0
- {pyopia-2.6.2 → pyopia-2.7.0}/pyopia/instrument/holo.py +0 -0
- {pyopia-2.6.2 → pyopia-2.7.0}/pyopia/instrument/silcam.py +0 -0
- {pyopia-2.6.2 → pyopia-2.7.0}/pyopia/instrument/uvp.py +0 -0
- {pyopia-2.6.2 → pyopia-2.7.0}/pyopia/io.py +0 -0
- {pyopia-2.6.2 → pyopia-2.7.0}/pyopia/pipeline.py +0 -0
- {pyopia-2.6.2 → pyopia-2.7.0}/pyopia/plotting.py +0 -0
- {pyopia-2.6.2 → pyopia-2.7.0}/pyopia/process.py +0 -0
- {pyopia-2.6.2 → pyopia-2.7.0}/pyopia/simulator/__init__.py +0 -0
- {pyopia-2.6.2 → pyopia-2.7.0}/pyopia/simulator/silcam.py +0 -0
- {pyopia-2.6.2 → pyopia-2.7.0}/pyopia/tests/__init__.py +0 -0
- {pyopia-2.6.2 → pyopia-2.7.0}/pyopia/tests/test_classify.py +0 -0
- {pyopia-2.6.2 → pyopia-2.7.0}/pyopia/tests/test_notebooks.py +0 -0
- {pyopia-2.6.2 → pyopia-2.7.0}/pyopia/tests/test_pipeline.py +0 -0
- {pyopia-2.6.2 → pyopia-2.7.0}/pyproject.toml +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '2.7.0'
|
|
@@ -95,9 +95,11 @@ def shift_bgstack_fast(bgstack, imbg, imnew):
|
|
|
95
95
|
return bgstack, imbg
|
|
96
96
|
|
|
97
97
|
|
|
98
|
-
def correct_im_accurate(imbg, imraw):
|
|
98
|
+
def correct_im_accurate(imbg, imraw, divide_bg=False):
|
|
99
99
|
'''
|
|
100
|
-
Corrects raw image by subtracting the background and scaling the output
|
|
100
|
+
Corrects raw image by subtracting or dividing the background and scaling the output
|
|
101
|
+
|
|
102
|
+
For dividing method see: https://doi.org/10.1016/j.marpolbul.2016.11.063)
|
|
101
103
|
|
|
102
104
|
There is a small chance of clipping of imc in both crushed blacks and blown
|
|
103
105
|
highlights if the background or raw images are very poorly obtained
|
|
@@ -108,6 +110,9 @@ def correct_im_accurate(imbg, imraw):
|
|
|
108
110
|
background averaged image
|
|
109
111
|
imraw : float64
|
|
110
112
|
raw image
|
|
113
|
+
divide_bg : (bool, optional)
|
|
114
|
+
If True, the correction will be performed by dividing the raw image by the background
|
|
115
|
+
Default to False
|
|
111
116
|
|
|
112
117
|
Returns
|
|
113
118
|
-------
|
|
@@ -115,10 +120,16 @@ def correct_im_accurate(imbg, imraw):
|
|
|
115
120
|
corrected image, same type as input
|
|
116
121
|
'''
|
|
117
122
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
123
|
+
if divide_bg:
|
|
124
|
+
imbg = np.clip(imbg, a_min=1/255, a_max=None) # Clipping the zero_value pixels
|
|
125
|
+
im_corrected = imraw / imbg
|
|
126
|
+
im_corrected += (1 / 2 - np.percentile(im_corrected, 50))
|
|
127
|
+
im_corrected -= im_corrected.min() # Shift the negative values to zero
|
|
128
|
+
im_corrected = np.clip(im_corrected, a_min=0, a_max=1)
|
|
129
|
+
else:
|
|
130
|
+
im_corrected = imraw - imbg
|
|
131
|
+
im_corrected += (1 / 2 - np.percentile(im_corrected, 50))
|
|
132
|
+
im_corrected += 1 - im_corrected.max() # Shift the positive values exceeding unity to one
|
|
122
133
|
|
|
123
134
|
return im_corrected
|
|
124
135
|
|
|
@@ -207,7 +218,7 @@ class CorrectBackgroundAccurate():
|
|
|
207
218
|
----------
|
|
208
219
|
bgshift_function : (string, optional)
|
|
209
220
|
Function used to shift the background. Defaults to passing (i.e. static background)
|
|
210
|
-
Available options are 'accurate', 'fast', or 'pass' to apply a
|
|
221
|
+
Available options are 'accurate', 'fast', or 'pass' to apply a static background correction:
|
|
211
222
|
|
|
212
223
|
:func:`pyopia.background.shift_bgstack_accurate`
|
|
213
224
|
|
|
@@ -220,6 +231,10 @@ class CorrectBackgroundAccurate():
|
|
|
220
231
|
The key in Pipeline.data of the image to be background corrected.
|
|
221
232
|
Defaults to 'imraw'
|
|
222
233
|
|
|
234
|
+
divide_bg : (bool)
|
|
235
|
+
If True, it performs background correction by dividing the raw image by the background.
|
|
236
|
+
Default to False.
|
|
237
|
+
|
|
223
238
|
Returns
|
|
224
239
|
-------
|
|
225
240
|
data : :class:`pyopia.pipeline.Data`
|
|
@@ -256,10 +271,11 @@ class CorrectBackgroundAccurate():
|
|
|
256
271
|
Then you could use :class:`pyopia.pipeline.CorrectBackgroundNone` if you need to instead.
|
|
257
272
|
'''
|
|
258
273
|
|
|
259
|
-
def __init__(self, bgshift_function='pass', average_window=1, image_source='imraw'):
|
|
274
|
+
def __init__(self, bgshift_function='pass', average_window=1, image_source='imraw', divide_bg=False):
|
|
260
275
|
self.bgshift_function = bgshift_function
|
|
261
276
|
self.average_window = average_window
|
|
262
277
|
self.image_source = image_source
|
|
278
|
+
self.divide_bg = divide_bg
|
|
263
279
|
|
|
264
280
|
def _build_background_step(self, data):
|
|
265
281
|
'''Add one layer to the background stack from the raw image in data pipeline, and update the background image.'''
|
|
@@ -284,7 +300,7 @@ class CorrectBackgroundAccurate():
|
|
|
284
300
|
data['skip_next_steps'] = True
|
|
285
301
|
return data
|
|
286
302
|
|
|
287
|
-
data['im_corrected'] = correct_im_accurate(data['imbg'], data[self.image_source])
|
|
303
|
+
data['im_corrected'] = correct_im_accurate(data['imbg'], data[self.image_source], divide_bg=self.divide_bg)
|
|
288
304
|
|
|
289
305
|
match self.bgshift_function:
|
|
290
306
|
case 'pass':
|
|
@@ -534,7 +534,7 @@ def get_j(dias, number_distribution):
|
|
|
534
534
|
|
|
535
535
|
# use polyfit to obtain the slope of the ditriubtion in log-space (which is
|
|
536
536
|
# assumed near-linear in most parts of the ocean)
|
|
537
|
-
p = np.polyfit(np.log(dias[ind]), np.log(number_distribution[ind]), 1)
|
|
537
|
+
p = np.polyfit(np.log(dias[ind]), np.log(number_distribution[ind], where=number_distribution[ind] > 0), 1)
|
|
538
538
|
junge_slope = p[0]
|
|
539
539
|
return junge_slope
|
|
540
540
|
|
pyopia-2.6.2/pyopia/__init__.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = '2.6.2'
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|