PyOPIA 2.4.6__tar.gz → 2.4.7__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.6 → pyopia-2.4.7}/PKG-INFO +1 -1
  2. pyopia-2.4.7/pyopia/__init__.py +1 -0
  3. {pyopia-2.4.6 → pyopia-2.4.7}/pyopia/io.py +33 -6
  4. pyopia-2.4.6/pyopia/__init__.py +0 -1
  5. {pyopia-2.4.6 → pyopia-2.4.7}/LICENSE +0 -0
  6. {pyopia-2.4.6 → pyopia-2.4.7}/README.md +0 -0
  7. {pyopia-2.4.6 → pyopia-2.4.7}/pyopia/background.py +0 -0
  8. {pyopia-2.4.6 → pyopia-2.4.7}/pyopia/classify.py +0 -0
  9. {pyopia-2.4.6 → pyopia-2.4.7}/pyopia/cli.py +0 -0
  10. {pyopia-2.4.6 → pyopia-2.4.7}/pyopia/exampledata.py +0 -0
  11. {pyopia-2.4.6 → pyopia-2.4.7}/pyopia/instrument/__init__.py +0 -0
  12. {pyopia-2.4.6 → pyopia-2.4.7}/pyopia/instrument/common.py +0 -0
  13. {pyopia-2.4.6 → pyopia-2.4.7}/pyopia/instrument/holo.py +0 -0
  14. {pyopia-2.4.6 → pyopia-2.4.7}/pyopia/instrument/silcam.py +0 -0
  15. {pyopia-2.4.6 → pyopia-2.4.7}/pyopia/instrument/uvp.py +0 -0
  16. {pyopia-2.4.6 → pyopia-2.4.7}/pyopia/pipeline.py +0 -0
  17. {pyopia-2.4.6 → pyopia-2.4.7}/pyopia/plotting.py +0 -0
  18. {pyopia-2.4.6 → pyopia-2.4.7}/pyopia/process.py +0 -0
  19. {pyopia-2.4.6 → pyopia-2.4.7}/pyopia/simulator/__init__.py +0 -0
  20. {pyopia-2.4.6 → pyopia-2.4.7}/pyopia/simulator/silcam.py +0 -0
  21. {pyopia-2.4.6 → pyopia-2.4.7}/pyopia/statistics.py +0 -0
  22. {pyopia-2.4.6 → pyopia-2.4.7}/pyopia/tests/__init__.py +0 -0
  23. {pyopia-2.4.6 → pyopia-2.4.7}/pyopia/tests/test_classify.py +0 -0
  24. {pyopia-2.4.6 → pyopia-2.4.7}/pyopia/tests/test_notebooks.py +0 -0
  25. {pyopia-2.4.6 → pyopia-2.4.7}/pyopia/tests/test_pipeline.py +0 -0
  26. {pyopia-2.4.6 → pyopia-2.4.7}/pyproject.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyOPIA
3
- Version: 2.4.6
3
+ Version: 2.4.7
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
@@ -0,0 +1 @@
1
+ __version__ = '2.4.7'
@@ -85,14 +85,39 @@ def write_stats(stats,
85
85
  elif not append:
86
86
  datafilename += ('-Image-D' +
87
87
  str(xstats['timestamp'][0].values).replace('-', '').replace(':', '').replace('.', '-'))
88
- encoding = {k: {'dtype': 'str'} for k in ['export name', 'holo_filename'] if k in xstats.data_vars}
88
+ encoding = setup_xstats_encoding(xstats)
89
89
  xstats.to_netcdf(datafilename + '-STATS.nc', encoding=encoding, engine=NETCDF_ENGINE, format='NETCDF4')
90
90
 
91
- # If we have image statistics, add this to a group
91
+ # If we have image statistics (summary data for each raw image), add the image_stats a group
92
92
  if image_stats is not None:
93
93
  image_stats.to_xarray().to_netcdf(datafilename + '-STATS.nc', group='image_stats', mode='a', engine=NETCDF_ENGINE)
94
94
 
95
95
 
96
+ def setup_xstats_encoding(xstats, string_vars=['export name', 'holo_filename']):
97
+ '''Setup encoding for writing to NetCDF, where string variables are explicitly defined as string types
98
+
99
+ Notes
100
+ -----
101
+ Setting up encoding like this for xstats is needed because default behaviour is to set everything as float if there is no
102
+ value, so in a situation where the first image contains no particles we must ensure that string variables are set as string
103
+ types.
104
+
105
+ Parameters
106
+ ----------
107
+ xstats : xarray.Dataset
108
+ Xarray version of stats dataframe, including metadata
109
+ string_vars : list, optional
110
+ list of string columns in xstats, by default ['export name', 'holo_filename']
111
+
112
+ Returns
113
+ -------
114
+ encoding : dict
115
+ 'encoding' input argument to be given to xstats.to_netcdf()
116
+ '''
117
+ encoding = {k: {'dtype': 'str'} for k in string_vars if k in xstats.data_vars}
118
+ return encoding
119
+
120
+
96
121
  def make_xstats(stats, toml_steps):
97
122
  '''Converts a stats dataframe into xarray DataSet, with metadata
98
123
 
@@ -225,10 +250,12 @@ def merge_and_save_mfdataset(path_to_data, prefix='*'):
225
250
  output_name = os.path.join(path_to_data, prefix_out)
226
251
 
227
252
  logging.info(f'writing {output_name}')
228
- write_stats(xstats,
229
- output_name,
230
- settings,
231
- image_stats=image_stats)
253
+ # save the particle statistics (xstats) to NetCDF
254
+ encoding = setup_xstats_encoding(xstats)
255
+ xstats.to_netcdf(output_name + '-STATS.nc', encoding=encoding, engine=NETCDF_ENGINE, format='NETCDF4')
256
+ # if summary data for each raw image are available (image_stats), save this into the image_stats group
257
+ if image_stats is not None:
258
+ image_stats.to_netcdf(output_name + '-STATS.nc', group='image_stats', mode='a', engine=NETCDF_ENGINE)
232
259
  logging.info(f'writing {output_name} done.')
233
260
 
234
261
 
@@ -1 +0,0 @@
1
- __version__ = '2.4.6'
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