water-column-sonar-processing 0.0.4__py3-none-any.whl → 0.0.6__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.
- water_column_sonar_processing/__init__.py +16 -0
- water_column_sonar_processing/aws/__init__.py +7 -0
- {aws_manager → water_column_sonar_processing/aws}/dynamodb_manager.py +71 -50
- {aws_manager → water_column_sonar_processing/aws}/s3_manager.py +120 -130
- {aws_manager → water_column_sonar_processing/aws}/s3fs_manager.py +13 -19
- {aws_manager → water_column_sonar_processing/aws}/sns_manager.py +10 -21
- {aws_manager → water_column_sonar_processing/aws}/sqs_manager.py +10 -18
- water_column_sonar_processing/cruise/__init__.py +4 -0
- {cruise → water_column_sonar_processing/cruise}/create_empty_zarr_store.py +62 -44
- {cruise → water_column_sonar_processing/cruise}/resample_regrid.py +117 -66
- water_column_sonar_processing/geometry/__init__.py +5 -0
- {geometry_manager → water_column_sonar_processing/geometry}/geometry_manager.py +80 -49
- {geometry_manager → water_column_sonar_processing/geometry}/geometry_simplification.py +13 -12
- {geometry_manager → water_column_sonar_processing/geometry}/pmtile_generation.py +25 -24
- water_column_sonar_processing/index/__init__.py +3 -0
- {index_manager → water_column_sonar_processing/index}/index_manager.py +106 -82
- water_column_sonar_processing/model/__init__.py +3 -0
- {zarr_manager → water_column_sonar_processing/model}/zarr_manager.py +119 -83
- water_column_sonar_processing/process.py +147 -0
- water_column_sonar_processing/utility/__init__.py +6 -0
- {utility → water_column_sonar_processing/utility}/cleaner.py +6 -7
- water_column_sonar_processing/utility/constants.py +63 -0
- {utility → water_column_sonar_processing/utility}/pipeline_status.py +37 -10
- {utility → water_column_sonar_processing/utility}/timestamp.py +3 -2
- {water_column_sonar_processing-0.0.4.dist-info → water_column_sonar_processing-0.0.6.dist-info}/METADATA +31 -1
- water_column_sonar_processing-0.0.6.dist-info/RECORD +29 -0
- water_column_sonar_processing-0.0.6.dist-info/top_level.txt +1 -0
- __init__.py +0 -0
- aws_manager/__init__.py +0 -4
- cruise/__init__.py +0 -0
- geometry_manager/__init__.py +0 -0
- index_manager/__init__.py +0 -0
- model.py +0 -140
- utility/__init__.py +0 -0
- utility/constants.py +0 -56
- water_column_sonar_processing-0.0.4.dist-info/RECORD +0 -29
- water_column_sonar_processing-0.0.4.dist-info/top_level.txt +0 -8
- zarr_manager/__init__.py +0 -0
- {water_column_sonar_processing-0.0.4.dist-info → water_column_sonar_processing-0.0.6.dist-info}/LICENSE +0 -0
- {water_column_sonar_processing-0.0.4.dist-info → water_column_sonar_processing-0.0.6.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from __future__ import absolute_import
|
|
2
|
+
|
|
3
|
+
from . import aws, cruise, geometry, index, model, utility, process
|
|
4
|
+
from .model import ZarrManager
|
|
5
|
+
from .process import Process
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
"aws",
|
|
9
|
+
"cruise",
|
|
10
|
+
"geometry",
|
|
11
|
+
"index",
|
|
12
|
+
"model",
|
|
13
|
+
"utility",
|
|
14
|
+
"process",
|
|
15
|
+
"Process",
|
|
16
|
+
]
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
from .dynamodb_manager import DynamoDBManager
|
|
2
|
+
from .s3_manager import S3Manager
|
|
3
|
+
from .s3fs_manager import S3FSManager
|
|
4
|
+
from .sns_manager import SNSManager
|
|
5
|
+
from .sqs_manager import SQSManager
|
|
6
|
+
|
|
7
|
+
__all__ = ["DynamoDBManager", "S3Manager", "S3FSManager", "SNSManager", "SQSManager"]
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import os
|
|
2
|
+
|
|
2
3
|
import boto3
|
|
3
4
|
import pandas as pd
|
|
4
|
-
from boto3.dynamodb.types import
|
|
5
|
+
from boto3.dynamodb.types import TypeDeserializer, TypeSerializer
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
#########################################################################
|
|
@@ -9,9 +10,9 @@ class DynamoDBManager:
|
|
|
9
10
|
#####################################################################
|
|
10
11
|
def __init__(self):
|
|
11
12
|
self.__dynamodb_session = boto3.Session(
|
|
12
|
-
aws_access_key_id=os.environ.get(
|
|
13
|
-
aws_secret_access_key=os.environ.get(
|
|
14
|
-
region_name=os.environ.get("AWS_REGION", default="us-east-1")
|
|
13
|
+
aws_access_key_id=os.environ.get("ACCESS_KEY_ID"),
|
|
14
|
+
aws_secret_access_key=os.environ.get("SECRET_ACCESS_KEY"),
|
|
15
|
+
region_name=os.environ.get("AWS_REGION", default="us-east-1"),
|
|
15
16
|
)
|
|
16
17
|
self.__dynamodb_resource = self.__dynamodb_session.resource(
|
|
17
18
|
service_name="dynamodb",
|
|
@@ -23,7 +24,7 @@ class DynamoDBManager:
|
|
|
23
24
|
self.type_deserializer = TypeDeserializer()
|
|
24
25
|
|
|
25
26
|
#####################################################################
|
|
26
|
-
### defined in raw-to-
|
|
27
|
+
### defined in raw-to-model, not used
|
|
27
28
|
# def put_item(
|
|
28
29
|
# self,
|
|
29
30
|
# table_name,
|
|
@@ -35,10 +36,10 @@ class DynamoDBManager:
|
|
|
35
36
|
|
|
36
37
|
#####################################################################
|
|
37
38
|
def create_table(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
self,
|
|
40
|
+
table_name,
|
|
41
|
+
key_schema,
|
|
42
|
+
attribute_definitions,
|
|
42
43
|
):
|
|
43
44
|
self.__dynamodb_client.create_table(
|
|
44
45
|
AttributeDefinitions=attribute_definitions,
|
|
@@ -52,98 +53,118 @@ class DynamoDBManager:
|
|
|
52
53
|
)
|
|
53
54
|
|
|
54
55
|
#####################################################################
|
|
55
|
-
def
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
key
|
|
56
|
+
def create_water_column_sonar_table(
|
|
57
|
+
self,
|
|
58
|
+
table_name,
|
|
59
59
|
):
|
|
60
|
+
self.create_table(
|
|
61
|
+
table_name=table_name,
|
|
62
|
+
key_schema=[
|
|
63
|
+
{
|
|
64
|
+
"AttributeName": "FILE_NAME",
|
|
65
|
+
"KeyType": "HASH",
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"AttributeName": "CRUISE_NAME",
|
|
69
|
+
"KeyType": "RANGE",
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
attribute_definitions=[
|
|
73
|
+
{"AttributeName": "FILE_NAME", "AttributeType": "S"},
|
|
74
|
+
{"AttributeName": "CRUISE_NAME", "AttributeType": "S"},
|
|
75
|
+
],
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
#####################################################################
|
|
79
|
+
def get_item(self, table_name, key):
|
|
60
80
|
response = self.__dynamodb_client.get_item(TableName=table_name, Key=key)
|
|
61
81
|
item = None
|
|
62
|
-
if response[
|
|
63
|
-
if
|
|
64
|
-
item = response[
|
|
82
|
+
if response["ResponseMetadata"]["HTTPStatusCode"] == 200:
|
|
83
|
+
if "Item" in response:
|
|
84
|
+
item = response["Item"]
|
|
65
85
|
return item
|
|
66
86
|
|
|
67
87
|
#####################################################################
|
|
68
88
|
def update_item(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
89
|
+
self,
|
|
90
|
+
table_name,
|
|
91
|
+
key,
|
|
92
|
+
expression_attribute_names,
|
|
93
|
+
expression_attribute_values,
|
|
94
|
+
update_expression,
|
|
75
95
|
):
|
|
76
96
|
response = self.__dynamodb_client.update_item(
|
|
77
97
|
TableName=table_name,
|
|
78
98
|
Key=key,
|
|
79
99
|
ExpressionAttributeNames=expression_attribute_names,
|
|
80
100
|
ExpressionAttributeValues=expression_attribute_values,
|
|
81
|
-
UpdateExpression=update_expression
|
|
101
|
+
UpdateExpression=update_expression,
|
|
82
102
|
)
|
|
83
|
-
status_code = response[
|
|
103
|
+
status_code = response["ResponseMetadata"]["HTTPStatusCode"]
|
|
84
104
|
# TODO: change to exception
|
|
85
|
-
assert
|
|
105
|
+
assert status_code == 200, "Problem, unable to update dynamodb table."
|
|
86
106
|
|
|
87
107
|
#####################################################################
|
|
88
108
|
def get_table_as_df(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
109
|
+
self,
|
|
110
|
+
ship_name,
|
|
111
|
+
cruise_name,
|
|
112
|
+
sensor_name,
|
|
113
|
+
table_name,
|
|
94
114
|
):
|
|
95
115
|
expression_attribute_values = {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
116
|
+
":cr": {"S": cruise_name},
|
|
117
|
+
":se": {"S": sensor_name},
|
|
118
|
+
":sh": {"S": ship_name},
|
|
99
119
|
}
|
|
100
120
|
|
|
101
|
-
filter_expression =
|
|
121
|
+
filter_expression = (
|
|
122
|
+
"CRUISE_NAME = :cr and SENSOR_NAME = :se and SHIP_NAME = :sh"
|
|
123
|
+
)
|
|
102
124
|
response = self.__dynamodb_client.scan(
|
|
103
125
|
TableName=table_name,
|
|
104
|
-
Select=
|
|
126
|
+
Select="ALL_ATTRIBUTES",
|
|
105
127
|
ExpressionAttributeValues=expression_attribute_values,
|
|
106
128
|
FilterExpression=filter_expression,
|
|
107
129
|
)
|
|
108
130
|
# Note: table.scan() has 1 MB limit on results so pagination is used
|
|
109
|
-
data = response[
|
|
131
|
+
data = response["Items"]
|
|
110
132
|
|
|
111
|
-
while
|
|
133
|
+
while "LastEvaluatedKey" in response:
|
|
112
134
|
response = self.__dynamodb_client.scan(
|
|
113
135
|
TableName=table_name,
|
|
114
|
-
Select=
|
|
136
|
+
Select="ALL_ATTRIBUTES",
|
|
115
137
|
ExpressionAttributeValues=expression_attribute_values,
|
|
116
138
|
FilterExpression=filter_expression,
|
|
117
|
-
ExclusiveStartKey=response[
|
|
139
|
+
ExclusiveStartKey=response["LastEvaluatedKey"],
|
|
118
140
|
)
|
|
119
|
-
data.extend(response[
|
|
141
|
+
data.extend(response["Items"])
|
|
120
142
|
|
|
121
143
|
deserializer = self.type_deserializer
|
|
122
144
|
df = pd.DataFrame([deserializer.deserialize({"M": i}) for i in data])
|
|
123
145
|
|
|
124
|
-
return df.sort_values(by=
|
|
146
|
+
return df.sort_values(by="START_TIME", ignore_index=True)
|
|
125
147
|
|
|
126
148
|
#####################################################################
|
|
127
149
|
# is this used?
|
|
128
150
|
def get_table_item(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
151
|
+
self,
|
|
152
|
+
table_name,
|
|
153
|
+
key,
|
|
132
154
|
):
|
|
133
155
|
# a bit more high level, uses resource to get table item
|
|
134
156
|
table = self.__dynamodb_resource.Table(table_name)
|
|
135
|
-
response = table.get_item(
|
|
136
|
-
Key=key
|
|
137
|
-
)
|
|
157
|
+
response = table.get_item(Key=key)
|
|
138
158
|
return response
|
|
139
159
|
|
|
140
160
|
#####################################################################
|
|
141
161
|
# TODO: add helper method to delete the data
|
|
142
162
|
def delete_cruise(
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
163
|
+
self,
|
|
164
|
+
table_name,
|
|
165
|
+
cruise_name,
|
|
146
166
|
):
|
|
147
167
|
pass
|
|
148
168
|
|
|
169
|
+
|
|
149
170
|
#########################################################################
|