water-column-sonar-processing 0.0.10__py3-none-any.whl → 0.0.11__py3-none-any.whl

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.

Potentially problematic release.


This version of water-column-sonar-processing might be problematic. Click here for more details.

@@ -111,17 +111,21 @@ class DynamoDBManager:
111
111
  expression_attribute_names,
112
112
  expression_attribute_values,
113
113
  update_expression,
114
- ):
115
- response = self.__dynamodb_client.update_item(
116
- TableName=table_name,
117
- Key=key,
118
- ExpressionAttributeNames=expression_attribute_names,
119
- ExpressionAttributeValues=expression_attribute_values,
120
- UpdateExpression=update_expression,
121
- )
122
- status_code = response["ResponseMetadata"]["HTTPStatusCode"]
123
- assert response['ConsumedCapacity']['TableName'] == table_name
124
- assert status_code == 200, "Problem, unable to update dynamodb table."
114
+ ): # TODO: convert to boolean
115
+ try:
116
+ response = self.__dynamodb_client.update_item(
117
+ TableName=table_name,
118
+ Key=key,
119
+ ExpressionAttributeNames=expression_attribute_names,
120
+ ExpressionAttributeValues=expression_attribute_values,
121
+ UpdateExpression=update_expression,
122
+ )
123
+ status_code = response["ResponseMetadata"]["HTTPStatusCode"]
124
+ print(f"HTTPStatusCode: {status_code}")
125
+ # assert status_code == 200, "Problem, unable to update dynamodb table."
126
+ # assert response['ConsumedCapacity']['TableName'] == table_name
127
+ except Exception as err:
128
+ print(f"Problem was encountered while updating item: {err}")
125
129
 
126
130
  #####################################################################
127
131
  # TODO: change to "get_cruise_as_df"
@@ -9,7 +9,7 @@ from pathlib import Path # , PurePath
9
9
 
10
10
  from water_column_sonar_processing.aws import DynamoDBManager, S3Manager
11
11
  from water_column_sonar_processing.geometry import GeometryManager
12
- from water_column_sonar_processing.utility import Cleaner
12
+ from water_column_sonar_processing.utility import Cleaner, PipelineStatus
13
13
 
14
14
  TEMPDIR = "/tmp"
15
15
 
@@ -53,10 +53,6 @@ class RawToZarr:
53
53
  ):
54
54
  print('Writing Zarr information to DynamoDB table.')
55
55
  dynamodb_manager = DynamoDBManager()
56
-
57
- # The problem is that these values were never populated
58
- # and so when the query looks for values that aren't there
59
- # they fail
60
56
  dynamodb_manager.update_item(
61
57
  table_name=table_name,
62
58
  key={
@@ -87,7 +83,8 @@ class RawToZarr:
87
83
  ":ma": {"N": str(np.round(max_echo_range, 4))},
88
84
  ":mi": {"N": str(np.round(min_echo_range, 4))},
89
85
  ":nd": {"N": str(num_ping_time_dropna)},
90
- ":ps": {"S": "PROCESSING_RESAMPLE_AND_WRITE_TO_ZARR_STORE"},
86
+ # ":ps": {"S": "PROCESSING_RESAMPLE_AND_WRITE_TO_ZARR_STORE"},
87
+ ":ps": {"S": PipelineStatus.LEVEL_1_PROCESSING.name},
91
88
  ":pt": {"S": datetime.now().isoformat(timespec="seconds") + "Z"},
92
89
  ":se": {"S": sensor_name},
93
90
  ":sh": {"S": ship_name},
@@ -113,6 +110,7 @@ class RawToZarr:
113
110
  "#ZP = :zp"
114
111
  ),
115
112
  )
113
+ print('Done writing Zarr information to DynamoDB table.')
116
114
 
117
115
  ############################################################################
118
116
  ############################################################################
@@ -143,6 +141,7 @@ class RawToZarr:
143
141
  def raw_to_zarr(
144
142
  self,
145
143
  table_name,
144
+ input_bucket_name,
146
145
  output_bucket_name,
147
146
  ship_name,
148
147
  cruise_name,
@@ -157,6 +156,14 @@ class RawToZarr:
157
156
  geometry_manager = GeometryManager()
158
157
  cleaner = Cleaner()
159
158
  cleaner.delete_local_files(file_types=["*.zarr", "*.json"]) # TODO: include bot and raw?
159
+
160
+ s3_manager = S3Manager()
161
+ s3_file_path = f"data/raw/{ship_name}/{cruise_name}/{sensor_name}/{raw_file_name}"
162
+ bottom_file_name = f"{Path(raw_file_name).stem}.bot"
163
+ s3_bottom_file_path = f"data/raw/{ship_name}/{cruise_name}/{sensor_name}/{bottom_file_name}"
164
+ s3_manager.download_file(bucket_name=input_bucket_name, key=s3_file_path, file_name=raw_file_name)
165
+ s3_manager.download_file(bucket_name=input_bucket_name, key=s3_bottom_file_path, file_name=bottom_file_name)
166
+
160
167
  try:
161
168
  gc.collect()
162
169
  print('Opening raw file with echopype.')
@@ -172,7 +179,12 @@ class RawToZarr:
172
179
  )
173
180
  print('Compute volume backscattering strength (Sv) from raw data.')
174
181
  ds_sv = ep.calibrate.compute_Sv(echodata)
175
- print('Done computing volume backscattering strength (Sv) from raw data.')
182
+ print('Done computing volume backscatter strength (Sv) from raw data.')
183
+ # Note: detected_seafloor_depth is located at echodata.vendor.detected_seafloor_depth
184
+ # but is not written out with ds_sv
185
+ if "detected_seafloor_depth" in list(echodata.vendor.variables):
186
+ ds_sv["detected_seafloor_depth"] = echodata.vendor.detected_seafloor_depth
187
+ #
176
188
  frequencies = echodata.environment.frequency_nominal.values
177
189
  #################################################################
178
190
  # Get GPS coordinates
@@ -191,12 +203,9 @@ class RawToZarr:
191
203
  # TODO: this var name is supposed to represent minimum resolution of depth measurements
192
204
  # TODO revert this so that smaller diffs can be used
193
205
  # The most minimum the resolution can be is as small as 0.25 meters
194
- min_echo_range = np.maximum(
195
- 0.25,
196
- np.nanmin(np.diff(ds_sv.echo_range.values))
197
- )
206
+ min_echo_range = np.round(np.nanmin(np.diff(ds_sv.echo_range.values)), 2)
198
207
  max_echo_range = float(np.nanmax(ds_sv.echo_range))
199
- #
208
+ # This is the number of missing values found throughout the lat/lon
200
209
  num_ping_time_dropna = lat[~np.isnan(lat)].shape[0] # symmetric to lon
201
210
  #
202
211
  start_time = np.datetime_as_string(ds_sv.ping_time.values[0], unit='ms') + "Z"
@@ -248,11 +257,12 @@ class RawToZarr:
248
257
  #######################################################################
249
258
  # TODO: verify count of objects matches, publish message, update status
250
259
  #######################################################################
251
- print('here')
260
+ print('Finished raw-to-zarr conversion.')
252
261
  except Exception as err:
253
262
  print(f'Exception encountered creating local Zarr store with echopype: {err}')
254
263
  raise RuntimeError(f"Problem creating local Zarr store, {err}")
255
264
  finally:
265
+ print("Finally.")
256
266
  cleaner.delete_local_files(file_types=["*.raw", "*.bot", "*.zarr", "*.json"])
257
267
  print('Done creating local zarr store.')
258
268
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: water_column_sonar_processing
3
- Version: 0.0.10
3
+ Version: 0.0.11
4
4
  Summary: A processing tool for water column sonar data.
5
5
  Author-email: Rudy Klucik <rudy.klucik@noaa.gov>
6
6
  Project-URL: Homepage, https://github.com/CI-CMG/water-column-sonar-processing
@@ -1,7 +1,7 @@
1
1
  water_column_sonar_processing/__init__.py,sha256=fvRK4uFo_A0l7w_T4yckvDqJ3wMUq4JB3VVPXqWfewE,226
2
2
  water_column_sonar_processing/process.py,sha256=-yQtK3rnZq6lGAr3q02zLDe1NuMH9c0PiUOxKzG_r18,5386
3
3
  water_column_sonar_processing/aws/__init__.py,sha256=KJqK8oYMn-u8n8i-Jp_lG5BvCOTjwWSjWP8yAyDlWVo,297
4
- water_column_sonar_processing/aws/dynamodb_manager.py,sha256=sZHn-hgCt3K3w0x5BcXfF5jLMt_F11dAtQHJToij9nU,10008
4
+ water_column_sonar_processing/aws/dynamodb_manager.py,sha256=gMDAXLE_p_nKmNZYICKA9T56PYDqtXBySlysSOVnWrI,10250
5
5
  water_column_sonar_processing/aws/s3_manager.py,sha256=kS48Vu_jE_fOKbwKOhCLWKDSqHzOGVEdZ_Lc4MaMCfA,15291
6
6
  water_column_sonar_processing/aws/s3fs_manager.py,sha256=thVJPQKhbvF1g-Ue3BYgwazFOFDYOICIEJx4zkXBQ1E,2381
7
7
  water_column_sonar_processing/aws/sns_manager.py,sha256=Dp9avG5VSugSWPR1dZ-askuAw1fCZkNUHbOUP65iR-k,1867
@@ -19,14 +19,14 @@ water_column_sonar_processing/model/__init__.py,sha256=FXaCdbPqxp0ogmZm9NplRirqp
19
19
  water_column_sonar_processing/model/zarr_manager.py,sha256=TbcVux-GWfX4XJ7UT20E7dI_h_islrKsGtjx_VwSsLg,14003
20
20
  water_column_sonar_processing/processing/__init__.py,sha256=UwdB3BnoUxy4q3k9-ZjBF6KzmCWVDcqbcArTeHgmvGA,118
21
21
  water_column_sonar_processing/processing/cruise_sampler.py,sha256=hadPrnH5nz7_oG_4pND7YbMFH6NMR9d6p3xAXedtKU8,15927
22
- water_column_sonar_processing/processing/raw_to_zarr.py,sha256=7vvoNe0jlB34R5mBPceQjL9N_5X0GTWs9xpCqvRK1nQ,15931
22
+ water_column_sonar_processing/processing/raw_to_zarr.py,sha256=OPu4CoIlHQFW38iY4DLe5A5Ttrdz4NXtjYThrB-FuPs,16874
23
23
  water_column_sonar_processing/utility/__init__.py,sha256=yDObMOL0_OxKWet5wffK2-XVJgoE9iwiY2q04GZrtBQ,234
24
24
  water_column_sonar_processing/utility/cleaner.py,sha256=bNbs-hopWxtKAFBK0Eu18xdRErZCGZvtla3j-1bTwQw,619
25
25
  water_column_sonar_processing/utility/constants.py,sha256=EbzsorvYKadsPjuutRjQKKByGibhFm0Gw6D-Sp2ZD3I,2143
26
26
  water_column_sonar_processing/utility/pipeline_status.py,sha256=O-0SySqdRGJ6bs3zQe1NV9vkOpmsRM7zj5QoHgzYioY,4395
27
27
  water_column_sonar_processing/utility/timestamp.py,sha256=bO0oir7KxxoEHPGRkz9FCBfOligkocUyRiWRzAq8fnU,361
28
- water_column_sonar_processing-0.0.10.dist-info/LICENSE,sha256=lz4IpJ5_adG3S0ali-WaIpQFVTnEAOucMDQPECUVEYw,1110
29
- water_column_sonar_processing-0.0.10.dist-info/METADATA,sha256=qFNeJ3GduRHKfcJRYShO9LamuMREk66qm18IUUXsMg8,4566
30
- water_column_sonar_processing-0.0.10.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
31
- water_column_sonar_processing-0.0.10.dist-info/top_level.txt,sha256=aRYU4A7RNBlNrL4vzjytFAir3BNnmOgsvIGKKA36tg4,30
32
- water_column_sonar_processing-0.0.10.dist-info/RECORD,,
28
+ water_column_sonar_processing-0.0.11.dist-info/LICENSE,sha256=lz4IpJ5_adG3S0ali-WaIpQFVTnEAOucMDQPECUVEYw,1110
29
+ water_column_sonar_processing-0.0.11.dist-info/METADATA,sha256=KFkI1367kV7L7pl8SIK4UFwUVJvUCHkRTPwBCqpnxWA,4566
30
+ water_column_sonar_processing-0.0.11.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
31
+ water_column_sonar_processing-0.0.11.dist-info/top_level.txt,sha256=aRYU4A7RNBlNrL4vzjytFAir3BNnmOgsvIGKKA36tg4,30
32
+ water_column_sonar_processing-0.0.11.dist-info/RECORD,,