water-column-sonar-processing 0.0.12__tar.gz → 24.1.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 (59) hide show
  1. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/.pre-commit-config.yaml +10 -0
  2. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/PKG-INFO +27 -21
  3. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/README.md +23 -18
  4. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/pyproject.toml +9 -3
  5. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/requirements.txt +4 -2
  6. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/requirements_dev.txt +3 -1
  7. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/tests/conftest.py +5 -1
  8. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/water_column_sonar_processing/aws/s3fs_manager.py +1 -0
  9. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/water_column_sonar_processing/cruise/create_empty_zarr_store.py +4 -5
  10. water_column_sonar_processing-24.1.1/water_column_sonar_processing/cruise/datatree_manager.py +24 -0
  11. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/water_column_sonar_processing/cruise/resample_regrid.py +26 -11
  12. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/water_column_sonar_processing/geometry/__init__.py +2 -1
  13. water_column_sonar_processing-24.1.1/water_column_sonar_processing/geometry/elevation_manager.py +112 -0
  14. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/water_column_sonar_processing/index/index_manager.py +92 -7
  15. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/water_column_sonar_processing/model/zarr_manager.py +15 -10
  16. water_column_sonar_processing-24.1.1/water_column_sonar_processing/processing/__init__.py +5 -0
  17. water_column_sonar_processing-24.1.1/water_column_sonar_processing/processing/batch_downloader.py +132 -0
  18. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/water_column_sonar_processing/processing/raw_to_zarr.py +0 -2
  19. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/water_column_sonar_processing/utility/constants.py +3 -2
  20. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/water_column_sonar_processing.egg-info/PKG-INFO +27 -21
  21. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/water_column_sonar_processing.egg-info/SOURCES.txt +3 -2
  22. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/water_column_sonar_processing.egg-info/requires.txt +2 -1
  23. water_column_sonar_processing-0.0.12/water_column_sonar_processing/cruise/experiment_datatree.py +0 -13
  24. water_column_sonar_processing-0.0.12/water_column_sonar_processing/processing/__init__.py +0 -4
  25. water_column_sonar_processing-0.0.12/water_column_sonar_processing/processing/cruise_sampler.py +0 -342
  26. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/.env-test +0 -0
  27. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/.github/workflows/test_action.yaml +0 -0
  28. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/.gitignore +0 -0
  29. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/.python-version +0 -0
  30. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/LICENSE +0 -0
  31. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/open-science-data-federation/ml/autoencoder_example.py +0 -0
  32. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/open-science-data-federation/osdf_examples/foo.ipynb +0 -0
  33. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/open-science-data-federation/osdf_examples/sonar_ai.ipynb +0 -0
  34. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/pytest.ini +0 -0
  35. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/setup.cfg +0 -0
  36. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/tests/test_process.py +0 -0
  37. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/tests/test_resources/index/calibrated_cruises.csv +0 -0
  38. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/tests/test_resources/raw_to_zarr/D20070724-T042400.bot +0 -0
  39. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/tests/test_resources/raw_to_zarr/D20070724-T042400.idx +0 -0
  40. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/tests/test_resources/raw_to_zarr/D20070724-T042400.raw +0 -0
  41. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/water_column_sonar_processing/__init__.py +0 -0
  42. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/water_column_sonar_processing/aws/__init__.py +0 -0
  43. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/water_column_sonar_processing/aws/dynamodb_manager.py +0 -0
  44. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/water_column_sonar_processing/aws/s3_manager.py +0 -0
  45. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/water_column_sonar_processing/aws/sns_manager.py +0 -0
  46. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/water_column_sonar_processing/aws/sqs_manager.py +0 -0
  47. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/water_column_sonar_processing/cruise/__init__.py +0 -0
  48. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/water_column_sonar_processing/geometry/geometry_manager.py +0 -0
  49. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/water_column_sonar_processing/geometry/geometry_simplification.py +0 -0
  50. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/water_column_sonar_processing/geometry/pmtile_generation.py +0 -0
  51. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/water_column_sonar_processing/index/__init__.py +0 -0
  52. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/water_column_sonar_processing/model/__init__.py +0 -0
  53. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/water_column_sonar_processing/process.py +0 -0
  54. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/water_column_sonar_processing/utility/__init__.py +0 -0
  55. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/water_column_sonar_processing/utility/cleaner.py +0 -0
  56. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/water_column_sonar_processing/utility/pipeline_status.py +0 -0
  57. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/water_column_sonar_processing/utility/timestamp.py +0 -0
  58. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/water_column_sonar_processing.egg-info/dependency_links.txt +0 -0
  59. {water_column_sonar_processing-0.0.12 → water_column_sonar_processing-24.1.1}/water_column_sonar_processing.egg-info/top_level.txt +0 -0
@@ -1,4 +1,5 @@
1
1
  repos:
2
+ ### Security Scan for AWS Secrets ###
2
3
  - repo: local
3
4
  hooks:
4
5
  - id: trufflehog
@@ -34,3 +35,12 @@ repos:
34
35
  # - id: isort
35
36
  # name: isort (python)
36
37
  # args: ["--profile", "black", "--filter-files"]
38
+
39
+ ### Static Security Scan ###
40
+ # To run manually you can do: "bandit -c pyproject.toml -r ."
41
+ - repo: https://github.com/PyCQA/bandit
42
+ rev: '1.8.0'
43
+ hooks:
44
+ - id: bandit
45
+ args: ["-c", "pyproject.toml"]
46
+ additional_dependencies: [ "bandit[toml]" ]
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: water_column_sonar_processing
3
- Version: 0.0.12
3
+ Version: 24.1.1
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
@@ -8,7 +8,7 @@ Project-URL: Issues, https://github.com/CI-CMG/water-column-sonar-processing/iss
8
8
  Classifier: Programming Language :: Python :: 3
9
9
  Classifier: License :: OSI Approved :: MIT License
10
10
  Classifier: Operating System :: OS Independent
11
- Requires-Python: >=3.10
11
+ Requires-Python: >=3.8
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
14
  Requires-Dist: aiobotocore==2.15.2
@@ -26,26 +26,19 @@ Requires-Dist: pandas==2.2.3
26
26
  Requires-Dist: pyarrow==18.1.0
27
27
  Requires-Dist: python-dotenv==1.0.1
28
28
  Requires-Dist: requests==2.32.3
29
- Requires-Dist: s3fs==2023.12.1
29
+ Requires-Dist: s3fs==2024.2.0
30
30
  Requires-Dist: scipy==1.14.1
31
31
  Requires-Dist: setuptools
32
32
  Requires-Dist: shapely==2.0.3
33
33
  Requires-Dist: typing-extensions==4.10.0
34
34
  Requires-Dist: xarray==2024.10.0
35
+ Requires-Dist: xbatcher==0.4.0
35
36
  Requires-Dist: zarr==2.18.3
36
37
 
37
38
  # Water Column Sonar Processing
38
39
  Processing tool for converting L0 data to L1 and L2 as well as generating geospatial information
39
40
 
40
- ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/CI-CMG/water-column-sonar-processing/test_action.yaml)
41
-
42
- ![GitHub License](https://img.shields.io/github/license/CI-CMG/water-column-sonar-processing)
43
-
44
- ![PyPI - Implementation](https://img.shields.io/pypi/v/water-column-sonar-processing?color=black)
45
-
46
- ![PyPI - Downloads](https://img.shields.io/pypi/dd/water-column-sonar-processing)
47
-
48
- ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/CI-CMG/water-column-sonar-processing) ![GitHub repo size](https://img.shields.io/github/repo-size/CI-CMG/water-column-sonar-processing)
41
+ ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/CI-CMG/water-column-sonar-processing/test_action.yaml?color=black) ![PyPI - Implementation](https://img.shields.io/pypi/v/water-column-sonar-processing?color=black) ![GitHub License](https://img.shields.io/github/license/CI-CMG/water-column-sonar-processing?color=black) ![PyPI - Downloads](https://img.shields.io/pypi/dd/water-column-sonar-processing?color=black) ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/CI-CMG/water-column-sonar-processing?color=black) ![GitHub repo size](https://img.shields.io/github/repo-size/CI-CMG/water-column-sonar-processing?color=black)
49
42
 
50
43
  # Setting up the Python Environment
51
44
  > Python 3.10.12
@@ -103,12 +96,6 @@ or
103
96
  Following this tutorial:
104
97
  https://packaging.python.org/en/latest/tutorials/packaging-projects/
105
98
 
106
- # To Publish To PROD
107
- ```commandline
108
- python -m build
109
- python -m twine upload --repository pypi dist/*
110
- ```
111
-
112
99
  # Pre Commit Hook
113
100
  see here for installation: https://pre-commit.com/
114
101
  https://dev.to/rafaelherik/using-trufflehog-and-pre-commit-hook-to-prevent-secret-exposure-edo
@@ -131,12 +118,31 @@ https://colab.research.google.com/drive/1KiLMueXiz9WVB9o4RuzYeGjNZ6PsZU7a#scroll
131
118
  3 failed, 38 passed, 3 skipped, 1 warning in 7.24s
132
119
 
133
120
  # Tag a Release
121
+ Step 1 --> increment the semantic version in the zarr_manager.py "metadata" & the "pyproject.toml"
122
+ ```commandline
123
+ git tag -a v24.01.01 -m "Releasing version v24.01.01"
124
+ ```
125
+
134
126
  ```commandline
135
- git tag "v0.0.12" -a
136
- # enter description
137
127
  git push origin --tags
138
128
  ```
139
129
 
130
+ # To Publish To PROD
131
+ ```commandline
132
+ python -m build
133
+ python -m twine upload --repository pypi dist/*
134
+ ```
135
+
140
136
  # TODO:
141
137
  add https://pypi.org/project/setuptools-scm/
142
138
  for extracting the version
139
+
140
+ # Security scanning
141
+ > bandit -r water_column_sonar_processing/
142
+
143
+ # Data Debugging
144
+ Experimental Plotting in Xarray (hvPlot):
145
+ https://colab.research.google.com/drive/18vrI9LAip4xRGEX6EvnuVFp35RAiVYwU#scrollTo=q9_j9p2yXsLV
146
+
147
+ HB0707 Cruise zoomable:
148
+ https://hb0707.s3.us-east-1.amazonaws.com/index.html
@@ -1,15 +1,7 @@
1
1
  # Water Column Sonar Processing
2
2
  Processing tool for converting L0 data to L1 and L2 as well as generating geospatial information
3
3
 
4
- ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/CI-CMG/water-column-sonar-processing/test_action.yaml)
5
-
6
- ![GitHub License](https://img.shields.io/github/license/CI-CMG/water-column-sonar-processing)
7
-
8
- ![PyPI - Implementation](https://img.shields.io/pypi/v/water-column-sonar-processing?color=black)
9
-
10
- ![PyPI - Downloads](https://img.shields.io/pypi/dd/water-column-sonar-processing)
11
-
12
- ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/CI-CMG/water-column-sonar-processing) ![GitHub repo size](https://img.shields.io/github/repo-size/CI-CMG/water-column-sonar-processing)
4
+ ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/CI-CMG/water-column-sonar-processing/test_action.yaml?color=black) ![PyPI - Implementation](https://img.shields.io/pypi/v/water-column-sonar-processing?color=black) ![GitHub License](https://img.shields.io/github/license/CI-CMG/water-column-sonar-processing?color=black) ![PyPI - Downloads](https://img.shields.io/pypi/dd/water-column-sonar-processing?color=black) ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/CI-CMG/water-column-sonar-processing?color=black) ![GitHub repo size](https://img.shields.io/github/repo-size/CI-CMG/water-column-sonar-processing?color=black)
13
5
 
14
6
  # Setting up the Python Environment
15
7
  > Python 3.10.12
@@ -67,12 +59,6 @@ or
67
59
  Following this tutorial:
68
60
  https://packaging.python.org/en/latest/tutorials/packaging-projects/
69
61
 
70
- # To Publish To PROD
71
- ```commandline
72
- python -m build
73
- python -m twine upload --repository pypi dist/*
74
- ```
75
-
76
62
  # Pre Commit Hook
77
63
  see here for installation: https://pre-commit.com/
78
64
  https://dev.to/rafaelherik/using-trufflehog-and-pre-commit-hook-to-prevent-secret-exposure-edo
@@ -95,12 +81,31 @@ https://colab.research.google.com/drive/1KiLMueXiz9WVB9o4RuzYeGjNZ6PsZU7a#scroll
95
81
  3 failed, 38 passed, 3 skipped, 1 warning in 7.24s
96
82
 
97
83
  # Tag a Release
84
+ Step 1 --> increment the semantic version in the zarr_manager.py "metadata" & the "pyproject.toml"
85
+ ```commandline
86
+ git tag -a v24.01.01 -m "Releasing version v24.01.01"
87
+ ```
88
+
98
89
  ```commandline
99
- git tag "v0.0.12" -a
100
- # enter description
101
90
  git push origin --tags
102
91
  ```
103
92
 
93
+ # To Publish To PROD
94
+ ```commandline
95
+ python -m build
96
+ python -m twine upload --repository pypi dist/*
97
+ ```
98
+
104
99
  # TODO:
105
100
  add https://pypi.org/project/setuptools-scm/
106
- for extracting the version
101
+ for extracting the version
102
+
103
+ # Security scanning
104
+ > bandit -r water_column_sonar_processing/
105
+
106
+ # Data Debugging
107
+ Experimental Plotting in Xarray (hvPlot):
108
+ https://colab.research.google.com/drive/18vrI9LAip4xRGEX6EvnuVFp35RAiVYwU#scrollTo=q9_j9p2yXsLV
109
+
110
+ HB0707 Cruise zoomable:
111
+ https://hb0707.s3.us-east-1.amazonaws.com/index.html
@@ -8,13 +8,14 @@ build-backend = "setuptools.build_meta"
8
8
 
9
9
  [project]
10
10
  name = "water_column_sonar_processing"
11
- version = "0.0.12"
11
+ version = "24.01.01"
12
12
  authors = [
13
13
  { name="Rudy Klucik", email="rudy.klucik@noaa.gov" },
14
14
  ]
15
15
  description = "A processing tool for water column sonar data."
16
16
  readme = "README.md"
17
- requires-python = ">=3.10"
17
+ #requires-python = ">=3.10"
18
+ requires-python = ">=3.8"
18
19
  classifiers = [
19
20
  "Programming Language :: Python :: 3",
20
21
  "License :: OSI Approved :: MIT License",
@@ -34,4 +35,9 @@ optional-dependencies = {dev = { file = ["requirements_dev.txt"] }}
34
35
  #fallback_version = "unknown"
35
36
  #local_scheme = "node-and-date"
36
37
  #write_to = "_water_column_sonar_processing_version.py"
37
- #write_to_template = 'version = "{version}"'
38
+ #write_to_template = 'version = "{version}"'
39
+
40
+ [tool.bandit]
41
+ exclude_dirs = ["tests"]
42
+ [tool.pre-commit-hooks.bandit]
43
+ exclude = ["*/tests/*"]
@@ -19,12 +19,14 @@ pyarrow==18.1.0
19
19
  python-dotenv==1.0.1
20
20
  requests==2.32.3
21
21
  #s3fs==2024.3.1
22
- #s3fs==2024.10.0 # this version creates problems
23
- s3fs==2023.12.1
22
+ #s3fs==2024.3.0 # does not work
23
+ s3fs==2024.2.0 # works ...something between 2024.2 and 2024.3 creates the problem
24
24
  scipy==1.14.1
25
25
  #setuptools==75.6.0
26
26
  setuptools
27
27
  shapely==2.0.3
28
28
  typing-extensions==4.10.0
29
29
  xarray==2024.10.0
30
+ # xbatcher[tensorflow]
31
+ xbatcher==0.4.0
30
32
  zarr==2.18.3
@@ -1,5 +1,6 @@
1
1
  -r requirements.txt
2
2
 
3
+ bandit[toml]==1.8.0
3
4
  build
4
5
  pre-commit
5
6
  pyinstaller
@@ -9,4 +10,5 @@ flake8==7.1.1
9
10
  pooch==1.8.2
10
11
  pytest~=8.3.3
11
12
  pytest-cov==6.0.0
12
- tqdm
13
+ tqdm
14
+ bandit
@@ -16,13 +16,17 @@ HB0707_RAW = pooch.create(
16
16
  #https://noaa-wcsd-pds.s3.amazonaws.com/data/raw/Henry_B._Bigelow/HB0707/EK60/D20070711-T182032.raw
17
17
  # TODO: add bottom files
18
18
  "D20070712-T124906.raw": "sha256:44f9b2402a8d6d51c69235d1e33c3e4ab570fc541e9f269009924378bf4d97a2", # 250 m, 158 MB
19
+ "D20070712-T124906.bot": "sha256:9eebd8b85a514f3df6b7c4ba127967302dfea7c5e9fb47c22e3182ad1a93c78f",
19
20
  "D20070712-T152416.raw": "sha256:94a937eefd6ae5763c27c9ba1e4769b2b76fcc2d840e7db6c2e0edd925d6f70f", # 1000 m, 200 MB
21
+ "D20070712-T152416.bot": "sha256:65b16cff596502889f841e58061217660e066b07fb732ccf211f1c6e46ee8210",
20
22
  },
21
23
  )
22
24
 
23
25
  def fetch_raw_files():
24
26
  HB0707_RAW.fetch(fname="D20070712-T124906.raw", progressbar=True)
25
- file_name = HB0707_RAW.fetch(fname="D20070712-T152416.raw", progressbar=True)
27
+ HB0707_RAW.fetch(fname="D20070712-T124906.bot", progressbar=True)
28
+ HB0707_RAW.fetch(fname="D20070712-T152416.raw", progressbar=True)
29
+ file_name = HB0707_RAW.fetch(fname="D20070712-T152416.bot", progressbar=True)
26
30
  return Path(file_name).parent #joinpath(Path(file_path).stem)
27
31
 
28
32
  @pytest.fixture(scope="session")
@@ -16,6 +16,7 @@ class S3FSManager:
16
16
  # self.output_bucket_name = os.environ.get("OUTPUT_BUCKET_NAME")
17
17
  self.s3_region = os.environ.get("AWS_REGION", default="us-east-1")
18
18
  self.s3fs = s3fs.S3FileSystem(
19
+ asynchronous=False,
19
20
  endpoint_url=endpoint_url,
20
21
  key=os.environ.get("OUTPUT_BUCKET_ACCESS_KEY"),
21
22
  secret=os.environ.get("OUTPUT_BUCKET_SECRET_ACCESS_KEY"),
@@ -1,4 +1,5 @@
1
1
  import os
2
+ import tempfile
2
3
 
3
4
  import numcodecs
4
5
  import numpy as np
@@ -11,7 +12,6 @@ from water_column_sonar_processing.utility import Cleaner
11
12
  numcodecs.blosc.use_threads = False
12
13
  numcodecs.blosc.set_nthreads(1)
13
14
 
14
- # TEMPDIR = "/tmp"
15
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)
@@ -61,7 +61,6 @@ class CreateEmptyZarrStore:
61
61
  # TODO: move to common place
62
62
 
63
63
  #######################################################
64
- # @classmethod
65
64
  def create_cruise_level_zarr_store(
66
65
  self,
67
66
  output_bucket_name: str,
@@ -69,8 +68,8 @@ class CreateEmptyZarrStore:
69
68
  cruise_name: str,
70
69
  sensor_name: str,
71
70
  table_name: str,
72
- tempdir: str,
73
71
  ) -> None:
72
+ tempdir = tempfile.TemporaryDirectory()
74
73
  try:
75
74
  # HB0806 - 123, HB0903 - 220
76
75
  dynamo_db_manager = DynamoDBManager()
@@ -146,7 +145,7 @@ class CreateEmptyZarrStore:
146
145
  print(f"new_height: {new_height}")
147
146
 
148
147
  zarr_manager.create_zarr_store(
149
- path=tempdir,
148
+ path=tempdir.name, # TODO: need to use .name or problem
150
149
  ship_name=ship_name,
151
150
  cruise_name=cruise_name,
152
151
  sensor_name=sensor_name,
@@ -159,7 +158,7 @@ class CreateEmptyZarrStore:
159
158
  #################################################################
160
159
  self.upload_zarr_store_to_s3(
161
160
  output_bucket_name=output_bucket_name,
162
- local_directory=tempdir,
161
+ local_directory=tempdir.name, # TODO: need to use .name or problem
163
162
  object_prefix=zarr_prefix,
164
163
  cruise_name=cruise_name,
165
164
  )
@@ -0,0 +1,24 @@
1
+ ### https://xarray-datatree.readthedocs.io/en/latest/data-structures.html
2
+ import numpy as np
3
+ from datatree import DataTree
4
+ import xarray as xr
5
+
6
+ class DatatreeManager:
7
+ #######################################################
8
+ def __init__(
9
+ self,
10
+ ):
11
+ self.dtype = "float32"
12
+
13
+ #################################################################
14
+ def create_datatree(
15
+ self,
16
+ input_ds,
17
+ ) -> None:
18
+ ds1 = xr.Dataset({"foo": "orange"})
19
+ dt = DataTree(name="root", data=ds1) # create root node
20
+ ds2 = xr.Dataset({"bar": 0}, coords={"y": ("y", [0, 1, 2])})
21
+ return dt
22
+
23
+
24
+
@@ -188,10 +188,10 @@ class ResampleRegrid:
188
188
  for file_name in all_file_names:
189
189
  gc.collect()
190
190
  file_name_stem = Path(file_name).stem
191
- # file_name_stem = "D20070724-T151330"
192
191
  print(f"Processing file: {file_name_stem}.")
193
- # if f"{file_name_stem}.raw" not in list(cruise_df['FILE_NAME']):
194
- # raise Exception(f"Raw file file_stem not found in dynamodb.")
192
+
193
+ if f"{file_name_stem}.raw" not in list(cruise_df['FILE_NAME']):
194
+ raise Exception(f"Raw file file_stem not found in dynamodb.")
195
195
 
196
196
  # status = PipelineStatus['LEVEL_1_PROCESSING']
197
197
  # TODO: filter rows by enum success, filter the dataframe just for enums >= LEVEL_1_PROCESSING
@@ -281,12 +281,7 @@ class ResampleRegrid:
281
281
  print(f"start_ping_time_index: {start_ping_time_index}, end_ping_time_index: {end_ping_time_index}")
282
282
  #########################################################################
283
283
  # write Sv values to cruise-level-model-store
284
- for channel in range(
285
- len(input_xr.channel.values)
286
- ): # does not like being written in one fell swoop :(
287
- output_zarr_store.Sv[
288
- :, start_ping_time_index:end_ping_time_index, channel
289
- ] = regrid_resample[:, :, channel]
284
+ output_zarr_store.Sv[:, start_ping_time_index:end_ping_time_index, :] = regrid_resample.values
290
285
 
291
286
  #########################################################################
292
287
  # [5] write subset of latitude/longitude
@@ -296,11 +291,31 @@ class ResampleRegrid:
296
291
  output_zarr_store.longitude[
297
292
  start_ping_time_index:end_ping_time_index
298
293
  ] = geospatial.dropna()["longitude"].values
294
+
295
+ #########################################################################
296
+ # TODO: add the "detected_seafloor_depth/" to the
297
+ # L2 cruise dataarrays
298
+ # TODO: make bottom optional
299
+ # TODO: Only checking the first channel for now. Need to average across all channels
300
+ # in the future. See https://github.com/CI-CMG/water-column-sonar-processing/issues/11
301
+ if 'detected_seafloor_depth' in input_xr.variables:
302
+ print('Found detected_seafloor_depth, adding data to output store.')
303
+ detected_seafloor_depth = input_xr.detected_seafloor_depth.values
304
+ detected_seafloor_depth[detected_seafloor_depth == 0.] = np.nan
305
+ # TODO: problem here: Processing file: D20070711-T210709.
306
+ detected_seafloor_depths = np.nanmean(detected_seafloor_depth, 0) # RuntimeWarning: Mean of empty slice detected_seafloor_depths = np.nanmean(detected_seafloor_depth, 0)
307
+ detected_seafloor_depths[detected_seafloor_depths == 0.] = np.nan
308
+ print(f"min depth measured: {np.nanmin(detected_seafloor_depths)}")
309
+ print(f"max depth measured: {np.nanmax(detected_seafloor_depths)}")
310
+ #available_indices = np.argwhere(np.isnan(geospatial['latitude'].values))
311
+ output_zarr_store.bottom[
312
+ start_ping_time_index:end_ping_time_index
313
+ ] = detected_seafloor_depths
314
+ #########################################################################
315
+ #########################################################################
299
316
  except Exception as err:
300
317
  print(f"Problem interpolating the data: {err}")
301
318
  raise err
302
- # else:
303
- # pass
304
319
  finally:
305
320
  print("Done interpolating data.")
306
321
  # TODO: read across times and verify data was written?
@@ -1,5 +1,6 @@
1
+ from .elevation_manager import ElevationManager
1
2
  from .geometry_manager import GeometryManager
2
3
  from .geometry_simplification import GeometrySimplification
3
4
  from .pmtile_generation import PMTileGeneration
4
5
 
5
- __all__ = ["GeometryManager", "GeometrySimplification", "PMTileGeneration"]
6
+ __all__ = ["ElevationManager", "GeometryManager", "GeometrySimplification", "PMTileGeneration"]
@@ -0,0 +1,112 @@
1
+ """
2
+ https://gis.ngdc.noaa.gov/arcgis/rest/services/DEM_mosaics/DEM_global_mosaic/ImageServer/identify?geometry=-31.70235%2C13.03332&geometryType=esriGeometryPoint&returnGeometry=false&returnCatalogItems=false&f=json
3
+
4
+ https://gis.ngdc.noaa.gov/arcgis/rest/services/DEM_mosaics/DEM_global_mosaic/ImageServer/
5
+ identify?
6
+ geometry=-31.70235%2C13.03332
7
+ &geometryType=esriGeometryPoint
8
+ &returnGeometry=false
9
+ &returnCatalogItems=false
10
+ &f=json
11
+ {"objectId":0,"name":"Pixel","value":"-5733","location":{"x":-31.702349999999999,"y":13.03332,"spatialReference":{"wkid":4326,"latestWkid":4326}},"properties":null,"catalogItems":null,"catalogItemVisibilities":[]}
12
+ -5733
13
+
14
+ (base) rudy:deleteME rudy$ curl https://api.opentopodata.org/v1/gebco2020?locations=13.03332,-31.70235
15
+ {
16
+ "results": [
17
+ {
18
+ "dataset": "gebco2020",
19
+ "elevation": -5729.0,
20
+ "location": {
21
+ "lat": 13.03332,
22
+ "lng": -31.70235
23
+ }
24
+ }
25
+ ],
26
+ "status": "OK"
27
+ }
28
+ """
29
+ import json
30
+ import time
31
+
32
+ import requests
33
+ from collections.abc import Generator
34
+
35
+ def chunked(
36
+ ll: list,
37
+ n: int
38
+ ) -> Generator:
39
+ # Yields successively n-sized chunks from ll.
40
+ for i in range(0, len(ll), n):
41
+ yield ll[i : i + n]
42
+
43
+
44
+ class ElevationManager:
45
+ #######################################################
46
+ def __init__(
47
+ self,
48
+ ):
49
+ self.DECIMAL_PRECISION = 5 # precision for GPS coordinates
50
+ self.TIMOUT_SECONDS = 10
51
+
52
+ #######################################################
53
+ def get_arcgis_elevation(
54
+ self,
55
+ lngs: list,
56
+ lats: list,
57
+ chunk_size: int=500, # I think this is the api limit
58
+ ) -> int:
59
+ # Reference: https://developers.arcgis.com/rest/services-reference/enterprise/map-to-image/
60
+ # Info: https://www.arcgis.com/home/item.html?id=c876e3c96a8642ab8557646a3b4fa0ff
61
+ ### 'https://gis.ngdc.noaa.gov/arcgis/rest/services/DEM_mosaics/DEM_global_mosaic/ImageServer/identify?geometry={"points":[[-31.70235,13.03332],[-32.70235,14.03332]]}&geometryType=esriGeometryMultipoint&returnGeometry=false&returnCatalogItems=false&f=json'
62
+ if len(lngs) != len(lats):
63
+ raise ValueError("lngs and lats must have same length")
64
+
65
+ geometryType = "esriGeometryMultipoint" # TODO: allow single point?
66
+
67
+ depths = []
68
+
69
+ list_of_points = [list(elem) for elem in list(zip(lngs, lats))]
70
+ for chunk in chunked(list_of_points, chunk_size):
71
+ time.sleep(0.1)
72
+ # order: (lng, lat)
73
+ geometry = f'{{"points":{str(chunk)}}}'
74
+ url=f'https://gis.ngdc.noaa.gov/arcgis/rest/services/DEM_mosaics/DEM_global_mosaic/ImageServer/identify?geometry={geometry}&geometryType={geometryType}&returnGeometry=false&returnCatalogItems=false&f=json'
75
+ result = requests.get(url, timeout=self.TIMOUT_SECONDS)
76
+ res = json.loads(result.content.decode('utf8'))
77
+ if 'results' in res:
78
+ for element in res['results']:
79
+ depths.append(float(element['value']))
80
+ elif 'value' in res:
81
+ depths.append(float(res['value']))
82
+
83
+ return depths
84
+
85
+ # def get_gebco_bathymetry_elevation(self) -> int:
86
+ # # Documentation: https://www.opentopodata.org/datasets/gebco2020/
87
+ # latitude = 13.03332
88
+ # longitude = -31.70235
89
+ # dataset = "gebco2020"
90
+ # url = f"https://api.opentopodata.org/v1/{dataset}?locations={latitude},{longitude}"
91
+ # pass
92
+
93
+ # def get_elevation(
94
+ # self,
95
+ # df,
96
+ # lat_column,
97
+ # lon_column,
98
+ # ) -> int:
99
+ # """Query service using lat, lon. add the elevation values as a new column."""
100
+ # url = r'https://epqs.nationalmap.gov/v1/json?'
101
+ # elevations = []
102
+ # for lat, lon in zip(df[lat_column], df[lon_column]):
103
+ # # define rest query params
104
+ # params = {
105
+ # 'output': 'json',
106
+ # 'x': lon,
107
+ # 'y': lat,
108
+ # 'units': 'Meters'
109
+ # }
110
+ # result = requests.get((url + urllib.parse.urlencode(params)))
111
+ # elevations.append(result.json()['value'])
112
+ # return elevations