water-column-sonar-processing 0.0.4__tar.gz → 0.0.5__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.
Potentially problematic release.
This version of water-column-sonar-processing might be problematic. Click here for more details.
- {water_column_sonar_processing-0.0.4/src/water_column_sonar_processing.egg-info → water_column_sonar_processing-0.0.5}/PKG-INFO +1 -1
- {water_column_sonar_processing-0.0.4 → water_column_sonar_processing-0.0.5}/pyproject.toml +1 -1
- {water_column_sonar_processing-0.0.4/src/aws_manager → water_column_sonar_processing-0.0.5/src/water_column_sonar_processing/aws}/dynamodb_manager.py +1 -1
- {water_column_sonar_processing-0.0.4/src/aws_manager → water_column_sonar_processing-0.0.5/src/water_column_sonar_processing/aws}/s3_manager.py +11 -11
- {water_column_sonar_processing-0.0.4/src → water_column_sonar_processing-0.0.5/src/water_column_sonar_processing}/cruise/create_empty_zarr_store.py +13 -13
- {water_column_sonar_processing-0.0.4/src → water_column_sonar_processing-0.0.5/src/water_column_sonar_processing}/cruise/resample_regrid.py +9 -9
- {water_column_sonar_processing-0.0.4/src/geometry_manager → water_column_sonar_processing-0.0.5/src/water_column_sonar_processing/geometry}/geometry_manager.py +2 -2
- {water_column_sonar_processing-0.0.4/src/geometry_manager → water_column_sonar_processing-0.0.5/src/water_column_sonar_processing/geometry}/pmtile_generation.py +1 -1
- {water_column_sonar_processing-0.0.4/src/index_manager → water_column_sonar_processing-0.0.5/src/water_column_sonar_processing/index}/index_manager.py +2 -2
- {water_column_sonar_processing-0.0.4/src/zarr_manager → water_column_sonar_processing-0.0.5/src/water_column_sonar_processing/model}/zarr_manager.py +8 -10
- water_column_sonar_processing-0.0.4/src/model.py → water_column_sonar_processing-0.0.5/src/water_column_sonar_processing/process.py +6 -6
- {water_column_sonar_processing-0.0.4/src → water_column_sonar_processing-0.0.5/src/water_column_sonar_processing}/utility/cleaner.py +2 -2
- {water_column_sonar_processing-0.0.4 → water_column_sonar_processing-0.0.5/src/water_column_sonar_processing.egg-info}/PKG-INFO +1 -1
- water_column_sonar_processing-0.0.5/src/water_column_sonar_processing.egg-info/SOURCES.txt +42 -0
- water_column_sonar_processing-0.0.5/src/water_column_sonar_processing.egg-info/top_level.txt +1 -0
- {water_column_sonar_processing-0.0.4 → water_column_sonar_processing-0.0.5}/tests/test_create_empty_zarr_store.py +1 -7
- {water_column_sonar_processing-0.0.4 → water_column_sonar_processing-0.0.5}/tests/test_dynamodb_manager.py +4 -8
- {water_column_sonar_processing-0.0.4 → water_column_sonar_processing-0.0.5}/tests/test_geometry_manager.py +2 -4
- {water_column_sonar_processing-0.0.4 → water_column_sonar_processing-0.0.5}/tests/test_geometry_simplification.py +1 -5
- {water_column_sonar_processing-0.0.4 → water_column_sonar_processing-0.0.5}/tests/test_index.py +10 -14
- water_column_sonar_processing-0.0.4/tests/test_model.py → water_column_sonar_processing-0.0.5/tests/test_process.py +11 -19
- {water_column_sonar_processing-0.0.4 → water_column_sonar_processing-0.0.5}/tests/test_resample_regrid.py +7 -11
- {water_column_sonar_processing-0.0.4 → water_column_sonar_processing-0.0.5}/tests/test_s3_manager.py +1 -7
- {water_column_sonar_processing-0.0.4 → water_column_sonar_processing-0.0.5}/tests/test_s3fs_manager.py +12 -34
- {water_column_sonar_processing-0.0.4 → water_column_sonar_processing-0.0.5}/tests/test_sns_sqs_manager.py +2 -9
- {water_column_sonar_processing-0.0.4 → water_column_sonar_processing-0.0.5}/tests/test_zarr_manager.py +15 -30
- water_column_sonar_processing-0.0.4/src/water_column_sonar_processing.egg-info/SOURCES.txt +0 -42
- water_column_sonar_processing-0.0.4/src/water_column_sonar_processing.egg-info/top_level.txt +0 -8
- {water_column_sonar_processing-0.0.4 → water_column_sonar_processing-0.0.5}/LICENSE +0 -0
- {water_column_sonar_processing-0.0.4 → water_column_sonar_processing-0.0.5}/README.md +0 -0
- {water_column_sonar_processing-0.0.4 → water_column_sonar_processing-0.0.5}/setup.cfg +0 -0
- {water_column_sonar_processing-0.0.4/src → water_column_sonar_processing-0.0.5/src/water_column_sonar_processing}/__init__.py +0 -0
- {water_column_sonar_processing-0.0.4/src/aws_manager → water_column_sonar_processing-0.0.5/src/water_column_sonar_processing/aws}/__init__.py +0 -0
- {water_column_sonar_processing-0.0.4/src/aws_manager → water_column_sonar_processing-0.0.5/src/water_column_sonar_processing/aws}/s3fs_manager.py +0 -0
- {water_column_sonar_processing-0.0.4/src/aws_manager → water_column_sonar_processing-0.0.5/src/water_column_sonar_processing/aws}/sns_manager.py +0 -0
- {water_column_sonar_processing-0.0.4/src/aws_manager → water_column_sonar_processing-0.0.5/src/water_column_sonar_processing/aws}/sqs_manager.py +0 -0
- {water_column_sonar_processing-0.0.4/src → water_column_sonar_processing-0.0.5/src/water_column_sonar_processing}/cruise/__init__.py +0 -0
- {water_column_sonar_processing-0.0.4/src/geometry_manager → water_column_sonar_processing-0.0.5/src/water_column_sonar_processing/geometry}/__init__.py +0 -0
- {water_column_sonar_processing-0.0.4/src/geometry_manager → water_column_sonar_processing-0.0.5/src/water_column_sonar_processing/geometry}/geometry_simplification.py +0 -0
- {water_column_sonar_processing-0.0.4/src/index_manager → water_column_sonar_processing-0.0.5/src/water_column_sonar_processing/index}/__init__.py +0 -0
- {water_column_sonar_processing-0.0.4/src/utility → water_column_sonar_processing-0.0.5/src/water_column_sonar_processing/model}/__init__.py +0 -0
- {water_column_sonar_processing-0.0.4/src/zarr_manager → water_column_sonar_processing-0.0.5/src/water_column_sonar_processing/utility}/__init__.py +0 -0
- {water_column_sonar_processing-0.0.4/src → water_column_sonar_processing-0.0.5/src/water_column_sonar_processing}/utility/constants.py +0 -0
- {water_column_sonar_processing-0.0.4/src → water_column_sonar_processing-0.0.5/src/water_column_sonar_processing}/utility/pipeline_status.py +0 -0
- {water_column_sonar_processing-0.0.4/src → water_column_sonar_processing-0.0.5/src/water_column_sonar_processing}/utility/timestamp.py +0 -0
- {water_column_sonar_processing-0.0.4 → water_column_sonar_processing-0.0.5}/src/water_column_sonar_processing.egg-info/dependency_links.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: water_column_sonar_processing
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.5
|
|
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
|
|
@@ -23,7 +23,7 @@ class DynamoDBManager:
|
|
|
23
23
|
self.type_deserializer = TypeDeserializer()
|
|
24
24
|
|
|
25
25
|
#####################################################################
|
|
26
|
-
### defined in raw-to-
|
|
26
|
+
### defined in raw-to-model, not used
|
|
27
27
|
# def put_item(
|
|
28
28
|
# self,
|
|
29
29
|
# table_name,
|
|
@@ -139,12 +139,12 @@ class S3Manager:
|
|
|
139
139
|
return all_uploads
|
|
140
140
|
|
|
141
141
|
#####################################################################
|
|
142
|
-
def upload_zarr_files_to_bucket( # noaa-wcsd-
|
|
142
|
+
def upload_zarr_files_to_bucket( # noaa-wcsd-model-pds
|
|
143
143
|
self,
|
|
144
144
|
local_directory,
|
|
145
145
|
remote_directory,
|
|
146
146
|
):
|
|
147
|
-
# Right now this is just for uploading a
|
|
147
|
+
# Right now this is just for uploading a model store to s3
|
|
148
148
|
print('Uploading files to output bucket.')
|
|
149
149
|
store_name = os.path.basename(local_directory)
|
|
150
150
|
all_files = []
|
|
@@ -162,8 +162,8 @@ class S3Manager:
|
|
|
162
162
|
return all_uploads
|
|
163
163
|
|
|
164
164
|
#####################################################################
|
|
165
|
-
# used: raw-to-
|
|
166
|
-
def list_objects( # noaa-wcsd-pds and noaa-wcsd-
|
|
165
|
+
# used: raw-to-model
|
|
166
|
+
def list_objects( # noaa-wcsd-pds and noaa-wcsd-model-pds
|
|
167
167
|
self,
|
|
168
168
|
bucket_name,
|
|
169
169
|
prefix
|
|
@@ -179,7 +179,7 @@ class S3Manager:
|
|
|
179
179
|
keys.extend([k['Key'] for k in page['Contents']])
|
|
180
180
|
return keys
|
|
181
181
|
|
|
182
|
-
def list_nodd_objects( # These are used by the
|
|
182
|
+
def list_nodd_objects( # These are used by the geometry for uploading data
|
|
183
183
|
self,
|
|
184
184
|
prefix,
|
|
185
185
|
):
|
|
@@ -250,8 +250,8 @@ class S3Manager:
|
|
|
250
250
|
return raw_files
|
|
251
251
|
|
|
252
252
|
#####################################################################
|
|
253
|
-
def get_object( # TODO: Move this to
|
|
254
|
-
# noaa-wcsd-pds or noaa-wcsd-
|
|
253
|
+
def get_object( # TODO: Move this to index.py
|
|
254
|
+
# noaa-wcsd-pds or noaa-wcsd-model-pds
|
|
255
255
|
self,
|
|
256
256
|
bucket_name,
|
|
257
257
|
key_name,
|
|
@@ -272,9 +272,9 @@ class S3Manager:
|
|
|
272
272
|
return response
|
|
273
273
|
|
|
274
274
|
#####################################################################
|
|
275
|
-
# used raw-to-
|
|
275
|
+
# used raw-to-model
|
|
276
276
|
def download_file( # TODO: change to download_object
|
|
277
|
-
# noaa-wcsd-pds or noaa-wcsd-
|
|
277
|
+
# noaa-wcsd-pds or noaa-wcsd-model-pds
|
|
278
278
|
self,
|
|
279
279
|
bucket_name,
|
|
280
280
|
key,
|
|
@@ -289,7 +289,7 @@ class S3Manager:
|
|
|
289
289
|
|
|
290
290
|
#####################################################################
|
|
291
291
|
# not used
|
|
292
|
-
# def delete_nodd_object( # noaa-wcsd-
|
|
292
|
+
# def delete_nodd_object( # noaa-wcsd-model-pds
|
|
293
293
|
# self,
|
|
294
294
|
# bucket_name,
|
|
295
295
|
# key
|
|
@@ -319,7 +319,7 @@ class S3Manager:
|
|
|
319
319
|
|
|
320
320
|
#####################################################################
|
|
321
321
|
# not used TODO: remove
|
|
322
|
-
def put( # noaa-wcsd-
|
|
322
|
+
def put( # noaa-wcsd-model-pds
|
|
323
323
|
self,
|
|
324
324
|
bucket_name,
|
|
325
325
|
key,
|
|
@@ -2,17 +2,17 @@ import os
|
|
|
2
2
|
import numcodecs
|
|
3
3
|
import numpy as np
|
|
4
4
|
|
|
5
|
-
from utility.cleaner import Cleaner
|
|
6
|
-
from
|
|
7
|
-
from
|
|
8
|
-
from
|
|
5
|
+
from water_column_sonar_processing.utility.cleaner import Cleaner
|
|
6
|
+
from water_column_sonar_processing.aws.dynamodb_manager import DynamoDBManager
|
|
7
|
+
from water_column_sonar_processing.aws.s3_manager import S3Manager
|
|
8
|
+
from water_column_sonar_processing.model.zarr_manager import ZarrManager
|
|
9
9
|
|
|
10
10
|
numcodecs.blosc.use_threads = False
|
|
11
11
|
numcodecs.blosc.set_nthreads(1)
|
|
12
12
|
|
|
13
13
|
TEMPDIR = "/tmp"
|
|
14
14
|
|
|
15
|
-
# TODO: when ready switch to version 3 of
|
|
15
|
+
# TODO: when ready switch to version 3 of model spec
|
|
16
16
|
# ZARR_V3_EXPERIMENTAL_API = 1
|
|
17
17
|
# creates the latlon data: foo = ep.consolidate.add_location(ds_Sv, echodata)
|
|
18
18
|
|
|
@@ -34,7 +34,7 @@ class CreateEmptyZarrStore:
|
|
|
34
34
|
object_prefix: str,
|
|
35
35
|
cruise_name: str,
|
|
36
36
|
) -> None:
|
|
37
|
-
print('uploading
|
|
37
|
+
print('uploading model store to s3')
|
|
38
38
|
s3_manager = S3Manager()
|
|
39
39
|
#
|
|
40
40
|
print('Starting upload with thread pool executor.')
|
|
@@ -43,8 +43,8 @@ class CreateEmptyZarrStore:
|
|
|
43
43
|
for subdir, dirs, files in os.walk(f"{local_directory}/{cruise_name}.zarr_manager"):
|
|
44
44
|
for file in files:
|
|
45
45
|
local_path = os.path.join(subdir, file)
|
|
46
|
-
# 'level_2/Henry_B._Bigelow/HB0806/EK60/HB0806.
|
|
47
|
-
s3_key = f'{object_prefix}/{cruise_name}.
|
|
46
|
+
# 'level_2/Henry_B._Bigelow/HB0806/EK60/HB0806.model/.zattrs'
|
|
47
|
+
s3_key = f'{object_prefix}/{cruise_name}.model{local_path.split(f"{cruise_name}.model")[-1]}'
|
|
48
48
|
all_files.append([local_path, s3_key])
|
|
49
49
|
#
|
|
50
50
|
# print(all_files)
|
|
@@ -98,10 +98,10 @@ class CreateEmptyZarrStore:
|
|
|
98
98
|
new_width = int(consolidated_zarr_width)
|
|
99
99
|
print(f"new_width: {new_width}")
|
|
100
100
|
#################################################################
|
|
101
|
-
store_name = f"{cruise_name}.
|
|
101
|
+
store_name = f"{cruise_name}.model"
|
|
102
102
|
print(store_name)
|
|
103
103
|
################################################################
|
|
104
|
-
# Delete existing
|
|
104
|
+
# Delete existing model store if it exists
|
|
105
105
|
s3_manager = S3Manager()
|
|
106
106
|
zarr_prefix = os.path.join("level_2", ship_name, cruise_name, sensor_name)
|
|
107
107
|
child_objects = s3_manager.get_child_objects(
|
|
@@ -113,7 +113,7 @@ class CreateEmptyZarrStore:
|
|
|
113
113
|
objects=child_objects,
|
|
114
114
|
)
|
|
115
115
|
################################################################
|
|
116
|
-
# Create new
|
|
116
|
+
# Create new model store
|
|
117
117
|
zarr_manager = ZarrManager()
|
|
118
118
|
new_height = len(zarr_manager.get_depth_values(
|
|
119
119
|
min_echo_range=cruise_min_echo_range,
|
|
@@ -157,11 +157,11 @@ class CreateEmptyZarrStore:
|
|
|
157
157
|
# TODO: update enum in dynamodb
|
|
158
158
|
#################################################################
|
|
159
159
|
except Exception as err:
|
|
160
|
-
print(f"Problem trying to create new cruise
|
|
160
|
+
print(f"Problem trying to create new cruise model store: {err}")
|
|
161
161
|
finally:
|
|
162
162
|
cleaner = Cleaner()
|
|
163
163
|
cleaner.delete_local_files()
|
|
164
|
-
print("Done creating cruise level
|
|
164
|
+
print("Done creating cruise level model store")
|
|
165
165
|
|
|
166
166
|
|
|
167
167
|
###########################################################
|
|
@@ -6,16 +6,16 @@ import numpy as np
|
|
|
6
6
|
import xarray as xr
|
|
7
7
|
import pandas as pd
|
|
8
8
|
|
|
9
|
-
from
|
|
10
|
-
from
|
|
11
|
-
from
|
|
9
|
+
from water_column_sonar_processing.aws.dynamodb_manager import DynamoDBManager
|
|
10
|
+
from water_column_sonar_processing.model.zarr_manager import ZarrManager
|
|
11
|
+
from water_column_sonar_processing.geometry.geometry_manager import GeometryManager
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
numcodecs.blosc.use_threads = False
|
|
15
15
|
numcodecs.blosc.set_nthreads(1)
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
# TODO: when ready switch to version 3 of
|
|
18
|
+
# TODO: when ready switch to version 3 of model spec
|
|
19
19
|
# ZARR_V3_EXPERIMENTAL_API = 1
|
|
20
20
|
# creates the latlon data: foo = ep.consolidate.add_location(ds_Sv, echodata)
|
|
21
21
|
|
|
@@ -115,7 +115,7 @@ class ResampleRegrid:
|
|
|
115
115
|
) -> None:
|
|
116
116
|
"""
|
|
117
117
|
The goal here is to interpolate the data against the depth values already populated
|
|
118
|
-
in the existing file level
|
|
118
|
+
in the existing file level model stores. We open the cruise-level store with model for
|
|
119
119
|
read/write operations. We open the file-level store with Xarray to leverage tools for
|
|
120
120
|
resampling and subsetting the data.
|
|
121
121
|
"""
|
|
@@ -124,7 +124,7 @@ class ResampleRegrid:
|
|
|
124
124
|
zarr_manager = ZarrManager()
|
|
125
125
|
# s3_manager = S3Manager()
|
|
126
126
|
geo_manager = GeometryManager()
|
|
127
|
-
# get
|
|
127
|
+
# get model store
|
|
128
128
|
output_zarr_store = zarr_manager.open_s3_zarr_store_with_zarr(
|
|
129
129
|
ship_name=ship_name,
|
|
130
130
|
cruise_name=cruise_name,
|
|
@@ -157,7 +157,7 @@ class ResampleRegrid:
|
|
|
157
157
|
# TODO: filter rows by enum success, filter the dataframe just for enums >= LEVEL_1_PROCESSING
|
|
158
158
|
# df[df['PIPELINE_STATUS'] < PipelineStatus.LEVEL_1_PROCESSING] = np.nan
|
|
159
159
|
|
|
160
|
-
# Get
|
|
160
|
+
# Get index from all cruise files. Note: should be based on which are included in cruise.
|
|
161
161
|
index = cruise_df.index[cruise_df['FILE_NAME'] == f"{file_name_stem}.raw"][0]
|
|
162
162
|
|
|
163
163
|
# get input store
|
|
@@ -169,7 +169,7 @@ class ResampleRegrid:
|
|
|
169
169
|
)
|
|
170
170
|
#########################################################################
|
|
171
171
|
# [3] Get needed indices
|
|
172
|
-
# Offset from start
|
|
172
|
+
# Offset from start index to insert new data. Note that missing values are excluded.
|
|
173
173
|
ping_time_cumsum = np.insert(
|
|
174
174
|
np.cumsum(cruise_df['NUM_PING_TIME_DROPNA'].dropna().to_numpy(dtype=int)),
|
|
175
175
|
obj=0,
|
|
@@ -223,7 +223,7 @@ class ResampleRegrid:
|
|
|
223
223
|
print(f"start_ping_time_index: {start_ping_time_index}, end_ping_time_index: {end_ping_time_index}")
|
|
224
224
|
|
|
225
225
|
#########################################################################
|
|
226
|
-
# write Sv values to cruise-level-
|
|
226
|
+
# write Sv values to cruise-level-model-store
|
|
227
227
|
for channel in range(len(input_xr.channel.values)): # doesn't like being written in one fell swoop :(
|
|
228
228
|
output_zarr_store.Sv[
|
|
229
229
|
:,
|
|
@@ -3,8 +3,8 @@ import numpy as np
|
|
|
3
3
|
import geopandas
|
|
4
4
|
import pandas as pd
|
|
5
5
|
|
|
6
|
-
from utility.cleaner import Cleaner
|
|
7
|
-
from
|
|
6
|
+
from water_column_sonar_processing.utility.cleaner import Cleaner
|
|
7
|
+
from water_column_sonar_processing.aws.s3_manager import S3Manager
|
|
8
8
|
|
|
9
9
|
"""
|
|
10
10
|
// [Decimal / Places / Degrees / Object that can be recognized at scale / N/S or E/W at equator, E/W at 23N/S, E/W at 45N/S, E/W at 67N/S]
|
|
@@ -23,7 +23,7 @@ class PMTileGeneration(object):
|
|
|
23
23
|
|
|
24
24
|
#######################################################
|
|
25
25
|
def generate_geojson_feature_collection(self):
|
|
26
|
-
# This was used to read from noaa-wcsd-
|
|
26
|
+
# This was used to read from noaa-wcsd-model-pds bucket geojson files and then to
|
|
27
27
|
# generate the geopandas dataframe which could be exported to another comprehensive
|
|
28
28
|
# geojson file. That
|
|
29
29
|
result = list(Path("/Users/r2d2/Documents/echofish/geojson").rglob("*.json"))
|
|
@@ -4,7 +4,7 @@ import pandas as pd
|
|
|
4
4
|
from datetime import datetime
|
|
5
5
|
from concurrent.futures import ThreadPoolExecutor
|
|
6
6
|
from concurrent.futures import as_completed
|
|
7
|
-
from
|
|
7
|
+
from water_column_sonar_processing.aws.s3_manager import S3Manager
|
|
8
8
|
|
|
9
9
|
class IndexManager:
|
|
10
10
|
|
|
@@ -193,7 +193,7 @@ class IndexManager:
|
|
|
193
193
|
return calibration_statuses
|
|
194
194
|
|
|
195
195
|
#################################################################
|
|
196
|
-
# def
|
|
196
|
+
# def index( # TODO: get rid of this?
|
|
197
197
|
# self
|
|
198
198
|
# ):
|
|
199
199
|
# start_time = datetime.now() # used for benchmarking
|
|
@@ -4,20 +4,18 @@ import numcodecs
|
|
|
4
4
|
import numpy as np
|
|
5
5
|
import xarray as xr
|
|
6
6
|
from numcodecs import Blosc
|
|
7
|
-
|
|
8
|
-
from utility.
|
|
9
|
-
from
|
|
10
|
-
from aws_manager.s3fs_manager import S3FSManager
|
|
7
|
+
from water_column_sonar_processing.utility.constants import Constants, Coordinates
|
|
8
|
+
from water_column_sonar_processing.utility.timestamp import Timestamp
|
|
9
|
+
from water_column_sonar_processing.aws.s3fs_manager import S3FSManager
|
|
11
10
|
|
|
12
11
|
numcodecs.blosc.use_threads = False
|
|
13
12
|
numcodecs.blosc.set_nthreads(1)
|
|
14
13
|
|
|
15
14
|
|
|
16
|
-
# TODO: when ready switch to version 3 of
|
|
15
|
+
# TODO: when ready switch to version 3 of model spec
|
|
17
16
|
# ZARR_V3_EXPERIMENTAL_API = 1
|
|
18
17
|
|
|
19
18
|
# creates the latlon data: foo = ep.consolidate.add_location(ds_Sv, echodata)
|
|
20
|
-
|
|
21
19
|
class ZarrManager:
|
|
22
20
|
#######################################################
|
|
23
21
|
def __init__(
|
|
@@ -37,7 +35,7 @@ class ZarrManager:
|
|
|
37
35
|
max_echo_range: float = 100., # maximum depth measured from whole cruise
|
|
38
36
|
):
|
|
39
37
|
# Gets the set of depth values that will be used when resampling and
|
|
40
|
-
# regridding the data to a cruise level
|
|
38
|
+
# regridding the data to a cruise level model store.
|
|
41
39
|
# Note: returned values do not start at zero.
|
|
42
40
|
print('Getting depth values.')
|
|
43
41
|
all_cruise_depth_values = np.linspace(
|
|
@@ -252,7 +250,7 @@ class ZarrManager:
|
|
|
252
250
|
s3fs_manager = S3FSManager()
|
|
253
251
|
root = f'{self.output_bucket_name}/level_2/{ship_name}/{cruise_name}/{sensor_name}/{cruise_name}.zarr'
|
|
254
252
|
store = s3fs_manager.s3_map(s3_zarr_store_path=root)
|
|
255
|
-
# synchronizer =
|
|
253
|
+
# synchronizer = model.ProcessSynchronizer(f"/tmp/{ship_name}_{cruise_name}.sync")
|
|
256
254
|
cruise_zarr = zarr.open(store=store, mode="r+")
|
|
257
255
|
except Exception as err: # Failure
|
|
258
256
|
print(f'Exception encountered opening Zarr store with Zarr.: {err}')
|
|
@@ -284,12 +282,12 @@ class ZarrManager:
|
|
|
284
282
|
|
|
285
283
|
#######################################################
|
|
286
284
|
# def create_process_synchronizer(self):
|
|
287
|
-
# # TODO: explore
|
|
285
|
+
# # TODO: explore aws redis options
|
|
288
286
|
# pass
|
|
289
287
|
|
|
290
288
|
#######################################################
|
|
291
289
|
# def verify_cruise_store_data(self):
|
|
292
|
-
# # TODO: run a check on a finished
|
|
290
|
+
# # TODO: run a check on a finished model store to ensure that
|
|
293
291
|
# # none of the time, latitude, longitude, or depth values
|
|
294
292
|
# # are NaN.
|
|
295
293
|
# pass
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import json
|
|
3
3
|
import numpy as np
|
|
4
|
-
from
|
|
5
|
-
from
|
|
6
|
-
from
|
|
7
|
-
from
|
|
4
|
+
from water_column_sonar_processing.aws.s3_manager import S3Manager
|
|
5
|
+
from water_column_sonar_processing.aws.s3fs_manager import S3FSManager
|
|
6
|
+
from water_column_sonar_processing.aws.sns_manager import SNSManager
|
|
7
|
+
from water_column_sonar_processing.aws.dynamodb_manager import DynamoDBManager
|
|
8
8
|
|
|
9
9
|
###########################################################
|
|
10
|
-
class
|
|
10
|
+
class Process:
|
|
11
11
|
#######################################################
|
|
12
12
|
def __init__(
|
|
13
13
|
self,
|
|
@@ -87,7 +87,7 @@ class Model:
|
|
|
87
87
|
':sh': {'S': ship_name},
|
|
88
88
|
':st': {'S': '2006-04-06T11:34:07.288Z'},
|
|
89
89
|
':zb': {'S': 'r2d2-dev-echofish2-118234403147-echofish-dev-output'},
|
|
90
|
-
':zp': {'S': 'level_1/David_Starr_Jordan/DS0604/EK60/DSJ0604-D20060406-T113407.
|
|
90
|
+
':zp': {'S': 'level_1/David_Starr_Jordan/DS0604/EK60/DSJ0604-D20060406-T113407.model'},
|
|
91
91
|
},
|
|
92
92
|
update_expression=(
|
|
93
93
|
'SET '
|
|
@@ -7,9 +7,9 @@ import shutil
|
|
|
7
7
|
class Cleaner:
|
|
8
8
|
@staticmethod
|
|
9
9
|
def delete_local_files(
|
|
10
|
-
file_types=['*.raw*', '*.
|
|
10
|
+
file_types=['*.raw*', '*.model'] # '*.json'
|
|
11
11
|
):
|
|
12
|
-
print('Deleting all local raw and
|
|
12
|
+
print('Deleting all local raw and model files')
|
|
13
13
|
for i in file_types:
|
|
14
14
|
for j in glob.glob(i):
|
|
15
15
|
if os.path.isdir(j):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: water_column_sonar_processing
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.5
|
|
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
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/water_column_sonar_processing/__init__.py
|
|
5
|
+
src/water_column_sonar_processing/process.py
|
|
6
|
+
src/water_column_sonar_processing.egg-info/PKG-INFO
|
|
7
|
+
src/water_column_sonar_processing.egg-info/SOURCES.txt
|
|
8
|
+
src/water_column_sonar_processing.egg-info/dependency_links.txt
|
|
9
|
+
src/water_column_sonar_processing.egg-info/top_level.txt
|
|
10
|
+
src/water_column_sonar_processing/aws/__init__.py
|
|
11
|
+
src/water_column_sonar_processing/aws/dynamodb_manager.py
|
|
12
|
+
src/water_column_sonar_processing/aws/s3_manager.py
|
|
13
|
+
src/water_column_sonar_processing/aws/s3fs_manager.py
|
|
14
|
+
src/water_column_sonar_processing/aws/sns_manager.py
|
|
15
|
+
src/water_column_sonar_processing/aws/sqs_manager.py
|
|
16
|
+
src/water_column_sonar_processing/cruise/__init__.py
|
|
17
|
+
src/water_column_sonar_processing/cruise/create_empty_zarr_store.py
|
|
18
|
+
src/water_column_sonar_processing/cruise/resample_regrid.py
|
|
19
|
+
src/water_column_sonar_processing/geometry/__init__.py
|
|
20
|
+
src/water_column_sonar_processing/geometry/geometry_manager.py
|
|
21
|
+
src/water_column_sonar_processing/geometry/geometry_simplification.py
|
|
22
|
+
src/water_column_sonar_processing/geometry/pmtile_generation.py
|
|
23
|
+
src/water_column_sonar_processing/index/__init__.py
|
|
24
|
+
src/water_column_sonar_processing/index/index_manager.py
|
|
25
|
+
src/water_column_sonar_processing/model/__init__.py
|
|
26
|
+
src/water_column_sonar_processing/model/zarr_manager.py
|
|
27
|
+
src/water_column_sonar_processing/utility/__init__.py
|
|
28
|
+
src/water_column_sonar_processing/utility/cleaner.py
|
|
29
|
+
src/water_column_sonar_processing/utility/constants.py
|
|
30
|
+
src/water_column_sonar_processing/utility/pipeline_status.py
|
|
31
|
+
src/water_column_sonar_processing/utility/timestamp.py
|
|
32
|
+
tests/test_create_empty_zarr_store.py
|
|
33
|
+
tests/test_dynamodb_manager.py
|
|
34
|
+
tests/test_geometry_manager.py
|
|
35
|
+
tests/test_geometry_simplification.py
|
|
36
|
+
tests/test_index.py
|
|
37
|
+
tests/test_process.py
|
|
38
|
+
tests/test_resample_regrid.py
|
|
39
|
+
tests/test_s3_manager.py
|
|
40
|
+
tests/test_s3fs_manager.py
|
|
41
|
+
tests/test_sns_sqs_manager.py
|
|
42
|
+
tests/test_zarr_manager.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
water_column_sonar_processing
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import os
|
|
2
|
-
import pytest
|
|
3
2
|
from moto import mock_aws
|
|
4
3
|
from dotenv import load_dotenv, find_dotenv
|
|
5
|
-
|
|
6
|
-
from cruise.create_empty_zarr_store import CreateEmptyZarrStore
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
# from src.model.cruise.create_empty_zarr_store import CreateEmptyZarrStore
|
|
4
|
+
from water_column_sonar_processing.cruise.create_empty_zarr_store import CreateEmptyZarrStore
|
|
10
5
|
|
|
11
6
|
|
|
12
7
|
#######################################################
|
|
@@ -25,7 +20,6 @@ TEMPDIR = "/tmp"
|
|
|
25
20
|
|
|
26
21
|
#######################################################
|
|
27
22
|
@mock_aws
|
|
28
|
-
# @pytest.mark.skip(reason="no way of currently testing this")
|
|
29
23
|
def test_create_empty_zarr_store(tmp_path=TEMPDIR):
|
|
30
24
|
# temporary_directory = str(tmp_path)
|
|
31
25
|
temporary_directory = str(tmp_path)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import numpy as np
|
|
2
2
|
from moto import mock_aws
|
|
3
3
|
from dotenv import load_dotenv, find_dotenv
|
|
4
|
+
from water_column_sonar_processing.aws.dynamodb_manager import DynamoDBManager
|
|
5
|
+
from water_column_sonar_processing.utility.pipeline_status import PipelineStatus
|
|
4
6
|
|
|
5
|
-
from aws_manager.dynamodb_manager import DynamoDBManager
|
|
6
|
-
from utility.pipeline_status import PipelineStatus
|
|
7
7
|
|
|
8
8
|
#######################################################
|
|
9
9
|
def setup_module():
|
|
@@ -11,13 +11,10 @@ def setup_module():
|
|
|
11
11
|
env_file = find_dotenv('.env-test')
|
|
12
12
|
load_dotenv(dotenv_path=env_file, override=True)
|
|
13
13
|
|
|
14
|
-
|
|
15
14
|
def teardown_module():
|
|
16
15
|
print('teardown')
|
|
17
16
|
|
|
18
|
-
|
|
19
17
|
#######################################################
|
|
20
|
-
|
|
21
18
|
def test_serializer_deserializer():
|
|
22
19
|
# ---Initialize--- #
|
|
23
20
|
low_level_data = {
|
|
@@ -35,7 +32,7 @@ def test_serializer_deserializer():
|
|
|
35
32
|
"customer": {
|
|
36
33
|
"S": "TEST"
|
|
37
34
|
},
|
|
38
|
-
"
|
|
35
|
+
"index": {
|
|
39
36
|
"N": "1"
|
|
40
37
|
}
|
|
41
38
|
}
|
|
@@ -58,7 +55,7 @@ def test_serializer_deserializer():
|
|
|
58
55
|
assert python_data['ACTIVE']
|
|
59
56
|
assert python_data['CRC'] == -1600155180
|
|
60
57
|
assert python_data['ID']
|
|
61
|
-
assert python_data['params'] == {'customer': 'TEST', '
|
|
58
|
+
assert python_data['params'] == {'customer': 'TEST', 'index': 1}
|
|
62
59
|
assert python_data['THIS_STATUS'] == 10
|
|
63
60
|
assert python_data['TYPE'] == 22
|
|
64
61
|
|
|
@@ -68,7 +65,6 @@ def test_serializer_deserializer():
|
|
|
68
65
|
|
|
69
66
|
assert low_level_data == low_level_copy
|
|
70
67
|
|
|
71
|
-
|
|
72
68
|
#######################################################
|
|
73
69
|
@mock_aws
|
|
74
70
|
def test_dynamodb_manager():
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import numpy as np
|
|
2
2
|
import echopype as ep
|
|
3
3
|
from dotenv import load_dotenv, find_dotenv
|
|
4
|
+
from water_column_sonar_processing.geometry.geometry_manager import GeometryManager
|
|
4
5
|
|
|
5
|
-
from geometry_manager.geometry_manager import GeometryManager
|
|
6
6
|
|
|
7
7
|
#######################################################
|
|
8
8
|
def setup_module():
|
|
9
9
|
print('setup')
|
|
10
10
|
env_file = find_dotenv('.env-test')
|
|
11
|
-
# env_file = find_dotenv('.env-prod')
|
|
12
11
|
load_dotenv(dotenv_path=env_file, override=True)
|
|
13
12
|
|
|
14
|
-
|
|
15
13
|
def teardown_module():
|
|
16
14
|
print('teardown')
|
|
17
15
|
|
|
@@ -29,7 +27,7 @@ def test_geometry_manager(tmp_path):
|
|
|
29
27
|
sensor_name = 'EK60'
|
|
30
28
|
|
|
31
29
|
s3_path = f"s3://{bucket_name}/data/raw/{ship_name}/{cruise_name}/{sensor_name}/{file_name}"
|
|
32
|
-
# s3_path = f"r2d2-testing-level-2-data/level_2/Henry_B._Bigelow/HB0707/EK60/HB0707.
|
|
30
|
+
# s3_path = f"r2d2-testing-level-2-data/level_2/Henry_B._Bigelow/HB0707/EK60/HB0707.model"
|
|
33
31
|
|
|
34
32
|
print(s3_path)
|
|
35
33
|
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
import unittest
|
|
3
1
|
from dotenv import load_dotenv, find_dotenv
|
|
4
2
|
|
|
5
|
-
# import os
|
|
6
|
-
|
|
7
3
|
# s3fs.core.setup_logging("DEBUG")
|
|
8
4
|
|
|
9
5
|
|
|
@@ -33,7 +29,7 @@ def teardown_module():
|
|
|
33
29
|
|
|
34
30
|
# @mock_s3
|
|
35
31
|
def test_geometry_simplification():
|
|
36
|
-
# bucket_name = 'noaa-wcsd-
|
|
32
|
+
# bucket_name = 'noaa-wcsd-model-pds'
|
|
37
33
|
pass
|
|
38
34
|
|
|
39
35
|
#######################################################
|
{water_column_sonar_processing-0.0.4 → water_column_sonar_processing-0.0.5}/tests/test_index.py
RENAMED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
from dotenv import load_dotenv, find_dotenv
|
|
2
|
+
from water_column_sonar_processing.index.index_manager import IndexManager
|
|
2
3
|
|
|
3
|
-
from index_manager.index_manager import IndexManager
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
# from src.model.index_manager.index_manager import IndexManager
|
|
7
4
|
|
|
8
5
|
#######################################################
|
|
9
6
|
def setup_module(module):
|
|
@@ -11,7 +8,6 @@ def setup_module(module):
|
|
|
11
8
|
env_file = find_dotenv('.env-prod')
|
|
12
9
|
load_dotenv(dotenv_path=env_file, override=True)
|
|
13
10
|
|
|
14
|
-
|
|
15
11
|
def teardown_module(module):
|
|
16
12
|
print('teardown')
|
|
17
13
|
|
|
@@ -19,7 +15,7 @@ def teardown_module(module):
|
|
|
19
15
|
|
|
20
16
|
def test_get_calibration_information():
|
|
21
17
|
input_bucket_name = 'noaa-wcsd-pds'
|
|
22
|
-
calibration_bucket = 'noaa-wcsd-pds-
|
|
18
|
+
calibration_bucket = 'noaa-wcsd-pds-index'
|
|
23
19
|
calibration_key = 'calibrated_cruises.csv'
|
|
24
20
|
|
|
25
21
|
index_manager = IndexManager(
|
|
@@ -35,21 +31,21 @@ def test_get_calibration_information():
|
|
|
35
31
|
# @mock_s3
|
|
36
32
|
# def test_index_manager(tmp_path):
|
|
37
33
|
# input_bucket_name = 'noaa-wcsd-pds'
|
|
38
|
-
# calibration_bucket = 'noaa-wcsd-pds-
|
|
34
|
+
# calibration_bucket = 'noaa-wcsd-pds-index'
|
|
39
35
|
# calibration_key = 'calibrated_crusies.csv'
|
|
40
36
|
#
|
|
41
|
-
#
|
|
37
|
+
# index = IndexManager(
|
|
42
38
|
# input_bucket_name,
|
|
43
39
|
# calibration_bucket,
|
|
44
40
|
# calibration_key
|
|
45
41
|
# )
|
|
46
42
|
#
|
|
47
|
-
# all_ek60_data =
|
|
43
|
+
# all_ek60_data = index.index()
|
|
48
44
|
# print(all_ek60_data)
|
|
49
45
|
|
|
50
46
|
def test_get_all_cruise_raw_files(tmp_path):
|
|
51
47
|
input_bucket_name = 'noaa-wcsd-pds'
|
|
52
|
-
calibration_bucket = 'noaa-wcsd-pds-
|
|
48
|
+
calibration_bucket = 'noaa-wcsd-pds-index'
|
|
53
49
|
calibration_key = 'calibrated_crusies.csv'
|
|
54
50
|
|
|
55
51
|
index_manager = IndexManager(
|
|
@@ -132,7 +128,7 @@ def test_get_all_cruise_raw_files(tmp_path):
|
|
|
132
128
|
]
|
|
133
129
|
|
|
134
130
|
# TODO: for each verify ek60 datagram
|
|
135
|
-
#
|
|
131
|
+
# index.get_raw_files_csv(
|
|
136
132
|
# ship_name='Henry_B._Bigelow',
|
|
137
133
|
# cruise_name='HB2206',
|
|
138
134
|
# sensor_name='EK60'
|
|
@@ -156,12 +152,12 @@ def test_get_all_cruise_raw_files(tmp_path):
|
|
|
156
152
|
)
|
|
157
153
|
else:
|
|
158
154
|
print(f"{c_n} is not ek60")
|
|
159
|
-
# all_raw_files =
|
|
155
|
+
# all_raw_files = index.get_raw_files(ship_name='Bell_M._Shimada', cruise_name='SH1906', sensor_name='EK60')
|
|
160
156
|
# 'data/raw/Bell_M._Shimada/SH1204/EK60/'
|
|
161
|
-
# all_ek60_data =
|
|
157
|
+
# all_ek60_data = index.index()
|
|
162
158
|
# print(all_ek60_data)
|
|
163
159
|
|
|
164
160
|
#######################################################
|
|
165
161
|
|
|
166
162
|
# TODO: for post analysis of coverage
|
|
167
|
-
# need to check each cruise has same number of files in noaa-wcsd-pds and noaa-wcsd-
|
|
163
|
+
# need to check each cruise has same number of files in noaa-wcsd-pds and noaa-wcsd-model-pds buckets
|
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import json
|
|
3
|
-
# import pytest
|
|
4
|
-
# import unittest
|
|
5
3
|
import numpy as np
|
|
6
4
|
from dotenv import load_dotenv, find_dotenv
|
|
7
5
|
from moto import mock_aws
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
from water_column_sonar_processing.aws.s3_manager import S3Manager
|
|
7
|
+
from water_column_sonar_processing.aws.sns_manager import SNSManager
|
|
8
|
+
from water_column_sonar_processing.aws.sqs_manager import SQSManager
|
|
9
|
+
from water_column_sonar_processing.aws.dynamodb_manager import DynamoDBManager
|
|
10
|
+
from water_column_sonar_processing.process import Process
|
|
13
11
|
|
|
14
|
-
from aws_manager.s3_manager import S3Manager
|
|
15
|
-
from aws_manager.sns_manager import SNSManager
|
|
16
|
-
from aws_manager.sqs_manager import SQSManager
|
|
17
|
-
from aws_manager.dynamodb_manager import DynamoDBManager
|
|
18
|
-
from model import Model
|
|
19
12
|
|
|
20
13
|
#######################################################
|
|
21
14
|
def setup_module():
|
|
@@ -27,7 +20,6 @@ def setup_module():
|
|
|
27
20
|
def teardown_module():
|
|
28
21
|
print('teardown')
|
|
29
22
|
|
|
30
|
-
|
|
31
23
|
#######################################################
|
|
32
24
|
@mock_aws
|
|
33
25
|
def test_model_happy_path():
|
|
@@ -116,7 +108,7 @@ def test_model_happy_path():
|
|
|
116
108
|
':sh': {'S': 'David_Starr_Jordan'},
|
|
117
109
|
':st': {'S': '2006-04-06T03:59:14.115Z'},
|
|
118
110
|
':zb': {'S': 'r2d2-dev-echofish2-118234403147-echofish-dev-output'},
|
|
119
|
-
':zp': {'S': 'level_1/David_Starr_Jordan/DS0604/EK60/DSJ0604-D20060406-T035914.
|
|
111
|
+
':zp': {'S': 'level_1/David_Starr_Jordan/DS0604/EK60/DSJ0604-D20060406-T035914.model'},
|
|
120
112
|
},
|
|
121
113
|
update_expression=(
|
|
122
114
|
'SET '
|
|
@@ -172,7 +164,7 @@ def test_model_happy_path():
|
|
|
172
164
|
':sh': {'S': 'David_Starr_Jordan'},
|
|
173
165
|
':st': {'S': '2006-04-06T13:35:30.701Z'},
|
|
174
166
|
':zb': {'S': 'r2d2-dev-echofish2-118234403147-echofish-dev-output'},
|
|
175
|
-
':zp': {'S': 'level_1/David_Starr_Jordan/DS0604/EK60/DSJ0604-D20060406-T133530.
|
|
167
|
+
':zp': {'S': 'level_1/David_Starr_Jordan/DS0604/EK60/DSJ0604-D20060406-T133530.model'},
|
|
176
168
|
},
|
|
177
169
|
update_expression=(
|
|
178
170
|
'SET '
|
|
@@ -232,7 +224,7 @@ def test_model_happy_path():
|
|
|
232
224
|
':sh': {'S': 'Okeanos_Explorer'},
|
|
233
225
|
':st': {'S': '2014-09-08T17:39:07.660Z'},
|
|
234
226
|
':zb': {'S': 'r2d2-dev-echofish2-118234403147-echofish-dev-output'},
|
|
235
|
-
':zp': {'S': 'level_1/Okeanos_Explorer/EX1404L2/EK60/EX1404L2_EK60_-D20140908-T173907.
|
|
227
|
+
':zp': {'S': 'level_1/Okeanos_Explorer/EX1404L2/EK60/EX1404L2_EK60_-D20140908-T173907.model'},
|
|
236
228
|
},
|
|
237
229
|
update_expression=(
|
|
238
230
|
'SET '
|
|
@@ -297,7 +289,7 @@ def test_model_happy_path():
|
|
|
297
289
|
':sh': {'S': 'Henry_B._Bigelow'},
|
|
298
290
|
':st': {'S': '2007-07-12T06:17:45.579Z'},
|
|
299
291
|
':zb': {'S': 'r2d2-dev-echofish2-118234403147-echofish-dev-output'},
|
|
300
|
-
':zp': {'S': 'level_1/Henry_B._Bigelow/HB0707/EK60/D20070712-T061745.
|
|
292
|
+
':zp': {'S': 'level_1/Henry_B._Bigelow/HB0707/EK60/D20070712-T061745.model'},
|
|
301
293
|
},
|
|
302
294
|
update_expression=(
|
|
303
295
|
'SET '
|
|
@@ -362,7 +354,7 @@ def test_model_happy_path():
|
|
|
362
354
|
':sh': {'S': 'Miller_Freeman'},
|
|
363
355
|
':st': {'S': '2007-07-08T20:04:49.552Z'},
|
|
364
356
|
':zb': {'S': 'r2d2-dev-echofish2-118234403147-echofish-dev-output'},
|
|
365
|
-
':zp': {'S': 'level_1/Miller_Freeman/MF0710/EK60/HAKE2007-D20070708-T200449.
|
|
357
|
+
':zp': {'S': 'level_1/Miller_Freeman/MF0710/EK60/HAKE2007-D20070708-T200449.model'},
|
|
366
358
|
},
|
|
367
359
|
update_expression=(
|
|
368
360
|
'SET '
|
|
@@ -424,7 +416,7 @@ def test_model_happy_path():
|
|
|
424
416
|
###### end setup ######
|
|
425
417
|
|
|
426
418
|
#############################################################
|
|
427
|
-
model_instance =
|
|
419
|
+
model_instance = Process()
|
|
428
420
|
# run the src
|
|
429
421
|
model_instance.execute()
|
|
430
422
|
#############################################################
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
from dotenv import load_dotenv, find_dotenv
|
|
2
2
|
import pytest
|
|
3
3
|
from moto import mock_aws
|
|
4
|
-
from cruise.resample_regrid import ResampleRegrid
|
|
4
|
+
from water_column_sonar_processing.cruise.resample_regrid import ResampleRegrid
|
|
5
5
|
|
|
6
6
|
#######################################################
|
|
7
7
|
def setup_module():
|
|
8
8
|
print('setup')
|
|
9
|
-
|
|
10
|
-
# env_file = find_dotenv('.env-test')
|
|
11
9
|
env_file = find_dotenv('.env-prod') # functional test
|
|
12
|
-
|
|
13
10
|
load_dotenv(dotenv_path=env_file, override=True)
|
|
14
11
|
|
|
15
|
-
|
|
16
12
|
def teardown_module():
|
|
17
13
|
print('teardown')
|
|
18
14
|
|
|
@@ -23,18 +19,18 @@ def teardown_module():
|
|
|
23
19
|
@mock_aws
|
|
24
20
|
@pytest.mark.skip(reason="no way of currently testing this")
|
|
25
21
|
def test_resample_regrid():
|
|
26
|
-
# Opens s3 input
|
|
22
|
+
# Opens s3 input model store as xr and writes data to output model store
|
|
27
23
|
resample_regrid = ResampleRegrid()
|
|
28
24
|
|
|
29
25
|
# HB0706 - 53 files
|
|
30
|
-
# bucket_name = 'noaa-wcsd-
|
|
26
|
+
# bucket_name = 'noaa-wcsd-model-pds'
|
|
31
27
|
ship_name = "Henry_B._Bigelow"
|
|
32
28
|
cruise_name = "HB0706"
|
|
33
29
|
sensor_name = "EK60"
|
|
34
|
-
# file_name = "D20070719-T232718.
|
|
35
|
-
#file_name = "D20070720-T021024.
|
|
36
|
-
#file_name = "D20070720-T224031.
|
|
37
|
-
# "D20070719-T232718.
|
|
30
|
+
# file_name = "D20070719-T232718.model" # first file
|
|
31
|
+
#file_name = "D20070720-T021024.model" # second file
|
|
32
|
+
#file_name = "D20070720-T224031.model" # third file, isn't in dynamodb
|
|
33
|
+
# "D20070719-T232718.model"
|
|
38
34
|
# file_name_stem = Path(file_name).stem # TODO: remove
|
|
39
35
|
table_name = "r2d2-dev-echofish-EchoFish-File-Info"
|
|
40
36
|
|
{water_column_sonar_processing-0.0.4 → water_column_sonar_processing-0.0.5}/tests/test_s3_manager.py
RENAMED
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
import os
|
|
2
|
-
|
|
3
2
|
from moto import mock_aws
|
|
4
3
|
from dotenv import load_dotenv, find_dotenv
|
|
5
|
-
|
|
6
|
-
from aws_manager.s3_manager import S3Manager, chunked
|
|
7
|
-
|
|
8
|
-
# from aws_manager.s3_manager import S3Manager, chunked
|
|
9
|
-
|
|
4
|
+
from water_column_sonar_processing.aws.s3_manager import S3Manager, chunked
|
|
10
5
|
|
|
11
6
|
input_bucket_name = 'example_input_bucket'
|
|
12
7
|
output_bucket_name = 'example_output_bucket'
|
|
13
8
|
|
|
14
|
-
|
|
15
9
|
#######################################################
|
|
16
10
|
def setup_module():
|
|
17
11
|
print('setup')
|
|
@@ -3,12 +3,9 @@ import zarr
|
|
|
3
3
|
import numpy as np
|
|
4
4
|
import xarray as xr
|
|
5
5
|
from dotenv import load_dotenv, find_dotenv
|
|
6
|
-
# import moto
|
|
7
|
-
|
|
8
6
|
from typing import Any # Callable
|
|
9
7
|
from moto import mock_aws
|
|
10
8
|
from unittest.mock import MagicMock
|
|
11
|
-
|
|
12
9
|
import aiobotocore.awsrequest
|
|
13
10
|
import aiobotocore.endpoint
|
|
14
11
|
import aiohttp
|
|
@@ -16,25 +13,8 @@ import aiohttp.client_reqrep
|
|
|
16
13
|
import aiohttp.typedefs
|
|
17
14
|
import botocore.awsrequest
|
|
18
15
|
import botocore.model
|
|
19
|
-
|
|
20
|
-
from
|
|
21
|
-
from aws_manager.s3fs_manager import S3FSManager
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
# import pytest
|
|
25
|
-
|
|
26
|
-
# # ### ATTEMPT TWO #@###
|
|
27
|
-
# from collections.abc import Awaitable, Callable, Iterator
|
|
28
|
-
# from dataclasses import dataclass
|
|
29
|
-
# from typing import TypeVar
|
|
30
|
-
# import aiobotocore
|
|
31
|
-
# import aiobotocore.endpoint
|
|
32
|
-
# import botocore
|
|
33
|
-
# import botocore.retries.standard
|
|
34
|
-
# from aws_manager.s3_manager import S3Manager
|
|
35
|
-
# from aws_manager.s3fs_manager import S3FSManager
|
|
36
|
-
# from aws_manager.s3_manager import S3Manager
|
|
37
|
-
# from aws_manager.s3fs_manager import S3FSManager
|
|
16
|
+
from water_column_sonar_processing.aws.s3_manager import S3Manager
|
|
17
|
+
from water_column_sonar_processing.aws.s3fs_manager import S3FSManager
|
|
38
18
|
|
|
39
19
|
|
|
40
20
|
#######################################################
|
|
@@ -45,11 +25,9 @@ def setup_module():
|
|
|
45
25
|
# https://docs.getmoto.org/en/latest/docs/server_mode.html
|
|
46
26
|
# free_port = 5000
|
|
47
27
|
|
|
48
|
-
|
|
49
28
|
def teardown_module():
|
|
50
29
|
print('teardown')
|
|
51
30
|
|
|
52
|
-
|
|
53
31
|
#####################################################################
|
|
54
32
|
# ### ATTEMPT ONE #@###
|
|
55
33
|
class MockAWSResponse(aiobotocore.awsrequest.AioAWSResponse):
|
|
@@ -254,7 +232,7 @@ def test_add_file(tmp_path):
|
|
|
254
232
|
|
|
255
233
|
# --- Create Local Zarr Store --- #
|
|
256
234
|
temporary_directory = str(tmp_path)
|
|
257
|
-
zarr_path = f'{temporary_directory}/example.
|
|
235
|
+
zarr_path = f'{temporary_directory}/example.model'
|
|
258
236
|
ds = xr.Dataset(
|
|
259
237
|
{
|
|
260
238
|
"a": (("y", "x"), np.random.rand(6).reshape(2, 3)),
|
|
@@ -267,23 +245,23 @@ def test_add_file(tmp_path):
|
|
|
267
245
|
# --- Upload to S3 --- #
|
|
268
246
|
s3fs_manager = S3FSManager()
|
|
269
247
|
# TODO: just copy from a to b
|
|
270
|
-
# foo = s3_manager.upload_files_to_bucket(local_directory=zarr_path, object_prefix='ship/cruise/sensor/example.
|
|
271
|
-
# s3_manager.upload_file(zarr_path + '/.zmetadata', test_bucket_name, 'ship/cruise/sensor/example.
|
|
248
|
+
# foo = s3_manager.upload_files_to_bucket(local_directory=zarr_path, object_prefix='ship/cruise/sensor/example.model', bucket_name=test_bucket_name)
|
|
249
|
+
# s3_manager.upload_file(zarr_path + '/.zmetadata', test_bucket_name, 'ship/cruise/sensor/example.model/.zmetadata')
|
|
272
250
|
|
|
273
251
|
# s3fs_manager.upload_data(
|
|
274
252
|
# bucket_name=test_bucket_name,
|
|
275
253
|
# file_path=zarr_path,
|
|
276
|
-
# file_name='ship/cruise/sensor/example.
|
|
254
|
+
# file_name='ship/cruise/sensor/example.model'
|
|
277
255
|
# )
|
|
278
256
|
|
|
279
|
-
# s3_object = s3_manager.get(bucket_name=test_bucket_name, key="ship/cruise/sensor/example.
|
|
257
|
+
# s3_object = s3_manager.get(bucket_name=test_bucket_name, key="ship/cruise/sensor/example.model/.zmetadata")
|
|
280
258
|
# body = s3_object.get()["Body"].read().decode("utf-8")
|
|
281
259
|
# print(body)
|
|
282
260
|
|
|
283
261
|
### The file is there, trying to copy with boto3, then mount with s3fs.... incompatible version of s3fs
|
|
284
262
|
|
|
285
|
-
# assert s3_manager.folder_exists_and_not_empty(test_bucket_name, "/example.
|
|
286
|
-
# assert s3fs_manager.exists(f"{test_bucket_name}/ship/cruise/sensor/example.
|
|
263
|
+
# assert s3_manager.folder_exists_and_not_empty(test_bucket_name, "/example.model")
|
|
264
|
+
# assert s3fs_manager.exists(f"{test_bucket_name}/ship/cruise/sensor/example.model")
|
|
287
265
|
#
|
|
288
266
|
#
|
|
289
267
|
# TODO: need to upload the file!!
|
|
@@ -296,13 +274,13 @@ def test_add_file(tmp_path):
|
|
|
296
274
|
# TODO: get this working with s3 client
|
|
297
275
|
s3fs_manager.upload_data(bucket_name=test_bucket_name, file_path=zarr_path, prefix="ship/cruise/sensor")
|
|
298
276
|
|
|
299
|
-
found = s3_manager.list_objects(test_bucket_name, 'ship/cruise/sensor/example.
|
|
277
|
+
found = s3_manager.list_objects(test_bucket_name, 'ship/cruise/sensor/example.model')
|
|
300
278
|
print(found)
|
|
301
|
-
s3_object = s3_manager.get(bucket_name=test_bucket_name, key="ship/cruise/sensor/example.
|
|
279
|
+
s3_object = s3_manager.get(bucket_name=test_bucket_name, key="ship/cruise/sensor/example.model/.zgroup")
|
|
302
280
|
body = s3_object.get()["Body"].read().decode("utf-8")
|
|
303
281
|
print(body)
|
|
304
282
|
|
|
305
|
-
s3_store = s3fs_manager.s3_map(s3_zarr_store_path=f"s3://{test_bucket_name}/ship/cruise/sensor/example.
|
|
283
|
+
s3_store = s3fs_manager.s3_map(s3_zarr_store_path=f"s3://{test_bucket_name}/ship/cruise/sensor/example.model")
|
|
306
284
|
|
|
307
285
|
# --- Test S3Map Opening Zarr store with Zarr for Writing --- #
|
|
308
286
|
cruise_zarr = zarr.open(store=s3_store, mode="r+") # , synchronizer=synchronizer) # TODO: test synchronizer
|
|
@@ -2,15 +2,8 @@ import os
|
|
|
2
2
|
import json
|
|
3
3
|
from dotenv import load_dotenv, find_dotenv
|
|
4
4
|
from moto import mock_aws
|
|
5
|
-
from
|
|
6
|
-
from
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
# from aws_manager.sns_manager import SNSManager
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
# from aws_manager.sns_manager import SNSManager
|
|
13
|
-
# from aws_manager.sqs_manager import SQSManager
|
|
5
|
+
from water_column_sonar_processing.aws.sns_manager import SNSManager
|
|
6
|
+
from water_column_sonar_processing.aws.sqs_manager import SQSManager
|
|
14
7
|
|
|
15
8
|
|
|
16
9
|
#######################################################
|
|
@@ -1,44 +1,29 @@
|
|
|
1
|
-
# import os
|
|
2
1
|
import zarr
|
|
3
2
|
import numcodecs
|
|
4
|
-
# import numpy as np
|
|
5
|
-
# import xarray as xr
|
|
6
|
-
# from moto import mock_s3
|
|
7
3
|
from moto import mock_aws
|
|
8
4
|
from dotenv import load_dotenv, find_dotenv
|
|
9
|
-
# import warnings
|
|
10
|
-
|
|
11
|
-
# import gc
|
|
12
5
|
import os
|
|
13
|
-
# import time
|
|
14
|
-
# import boto3
|
|
15
|
-
# import shutil
|
|
16
6
|
import numpy as np
|
|
17
|
-
# import pandas as pd
|
|
18
7
|
import xarray as xr
|
|
19
|
-
|
|
20
|
-
from
|
|
21
|
-
from zarr_manager.zarr_manager import ZarrManager
|
|
8
|
+
from water_column_sonar_processing.aws.s3_manager import S3Manager
|
|
9
|
+
from water_column_sonar_processing.model.zarr_manager import ZarrManager
|
|
22
10
|
|
|
23
11
|
|
|
12
|
+
TEMPDIR = "/tmp"
|
|
24
13
|
#######################################################
|
|
25
|
-
# def setup_module(module):
|
|
26
14
|
def setup_module():
|
|
27
15
|
print('setup')
|
|
28
16
|
env_file = find_dotenv('.env-test')
|
|
29
17
|
load_dotenv(dotenv_path=env_file, override=True)
|
|
30
18
|
|
|
31
|
-
|
|
32
19
|
def teardown_module():
|
|
33
20
|
print('teardown')
|
|
34
21
|
|
|
35
|
-
TEMPDIR = "/tmp"
|
|
36
|
-
|
|
37
22
|
#######################################################
|
|
38
23
|
@mock_aws
|
|
39
24
|
def test_zarr_manager(tmp_path=TEMPDIR):
|
|
40
|
-
# Tests creating
|
|
41
|
-
#
|
|
25
|
+
# Tests creating model store and opening with both xarray and
|
|
26
|
+
# model libraries
|
|
42
27
|
|
|
43
28
|
temporary_directory = str(tmp_path)
|
|
44
29
|
|
|
@@ -66,7 +51,7 @@ def test_zarr_manager(tmp_path=TEMPDIR):
|
|
|
66
51
|
numcodecs.blosc.use_threads = False
|
|
67
52
|
numcodecs.blosc.set_nthreads(1)
|
|
68
53
|
|
|
69
|
-
# synchronizer =
|
|
54
|
+
# synchronizer = model.ProcessSynchronizer(f"/mnt/model/{ship_name}_{cruise_name}.sync")
|
|
70
55
|
|
|
71
56
|
cruise_zarr = zarr.open(store=f"{temporary_directory}/{cruise_name}.zarr", mode="r") # synchronizer=synchronizer)
|
|
72
57
|
print(cruise_zarr.info)
|
|
@@ -79,7 +64,7 @@ def test_zarr_manager(tmp_path=TEMPDIR):
|
|
|
79
64
|
file_xr = xr.open_zarr(store=f"{temporary_directory}/{cruise_name}.zarr", consolidated=None) # synchronizer=SYNCHRONIZER)
|
|
80
65
|
print(file_xr)
|
|
81
66
|
|
|
82
|
-
# for newly initialized
|
|
67
|
+
# for newly initialized model store all the timestamps will be 0 epoch time
|
|
83
68
|
assert file_xr.time.values[0] == np.datetime64('1970-01-01T00:00:00.000000000')
|
|
84
69
|
assert str(file_xr.time.values[0].dtype) == 'datetime64[ns]'
|
|
85
70
|
|
|
@@ -110,14 +95,14 @@ def test_zarr_manager(tmp_path=TEMPDIR):
|
|
|
110
95
|
def test_open_zarr_with_zarr_read_write(tmp_path):
|
|
111
96
|
temporary_directory = str(tmp_path)
|
|
112
97
|
|
|
113
|
-
# TODO: open with
|
|
98
|
+
# TODO: open with model python library and check format
|
|
114
99
|
test_bucket_name = os.environ.get("OUTPUT_BUCKET_NAME")
|
|
115
100
|
|
|
116
101
|
# create a bucket
|
|
117
102
|
s3_manager = S3Manager()
|
|
118
103
|
s3_manager.create_bucket(bucket_name=test_bucket_name)
|
|
119
104
|
|
|
120
|
-
# initialize
|
|
105
|
+
# initialize model store
|
|
121
106
|
ship_name = "test_ship"
|
|
122
107
|
cruise_name = "test_cruise"
|
|
123
108
|
sensor_name = "test_sensor"
|
|
@@ -138,7 +123,7 @@ def test_open_zarr_with_zarr_read_write(tmp_path):
|
|
|
138
123
|
|
|
139
124
|
# TODO: copy store to bucket
|
|
140
125
|
|
|
141
|
-
# TODO: open
|
|
126
|
+
# TODO: open model store with model
|
|
142
127
|
pass
|
|
143
128
|
|
|
144
129
|
|
|
@@ -149,7 +134,7 @@ def test_open_zarr_with_xarray(tmp_path):
|
|
|
149
134
|
# [1] check timestamps are in proper format
|
|
150
135
|
# [2] check that lat/lons are formatted (need data)
|
|
151
136
|
# [3] check
|
|
152
|
-
# TODO: open with
|
|
137
|
+
# TODO: open with model python library and check format
|
|
153
138
|
ship_name = "Okeanos_Explorer"
|
|
154
139
|
cruise_name = "EX1404L2"
|
|
155
140
|
sensor_name = "EK60"
|
|
@@ -163,8 +148,8 @@ def test_open_zarr_with_xarray(tmp_path):
|
|
|
163
148
|
s3_manager = S3Manager()
|
|
164
149
|
s3_manager.create_bucket(bucket_name=bucket_name)
|
|
165
150
|
|
|
166
|
-
# initialize
|
|
167
|
-
# zarr_name = f"{cruise_name}.
|
|
151
|
+
# initialize model store
|
|
152
|
+
# zarr_name = f"{cruise_name}.model"
|
|
168
153
|
min_echo_range = 0.50
|
|
169
154
|
max_echo_range = 250.0
|
|
170
155
|
|
|
@@ -189,13 +174,13 @@ def test_open_zarr_with_xarray(tmp_path):
|
|
|
189
174
|
)
|
|
190
175
|
|
|
191
176
|
# copy store to bucket
|
|
192
|
-
# TODO: create function to get list of files in
|
|
177
|
+
# TODO: create function to get list of files in model store
|
|
193
178
|
# s3_manager.upload_files_to_bucket(
|
|
194
179
|
# local_path, # TODO: change to path
|
|
195
180
|
# s3_path
|
|
196
181
|
# )
|
|
197
182
|
|
|
198
|
-
# open
|
|
183
|
+
# open model store with model
|
|
199
184
|
|
|
200
185
|
#assert root.Sv.shape == (501, 1201, 4)
|
|
201
186
|
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
LICENSE
|
|
2
|
-
README.md
|
|
3
|
-
pyproject.toml
|
|
4
|
-
src/__init__.py
|
|
5
|
-
src/model.py
|
|
6
|
-
src/aws_manager/__init__.py
|
|
7
|
-
src/aws_manager/dynamodb_manager.py
|
|
8
|
-
src/aws_manager/s3_manager.py
|
|
9
|
-
src/aws_manager/s3fs_manager.py
|
|
10
|
-
src/aws_manager/sns_manager.py
|
|
11
|
-
src/aws_manager/sqs_manager.py
|
|
12
|
-
src/cruise/__init__.py
|
|
13
|
-
src/cruise/create_empty_zarr_store.py
|
|
14
|
-
src/cruise/resample_regrid.py
|
|
15
|
-
src/geometry_manager/__init__.py
|
|
16
|
-
src/geometry_manager/geometry_manager.py
|
|
17
|
-
src/geometry_manager/geometry_simplification.py
|
|
18
|
-
src/geometry_manager/pmtile_generation.py
|
|
19
|
-
src/index_manager/__init__.py
|
|
20
|
-
src/index_manager/index_manager.py
|
|
21
|
-
src/utility/__init__.py
|
|
22
|
-
src/utility/cleaner.py
|
|
23
|
-
src/utility/constants.py
|
|
24
|
-
src/utility/pipeline_status.py
|
|
25
|
-
src/utility/timestamp.py
|
|
26
|
-
src/water_column_sonar_processing.egg-info/PKG-INFO
|
|
27
|
-
src/water_column_sonar_processing.egg-info/SOURCES.txt
|
|
28
|
-
src/water_column_sonar_processing.egg-info/dependency_links.txt
|
|
29
|
-
src/water_column_sonar_processing.egg-info/top_level.txt
|
|
30
|
-
src/zarr_manager/__init__.py
|
|
31
|
-
src/zarr_manager/zarr_manager.py
|
|
32
|
-
tests/test_create_empty_zarr_store.py
|
|
33
|
-
tests/test_dynamodb_manager.py
|
|
34
|
-
tests/test_geometry_manager.py
|
|
35
|
-
tests/test_geometry_simplification.py
|
|
36
|
-
tests/test_index.py
|
|
37
|
-
tests/test_model.py
|
|
38
|
-
tests/test_resample_regrid.py
|
|
39
|
-
tests/test_s3_manager.py
|
|
40
|
-
tests/test_s3fs_manager.py
|
|
41
|
-
tests/test_sns_sqs_manager.py
|
|
42
|
-
tests/test_zarr_manager.py
|
|
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
|