Skip to content

Commit

Permalink
Merge pull request #23 from willem0boone/dev
Browse files Browse the repository at this point in the history
updated tests
  • Loading branch information
willem0boone authored Sep 19, 2024
2 parents 416b525 + 673a9ed commit 56b4064
Show file tree
Hide file tree
Showing 8 changed files with 387 additions and 346 deletions.
48 changes: 33 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,50 @@
[![DOI](https://sandbox.zenodo.org/badge/851485026.svg)](https://handle.stage.datacite.org/10.5072/zenodo.109216)

# Edito Resampling datasets

## About
This project is part of EDITO-INFRA ([Grant agreement ID: 101101473](https://doi.org/10.3030/101101473)):
- T7.3: End-to-end demonstrator for aquaculture and maritime industry
This project is part of EDITO-INFRA
([Grant agreement ID: 101101473](https://doi.org/10.3030/101101473)):
- T7.3: End-to-end demonstrator for aquaculture and maritime industry.

Author: Willem Boone | contact: [[email protected]]([email protected])

## Goal
#### Summary of Demonstrator
The demonstrator use case (DUC) consists of a smartviewer that hosts a model to predict habitat suitability based on environmental living conditions. The smartviewer is maintained in a separate [repository](https://github.com/willem0boone/Edito_model_viewer) and is based on Carbonplan its [seaweed-farming-web](https://carbonplan.org/research/seaweed-farming)/[GitHub](https://github.com/carbonplan/seaweed-farming-web).

In this demonstrator, habitat suitability is calculated using a deterministic model that uses minimum and maximum thresholds on the environmental variables.
The demonstrator use case (DUC) consists of a smartviewer that hosts a model to
predict habitat suitability based on environmental living conditions. The
smartviewer is maintained in a separate repository
[GitHub - Edito_model_viewer](https://github.com/willem0boone/Edito_model_viewer)
and is based on Carbonplan its
[Mapping seaweed farming potential](https://carbonplan.org/research/seaweed-farming)
/
[GitHub - seaweed-farming-web](https://github.com/carbonplan/seaweed-farming-web).

In this demonstrator, habitat suitability is calculated using a deterministic
model that uses minimum and maximum thresholds on the environmental variables.
The environmental parameters that are used are:

- Sea surface temperature (°C)
- Sea surface salinity ()
- Bathymetry (depth in m)
- Sea surface temperatur
- Sea surface salinity
- Bathymetry

The thresholds for all variables can be adopted using slider widgets. On any changing parameter, the suitability map is updated and rendered in the viewer. Using a time slider, environmental parameters for several future climate scenarios can be accessed and converted in suitability maps.
This work is available on this [GitHub page](https://github.com/willem0boone/Edito_model_viewer).
The thresholds for all variables can be adopted using slider widgets. On any
changing parameter, the suitability map is updated and rendered in the viewer.
Using a time slider, environmental parameters for several future climate
scenarios can be accessed and converted in suitability maps.

#### Data formatting
The environmental variable dataset used by the smartviewer, need to be provided in a specific format. To create this dataset, different sources and storage from Edito data lake are used. Two pipelines were required:
- Downscaling large .zarr datasets to lower resolution. E.g. the bathymetry dataset is around 20GB, which is to large for the demonstrator purpose.
- Creating pyramids in which each level has increasing resolution (for optimal zooming/rendering).

This work is available on this [GitHub page](https://github.com/willem0boone/Edito_resampling_datasets)
The environmental variable dataset used by the smartviewer, need to be provided
in a specific format. To create this dataset, different sources and storage
from Edito data lake are used. Two pipelines were required:
- Downscaling large .zarr datasets to lower resolution. E.g. the bathymetry
- dataset is around 20GB, which is to large for the demonstrator purpose.
- Creating pyramids in which each level has increasing resolution (for optimal
zooming/rendering).

This work is available on
[GitHub - Edito_resampling_datasets](https://github.com/willem0boone/Edito_resampling_datasets)
.

## How to use
- resampling: package, pip install & documentation will follow.
Expand Down
3 changes: 2 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ def extract_version_from_file(file_path):
# release = '0.1'
# version = '0.1.0'

codemeta = "../codemeta.json"
codemeta = "../../codemeta.json"
version = extract_version_from_file(codemeta)


# -- General configuration

extensions = [
Expand Down
1 change: 1 addition & 0 deletions docs/source/pyramids.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ latitude/longitude as geographical coordinates. On the y axis, coordinates go
from 1800 (north pole> to 900 (equator> to 0 (south pole>. Notice that this is
high to low while the plot uses low to high. so the plotting of the map is
mirrored but it doesn't affect the dataset and pyramid building.

Create pyramid
^^^^^^^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Usage
This page contains examples for both downsampling and creating pyramids. The
examples are also available in notebooks on the
`github page <https://github.com/willem0boone/Edito_resampling_datasets/tree/
main/notebooksL>`_
main/notebooks>`_.


Contents
Expand Down
8 changes: 5 additions & 3 deletions resampling/config/config.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
endpoint_url='https://minio.lab.dive.edito.eu'
bucket='oidc-willemboone/EDITO_DUC'
aws_access_key_id='FDR029N2ZKIUSZHV8GUH'
aws_secret_access_key='5kAXkWfDpzBm0Beav2sMqcw1zg2FVEtQVhtE19yX'
aws_session_token="eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3NLZXkiOiJGRFIwMjlOMlpLSVVTWkhWOEdVSCIsImFjciI6IjAiLCJhbGxvd2VkLW9yaWdpbnMiOlsiKiJdLCJhdWQiOlsibWluaW8iLCJhY2NvdW50Il0sImF1dGhfdGltZSI6MTcyNjY0ODcwOCwiYXpwIjoib255eGlhLW1pbmlvIiwiZW1haWwiOiJ3aWxsZW0uYm9vbmVAdmxpei5iZSIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJleHAiOjE3MjY3MzUxMTYsImZhbWlseV9uYW1lIjoiQm9vbmUiLCJnaXZlbl9uYW1lIjoiV2lsbGVtIiwiZ3JvdXBzIjpbIkVESVRPX1VTRVIiLCJ2bGl6LW1vZGVsZXJzIl0sImlhdCI6MTcyNjY0ODcxNiwiaXNzIjoiaHR0cHM6Ly9hdXRoLmxhYi5kaXZlLmVkaXRvLmV1L2F1dGgvcmVhbG1zL2RhdGFsYWIiLCJqdGkiOiI4N2FlYzJhMS1hNDlhLTQ4MjItYjIxMi01YTVjYzliN2QxZTIiLCJuYW1lIjoiV2lsbGVtIEJvb25lIiwicG9saWN5Ijoic3Rzb25seSIsInByZWZlcnJlZF91c2VybmFtZSI6IndpbGxlbWJvb25lIiwicmVhbG1fYWNjZXNzIjp7InJvbGV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J2bGl6LW1vZGVsZXJzIl0sImlhdCI6MTcyNjczMTU1MSwiaXNzIjoiaHR0cHM6Ly9hdXRoLmxhYi5kaXZlLmVkaXRvLmV1L2F1dGgvcmVhbG1zL2RhdGFsYWIiLCJqdGkiOiJmZWU4ZGQ3Yy03NzM1LTRjMDItYTliNC00NWMzMTI4MzMxNDUiLCJuYW1lIjoiV2lsbGVtIEJvb25lIiwicG9saWN5Ijoic3Rzb25seSIsInByZWZlcnJlZF91c2VybmFtZSI6IndpbGxlbWJvb25lIiwicmVhbG1fYWNjZXNzIjp7InJvbGVzIjpbImRlZmF1bHQtcm9sZXMtZGF0YWxhYiIsIm9mZmxpbmVfYWNjZXNzIiwidW1hX2F1dGhvcml6YXRpb24iXX0sInJlc291cmNlX2FjY2VzcyI6eyJhY2NvdW50Ijp7InJvbGVzIjpbIm1hbmFnZS1hY2NvdW50IiwibWFuYWdlLWFjY291bnQtbGlua3MiLCJ2aWV3LXByb2ZpbGUiXX19LCJzY29wZSI6Im9wZW5pZCBlbWFpbCBwcm9maWxlIiwic2Vzc2lvbl9zdGF0ZSI6IjY2NzFmZGRmLTNhNzctNDU1Mi05MTRlLWQwN2Q0YjY0Y2MwOSIsInNpZCI6IjY2NzFmZGRmLTNhNzctNDU1Mi05MTRlLWQwN2Q0YjY0Y2MwOSIsInN1YiI6ImI5MGIyYTUxLTk3MDQtNDE3My1iNDNjLTFlYThiZmEzZWIzNyIsInR5cCI6IkJlYXJlciJ9.qR32cJtauR_HbG-fh-BMeMt0_GCm5BzHRWn7yHcmDr9cXtJbAoZ7XjpBITmasTq_WcIoeIf5GNZSYUzkO738LA"


43 changes: 30 additions & 13 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,54 @@
from botocore.exceptions import NoCredentialsError
from botocore.exceptions import PartialCredentialsError
from botocore.exceptions import ClientError
from config import Config
from resampling.my_store import get_my_store
import warnings


class TestConfig(unittest.TestCase):
def test_object(self):
class TestObjectStore(unittest.TestCase):

def setUp(self):
""" Set up variables shared across tests """
self.my_store = None

def test_get_my_store(self):
""" Test to initiate ObjectStore """
try:
config = Config()
self.my_store = get_my_store()
except Exception as e:
self.fail(f"Creating Config instance failed with exception: {e}")
warnings.warn(
f"Initiating Objectstore via get_my_store encountered an "
f"error: {e}")
self.my_store = None

def test_s3_connection(self):
""" Test to check S3 connection, dependent on test_get_my_store """
if self.my_store is None:
self.skipTest(
"Skipping S3 connection test because my_store initialization "
"failed.")

try:
settings = Config().settings
# Create an S3 client
s3_client = boto3.client(
's3',
endpoint_url=settings.endpoint_url,
aws_access_key_id=settings.aws_access_key_id,
aws_secret_access_key=settings.aws_secret_access_key,
aws_session_token=settings.aws_session_token
endpoint_url=self.my_store._endpoint_url,
aws_access_key_id=self.my_store._aws_access_key_id,
aws_secret_access_key=self.my_store._aws_secret_access_key,
aws_session_token=self.my_store._aws_session_token
)

# Test listing buckets
response = s3_client.list_buckets()
self.assertIn('Buckets', response)

# Optionally check if a specific bucket exists
bucket_exists = any(bucket['Name'] == settings.bucket for bucket in
response.get('Buckets', []))
bucket_exists = any(
bucket['Name'] == self.my_store._bucket for bucket in
response.get('Buckets', []))
self.assertTrue(bucket_exists,
f"Bucket {settings.bucket} does not exist.")
f"Bucket {self.my_store._bucket} does not "
f"exist.")

except (NoCredentialsError, PartialCredentialsError) as e:
self.fail(f"Credentials error: {e}")
Expand Down
Loading

0 comments on commit 56b4064

Please sign in to comment.