PyOPIA 2.16.5__tar.gz → 2.16.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 (38) hide show
  1. {pyopia-2.16.5 → pyopia-2.16.6}/PKG-INFO +1 -1
  2. pyopia-2.16.6/pyopia/__init__.py +1 -0
  3. {pyopia-2.16.5 → pyopia-2.16.6}/pyopia/instrument/holo.py +23 -11
  4. {pyopia-2.16.5 → pyopia-2.16.6}/pyopia/instrument/silcam.py +17 -6
  5. pyopia-2.16.5/pyopia/__init__.py +0 -1
  6. {pyopia-2.16.5 → pyopia-2.16.6}/.gitignore +0 -0
  7. {pyopia-2.16.5 → pyopia-2.16.6}/LICENSE +0 -0
  8. {pyopia-2.16.5 → pyopia-2.16.6}/README.md +0 -0
  9. {pyopia-2.16.5 → pyopia-2.16.6}/pyopia/auxillarydata.py +0 -0
  10. {pyopia-2.16.5 → pyopia-2.16.6}/pyopia/background.py +0 -0
  11. {pyopia-2.16.5 → pyopia-2.16.6}/pyopia/cf_metadata.json +0 -0
  12. {pyopia-2.16.5 → pyopia-2.16.6}/pyopia/classify.py +0 -0
  13. {pyopia-2.16.5 → pyopia-2.16.6}/pyopia/classify_torch.py +0 -0
  14. {pyopia-2.16.5 → pyopia-2.16.6}/pyopia/cli.py +0 -0
  15. {pyopia-2.16.5 → pyopia-2.16.6}/pyopia/dataexport/__init__.py +0 -0
  16. {pyopia-2.16.5 → pyopia-2.16.6}/pyopia/dataexport/ecotaxa.py +0 -0
  17. {pyopia-2.16.5 → pyopia-2.16.6}/pyopia/exampledata.py +0 -0
  18. {pyopia-2.16.5 → pyopia-2.16.6}/pyopia/instrument/__init__.py +0 -0
  19. {pyopia-2.16.5 → pyopia-2.16.6}/pyopia/instrument/common.py +0 -0
  20. {pyopia-2.16.5 → pyopia-2.16.6}/pyopia/instrument/uvp.py +0 -0
  21. {pyopia-2.16.5 → pyopia-2.16.6}/pyopia/io.py +0 -0
  22. {pyopia-2.16.5 → pyopia-2.16.6}/pyopia/metadata.py +0 -0
  23. {pyopia-2.16.5 → pyopia-2.16.6}/pyopia/pipeline.py +0 -0
  24. {pyopia-2.16.5 → pyopia-2.16.6}/pyopia/plotting.py +0 -0
  25. {pyopia-2.16.5 → pyopia-2.16.6}/pyopia/process.py +0 -0
  26. {pyopia-2.16.5 → pyopia-2.16.6}/pyopia/realtime.py +0 -0
  27. {pyopia-2.16.5 → pyopia-2.16.6}/pyopia/simulator/__init__.py +0 -0
  28. {pyopia-2.16.5 → pyopia-2.16.6}/pyopia/simulator/silcam.py +0 -0
  29. {pyopia-2.16.5 → pyopia-2.16.6}/pyopia/statistics.py +0 -0
  30. {pyopia-2.16.5 → pyopia-2.16.6}/pyopia/tests/__init__.py +0 -0
  31. {pyopia-2.16.5 → pyopia-2.16.6}/pyopia/tests/test_auxillarydata.py +0 -0
  32. {pyopia-2.16.5 → pyopia-2.16.6}/pyopia/tests/test_classify.py +0 -0
  33. {pyopia-2.16.5 → pyopia-2.16.6}/pyopia/tests/test_io.py +0 -0
  34. {pyopia-2.16.5 → pyopia-2.16.6}/pyopia/tests/test_notebooks.py +0 -0
  35. {pyopia-2.16.5 → pyopia-2.16.6}/pyopia/tests/test_pipeline.py +0 -0
  36. {pyopia-2.16.5 → pyopia-2.16.6}/pyopia/tests/test_process.py +0 -0
  37. {pyopia-2.16.5 → pyopia-2.16.6}/pyopia/tests/test_realtime.py +0 -0
  38. {pyopia-2.16.5 → pyopia-2.16.6}/pyproject.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyOPIA
3
- Version: 2.16.5
3
+ Version: 2.16.6
4
4
  Summary: A Python Ocean Particle Image Analysis toolbox.
5
5
  Project-URL: Repository, https://github.com/sintef/pyopia
6
6
  Project-URL: Documentation, https://pyopia.readthedocs.io
@@ -0,0 +1 @@
1
+ __version__ = "2.16.6"
@@ -21,7 +21,7 @@ from skimage.filters import sobel
21
21
  from skimage.morphology import disk, erosion, dilation
22
22
  import pyopia.process
23
23
  import struct
24
- from datetime import timedelta, datetime
24
+ from datetime import timedelta
25
25
  from glob import glob
26
26
 
27
27
  import logging
@@ -69,10 +69,10 @@ class Initial():
69
69
  self.filename = raw_files[0]
70
70
  imtmp = load_image(self.filename)
71
71
  self.pixel_size = data['settings']['general']['pixel_size']
72
- logger.info('Build kernel with pixel_size = ', self.pixel_size, 'um')
72
+ logger.info(f'Build kernel with pixel_size = {self.pixel_size} um')
73
73
  kern = create_kernel(imtmp, self.pixel_size, self.wavelength, self.n, self.offset, self.minZ, self.maxZ, self.stepZ)
74
74
  im_stack = np.zeros(np.shape(kern)).astype(np.float64)
75
- logger.info('HoloInitial done', datetime.now())
75
+ logger.info('HoloInitial done')
76
76
  data['kern'] = kern
77
77
  data['im_stack'] = im_stack
78
78
  return data
@@ -103,24 +103,27 @@ class Load():
103
103
  filename : string
104
104
  hologram filename (.pgm)
105
105
 
106
+ prefix_chars : int, optional
107
+ number of characters to ignore at start of filename when parsing timestamp,
108
+ by default 1 (e.g. to ignore 'D' in 'D20221101T120000.pgm')
109
+
106
110
  Returns
107
111
  -------
108
- timestamp : timestamp
109
- timestamp @todo
110
- imraw : np.arraym
112
+ timestamp : pandas.Timestamp
113
+ timestamp from filename
114
+ imraw : np.array
111
115
  hologram
112
116
  '''
113
117
 
114
- def __init__(self):
115
- pass
118
+ def __init__(self, prefix_chars=1):
119
+ self.prefix_chars = prefix_chars
116
120
 
117
121
  def __call__(self, data):
118
122
  logger.info(data['filename'])
119
123
  try:
120
124
  timestamp = read_lisst_holo_info(data['filename'])
121
125
  except ValueError:
122
- timestamp = pd.to_datetime(os.path.splitext(os.path.basename(data['filename']))[0][1:])
123
- logger.info(timestamp)
126
+ timestamp = pd.to_datetime(os.path.splitext(os.path.basename(data['filename']))[0][self.prefix_chars:])
124
127
  im = load_image(data['filename'])
125
128
  data['timestamp'] = timestamp
126
129
  data['imraw'] = im
@@ -559,6 +562,16 @@ class MergeStats():
559
562
  stack_rp = data['stack_rp']
560
563
  stack_ifocus = data['stack_ifocus']
561
564
 
565
+ # If there are no particles in the image, then stats has one row of nans
566
+ # This means that variables created here just need allocating and returning
567
+ if len(stack_ifocus) == 0:
568
+ logger.debug(f"stack_ifocus is empty. Allocating nan to ifocus and z. Filename: {data['filename']}")
569
+ stats['ifocus'] = np.nan
570
+ stats['z'] = np.nan
571
+ stats['holo_filename'] = data['filename']
572
+ data['stats'] = stats
573
+ return data
574
+
562
575
  bbox = np.empty((0, 4), int)
563
576
  for rp in stack_rp:
564
577
  bbox = np.append(bbox, [rp.bbox], axis=0)
@@ -603,7 +616,6 @@ def read_lisst_holo_info(filename):
603
616
  filenum = int(filenum.rsplit('.', 1)[0])
604
617
  timestamp = timestamp + timedelta(microseconds=filenum)
605
618
  timestamp = timestamp[0]
606
- logger.info(timestamp.strftime('D%Y%m%dT%H%M%S.%f'))
607
619
  f.close()
608
620
 
609
621
  return timestamp
@@ -14,21 +14,26 @@ from skimage.exposure import rescale_intensity
14
14
  import skimage.io
15
15
 
16
16
 
17
- def timestamp_from_filename(filename):
17
+ def timestamp_from_filename(filename, prefix_chars=1):
18
18
  '''get a pandas timestamp from a silcam filename
19
19
 
20
20
  Parameters
21
21
  ----------
22
- filename (string): silcam filename (.silc)
22
+ filename : string
23
+ silcam filename (.silc)
24
+
25
+ prefix_chars : int, optional
26
+ number of characters to ignore at start of filename when parsing timestamp,
27
+ by default 1 (e.g. to ignore 'D' in 'D20221101T120000.silc')
23
28
 
24
29
  Returns
25
30
  -------
26
- timestamp: timestamp
31
+ timestamp : pandas.Timestamp
27
32
  timestamp from pandas.to_datetime()
28
33
  '''
29
34
 
30
35
  # get the timestamp of the image (in this case from the filename)
31
- timestamp = pd.to_datetime(os.path.splitext(os.path.basename(filename))[0][1:])
36
+ timestamp = pd.to_datetime(os.path.splitext(os.path.basename(filename))[0][prefix_chars:])
32
37
  return timestamp
33
38
 
34
39
 
@@ -222,6 +227,10 @@ class SilCamLoad():
222
227
  image_format : str, optional
223
228
  Image file format. Can be either 'infer', 'rgb8', 'bayer_rg8' or 'mono8', by default 'infer'.
224
229
 
230
+ prefix_chars : int, optional
231
+ number of characters to ignore at start of filename when parsing timestamp,
232
+ by default 1 (e.g. to ignore 'D' in 'D20221101T120000.silc')
233
+
225
234
  Note
226
235
  ----
227
236
  'infer' uses the file extension to determine the image format using the following convention:
@@ -240,7 +249,8 @@ class SilCamLoad():
240
249
  :attr:`pyopia.pipeline.Data.img`
241
250
  '''
242
251
 
243
- def __init__(self, image_format='infer'):
252
+ def __init__(self, image_format='infer', prefix_chars=1):
253
+ self.prefix_chars = prefix_chars
244
254
  self.image_format = image_format
245
255
  self.extension_load = {'.silc': load_rgb8,
246
256
  '.msilc': load_mono8,
@@ -250,7 +260,8 @@ class SilCamLoad():
250
260
  'MONO8': load_mono8, 'BAYER_RG8': load_bayer_rgb8}
251
261
 
252
262
  def __call__(self, data):
253
- data['timestamp'] = timestamp_from_filename(data['filename'])
263
+ data['timestamp'] = timestamp_from_filename(data['filename'],
264
+ prefix_chars=self.prefix_chars)
254
265
  data['imraw'] = self.load_image(data['filename'])
255
266
  return data
256
267
 
@@ -1 +0,0 @@
1
- __version__ = "2.16.5"
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