PyOPIA 2.5.1__tar.gz → 2.5.3__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.5.1 → pyopia-2.5.3}/PKG-INFO +1 -1
- pyopia-2.5.3/pyopia/__init__.py +1 -0
- {pyopia-2.5.1 → pyopia-2.5.3}/pyopia/instrument/holo.py +1 -1
- {pyopia-2.5.1 → pyopia-2.5.3}/pyopia/instrument/silcam.py +9 -3
- {pyopia-2.5.1 → pyopia-2.5.3}/pyopia/instrument/uvp.py +1 -1
- {pyopia-2.5.1 → pyopia-2.5.3}/pyopia/io.py +59 -12
- {pyopia-2.5.1 → pyopia-2.5.3}/pyopia/statistics.py +9 -4
- {pyopia-2.5.1 → pyopia-2.5.3}/pyopia/tests/test_pipeline.py +2 -2
- pyopia-2.5.1/pyopia/__init__.py +0 -1
- {pyopia-2.5.1 → pyopia-2.5.3}/LICENSE +0 -0
- {pyopia-2.5.1 → pyopia-2.5.3}/README.md +0 -0
- {pyopia-2.5.1 → pyopia-2.5.3}/pyopia/background.py +0 -0
- {pyopia-2.5.1 → pyopia-2.5.3}/pyopia/classify.py +0 -0
- {pyopia-2.5.1 → pyopia-2.5.3}/pyopia/cli.py +0 -0
- {pyopia-2.5.1 → pyopia-2.5.3}/pyopia/exampledata.py +0 -0
- {pyopia-2.5.1 → pyopia-2.5.3}/pyopia/instrument/__init__.py +0 -0
- {pyopia-2.5.1 → pyopia-2.5.3}/pyopia/instrument/common.py +0 -0
- {pyopia-2.5.1 → pyopia-2.5.3}/pyopia/pipeline.py +0 -0
- {pyopia-2.5.1 → pyopia-2.5.3}/pyopia/plotting.py +0 -0
- {pyopia-2.5.1 → pyopia-2.5.3}/pyopia/process.py +0 -0
- {pyopia-2.5.1 → pyopia-2.5.3}/pyopia/simulator/__init__.py +0 -0
- {pyopia-2.5.1 → pyopia-2.5.3}/pyopia/simulator/silcam.py +0 -0
- {pyopia-2.5.1 → pyopia-2.5.3}/pyopia/tests/__init__.py +0 -0
- {pyopia-2.5.1 → pyopia-2.5.3}/pyopia/tests/test_classify.py +0 -0
- {pyopia-2.5.1 → pyopia-2.5.3}/pyopia/tests/test_notebooks.py +0 -0
- {pyopia-2.5.1 → pyopia-2.5.3}/pyproject.toml +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '2.5.3'
|
|
@@ -681,7 +681,7 @@ def generate_config(raw_files: str, model_path: str, outfolder: str, output_pref
|
|
|
681
681
|
'pipeline_class': 'pyopia.instrument.holo.MergeStats',
|
|
682
682
|
},
|
|
683
683
|
'output': {
|
|
684
|
-
'pipeline_class': 'pyopia.io.
|
|
684
|
+
'pipeline_class': 'pyopia.io.StatsToDisc',
|
|
685
685
|
'output_datafile': os.path.join(outfolder, output_prefix)
|
|
686
686
|
}
|
|
687
687
|
}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
'''
|
|
2
2
|
Module containing SilCam specific tools to enable compatability with the :mod:`pyopia.pipeline`
|
|
3
|
+
|
|
4
|
+
See:
|
|
5
|
+
Davies, E. J., Brandvik, P. J., Leirvik, F., & Nepstad, R. (2017). The use of wide-band transmittance imaging to size and
|
|
6
|
+
classify suspended particulate matter in seawater. Marine Pollution Bulletin,
|
|
7
|
+
115(1–2). https://doi.org/10.1016/j.marpolbul.2016.11.063
|
|
3
8
|
'''
|
|
4
9
|
|
|
5
10
|
import os
|
|
@@ -14,11 +19,12 @@ def timestamp_from_filename(filename):
|
|
|
14
19
|
|
|
15
20
|
Parameters
|
|
16
21
|
----------
|
|
17
|
-
|
|
22
|
+
filename (string): silcam filename (.silc)
|
|
18
23
|
|
|
19
24
|
Returns
|
|
20
25
|
-------
|
|
21
|
-
|
|
26
|
+
timestamp: timestamp
|
|
27
|
+
timestamp from pandas.to_datetime()
|
|
22
28
|
'''
|
|
23
29
|
|
|
24
30
|
# get the timestamp of the image (in this case from the filename)
|
|
@@ -332,7 +338,7 @@ def generate_config(raw_files: str, model_path: str, outfolder: str, output_pref
|
|
|
332
338
|
'roi_source': 'imref'
|
|
333
339
|
},
|
|
334
340
|
'output': {
|
|
335
|
-
'pipeline_class': 'pyopia.io.
|
|
341
|
+
'pipeline_class': 'pyopia.io.StatsToDisc',
|
|
336
342
|
'output_datafile': os.path.join(outfolder, output_prefix)
|
|
337
343
|
}
|
|
338
344
|
}
|
|
@@ -117,7 +117,7 @@ def generate_config(raw_files: str, model_path: str, outfolder: str, output_pref
|
|
|
117
117
|
'roi_source': 'imraw'
|
|
118
118
|
},
|
|
119
119
|
'output': {
|
|
120
|
-
'pipeline_class': 'pyopia.io.
|
|
120
|
+
'pipeline_class': 'pyopia.io.StatsToDisc',
|
|
121
121
|
'output_datafile': os.path.join(outfolder, output_prefix)
|
|
122
122
|
}
|
|
123
123
|
}
|
|
@@ -213,23 +213,20 @@ def combine_stats_netcdf_files(path_to_data, prefix='*'):
|
|
|
213
213
|
coords='minimal', compat='override') as ds:
|
|
214
214
|
xstats = ds.load()
|
|
215
215
|
|
|
216
|
-
# Check if we have image statistics
|
|
217
|
-
# The last file should contain the entire time series of processed images.
|
|
216
|
+
# Check if we have image statistics, if so, load it.
|
|
218
217
|
try:
|
|
219
|
-
|
|
218
|
+
with xarray.open_mfdataset(sorted_filelist, group='image_stats') as ds:
|
|
219
|
+
image_stats = ds.load()
|
|
220
220
|
except OSError:
|
|
221
|
+
logger.info('Could get image_stats from netcdf files for merging, returning None for this.')
|
|
221
222
|
image_stats = None
|
|
222
|
-
else:
|
|
223
|
-
image_stats = ds.load()
|
|
224
|
-
finally:
|
|
225
|
-
ds.close()
|
|
226
223
|
|
|
227
224
|
return xstats, image_stats
|
|
228
225
|
|
|
229
226
|
|
|
230
227
|
def merge_and_save_mfdataset(path_to_data, prefix='*'):
|
|
231
228
|
'''Combine a multi-file directory of STATS.nc files into a single '-STATS.nc' file
|
|
232
|
-
that can then be loaded with
|
|
229
|
+
that can then be loaded with :func:`pyopia.io.load_stats`
|
|
233
230
|
|
|
234
231
|
Parameters
|
|
235
232
|
----------
|
|
@@ -321,8 +318,6 @@ def show_h5_meta(h5file):
|
|
|
321
318
|
class StatsToDisc():
|
|
322
319
|
'''PyOpia pipline-compatible class for calling write_stats() that created NetCDF files.
|
|
323
320
|
|
|
324
|
-
Replaces the old StatsH5 class
|
|
325
|
-
|
|
326
321
|
Parameters
|
|
327
322
|
----------
|
|
328
323
|
output_datafile : str
|
|
@@ -377,10 +372,62 @@ class StatsToDisc():
|
|
|
377
372
|
return data
|
|
378
373
|
|
|
379
374
|
|
|
380
|
-
|
|
375
|
+
def load_toml(toml_file):
|
|
376
|
+
'''Load a TOML settings file from file
|
|
381
377
|
|
|
378
|
+
Parameters
|
|
379
|
+
----------
|
|
380
|
+
toml_file : str
|
|
381
|
+
TOML filename
|
|
382
382
|
|
|
383
|
-
|
|
383
|
+
Returns
|
|
384
|
+
-------
|
|
385
|
+
settings : dict
|
|
386
|
+
TOML settings
|
|
387
|
+
'''
|
|
384
388
|
with open(toml_file, 'r') as f:
|
|
385
389
|
settings = toml.load(f)
|
|
386
390
|
return settings
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
def StatsH5():
|
|
394
|
+
'''.. deprecated:: 2.4.8
|
|
395
|
+
:class:`pyopia.io.StatsH5` will be removed in version 3.0.0, it is replaced by
|
|
396
|
+
:class:`pyopia.io.StatsToDisc`.
|
|
397
|
+
|
|
398
|
+
PyOpia pipline-compatible class for calling write_stats() that creates h5 files.
|
|
399
|
+
|
|
400
|
+
Parameters
|
|
401
|
+
----------
|
|
402
|
+
output_datafile : str
|
|
403
|
+
prefix path for output nc file
|
|
404
|
+
dataformat : str
|
|
405
|
+
either 'nc' or 'h5
|
|
406
|
+
export_name_len : int
|
|
407
|
+
max number of chars allowed for col 'export name'. Defaults to 40
|
|
408
|
+
append : bool
|
|
409
|
+
Append all processed data into one nc file.
|
|
410
|
+
Defaults to True.
|
|
411
|
+
If False, then one nc file will be generated per raw image,
|
|
412
|
+
which can be loaded using :func:`pyopia.io.combine_stats_netcdf_files`
|
|
413
|
+
This is useful for larger datasets, where appending causes substantial slowdown
|
|
414
|
+
as the dataset gets larger.
|
|
415
|
+
|
|
416
|
+
Returns
|
|
417
|
+
-------
|
|
418
|
+
data : :class:`pyopia.pipeline.Data`
|
|
419
|
+
data from the pipeline
|
|
420
|
+
|
|
421
|
+
Example
|
|
422
|
+
-------
|
|
423
|
+
Example config for pipeline useage:
|
|
424
|
+
|
|
425
|
+
.. code-block:: toml
|
|
426
|
+
|
|
427
|
+
[steps.output]
|
|
428
|
+
pipeline_class = 'pyopia.io.StatsH5'
|
|
429
|
+
output_datafile = './test' # prefix path for output nc file
|
|
430
|
+
append = true
|
|
431
|
+
'''
|
|
432
|
+
logger.warning('StatsH5 will be removed in version 3.0.0, it is replaced by pyopia.io.StatsToDisc')
|
|
433
|
+
return StatsToDisc()
|
|
@@ -763,12 +763,14 @@ def make_timeseries_vd(stats, pixel_size, path_length, time_reference):
|
|
|
763
763
|
similar to Sequoia LISST-100 output,
|
|
764
764
|
and exportable to things like Excel or csv.
|
|
765
765
|
|
|
766
|
-
Note
|
|
766
|
+
Note
|
|
767
|
+
----
|
|
768
|
+
If zero particles are detected within the stats daraframe,
|
|
767
769
|
then the volume concentration should be reported as zero for that
|
|
768
770
|
time. For this function to have awareness of these times, it requires
|
|
769
771
|
time_reference variable. If you use `stats['timestamp'].unique()` for this,
|
|
770
772
|
then you are assuming you have at least one particle per image.
|
|
771
|
-
It is better to use image_stats['
|
|
773
|
+
It is better to use `image_stats['timestamp'].values` instead, which can be obtained from
|
|
772
774
|
:func:`pyopia.io.load_image_stats`
|
|
773
775
|
|
|
774
776
|
Parameters
|
|
@@ -790,9 +792,12 @@ def make_timeseries_vd(stats, pixel_size, path_length, time_reference):
|
|
|
790
792
|
Example
|
|
791
793
|
-------
|
|
792
794
|
.. code-block:: python
|
|
795
|
+
path_length = 40 # for a 40mm long path length
|
|
796
|
+
|
|
793
797
|
time_series_vd = pyopia.statistics.make_timeseries_vd(stats,
|
|
794
798
|
settings['general']['pixel_size'],
|
|
795
|
-
path_length
|
|
799
|
+
path_length,
|
|
800
|
+
image_stats['timestamp'].values)
|
|
796
801
|
|
|
797
802
|
# particle diameters
|
|
798
803
|
dias = np.array(time_series_vd.columns[0:52], dtype=float)
|
|
@@ -807,7 +812,7 @@ def make_timeseries_vd(stats, pixel_size, path_length, time_reference):
|
|
|
807
812
|
time = pd.to_datetime(time_series_vd['Time'].values)
|
|
808
813
|
|
|
809
814
|
# time-series of total volume concentration
|
|
810
|
-
|
|
815
|
+
volume_concentration = np.sum(vdarray, axis=1)
|
|
811
816
|
'''
|
|
812
817
|
sample_volume = get_sample_volume(pixel_size, path_length=path_length)
|
|
813
818
|
|
|
@@ -93,7 +93,7 @@ def test_holo_pipeline():
|
|
|
93
93
|
'pipeline_class': 'pyopia.instrument.holo.MergeStats',
|
|
94
94
|
},
|
|
95
95
|
'output': {
|
|
96
|
-
'pipeline_class': 'pyopia.io.
|
|
96
|
+
'pipeline_class': 'pyopia.io.StatsToDisc',
|
|
97
97
|
'output_datafile': datafile_prefix
|
|
98
98
|
}
|
|
99
99
|
}
|
|
@@ -164,7 +164,7 @@ def test_silcam_pipeline():
|
|
|
164
164
|
'roi_source': 'im_minimum'
|
|
165
165
|
},
|
|
166
166
|
'output': {
|
|
167
|
-
'pipeline_class': 'pyopia.io.
|
|
167
|
+
'pipeline_class': 'pyopia.io.StatsToDisc',
|
|
168
168
|
'output_datafile': datafile_prefix
|
|
169
169
|
}
|
|
170
170
|
}
|
pyopia-2.5.1/pyopia/__init__.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = '2.5.1'
|
|
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
|