water-column-sonar-processing 0.0.1__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.

Files changed (36) hide show
  1. water_column_sonar_processing-0.0.1/LICENSE +21 -0
  2. water_column_sonar_processing-0.0.1/PKG-INFO +89 -0
  3. water_column_sonar_processing-0.0.1/README.md +75 -0
  4. water_column_sonar_processing-0.0.1/pyproject.toml +22 -0
  5. water_column_sonar_processing-0.0.1/setup.cfg +4 -0
  6. water_column_sonar_processing-0.0.1/src/__init__.py +0 -0
  7. water_column_sonar_processing-0.0.1/src/model/__init__.py +0 -0
  8. water_column_sonar_processing-0.0.1/src/model/aws/__init__.py +0 -0
  9. water_column_sonar_processing-0.0.1/src/model/aws/dynamodb_manager.py +149 -0
  10. water_column_sonar_processing-0.0.1/src/model/aws/s3_manager.py +356 -0
  11. water_column_sonar_processing-0.0.1/src/model/aws/s3fs_manager.py +74 -0
  12. water_column_sonar_processing-0.0.1/src/model/aws/sns_manager.py +67 -0
  13. water_column_sonar_processing-0.0.1/src/model/aws/sqs_manager.py +50 -0
  14. water_column_sonar_processing-0.0.1/src/model/cruise/__init__.py +0 -0
  15. water_column_sonar_processing-0.0.1/src/model/cruise/create_empty_zarr_store.py +166 -0
  16. water_column_sonar_processing-0.0.1/src/model/cruise/resample_regrid.py +248 -0
  17. water_column_sonar_processing-0.0.1/src/model/geospatial/__init__.py +0 -0
  18. water_column_sonar_processing-0.0.1/src/model/geospatial/geometry_manager.py +194 -0
  19. water_column_sonar_processing-0.0.1/src/model/geospatial/geometry_simplification.py +81 -0
  20. water_column_sonar_processing-0.0.1/src/model/geospatial/pmtile_generation.py +74 -0
  21. water_column_sonar_processing-0.0.1/src/model/index/__init__.py +0 -0
  22. water_column_sonar_processing-0.0.1/src/model/index/index.py +228 -0
  23. water_column_sonar_processing-0.0.1/src/model/model.py +138 -0
  24. water_column_sonar_processing-0.0.1/src/model/utility/__init__.py +0 -0
  25. water_column_sonar_processing-0.0.1/src/model/utility/cleaner.py +21 -0
  26. water_column_sonar_processing-0.0.1/src/model/utility/constants.py +56 -0
  27. water_column_sonar_processing-0.0.1/src/model/utility/pipeline_status.py +98 -0
  28. water_column_sonar_processing-0.0.1/src/model/utility/timestamp.py +12 -0
  29. water_column_sonar_processing-0.0.1/src/model/zarr/__init__.py +0 -0
  30. water_column_sonar_processing-0.0.1/src/model/zarr/bar.py +28 -0
  31. water_column_sonar_processing-0.0.1/src/model/zarr/foo.py +11 -0
  32. water_column_sonar_processing-0.0.1/src/model/zarr/zarr_manager.py +298 -0
  33. water_column_sonar_processing-0.0.1/src/water_column_sonar_processing.egg-info/PKG-INFO +89 -0
  34. water_column_sonar_processing-0.0.1/src/water_column_sonar_processing.egg-info/SOURCES.txt +34 -0
  35. water_column_sonar_processing-0.0.1/src/water_column_sonar_processing.egg-info/dependency_links.txt +1 -0
  36. water_column_sonar_processing-0.0.1/src/water_column_sonar_processing.egg-info/top_level.txt +2 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Cooperative Institutes, Coastal and Marine Geophysics
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,89 @@
1
+ Metadata-Version: 2.1
2
+ Name: water-column-sonar-processing
3
+ Version: 0.0.1
4
+ Summary: A processing tool for water column sonar data.
5
+ Author-email: Rudy Klucik <rudy.klucik@noaa.gov>
6
+ Project-URL: Homepage, https://github.com/CI-CMG/water-column-sonar-processing
7
+ Project-URL: Issues, https://github.com/CI-CMG/water-column-sonar-processing/issues
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+
15
+ # water-column-sonar-processing
16
+ Processing tool for converting L0 data to L1 and L2 as well as generating geospatial information
17
+
18
+ ## Setting up the Python Environment
19
+ > Python 3.10.12
20
+
21
+ # MacOS Pyenv Installation Instructions
22
+ 1. Install pyenv (https://github.com/pyenv/pyenv#set-up-your-shell-environment-for-pyenv)
23
+ 1. ```brew update```
24
+ 2. ```arch -arm64 brew install pyenv```
25
+ 3. In ~/.bashrc add
26
+ 1. ```export PYENV_ROOT="$HOME/.pyenv"```
27
+ 2. ```export PATH="$PYENV_ROOT/bin:$PATH"```
28
+ 3. ```eval "$(pyenv init -)"```
29
+ 4. ```arch -arm64 brew install openssl readline sqlite3 xz zlib tcl-tk```
30
+ 2. Install pyenv-virtualenv (https://github.com/pyenv/pyenv-virtualenv)
31
+ 1. ```arch -arm64 brew install pyenv-virtualenv```
32
+ 2. In ~/.bashrc add
33
+ 1. ```eval "$(pyenv virtualenv-init -)"```
34
+ 3. Open a new terminal
35
+ 4. Install Python version
36
+ 1. ```env PYTHON_CONFIGURE_OPTS="--enable-shared"```
37
+ 2. ```env CONFIGURE_OPTS='--enable-optimizations' arch -arm64 pyenv install 3.10.12```
38
+ 5. Create virtual env (to delete 'pyenv uninstall 3.10.12/water-column-sonar-processing')
39
+ 1. ```pyenv virtualenv 3.10.12 water-column-sonar-processing```
40
+ 6. Set local version of python (if not done already)
41
+ 1. change directory to root of project
42
+ 2. ```pyenv local 3.10.12 water-column-sonar-processing```
43
+ 3. ```pyenv activate water-column-sonar-processing```
44
+
45
+ ## Setting up IntelliJ
46
+
47
+ 1. Install the IntelliJ Python plugin
48
+ 2. Set up pyenv
49
+ 1. File -> Project Structure or CMD + ;
50
+ 2. SDKs -> + -> Add Python SDK -> Virtual Environment
51
+ 3. Select Existing Environment
52
+ 4. Choose ~/.pyenv/versions/mocking_aws/bin/python
53
+ 3. Set up Python Facet (not sure if this is required)
54
+ 1. File -> Project Structure or CMD + ;
55
+ 2. Facets -> + -> Python
56
+ 3. Set interpreter
57
+
58
+ ## Installing Dependencies
59
+
60
+ 1. Add dependencies with versions to requirements.txt
61
+ 2. ```pip install --upgrade pip && pip install -r requirements_dev.txt```
62
+
63
+
64
+ ## Pytest
65
+ ```commandline
66
+ pytest --disable-warnings
67
+ ```
68
+
69
+ ## Instructions
70
+ Following this tutorial:
71
+ https://packaging.python.org/en/latest/tutorials/packaging-projects/
72
+
73
+ ## To Publish To TEST
74
+ ```commandline
75
+ python -m build
76
+ python -m twine upload --repository testpypi dist/*
77
+ pytho -m pip install --index-url https://test.pypi.org/simple/ hello-pypi-rudy-klucik
78
+ python
79
+ ```
80
+ ```python
81
+ from water-column-sonar-processing import ZarrManager
82
+ example.add_one(2)
83
+ ```
84
+
85
+ ## To Publish To PROD
86
+ ```commandline
87
+ python -m build
88
+ python -m twine upload --repository pypi dist/*
89
+ ```
@@ -0,0 +1,75 @@
1
+ # water-column-sonar-processing
2
+ Processing tool for converting L0 data to L1 and L2 as well as generating geospatial information
3
+
4
+ ## Setting up the Python Environment
5
+ > Python 3.10.12
6
+
7
+ # MacOS Pyenv Installation Instructions
8
+ 1. Install pyenv (https://github.com/pyenv/pyenv#set-up-your-shell-environment-for-pyenv)
9
+ 1. ```brew update```
10
+ 2. ```arch -arm64 brew install pyenv```
11
+ 3. In ~/.bashrc add
12
+ 1. ```export PYENV_ROOT="$HOME/.pyenv"```
13
+ 2. ```export PATH="$PYENV_ROOT/bin:$PATH"```
14
+ 3. ```eval "$(pyenv init -)"```
15
+ 4. ```arch -arm64 brew install openssl readline sqlite3 xz zlib tcl-tk```
16
+ 2. Install pyenv-virtualenv (https://github.com/pyenv/pyenv-virtualenv)
17
+ 1. ```arch -arm64 brew install pyenv-virtualenv```
18
+ 2. In ~/.bashrc add
19
+ 1. ```eval "$(pyenv virtualenv-init -)"```
20
+ 3. Open a new terminal
21
+ 4. Install Python version
22
+ 1. ```env PYTHON_CONFIGURE_OPTS="--enable-shared"```
23
+ 2. ```env CONFIGURE_OPTS='--enable-optimizations' arch -arm64 pyenv install 3.10.12```
24
+ 5. Create virtual env (to delete 'pyenv uninstall 3.10.12/water-column-sonar-processing')
25
+ 1. ```pyenv virtualenv 3.10.12 water-column-sonar-processing```
26
+ 6. Set local version of python (if not done already)
27
+ 1. change directory to root of project
28
+ 2. ```pyenv local 3.10.12 water-column-sonar-processing```
29
+ 3. ```pyenv activate water-column-sonar-processing```
30
+
31
+ ## Setting up IntelliJ
32
+
33
+ 1. Install the IntelliJ Python plugin
34
+ 2. Set up pyenv
35
+ 1. File -> Project Structure or CMD + ;
36
+ 2. SDKs -> + -> Add Python SDK -> Virtual Environment
37
+ 3. Select Existing Environment
38
+ 4. Choose ~/.pyenv/versions/mocking_aws/bin/python
39
+ 3. Set up Python Facet (not sure if this is required)
40
+ 1. File -> Project Structure or CMD + ;
41
+ 2. Facets -> + -> Python
42
+ 3. Set interpreter
43
+
44
+ ## Installing Dependencies
45
+
46
+ 1. Add dependencies with versions to requirements.txt
47
+ 2. ```pip install --upgrade pip && pip install -r requirements_dev.txt```
48
+
49
+
50
+ ## Pytest
51
+ ```commandline
52
+ pytest --disable-warnings
53
+ ```
54
+
55
+ ## Instructions
56
+ Following this tutorial:
57
+ https://packaging.python.org/en/latest/tutorials/packaging-projects/
58
+
59
+ ## To Publish To TEST
60
+ ```commandline
61
+ python -m build
62
+ python -m twine upload --repository testpypi dist/*
63
+ pytho -m pip install --index-url https://test.pypi.org/simple/ hello-pypi-rudy-klucik
64
+ python
65
+ ```
66
+ ```python
67
+ from water-column-sonar-processing import ZarrManager
68
+ example.add_one(2)
69
+ ```
70
+
71
+ ## To Publish To PROD
72
+ ```commandline
73
+ python -m build
74
+ python -m twine upload --repository pypi dist/*
75
+ ```
@@ -0,0 +1,22 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "water-column-sonar-processing"
7
+ version = "0.0.1"
8
+ authors = [
9
+ { name="Rudy Klucik", email="rudy.klucik@noaa.gov" },
10
+ ]
11
+ description = "A processing tool for water column sonar data."
12
+ readme = "README.md"
13
+ requires-python = ">=3.10"
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Operating System :: OS Independent",
18
+ ]
19
+
20
+ [project.urls]
21
+ Homepage = "https://github.com/CI-CMG/water-column-sonar-processing"
22
+ Issues = "https://github.com/CI-CMG/water-column-sonar-processing/issues"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
File without changes
@@ -0,0 +1,149 @@
1
+ import os
2
+ import boto3
3
+ import pandas as pd
4
+ from boto3.dynamodb.types import TypeSerializer, TypeDeserializer
5
+
6
+
7
+ #########################################################################
8
+ class DynamoDBManager:
9
+ #####################################################################
10
+ def __init__(self):
11
+ self.__dynamodb_session = boto3.Session(
12
+ aws_access_key_id=os.environ.get('ACCESS_KEY_ID'),
13
+ aws_secret_access_key=os.environ.get('SECRET_ACCESS_KEY'),
14
+ region_name=os.environ.get("AWS_REGION", default="us-east-1")
15
+ )
16
+ self.__dynamodb_resource = self.__dynamodb_session.resource(
17
+ service_name="dynamodb",
18
+ )
19
+ self.__dynamodb_client = self.__dynamodb_session.client(
20
+ service_name="dynamodb",
21
+ )
22
+ self.type_serializer = TypeSerializer() # https://stackoverflow.com/a/46738251
23
+ self.type_deserializer = TypeDeserializer()
24
+
25
+ #####################################################################
26
+ ### defined in raw-to-zarr, not used
27
+ # def put_item(
28
+ # self,
29
+ # table_name,
30
+ # item
31
+ # ):
32
+ # response = boto3.Session().client(service_name='dynamodb').put_item(TableName=table_name, Item=item)
33
+ # status_code = response['ResponseMetadata']['HTTPStatusCode']
34
+ # assert (status_code == 200), "Problem, unable to update dynamodb table."
35
+
36
+ #####################################################################
37
+ def create_table(
38
+ self,
39
+ table_name,
40
+ key_schema,
41
+ attribute_definitions,
42
+ ):
43
+ self.__dynamodb_client.create_table(
44
+ AttributeDefinitions=attribute_definitions,
45
+ TableName=table_name,
46
+ KeySchema=key_schema,
47
+ BillingMode="PAY_PER_REQUEST", # "PROVISIONED",
48
+ # ProvisionedThroughput={
49
+ # 'ReadCapacityUnits': 1_000,
50
+ # 'WriteCapacityUnits': 1_000
51
+ # }
52
+ )
53
+
54
+ #####################################################################
55
+ def get_item(
56
+ self,
57
+ table_name,
58
+ key
59
+ ):
60
+ response = self.__dynamodb_client.get_item(TableName=table_name, Key=key)
61
+ item = None
62
+ if response['ResponseMetadata']['HTTPStatusCode'] == 200:
63
+ if 'Item' in response:
64
+ item = response['Item']
65
+ return item
66
+
67
+ #####################################################################
68
+ def update_item(
69
+ self,
70
+ table_name,
71
+ key,
72
+ expression_attribute_names,
73
+ expression_attribute_values,
74
+ update_expression
75
+ ):
76
+ response = self.__dynamodb_client.update_item(
77
+ TableName=table_name,
78
+ Key=key,
79
+ ExpressionAttributeNames=expression_attribute_names,
80
+ ExpressionAttributeValues=expression_attribute_values,
81
+ UpdateExpression=update_expression
82
+ )
83
+ status_code = response['ResponseMetadata']['HTTPStatusCode']
84
+ # TODO: change to exception
85
+ assert (status_code == 200), "Problem, unable to update dynamodb table."
86
+
87
+ #####################################################################
88
+ def get_table_as_df(
89
+ self,
90
+ ship_name,
91
+ cruise_name,
92
+ sensor_name,
93
+ table_name,
94
+ ):
95
+ expression_attribute_values = {
96
+ ':cr': {'S': cruise_name},
97
+ ':se': {'S': sensor_name},
98
+ ':sh': {'S': ship_name},
99
+ }
100
+
101
+ filter_expression = 'CRUISE_NAME = :cr and SENSOR_NAME = :se and SHIP_NAME = :sh'
102
+ response = self.__dynamodb_client.scan(
103
+ TableName=table_name,
104
+ Select='ALL_ATTRIBUTES',
105
+ ExpressionAttributeValues=expression_attribute_values,
106
+ FilterExpression=filter_expression,
107
+ )
108
+ # Note: table.scan() has 1 MB limit on results so pagination is used
109
+ data = response['Items']
110
+
111
+ while 'LastEvaluatedKey' in response:
112
+ response = self.__dynamodb_client.scan(
113
+ TableName=table_name,
114
+ Select='ALL_ATTRIBUTES',
115
+ ExpressionAttributeValues=expression_attribute_values,
116
+ FilterExpression=filter_expression,
117
+ ExclusiveStartKey=response['LastEvaluatedKey']
118
+ )
119
+ data.extend(response['Items'])
120
+
121
+ deserializer = self.type_deserializer
122
+ df = pd.DataFrame([deserializer.deserialize({"M": i}) for i in data])
123
+
124
+ return df.sort_values(by='START_TIME', ignore_index=True)
125
+
126
+ #####################################################################
127
+ # is this used?
128
+ def get_table_item(
129
+ self,
130
+ table_name,
131
+ key,
132
+ ):
133
+ # a bit more high level, uses resource to get table item
134
+ table = self.__dynamodb_resource.Table(table_name)
135
+ response = table.get_item(
136
+ Key=key
137
+ )
138
+ return response
139
+
140
+ #####################################################################
141
+ # TODO: add helper method to delete the data
142
+ def delete_cruise(
143
+ self,
144
+ table_name,
145
+ cruise_name,
146
+ ):
147
+ pass
148
+
149
+ #########################################################################