From 1dfb2f775feeb25d8b3b21b08a261fe94c657a82 Mon Sep 17 00:00:00 2001 From: Robin Fievet Date: Fri, 19 Dec 2025 11:22:59 -0500 Subject: [PATCH 1/8] lint fix --- .gitignore | 1 + LICENSE | 1 - README.md | 4 +- config/models/base.json | 2 +- config/models/nano.json | 2 +- config/models/tiny.json | 2 +- config/normalization.json | 2 +- data/models/nano/config.json | 2 +- pyproject.toml | 6 + uv.lock | 272 +++++++++++++++++++++++++++++++++ visualizing_embeddings.ipynb | 287 ----------------------------------- visualizing_embeddings.py | 207 +++++++++++++++++++++++++ 12 files changed, 494 insertions(+), 294 deletions(-) delete mode 100644 visualizing_embeddings.ipynb create mode 100644 visualizing_embeddings.py diff --git a/.gitignore b/.gitignore index 2c9c089..033488d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ __pycache__ # data needs to be explicitly added data/* .ipynb_checkpoints +__marimo__/ baseline_weights models slurm diff --git a/LICENSE b/LICENSE index 109e493..108dda2 100644 --- a/LICENSE +++ b/LICENSE @@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/README.md b/README.md index c742869..fdc1ce1 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ s2 = torch.randn((t, h, w, len(S2_BANDS))) masked_output = construct_galileo_input(s2=s2, normalize=normalize) ``` -If you want to see Galileo being used on real data, we also have a [notebook](visualizing_embeddings.ipynb) which generates embeddings for a real training tif file: +If you want to see Galileo being used on real data, we also have a [marimo app](visualizing_embeddings.py) which generates embeddings for a real training tif file: Galileo model outputs @@ -125,6 +125,8 @@ uv run ruff check . # Lint code uv run ruff format . # Format code uv run mypy . # Type checking uv run pre-commit run --all-files # Run all pre-commit checks +uv run marimo run visualizing_embeddings.py # Run marimo app for visualization +uv run marimo edit visualizing_embeddings.py # Edit marimo app ``` **Optional - Codecov setup:** diff --git a/config/models/base.json b/config/models/base.json index f7e8cfb..4c44e70 100644 --- a/config/models/base.json +++ b/config/models/base.json @@ -130,4 +130,4 @@ "embedding_size": 768 } } -} \ No newline at end of file +} diff --git a/config/models/nano.json b/config/models/nano.json index 1bebb17..2530019 100644 --- a/config/models/nano.json +++ b/config/models/nano.json @@ -130,4 +130,4 @@ "embedding_size": 128 } } -} \ No newline at end of file +} diff --git a/config/models/tiny.json b/config/models/tiny.json index ea5412e..ced4ebc 100644 --- a/config/models/tiny.json +++ b/config/models/tiny.json @@ -130,4 +130,4 @@ "embedding_size": 192 } } -} \ No newline at end of file +} diff --git a/config/normalization.json b/config/normalization.json index 5ac0220..5232a7b 100644 --- a/config/normalization.json +++ b/config/normalization.json @@ -1 +1 @@ -{"total_n": 127155, "sampled_n": 10000, "13": {"mean": [-11.728724389184965, -18.85558188024017, 1395.3408730676722, 1338.4026921784578, 1343.09883810357, 1543.8607982512297, 2186.2022069512263, 2525.0932853316694, 2410.3377187373408, 2750.2854646886753, 2234.911100061487, 1474.5311266077113, 0.2892116502999044], "std": [4.887145774840316, 5.730270320384293, 917.7041440370853, 913.2988423581528, 1092.678723527555, 1047.2206083460424, 1048.0101611156767, 1143.6903026819996, 1098.979177731649, 1204.472755085893, 1145.9774063078878, 980.2429840007796, 0.2720939024500081]}, "16": {"mean": [673.0152819503361, 5.930092668915115, 0.10470439140978786, 0.23965913270066183, 0.08158044385860364, 0.04246976254259546, 0.11304392863520317, 0.17329647890362473, 0.0698981691616277, 0.12130267132802142, 0.04671318615236216, 10.973119802517362, 1.0927069179958768, 1.6991394232855903, 0.03720594618055555, 1.3671352688259548], "std": [983.0697298296237, 8.167406789813247, 0.18771647977504985, 0.2368313455675914, 0.08024268534756586, 0.04045374496146404, 0.11350342472061795, 0.1279898111718168, 0.12042341550438586, 0.13602408145504347, 0.043971116096060345, 31.255340146970997, 10.395974878206689, 12.92380617159917, 1.9285254295940466, 11.612179775408928]}, "6": {"mean": [271.5674963541667, 0.08554303677156568, 657.3181260091111, 692.1291795806885, 562.781331880633, 1.5647115934036673], "std": [79.80828940314429, 0.11669547098151486, 704.0008695557707, 925.0116126406431, 453.2434022278578, 7.513020170832818]}, "18": {"mean": [188.20315880851746, 0.2804946561574936, 0.11371652073860168, 0.058778801321983334, 0.10474256777763366, 0.2396918488264084, 0.08152248692512512, 0.04248040814399719, 0.11303179881572724, 0.17326324067115784, 0.06998309404850006, 0.12122812910079957, 0.04671641788482666, 10.98456594619751, 1.0968475807189941, 1.6947754135131836, 0.03320046615600586, 1.3602827312469483], "std": [1154.5919128300602, 0.5276998078079327, 0.7021637331734328, 0.36528892213195063, 0.17470213191865785, 0.20411195416718833, 0.0660782470089761, 0.03380702424871257, 0.09809195568521663, 0.11292471052124119, 0.09720748930233268, 0.12912217763726777, 0.0399973913151906, 23.725471823867462, 5.715238079725388, 9.030481416228302, 0.9950220242487364, 7.754429123862099]}} \ No newline at end of file +{"total_n": 127155, "sampled_n": 10000, "13": {"mean": [-11.728724389184965, -18.85558188024017, 1395.3408730676722, 1338.4026921784578, 1343.09883810357, 1543.8607982512297, 2186.2022069512263, 2525.0932853316694, 2410.3377187373408, 2750.2854646886753, 2234.911100061487, 1474.5311266077113, 0.2892116502999044], "std": [4.887145774840316, 5.730270320384293, 917.7041440370853, 913.2988423581528, 1092.678723527555, 1047.2206083460424, 1048.0101611156767, 1143.6903026819996, 1098.979177731649, 1204.472755085893, 1145.9774063078878, 980.2429840007796, 0.2720939024500081]}, "16": {"mean": [673.0152819503361, 5.930092668915115, 0.10470439140978786, 0.23965913270066183, 0.08158044385860364, 0.04246976254259546, 0.11304392863520317, 0.17329647890362473, 0.0698981691616277, 0.12130267132802142, 0.04671318615236216, 10.973119802517362, 1.0927069179958768, 1.6991394232855903, 0.03720594618055555, 1.3671352688259548], "std": [983.0697298296237, 8.167406789813247, 0.18771647977504985, 0.2368313455675914, 0.08024268534756586, 0.04045374496146404, 0.11350342472061795, 0.1279898111718168, 0.12042341550438586, 0.13602408145504347, 0.043971116096060345, 31.255340146970997, 10.395974878206689, 12.92380617159917, 1.9285254295940466, 11.612179775408928]}, "6": {"mean": [271.5674963541667, 0.08554303677156568, 657.3181260091111, 692.1291795806885, 562.781331880633, 1.5647115934036673], "std": [79.80828940314429, 0.11669547098151486, 704.0008695557707, 925.0116126406431, 453.2434022278578, 7.513020170832818]}, "18": {"mean": [188.20315880851746, 0.2804946561574936, 0.11371652073860168, 0.058778801321983334, 0.10474256777763366, 0.2396918488264084, 0.08152248692512512, 0.04248040814399719, 0.11303179881572724, 0.17326324067115784, 0.06998309404850006, 0.12122812910079957, 0.04671641788482666, 10.98456594619751, 1.0968475807189941, 1.6947754135131836, 0.03320046615600586, 1.3602827312469483], "std": [1154.5919128300602, 0.5276998078079327, 0.7021637331734328, 0.36528892213195063, 0.17470213191865785, 0.20411195416718833, 0.0660782470089761, 0.03380702424871257, 0.09809195568521663, 0.11292471052124119, 0.09720748930233268, 0.12912217763726777, 0.0399973913151906, 23.725471823867462, 5.715238079725388, 9.030481416228302, 0.9950220242487364, 7.754429123862099]}} diff --git a/data/models/nano/config.json b/data/models/nano/config.json index 14c5e23..6264ace 100644 --- a/data/models/nano/config.json +++ b/data/models/nano/config.json @@ -1 +1 @@ -{"training": {"patch_sizes": [1, 2, 3, 4, 5, 6, 7, 8], "conditioner_mode": "no_cond", "max_lr": 0.003, "num_epochs": 500, "batch_size": 32, "effective_batch_size": 512, "warmup_epochs": 30, "final_lr": 1e-06, "conditioner_multiplier": 0.1, "weight_decay": 0.02, "conditioner_weight_decay": 0.02, "grad_clip": true, "betas": [0.9, 0.999], "ema": [0.996, 1.0], "shape_time_combinations": [{"size": 4, "timesteps": 12}, {"size": 5, "timesteps": 6}, {"size": 6, "timesteps": 4}, {"size": 7, "timesteps": 3}, {"size": 9, "timesteps": 3}, {"size": 12, "timesteps": 3}], "masking_probabilities": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], "augmentation": {"flip+rotate": true}, "max_unmasking_channels": 17, "target_condition": false, "loss_type": "patch_disc", "tau": 0.1, "pred2unit": false, "loss_mask_other_samples": true, "normalization": "std", "eval_eurosat_every_n_epochs": 10, "random_masking": "half", "unmasking_channels_combo": "all", "double_loss": true, "double_predictors": true, "target_exit_after": 0, "token_exit_cfg": {"S1": 4, "S2_RGB": 4, "S2_Red_Edge": 4, "S2_NIR_10m": 4, "S2_NIR_20m": 4, "S2_SWIR": 4, "NDVI": 2, "ERA5": 2, "TC": 2, "VIIRS": 4, "SRTM": 2, "DW": 0, "WC": 0, "LS": 0, "location": 4, "DW_static": 0, "WC_static": 0}, "target_masking": "all", "ignore_band_groups": null, "st_encode_ratio": 0.1, "random_encode_ratio": 0.1, "st_decode_ratio": 0.5, "random_decode_ratio": 0.5, "loss_dict": {"loss_type": "patch_disc", "loss_mask_other_samples": true, "pred2unit": false, "tau": 0.1}, "training_samples": 127155}, "model": {"encoder": {"embedding_size": 128, "depth": 4, "num_heads": 8, "mlp_ratio": 4, "max_sequence_length": 24, "freeze_projections": false, "drop_path": 0.1, "max_patch_size": 8}, "decoder": {"depth": 2, "num_heads": 8, "mlp_ratio": 4, "max_sequence_length": 24, "learnable_channel_embeddings": true, "max_patch_size": 8, "encoder_embedding_size": 128, "decoder_embedding_size": 128}}, "run_name": "304.json config file", "wandb_run_id": "zzchxp4e", "beaker_workload_id": "01JEXWET7KM037TCX56JJENQ23", "beaker_node_hostname": "saturn-cs-aus-245.reviz.ai2.in", "beaker_experiment_url": "https://beaker.org/ex/01JEXWET7KM037TCX56JJENQ23/", "cur_epoch": 500} \ No newline at end of file +{"training": {"patch_sizes": [1, 2, 3, 4, 5, 6, 7, 8], "conditioner_mode": "no_cond", "max_lr": 0.003, "num_epochs": 500, "batch_size": 32, "effective_batch_size": 512, "warmup_epochs": 30, "final_lr": 1e-06, "conditioner_multiplier": 0.1, "weight_decay": 0.02, "conditioner_weight_decay": 0.02, "grad_clip": true, "betas": [0.9, 0.999], "ema": [0.996, 1.0], "shape_time_combinations": [{"size": 4, "timesteps": 12}, {"size": 5, "timesteps": 6}, {"size": 6, "timesteps": 4}, {"size": 7, "timesteps": 3}, {"size": 9, "timesteps": 3}, {"size": 12, "timesteps": 3}], "masking_probabilities": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], "augmentation": {"flip+rotate": true}, "max_unmasking_channels": 17, "target_condition": false, "loss_type": "patch_disc", "tau": 0.1, "pred2unit": false, "loss_mask_other_samples": true, "normalization": "std", "eval_eurosat_every_n_epochs": 10, "random_masking": "half", "unmasking_channels_combo": "all", "double_loss": true, "double_predictors": true, "target_exit_after": 0, "token_exit_cfg": {"S1": 4, "S2_RGB": 4, "S2_Red_Edge": 4, "S2_NIR_10m": 4, "S2_NIR_20m": 4, "S2_SWIR": 4, "NDVI": 2, "ERA5": 2, "TC": 2, "VIIRS": 4, "SRTM": 2, "DW": 0, "WC": 0, "LS": 0, "location": 4, "DW_static": 0, "WC_static": 0}, "target_masking": "all", "ignore_band_groups": null, "st_encode_ratio": 0.1, "random_encode_ratio": 0.1, "st_decode_ratio": 0.5, "random_decode_ratio": 0.5, "loss_dict": {"loss_type": "patch_disc", "loss_mask_other_samples": true, "pred2unit": false, "tau": 0.1}, "training_samples": 127155}, "model": {"encoder": {"embedding_size": 128, "depth": 4, "num_heads": 8, "mlp_ratio": 4, "max_sequence_length": 24, "freeze_projections": false, "drop_path": 0.1, "max_patch_size": 8}, "decoder": {"depth": 2, "num_heads": 8, "mlp_ratio": 4, "max_sequence_length": 24, "learnable_channel_embeddings": true, "max_patch_size": 8, "encoder_embedding_size": 128, "decoder_embedding_size": 128}}, "run_name": "304.json config file", "wandb_run_id": "zzchxp4e", "beaker_workload_id": "01JEXWET7KM037TCX56JJENQ23", "beaker_node_hostname": "saturn-cs-aus-245.reviz.ai2.in", "beaker_experiment_url": "https://beaker.org/ex/01JEXWET7KM037TCX56JJENQ23/", "cur_epoch": 500} diff --git a/pyproject.toml b/pyproject.toml index 3a655a7..bee060f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,6 +49,7 @@ dev = [ "mypy==1.8.0", "coverage==7.4.0", "pre-commit==3.6.0", + "marimo", ] [project.urls] @@ -69,3 +70,8 @@ packages = ["src"] lint.extend-select = ["I"] line-length = 99 exclude = ["anysat"] + +[dependency-groups] +dev = [ + "marimo>=0.18.4", +] diff --git a/uv.lock b/uv.lock index 1fadcfd..343685c 100644 --- a/uv.lock +++ b/uv.lock @@ -579,6 +579,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/f5/e8/f6bd1eee09314e7e6dee49cbe2c5e22314ccdb38db16c9fc72d2fa80d054/docker_pycreds-0.4.0-py2.py3-none-any.whl", hash = "sha256:7266112468627868005106ec19cd0d722702d2b7d5912a28e19b826c3d37af49", size = 8982, upload-time = "2018-11-29T03:26:49.575Z" }, ] +[[package]] +name = "docutils" +version = "0.22.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d9/02/111134bfeb6e6c7ac4c74594e39a59f6c0195dc4846afbeac3cba60f1927/docutils-0.22.3.tar.gz", hash = "sha256:21486ae730e4ca9f622677b1412b879af1791efcfba517e4c6f60be543fc8cdd", size = 2290153, upload-time = "2025-11-06T02:35:55.655Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/11/a8/c6a4b901d17399c77cd81fb001ce8961e9f5e04d3daf27e8925cb012e163/docutils-0.22.3-py3-none-any.whl", hash = "sha256:bd772e4aca73aff037958d44f2be5229ded4c09927fcf8690c577b66234d6ceb", size = 633032, upload-time = "2025-11-06T02:35:52.391Z" }, +] + [[package]] name = "earthengine-api" version = "0.1.391" @@ -765,11 +774,17 @@ dependencies = [ [package.optional-dependencies] dev = [ { name = "coverage" }, + { name = "marimo" }, { name = "mypy" }, { name = "pre-commit" }, { name = "ruff" }, ] +[package.dev-dependencies] +dev = [ + { name = "marimo" }, +] + [package.metadata] requires-dist = [ { name = "breizhcrops" }, @@ -781,6 +796,7 @@ requires-dist = [ { name = "geobench", specifier = "==1.0.0" }, { name = "geopandas", specifier = "==0.14.3" }, { name = "h5py", specifier = "==3.10.0" }, + { name = "marimo", marker = "extra == 'dev'" }, { name = "mypy", marker = "extra == 'dev'", specifier = "==1.8.0" }, { name = "numpy", specifier = "==1.26.4" }, { name = "pre-commit", marker = "extra == 'dev'", specifier = "==3.6.0" }, @@ -798,6 +814,9 @@ requires-dist = [ ] provides-extras = ["dev"] +[package.metadata.requires-dev] +dev = [{ name = "marimo", specifier = ">=0.18.4" }] + [[package]] name = "geobench" version = "1.0.0" @@ -1246,6 +1265,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/7b/55/e5326141505c5d5e34c5e0935d2908a74e4561eca44108fbfb9c13d2911a/isoduration-20.11.0-py3-none-any.whl", hash = "sha256:b2904c2a4228c3d44f409c8ae8e2370eb21a26f7ac2ec5446df141dde3452042", size = 11321, upload-time = "2020-11-01T10:59:58.02Z" }, ] +[[package]] +name = "itsdangerous" +version = "2.2.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/9c/cb/8ac0172223afbccb63986cc25049b154ecfb5e85932587206f42317be31d/itsdangerous-2.2.0.tar.gz", hash = "sha256:e0050c0b7da1eea53ffaf149c0cfbb5c6e2e2b69c4bef22c81fa6eb73e5f6173", size = 54410, upload-time = "2024-04-16T21:28:15.614Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/04/96/92447566d16df59b2a776c0fb82dbc4d9e07cd95062562af01e408583fc4/itsdangerous-2.2.0-py3-none-any.whl", hash = "sha256:c6242fc49e35958c8b15141343aa660db5fc54d4f13a1db01a3f5891b98700ef", size = 16234, upload-time = "2024-04-16T21:28:14.499Z" }, +] + [[package]] name = "jedi" version = "0.19.2" @@ -1604,6 +1632,112 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/82/3d/14ce75ef66813643812f3093ab17e46d3a206942ce7376d31ec2d36229e7/lark-1.3.1-py3-none-any.whl", hash = "sha256:c629b661023a014c37da873b4ff58a817398d12635d3bbb2c5a03be7fe5d1e12", size = 113151, upload-time = "2025-10-27T18:25:54.882Z" }, ] +[[package]] +name = "loro" +version = "1.10.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/7d/27/ea6f3298fc87ea5f2d60ebfbca088e7d9b2ceb3993f67c83bfb81778ec01/loro-1.10.3.tar.gz", hash = "sha256:68184ab1c2ab94af6ad4aaba416d22f579cabee0b26cbb09a1f67858207bbce8", size = 68833, upload-time = "2025-12-09T10:14:06.644Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b1/af/517956be7153d3450263f35ca70b1d7845b404e197045274db07b869e26f/loro-1.10.3-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:7e7e3461439c57efaadfd364a5a504a849653cf408c97086033004dffb3f2857", size = 3258650, upload-time = "2025-12-09T10:11:29.657Z" }, + { url = "https://files.pythonhosted.org/packages/0d/a4/8a44499630922af97359971ab01738f568319cbfa5045830eda7393cc758/loro-1.10.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:ed91dae34236f888c357b367d37b050ac4fa21ff30ab0231122f580ca87f46ba", size = 3061526, upload-time = "2025-12-09T10:11:14.823Z" }, + { url = "https://files.pythonhosted.org/packages/bb/93/2088ca72f21fbf59bd31a847a6fd989038dcf4179166e829631482410336/loro-1.10.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c5d417a99bae161ecb1250f3272a80c87f2ae546dfb705cadac3ebbc623b7382", size = 3287817, upload-time = "2025-12-09T10:08:11.002Z" }, + { url = "https://files.pythonhosted.org/packages/4a/72/136fbb2077a0fc92f97e94dc88f48bf515fab034b218d007afcede08eed5/loro-1.10.3-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:4a9b821925c9051ee2653a519a99b1d2fc1177a4bac1f02b1f8eaec491f6d43b", size = 3349471, upload-time = "2025-12-09T10:08:45.441Z" }, + { url = "https://files.pythonhosted.org/packages/91/ab/6b484590ffcb2997a5f163ff26641c8ea9738cacb883f4aa3669dd720433/loro-1.10.3-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:0ee8982a6b82660165e516932cda0e5fd7065023f35ae5e2d17562cf14969e87", size = 3708083, upload-time = "2025-12-09T10:09:23.623Z" }, + { url = "https://files.pythonhosted.org/packages/ba/7f/b44b0a6228d8f2aad70d8d93c4dc29d72ff4da223cd054c56dbdde9cada5/loro-1.10.3-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cd391a27550dcf837c82d8ae4e420b4d3b16bdc5a698c3862540803a16bf52dd", size = 3416777, upload-time = "2025-12-09T10:09:57.794Z" }, + { url = "https://files.pythonhosted.org/packages/53/ad/df58cc6c7168fa4859ba16a447131a0212a07b68fa0250898be132fef365/loro-1.10.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e74235d480c6e9b362c6f2265a7d28dd848e6a6142a3c9d0831b82cf3776efee", size = 3347414, upload-time = "2025-12-09T10:10:51.95Z" }, + { url = "https://files.pythonhosted.org/packages/78/90/3d5bb124d4d333824779fd09b25026876b9670c09e5a384760abc7bc863a/loro-1.10.3-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:df7baf726db4e82f411f7a0454500047812f41bef9552109cb738b8f6ee89c9f", size = 3688343, upload-time = "2025-12-09T10:10:30.393Z" }, + { url = "https://files.pythonhosted.org/packages/74/01/c78b11ef4ecdbffb1236cdf2f010f89b4a9ad77554e67513aa88cd2280f4/loro-1.10.3-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:112d5eeaf76ca6dfbe811e6f6d18649ceeb7697626288ed1185bd1a7d4aae182", size = 3468739, upload-time = "2025-12-09T10:11:46.654Z" }, + { url = "https://files.pythonhosted.org/packages/0b/26/27123477c458c7e2f26da58d346efab87bb1dbf8f082ed3663cdb8b87581/loro-1.10.3-cp310-cp310-musllinux_1_2_armv7l.whl", hash = "sha256:a2cbc231a07f11b82099b76386b1e5659687f4415d6f111699bbd4f291c945a4", size = 3618995, upload-time = "2025-12-09T10:12:22.466Z" }, + { url = "https://files.pythonhosted.org/packages/15/de/41d21b38d55685715ae6dd7c390dcd29521669ee7e7b8246e6cec71f480d/loro-1.10.3-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:dbf31ae00bae9c76a4429f73cec3fb3000f1b4d41603244793c660e17747ce1f", size = 3666508, upload-time = "2025-12-09T10:12:57.538Z" }, + { url = "https://files.pythonhosted.org/packages/38/94/4a8016e5d6400994a82834369aabfaa40cfb62b1f8f40c17bfc3e76ecff7/loro-1.10.3-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:98d8855a94e2123dab0e40fb5ac7760edbb9b87cd4b29608327899874721ed0b", size = 3558656, upload-time = "2025-12-09T10:13:32.685Z" }, + { url = "https://files.pythonhosted.org/packages/e1/f7/85bb7f6c953b078d74bbb0ec9bb161482c27dde49ed979ddea55c40aafd8/loro-1.10.3-cp310-cp310-win32.whl", hash = "sha256:b539f86cf5e44ad7eefd05772ec637985fddd31137deadca508cd8f3bad211a9", size = 2722340, upload-time = "2025-12-09T10:14:25.47Z" }, + { url = "https://files.pythonhosted.org/packages/ae/94/d7ef82e9698671f7529ba56b447b546312edcb40dadd4c71af25ea499033/loro-1.10.3-cp310-cp310-win_amd64.whl", hash = "sha256:a5da9963be9a323424695c04d9be836577705077a359d1bb4cabd43963ed2600", size = 2952931, upload-time = "2025-12-09T10:14:07.521Z" }, + { url = "https://files.pythonhosted.org/packages/7d/bb/61f36aac7981f84ffba922ac1220505365df3e064bc91c015790bff92007/loro-1.10.3-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:7ee0e1c9a6d0e4a1df4f1847d3b31cef8088860c1193442f131936d084bd3fe1", size = 3254532, upload-time = "2025-12-09T10:11:31.215Z" }, + { url = "https://files.pythonhosted.org/packages/15/28/5708da252eb6be90131338b104e5030c9b815c41f9e97647391206bec092/loro-1.10.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:d7225471b29a892a10589d7cf59c70b0e4de502fa20da675e9aaa1060c7703ae", size = 3055231, upload-time = "2025-12-09T10:11:16.111Z" }, + { url = "https://files.pythonhosted.org/packages/16/b6/68c350a39fd96f24c55221f883230aa83db0bb5f5d8e9776ccdb25ea1f7b/loro-1.10.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fc04a714e0a604e191279501fa4d2db3b39cee112275f31e87d95ecfbafdfb6c", size = 3286945, upload-time = "2025-12-09T10:08:12.633Z" }, + { url = "https://files.pythonhosted.org/packages/23/af/8245b8a20046423e035cd17de9811ab1b27fc9e73425394c34387b41cc13/loro-1.10.3-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:375c888a4ddf758b034eb6ebd093348547d17364fae72aa7459d1358e4843b1f", size = 3349533, upload-time = "2025-12-09T10:08:46.754Z" }, + { url = "https://files.pythonhosted.org/packages/cc/8c/d764c60914e45a2b8c562e01792172e3991430103c019cc129d56c24c868/loro-1.10.3-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:2020d9384a426e91a7d38c9d0befd42e8ad40557892ed50d47aad79f8d92b654", size = 3704622, upload-time = "2025-12-09T10:09:25.068Z" }, + { url = "https://files.pythonhosted.org/packages/54/cc/ebdbdf0b1c7a223fe84fc0de78678904ed6424b426f90b98503b95b1dff9/loro-1.10.3-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:95afacd832dce152700c2bc643f7feb27d5611fc97b5141684b5831b22845380", size = 3416659, upload-time = "2025-12-09T10:09:59.107Z" }, + { url = "https://files.pythonhosted.org/packages/fa/bc/db7f3fc619483b60c03d85b4f9bb5812b2229865b574c8802b46a578f545/loro-1.10.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7c95868bcf6361d700e215f33a88b8f51d7bc3ae7bbe3d35998148932e23d3fa", size = 3345007, upload-time = "2025-12-09T10:10:53.327Z" }, + { url = "https://files.pythonhosted.org/packages/91/65/bcd3b1d3a3615e679177c1256f2e0ff7ee242c3d5d1b9cb725b0ec165b51/loro-1.10.3-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:68f5c7fad09d8937ef4b55e7dd4a0f9f175f026369b3f55a5b054d3513f6846d", size = 3687874, upload-time = "2025-12-09T10:10:31.674Z" }, + { url = "https://files.pythonhosted.org/packages/3a/e4/0d51e2da2ae6143bfd03f7127b9daf58a3f8dae9d5ca7740ccba63a04de4/loro-1.10.3-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:740bb548139d71eccd6317f3df40a0dc5312e98bbb2be09a6e4aaddcaf764206", size = 3467200, upload-time = "2025-12-09T10:11:47.994Z" }, + { url = "https://files.pythonhosted.org/packages/06/99/ada2baeaf6496e34962fe350cd41129e583219bf4ce5e680c37baa0613a8/loro-1.10.3-cp311-cp311-musllinux_1_2_armv7l.whl", hash = "sha256:c756a6ee37ed851e9cf91e5fedbc68ca21e05969c4e2ec6531c15419a4649b58", size = 3618468, upload-time = "2025-12-09T10:12:24.182Z" }, + { url = "https://files.pythonhosted.org/packages/87/ec/83335935959c5e3946e02b748af71d801412b2aa3876f870beae1cd56d4d/loro-1.10.3-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:3553390518e188c055b56bcbae76bf038329f9c3458cb1d69068c55b3f8f49f1", size = 3666852, upload-time = "2025-12-09T10:12:59.117Z" }, + { url = "https://files.pythonhosted.org/packages/9f/53/1bd455b3254afa35638d617e06c65a22e604b1fae2f494abb9a621c8e69b/loro-1.10.3-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:0885388c0c2b53f5140229921bd64c7838827e3101a05d4d53346191ba76b15d", size = 3556829, upload-time = "2025-12-09T10:13:34.002Z" }, + { url = "https://files.pythonhosted.org/packages/66/30/6f48726ef50f911751c6b69d7fa81482cac70d4ed817216f846776fec28c/loro-1.10.3-cp311-cp311-win32.whl", hash = "sha256:764b68c4ff0411399c9cf936d8b6db1161ec445388ff2944a25bbdeb2bbac15c", size = 2723776, upload-time = "2025-12-09T10:14:27.261Z" }, + { url = "https://files.pythonhosted.org/packages/69/39/0b08203d94a6f200bbfefa8025a1b825c8cfb30e8cc8b2a1224629150d08/loro-1.10.3-cp311-cp311-win_amd64.whl", hash = "sha256:9e583e6aabd6f9b2bdf3ff3f6e0de10c3f7f8ab9d4c05c01a9ecca309c969017", size = 2950529, upload-time = "2025-12-09T10:14:08.857Z" }, + { url = "https://files.pythonhosted.org/packages/dd/b6/cfbf8088e8ca07d66e6c1eccde42e00bd61708f28e8ea0936f9582306323/loro-1.10.3-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:028948b48dcc5c2127f974dae4ad466ab69f0d1eeaf367a8145eb6501fb988f2", size = 3239592, upload-time = "2025-12-09T10:11:32.505Z" }, + { url = "https://files.pythonhosted.org/packages/78/e4/7b614260bf16c5e33c0bea6ac47ab0284efd21f89f2e5e4e15cd93bead40/loro-1.10.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:5253b8f436d90412b373c583f22ac9539cfb495bf88f78d4bb41daafef0830b7", size = 3045107, upload-time = "2025-12-09T10:11:17.481Z" }, + { url = "https://files.pythonhosted.org/packages/ae/17/0a78ec341ca69d376629ff2a1b9b3511ee7dd54f2b018616ef03328024f7/loro-1.10.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:14be8a5539d49468c94d65742355dbe79745123d78bf769a23e53bf9b60dd46a", size = 3292720, upload-time = "2025-12-09T10:08:14.027Z" }, + { url = "https://files.pythonhosted.org/packages/d4/9b/f36a4654508e9b8ddbe08a62a0ce8b8e7fd511a39b161821917530cffd8e/loro-1.10.3-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:91b2b9139dfc5314a0197132a53b6673fddb63738380a522d12a05cec7ad76b4", size = 3353260, upload-time = "2025-12-09T10:08:48.251Z" }, + { url = "https://files.pythonhosted.org/packages/b4/0e/7d441ddecc7695153dbe68af4067d62e8d7607fce3747a184878456a91f6/loro-1.10.3-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:247897288911c712ee7746965573299fc23ce091e94456da8da371e6adae30f4", size = 3712354, upload-time = "2025-12-09T10:09:26.38Z" }, + { url = "https://files.pythonhosted.org/packages/1c/33/10e66bb84599e61df124f76c00c5398eb59cbb6f69755f81c40f65a18344/loro-1.10.3-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:835abc6025eb5b6a0fe22c808472affc95e9a661b212400cfd88ba186b0d304c", size = 3422926, upload-time = "2025-12-09T10:10:00.347Z" }, + { url = "https://files.pythonhosted.org/packages/b2/70/00dc4246d9f3c69ecbb9bc36d5ad1a359884464a44711c665cb0afb1e9de/loro-1.10.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e660853617fc29e71bb7b796e6f2c21f7722c215f593a89e95cd4d8d5a32aca0", size = 3353092, upload-time = "2025-12-09T10:10:55.786Z" }, + { url = "https://files.pythonhosted.org/packages/19/37/60cc0353c5702e1e469b5d49d1762e782af5d5bd5e7c4e8c47556335b4c6/loro-1.10.3-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:8059063cab57ca521012ed315a454784c20b0a86653e9014795e804e0a333659", size = 3687798, upload-time = "2025-12-09T10:10:33.253Z" }, + { url = "https://files.pythonhosted.org/packages/88/c4/4db1887eb08dfbb305d9424fdf1004c0edf147fd53ab0aaf64a90450567a/loro-1.10.3-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:9748359343b5fd7019ab3c2d1d583a0c13c633a4dd21d75e50e3815ab479f493", size = 3474451, upload-time = "2025-12-09T10:11:49.489Z" }, + { url = "https://files.pythonhosted.org/packages/d8/66/10d2e00c43b05f56e96e62100f86a1261f8bbd6422605907f118a752fe61/loro-1.10.3-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:def7c9c2e16ad5470c9c56f096ac649dd4cd42d5936a32bb0817509a92d82467", size = 3621647, upload-time = "2025-12-09T10:12:25.536Z" }, + { url = "https://files.pythonhosted.org/packages/47/f0/ef8cd6654b09a03684195c650b1fba00f42791fa4844ea400d94030c5615/loro-1.10.3-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:34b223fab58591a823f439d9a13d1a1ddac18dc4316866503c588ae8a9147cb1", size = 3667946, upload-time = "2025-12-09T10:13:00.711Z" }, + { url = "https://files.pythonhosted.org/packages/bb/5d/960b62bf85c38d6098ea067438f037a761958f3a17ba674db0cf316b0f60/loro-1.10.3-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:9d5fa4baceb248d771897b76d1426c7656176e82e770f6790940bc3e3812436d", size = 3565866, upload-time = "2025-12-09T10:13:35.401Z" }, + { url = "https://files.pythonhosted.org/packages/8f/d4/0d499a5e00df13ce497263aef2494d9de9e9d1f11d8ab68f89328203befb/loro-1.10.3-cp312-cp312-win32.whl", hash = "sha256:f25ab769b84a5fbeb1f9a1111f5d28927eaeaa8f5d2d871e237f80eaca5c684e", size = 2720785, upload-time = "2025-12-09T10:14:28.79Z" }, + { url = "https://files.pythonhosted.org/packages/1a/9b/2b5be23f1da4cf20c6ce213cfffc66bdab2ea012595abc9e3383103793d0/loro-1.10.3-cp312-cp312-win_amd64.whl", hash = "sha256:3b73b7a3a32e60c3424fc7deaf8b127af7580948e27d8bbe749e3f43508aa0a2", size = 2954650, upload-time = "2025-12-09T10:14:10.235Z" }, + { url = "https://files.pythonhosted.org/packages/2d/12/0ec38fe0a1fa6b8e76989bbbbf22bdd34f8824ce6934c97f94ca50dba49c/loro-1.10.3-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:55214615c1cb9f727a5278f5e57b9660743e7d095e08899e8936f174a45471b9", size = 3284859, upload-time = "2025-12-09T10:08:24.621Z" }, + { url = "https://files.pythonhosted.org/packages/c1/26/c01691a85fe1047dcc0398054124069af92b8ce1602eaabbe9b7e0fac1f1/loro-1.10.3-pp310-pypy310_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:10591fa32dc628f770da472beac7544d2ba16a3a22d590211364331c5871b9f6", size = 3349886, upload-time = "2025-12-09T10:09:01.286Z" }, + { url = "https://files.pythonhosted.org/packages/53/35/3fcd13a2ae7686b467b5210b991e1682576a4be7e121bc9f8690c3d59929/loro-1.10.3-pp310-pypy310_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f18df6892097603e5bd2e149384d4bcb996be8a3b6ba10d3da74bce39e1d5093", size = 3703226, upload-time = "2025-12-09T10:09:36.464Z" }, + { url = "https://files.pythonhosted.org/packages/b1/47/52ce515ac76893f57ed071bb1d5cd3687a059cf1e81e66535364b9581ed6/loro-1.10.3-pp310-pypy310_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:0a8911b8cd97652a04e22481dd90b3c8d286f12c8d8286a4e34a655835dd6506", size = 3413121, upload-time = "2025-12-09T10:10:09.528Z" }, + { url = "https://files.pythonhosted.org/packages/e5/1c/39f39e731d3af9c387e4238bd8da8e545e16922524bc0bca991d3ce475e1/loro-1.10.3-pp310-pypy310_pp73-musllinux_1_2_aarch64.whl", hash = "sha256:73d5737c95bccf725950555c51374e5823c9be16bfc5496d8c1fafb2bb04690f", size = 3466280, upload-time = "2025-12-09T10:11:59.889Z" }, + { url = "https://files.pythonhosted.org/packages/54/f9/b85b76b882f1e62da461552157b061dd79c52c59afd8074969f04fb32a2c/loro-1.10.3-pp310-pypy310_pp73-musllinux_1_2_armv7l.whl", hash = "sha256:fa875a691556daaedb639dc920ee9c3743745eea2aa4c7fd914841e31b92c556", size = 3617971, upload-time = "2025-12-09T10:12:36.704Z" }, + { url = "https://files.pythonhosted.org/packages/90/1a/ef79aa94144453157bc139e341b983640fcda70bf2e8fdc6120773f210a0/loro-1.10.3-pp310-pypy310_pp73-musllinux_1_2_i686.whl", hash = "sha256:e7ddfd247fa3ae3c05d38019fb1424a903ea98e5730a10105081f5f7dc08f9c1", size = 3663111, upload-time = "2025-12-09T10:13:11.173Z" }, + { url = "https://files.pythonhosted.org/packages/96/b4/ca47f1b4b926a4b0dd3a7d7f0edd46a63e74b64c2b628c0463f25f0f1dd2/loro-1.10.3-pp310-pypy310_pp73-musllinux_1_2_x86_64.whl", hash = "sha256:033a456647d487d61af82ea96aff95a789a3776441ea8af86556f2877867530d", size = 3554651, upload-time = "2025-12-09T10:13:46.496Z" }, + { url = "https://files.pythonhosted.org/packages/43/1a/49e864102721e0e15a4e4c56d7f2dddad5cd589c2d0aceafe14990513583/loro-1.10.3-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:16ca42e991589ea300b59da9e98940d5ddda76275fe4363b1f1e079d244403a1", size = 3284236, upload-time = "2025-12-09T10:08:25.836Z" }, + { url = "https://files.pythonhosted.org/packages/e9/c6/d46b433105d8002e4c90248c07f00cd2c8ea76f1048cc5f35b733be96723/loro-1.10.3-pp311-pypy311_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:b9ca16dae359397aa7772891bb3967939ffda8da26e0b392d331b506e16afc78", size = 3348996, upload-time = "2025-12-09T10:09:03.951Z" }, + { url = "https://files.pythonhosted.org/packages/e7/f3/e918c7b396c547b22a7ab3cff1b570c5ce94293f0dcb17cd96cbe6ba2d50/loro-1.10.3-pp311-pypy311_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d87cfc0a6e119c1c8cfa93078f5d012e557c6b75edcd0977da58ec46d28dc242", size = 3701875, upload-time = "2025-12-09T10:09:37.924Z" }, + { url = "https://files.pythonhosted.org/packages/4c/67/140ecb65b4f436099ad674fbe7502378156f43b737cb43f5fd76c42a0da8/loro-1.10.3-pp311-pypy311_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4541ed987306c51e718f51196fd2b2d05e87b323da5d850b37900d2e8ac6aae6", size = 3412283, upload-time = "2025-12-09T10:10:10.946Z" }, + { url = "https://files.pythonhosted.org/packages/d0/93/b7b41cf8b3e591b7191494e12be24cbb101f137fe82f0a24ed7934bbacf3/loro-1.10.3-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ce0b0a500e08b190038380d4593efcb33c98ed4282cc8347ca6ce55d05cbdf6e", size = 3340580, upload-time = "2025-12-09T10:11:02.956Z" }, + { url = "https://files.pythonhosted.org/packages/94/19/fdc9ea9ce6510147460200c90164a84c22b0cc9e33f7dd5c0d5f76484314/loro-1.10.3-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:987dbcb42b4b8d2c799660a6d8942e53ae346f51d51c9ad7ef5d7e640422fe4a", size = 3680924, upload-time = "2025-12-09T10:10:39.877Z" }, + { url = "https://files.pythonhosted.org/packages/40/61/548491499394fe02e7451b0d7367f7eeed32f0f6dd8f1826be8b4c329f28/loro-1.10.3-pp311-pypy311_pp73-musllinux_1_2_aarch64.whl", hash = "sha256:f876d477cb38c6c623c4ccb5dc4b7041dbeff04167bf9c19fa461d57a3a1b916", size = 3465033, upload-time = "2025-12-09T10:12:03.122Z" }, + { url = "https://files.pythonhosted.org/packages/26/68/d8bebb6b583fe5a3dc4da32c9070964548e3ca1d524f383c71f9becf4197/loro-1.10.3-pp311-pypy311_pp73-musllinux_1_2_armv7l.whl", hash = "sha256:641c8445bd1e4181b5b28b75a0bc544ef51f065b15746e8714f90e2e029b5202", size = 3616740, upload-time = "2025-12-09T10:12:38.187Z" }, + { url = "https://files.pythonhosted.org/packages/52/9b/8f8ecc85eb925122a79348eb77ff7109a7ee41ee7d1a282122be2daff378/loro-1.10.3-pp311-pypy311_pp73-musllinux_1_2_i686.whl", hash = "sha256:a6ab6244472402b8d1f4f77e5210efa44dfa4914423cafcfcbd09232ea8bbff0", size = 3661160, upload-time = "2025-12-09T10:13:12.513Z" }, + { url = "https://files.pythonhosted.org/packages/79/3c/e884d06859f9a9fc64afd21c426b9d681af0856181c1fe66571a65d35ef7/loro-1.10.3-pp311-pypy311_pp73-musllinux_1_2_x86_64.whl", hash = "sha256:ae4c765671ee7d7618962ec11cb3bb471965d9b88c075166fe383263235d58d6", size = 3553653, upload-time = "2025-12-09T10:13:47.917Z" }, +] + +[[package]] +name = "marimo" +version = "0.18.4" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "click" }, + { name = "docutils" }, + { name = "itsdangerous" }, + { name = "jedi" }, + { name = "loro", marker = "python_full_version >= '3.11'" }, + { name = "markdown" }, + { name = "msgspec" }, + { name = "narwhals" }, + { name = "packaging" }, + { name = "psutil" }, + { name = "pygments" }, + { name = "pymdown-extensions" }, + { name = "pyyaml" }, + { name = "starlette" }, + { name = "tomlkit" }, + { name = "typing-extensions", marker = "python_full_version < '3.11'" }, + { name = "uvicorn" }, + { name = "websockets" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/04/dc/46cdff84f6a92847bada01ba20cfa79e3c77d1f39a7627f35855ab5451ad/marimo-0.18.4.tar.gz", hash = "sha256:30b5d8cd8f3e9054b5f7332bf0f4d11cb608712995e4f4feed7337d118eef8ab", size = 37851688, upload-time = "2025-12-09T17:42:44.82Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/60/c7/cd3b652650c188d7b1d7cefad8194d51f10600c84e5d1b68be8d6f0b40ba/marimo-0.18.4-py3-none-any.whl", hash = "sha256:7c1d72f37e9662e8811eff801f6c85451af685fe1cbd22c49a85e7b1f57aebec", size = 38369689, upload-time = "2025-12-09T17:42:48.972Z" }, +] + +[[package]] +name = "markdown" +version = "3.10" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/7d/ab/7dd27d9d863b3376fcf23a5a13cb5d024aed1db46f963f1b5735ae43b3be/markdown-3.10.tar.gz", hash = "sha256:37062d4f2aa4b2b6b32aefb80faa300f82cc790cb949a35b8caede34f2b68c0e", size = 364931, upload-time = "2025-11-03T19:51:15.007Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/70/81/54e3ce63502cd085a0c556652a4e1b919c45a446bd1e5300e10c44c8c521/markdown-3.10-py3-none-any.whl", hash = "sha256:b5b99d6951e2e4948d939255596523444c0e677c669700b1d17aa4a8a464cb7c", size = 107678, upload-time = "2025-11-03T19:51:13.887Z" }, +] + [[package]] name = "markupsafe" version = "3.0.3" @@ -1716,6 +1850,38 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/43/e3/7d92a15f894aa0c9c4b49b8ee9ac9850d6e63b03c9c32c0367a13ae62209/mpmath-1.3.0-py3-none-any.whl", hash = "sha256:a0b2b9fe80bbcd81a6647ff13108738cfb482d481d826cc0e02f5b35e5c88d2c", size = 536198, upload-time = "2023-03-07T16:47:09.197Z" }, ] +[[package]] +name = "msgspec" +version = "0.20.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/ea/9c/bfbd12955a49180cbd234c5d29ec6f74fe641698f0cd9df154a854fc8a15/msgspec-0.20.0.tar.gz", hash = "sha256:692349e588fde322875f8d3025ac01689fead5901e7fb18d6870a44519d62a29", size = 317862, upload-time = "2025-11-24T03:56:28.934Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e3/5e/151883ba2047cca9db8ed2f86186b054ad200bc231352df15b0c1dd75b1f/msgspec-0.20.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:23a6ec2a3b5038c233b04740a545856a068bc5cb8db184ff493a58e08c994fbf", size = 195191, upload-time = "2025-11-24T03:55:08.549Z" }, + { url = "https://files.pythonhosted.org/packages/50/88/a795647672f547c983eff0823b82aaa35db922c767e1b3693e2dcf96678d/msgspec-0.20.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:cde2c41ed3eaaef6146365cb0d69580078a19f974c6cb8165cc5dcd5734f573e", size = 188513, upload-time = "2025-11-24T03:55:10.008Z" }, + { url = "https://files.pythonhosted.org/packages/4b/91/eb0abb0e0de142066cebfe546dc9140c5972ea824aa6ff507ad0b6a126ac/msgspec-0.20.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:5da0daa782f95d364f0d95962faed01e218732aa1aa6cad56b25a5d2092e75a4", size = 216370, upload-time = "2025-11-24T03:55:11.566Z" }, + { url = "https://files.pythonhosted.org/packages/15/2a/48e41d9ef0a24b1c6e67cbd94a676799e0561bfbc163be1aaaff5ca853f5/msgspec-0.20.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:9369d5266144bef91be2940a3821e03e51a93c9080fde3ef72728c3f0a3a8bb7", size = 222653, upload-time = "2025-11-24T03:55:13.159Z" }, + { url = "https://files.pythonhosted.org/packages/90/c9/14b825df203d980f82a623450d5f39e7f7a09e6e256c52b498ea8f29d923/msgspec-0.20.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:90fb865b306ca92c03964a5f3d0cd9eb1adda14f7e5ac7943efd159719ea9f10", size = 222337, upload-time = "2025-11-24T03:55:14.777Z" }, + { url = "https://files.pythonhosted.org/packages/8b/d7/39a5c3ddd294f587d6fb8efccc8361b6aa5089974015054071e665c9d24b/msgspec-0.20.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:e8112cd48b67dfc0cfa49fc812b6ce7eb37499e1d95b9575061683f3428975d3", size = 225565, upload-time = "2025-11-24T03:55:16.4Z" }, + { url = "https://files.pythonhosted.org/packages/98/bd/5db3c14d675ee12842afb9b70c94c64f2c873f31198c46cbfcd7dffafab0/msgspec-0.20.0-cp310-cp310-win_amd64.whl", hash = "sha256:666b966d503df5dc27287675f525a56b6e66a2b8e8ccd2877b0c01328f19ae6c", size = 188412, upload-time = "2025-11-24T03:55:17.747Z" }, + { url = "https://files.pythonhosted.org/packages/76/c7/06cc218bc0c86f0c6c6f34f7eeea6cfb8b835070e8031e3b0ef00f6c7c69/msgspec-0.20.0-cp310-cp310-win_arm64.whl", hash = "sha256:099e3e85cd5b238f2669621be65f0728169b8c7cb7ab07f6137b02dc7feea781", size = 173951, upload-time = "2025-11-24T03:55:19.335Z" }, + { url = "https://files.pythonhosted.org/packages/03/59/fdcb3af72f750a8de2bcf39d62ada70b5eb17b06d7f63860e0a679cb656b/msgspec-0.20.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:09e0efbf1ac641fedb1d5496c59507c2f0dc62a052189ee62c763e0aae217520", size = 193345, upload-time = "2025-11-24T03:55:20.613Z" }, + { url = "https://files.pythonhosted.org/packages/5a/15/3c225610da9f02505d37d69a77f4a2e7daae2a125f99d638df211ba84e59/msgspec-0.20.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:23ee3787142e48f5ee746b2909ce1b76e2949fbe0f97f9f6e70879f06c218b54", size = 186867, upload-time = "2025-11-24T03:55:22.4Z" }, + { url = "https://files.pythonhosted.org/packages/81/36/13ab0c547e283bf172f45491edfdea0e2cecb26ae61e3a7b1ae6058b326d/msgspec-0.20.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:81f4ac6f0363407ac0465eff5c7d4d18f26870e00674f8fcb336d898a1e36854", size = 215351, upload-time = "2025-11-24T03:55:23.958Z" }, + { url = "https://files.pythonhosted.org/packages/6b/96/5c095b940de3aa6b43a71ec76275ac3537b21bd45c7499b5a17a429110fa/msgspec-0.20.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:bb4d873f24ae18cd1334f4e37a178ed46c9d186437733351267e0a269bdf7e53", size = 219896, upload-time = "2025-11-24T03:55:25.356Z" }, + { url = "https://files.pythonhosted.org/packages/98/7a/81a7b5f01af300761087b114dafa20fb97aed7184d33aab64d48874eb187/msgspec-0.20.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:b92b8334427b8393b520c24ff53b70f326f79acf5f74adb94fd361bcff8a1d4e", size = 220389, upload-time = "2025-11-24T03:55:26.99Z" }, + { url = "https://files.pythonhosted.org/packages/70/c0/3d0cce27db9a9912421273d49eab79ce01ecd2fed1a2f1b74af9b445f33c/msgspec-0.20.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:562c44b047c05cc0384e006fae7a5e715740215c799429e0d7e3e5adf324285a", size = 223348, upload-time = "2025-11-24T03:55:28.311Z" }, + { url = "https://files.pythonhosted.org/packages/89/5e/406b7d578926b68790e390d83a1165a9bfc2d95612a1a9c1c4d5c72ea815/msgspec-0.20.0-cp311-cp311-win_amd64.whl", hash = "sha256:d1dcc93a3ce3d3195985bfff18a48274d0b5ffbc96fa1c5b89da6f0d9af81b29", size = 188713, upload-time = "2025-11-24T03:55:29.553Z" }, + { url = "https://files.pythonhosted.org/packages/47/87/14fe2316624ceedf76a9e94d714d194cbcb699720b210ff189f89ca4efd7/msgspec-0.20.0-cp311-cp311-win_arm64.whl", hash = "sha256:aa387aa330d2e4bd69995f66ea8fdc87099ddeedf6fdb232993c6a67711e7520", size = 174229, upload-time = "2025-11-24T03:55:31.107Z" }, + { url = "https://files.pythonhosted.org/packages/d9/6f/1e25eee957e58e3afb2a44b94fa95e06cebc4c236193ed0de3012fff1e19/msgspec-0.20.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:2aba22e2e302e9231e85edc24f27ba1f524d43c223ef5765bd8624c7df9ec0a5", size = 196391, upload-time = "2025-11-24T03:55:32.677Z" }, + { url = "https://files.pythonhosted.org/packages/7f/ee/af51d090ada641d4b264992a486435ba3ef5b5634bc27e6eb002f71cef7d/msgspec-0.20.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:716284f898ab2547fedd72a93bb940375de9fbfe77538f05779632dc34afdfde", size = 188644, upload-time = "2025-11-24T03:55:33.934Z" }, + { url = "https://files.pythonhosted.org/packages/49/d6/9709ee093b7742362c2934bfb1bbe791a1e09bed3ea5d8a18ce552fbfd73/msgspec-0.20.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:558ed73315efa51b1538fa8f1d3b22c8c5ff6d9a2a62eff87d25829b94fc5054", size = 218852, upload-time = "2025-11-24T03:55:35.575Z" }, + { url = "https://files.pythonhosted.org/packages/5c/a2/488517a43ccf5a4b6b6eca6dd4ede0bd82b043d1539dd6bb908a19f8efd3/msgspec-0.20.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:509ac1362a1d53aa66798c9b9fd76872d7faa30fcf89b2fba3bcbfd559d56eb0", size = 224937, upload-time = "2025-11-24T03:55:36.859Z" }, + { url = "https://files.pythonhosted.org/packages/d5/e8/49b832808aa23b85d4f090d1d2e48a4e3834871415031ed7c5fe48723156/msgspec-0.20.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:1353c2c93423602e7dea1aa4c92f3391fdfc25ff40e0bacf81d34dbc68adb870", size = 222858, upload-time = "2025-11-24T03:55:38.187Z" }, + { url = "https://files.pythonhosted.org/packages/9f/56/1dc2fa53685dca9c3f243a6cbecd34e856858354e455b77f47ebd76cf5bf/msgspec-0.20.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:cb33b5eb5adb3c33d749684471c6a165468395d7aa02d8867c15103b81e1da3e", size = 227248, upload-time = "2025-11-24T03:55:39.496Z" }, + { url = "https://files.pythonhosted.org/packages/5a/51/aba940212c23b32eedce752896205912c2668472ed5b205fc33da28a6509/msgspec-0.20.0-cp312-cp312-win_amd64.whl", hash = "sha256:fb1d934e435dd3a2b8cf4bbf47a8757100b4a1cfdc2afdf227541199885cdacb", size = 190024, upload-time = "2025-11-24T03:55:40.829Z" }, + { url = "https://files.pythonhosted.org/packages/41/ad/3b9f259d94f183daa9764fef33fdc7010f7ecffc29af977044fa47440a83/msgspec-0.20.0-cp312-cp312-win_arm64.whl", hash = "sha256:00648b1e19cf01b2be45444ba9dc961bd4c056ffb15706651e64e5d6ec6197b7", size = 175390, upload-time = "2025-11-24T03:55:42.05Z" }, +] + [[package]] name = "mypy" version = "1.8.0" @@ -1754,6 +1920,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/79/7b/2c79738432f5c924bef5071f933bcc9efd0473bac3b4aa584a6f7c1c8df8/mypy_extensions-1.1.0-py3-none-any.whl", hash = "sha256:1be4cccdb0f2482337c4743e60421de3a356cd97508abadd57d47403e94f5505", size = 4963, upload-time = "2025-04-22T14:54:22.983Z" }, ] +[[package]] +name = "narwhals" +version = "2.14.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/4a/84/897fe7b6406d436ef312e57e5a1a13b4a5e7e36d1844e8d934ce8880e3d3/narwhals-2.14.0.tar.gz", hash = "sha256:98be155c3599db4d5c211e565c3190c398c87e7bf5b3cdb157dece67641946e0", size = 600648, upload-time = "2025-12-16T11:29:13.458Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/79/3e/b8ecc67e178919671695f64374a7ba916cf0adbf86efedc6054f38b5b8ae/narwhals-2.14.0-py3-none-any.whl", hash = "sha256:b56796c9a00179bd757d15282c540024e1d5c910b19b8c9944d836566c030acf", size = 430788, upload-time = "2025-12-16T11:29:11.699Z" }, +] + [[package]] name = "nbclient" version = "0.10.2" @@ -2293,6 +2468,19 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/c7/21/705964c7812476f378728bdf590ca4b771ec72385c533964653c68e86bdc/pygments-2.19.2-py3-none-any.whl", hash = "sha256:86540386c03d588bb81d44bc3928634ff26449851e99741617ecb9037ee5ec0b", size = 1225217, upload-time = "2025-06-21T13:39:07.939Z" }, ] +[[package]] +name = "pymdown-extensions" +version = "10.19.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "markdown" }, + { name = "pyyaml" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/72/2d/9f30cee56d4d6d222430d401e85b0a6a1ae229819362f5786943d1a8c03b/pymdown_extensions-10.19.1.tar.gz", hash = "sha256:4969c691009a389fb1f9712dd8e7bd70dcc418d15a0faf70acb5117d022f7de8", size = 847839, upload-time = "2025-12-14T17:25:24.42Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/fb/35/b763e8fbcd51968329b9adc52d188fc97859f85f2ee15fe9f379987d99c5/pymdown_extensions-10.19.1-py3-none-any.whl", hash = "sha256:e8698a66055b1dc0dca2a7f2c9d0ea6f5faa7834a9c432e3535ab96c0c4e509b", size = 266693, upload-time = "2025-12-14T17:25:22.999Z" }, +] + [[package]] name = "pyparsing" version = "3.2.5" @@ -3056,6 +3244,19 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/f1/7b/ce1eafaf1a76852e2ec9b22edecf1daa58175c090266e9f6c64afcd81d91/stack_data-0.6.3-py3-none-any.whl", hash = "sha256:d5558e0c25a4cb0853cddad3d77da9891a08cb85dd9f9f91b9f8cd66e511e695", size = 24521, upload-time = "2023-09-30T13:58:03.53Z" }, ] +[[package]] +name = "starlette" +version = "0.50.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/ba/b8/73a0e6a6e079a9d9cfa64113d771e421640b6f679a52eeb9b32f72d871a1/starlette-0.50.0.tar.gz", hash = "sha256:a2a17b22203254bcbc2e1f926d2d55f3f9497f769416b3190768befe598fa3ca", size = 2646985, upload-time = "2025-11-01T15:25:27.516Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d9/52/1064f510b141bd54025f9b55105e26d1fa970b9be67ad766380a3c9b74b0/starlette-0.50.0-py3-none-any.whl", hash = "sha256:9e5391843ec9b6e472eed1365a78c8098cfceb7a74bfd4d6b1c0c0095efb3bca", size = 74033, upload-time = "2025-11-01T15:25:25.461Z" }, +] + [[package]] name = "sympy" version = "1.14.0" @@ -3144,6 +3345,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/77/b8/0135fadc89e73be292b473cb820b4f5a08197779206b33191e801feeae40/tomli-2.3.0-py3-none-any.whl", hash = "sha256:e95b1af3c5b07d9e643909b5abbec77cd9f1217e6d0bca72b0234736b9fb1f1b", size = 14408, upload-time = "2025-10-08T22:01:46.04Z" }, ] +[[package]] +name = "tomlkit" +version = "0.13.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/cc/18/0bbf3884e9eaa38819ebe46a7bd25dcd56b67434402b66a58c4b8e552575/tomlkit-0.13.3.tar.gz", hash = "sha256:430cf247ee57df2b94ee3fbe588e71d362a941ebb545dec29b53961d61add2a1", size = 185207, upload-time = "2025-06-05T07:13:44.947Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/bd/75/8539d011f6be8e29f339c42e633aae3cb73bffa95dd0f9adec09b9c58e85/tomlkit-0.13.3-py3-none-any.whl", hash = "sha256:c89c649d79ee40629a9fda55f8ace8c6a1b42deb912b2a8fd8d942ddadb606b0", size = 38901, upload-time = "2025-06-05T07:13:43.546Z" }, +] + [[package]] name = "torch" version = "2.2.1" @@ -3324,6 +3534,20 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/56/1a/9ffe814d317c5224166b23e7c47f606d6e473712a2fad0f704ea9b99f246/urllib3-2.6.0-py3-none-any.whl", hash = "sha256:c90f7a39f716c572c4e3e58509581ebd83f9b59cced005b7db7ad2d22b0db99f", size = 131083, upload-time = "2025-12-05T15:08:45.983Z" }, ] +[[package]] +name = "uvicorn" +version = "0.38.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "click" }, + { name = "h11" }, + { name = "typing-extensions", marker = "python_full_version < '3.11'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/cb/ce/f06b84e2697fef4688ca63bdb2fdf113ca0a3be33f94488f2cadb690b0cf/uvicorn-0.38.0.tar.gz", hash = "sha256:fd97093bdd120a2609fc0d3afe931d4d4ad688b6e75f0f929fde1bc36fe0e91d", size = 80605, upload-time = "2025-10-18T13:46:44.63Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ee/d9/d88e73ca598f4f6ff671fb5fde8a32925c2e08a637303a1d12883c7305fa/uvicorn-0.38.0-py3-none-any.whl", hash = "sha256:48c0afd214ceb59340075b4a052ea1ee91c16fbc2a9b1469cca0e54566977b02", size = 68109, upload-time = "2025-10-18T13:46:42.958Z" }, +] + [[package]] name = "virtualenv" version = "20.35.4" @@ -3397,6 +3621,54 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/34/db/b10e48aa8fff7407e67470363eac595018441cf32d5e1001567a7aeba5d2/websocket_client-1.9.0-py3-none-any.whl", hash = "sha256:af248a825037ef591efbf6ed20cc5faa03d3b47b9e5a2230a529eeee1c1fc3ef", size = 82616, upload-time = "2025-10-07T21:16:34.951Z" }, ] +[[package]] +name = "websockets" +version = "15.0.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/21/e6/26d09fab466b7ca9c7737474c52be4f76a40301b08362eb2dbc19dcc16c1/websockets-15.0.1.tar.gz", hash = "sha256:82544de02076bafba038ce055ee6412d68da13ab47f0c60cab827346de828dee", size = 177016, upload-time = "2025-03-05T20:03:41.606Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/1e/da/6462a9f510c0c49837bbc9345aca92d767a56c1fb2939e1579df1e1cdcf7/websockets-15.0.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:d63efaa0cd96cf0c5fe4d581521d9fa87744540d4bc999ae6e08595a1014b45b", size = 175423, upload-time = "2025-03-05T20:01:35.363Z" }, + { url = "https://files.pythonhosted.org/packages/1c/9f/9d11c1a4eb046a9e106483b9ff69bce7ac880443f00e5ce64261b47b07e7/websockets-15.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:ac60e3b188ec7574cb761b08d50fcedf9d77f1530352db4eef1707fe9dee7205", size = 173080, upload-time = "2025-03-05T20:01:37.304Z" }, + { url = "https://files.pythonhosted.org/packages/d5/4f/b462242432d93ea45f297b6179c7333dd0402b855a912a04e7fc61c0d71f/websockets-15.0.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:5756779642579d902eed757b21b0164cd6fe338506a8083eb58af5c372e39d9a", size = 173329, upload-time = "2025-03-05T20:01:39.668Z" }, + { url = "https://files.pythonhosted.org/packages/6e/0c/6afa1f4644d7ed50284ac59cc70ef8abd44ccf7d45850d989ea7310538d0/websockets-15.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0fdfe3e2a29e4db3659dbd5bbf04560cea53dd9610273917799f1cde46aa725e", size = 182312, upload-time = "2025-03-05T20:01:41.815Z" }, + { url = "https://files.pythonhosted.org/packages/dd/d4/ffc8bd1350b229ca7a4db2a3e1c482cf87cea1baccd0ef3e72bc720caeec/websockets-15.0.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4c2529b320eb9e35af0fa3016c187dffb84a3ecc572bcee7c3ce302bfeba52bf", size = 181319, upload-time = "2025-03-05T20:01:43.967Z" }, + { url = "https://files.pythonhosted.org/packages/97/3a/5323a6bb94917af13bbb34009fac01e55c51dfde354f63692bf2533ffbc2/websockets-15.0.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ac1e5c9054fe23226fb11e05a6e630837f074174c4c2f0fe442996112a6de4fb", size = 181631, upload-time = "2025-03-05T20:01:46.104Z" }, + { url = "https://files.pythonhosted.org/packages/a6/cc/1aeb0f7cee59ef065724041bb7ed667b6ab1eeffe5141696cccec2687b66/websockets-15.0.1-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:5df592cd503496351d6dc14f7cdad49f268d8e618f80dce0cd5a36b93c3fc08d", size = 182016, upload-time = "2025-03-05T20:01:47.603Z" }, + { url = "https://files.pythonhosted.org/packages/79/f9/c86f8f7af208e4161a7f7e02774e9d0a81c632ae76db2ff22549e1718a51/websockets-15.0.1-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:0a34631031a8f05657e8e90903e656959234f3a04552259458aac0b0f9ae6fd9", size = 181426, upload-time = "2025-03-05T20:01:48.949Z" }, + { url = "https://files.pythonhosted.org/packages/c7/b9/828b0bc6753db905b91df6ae477c0b14a141090df64fb17f8a9d7e3516cf/websockets-15.0.1-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:3d00075aa65772e7ce9e990cab3ff1de702aa09be3940d1dc88d5abf1ab8a09c", size = 181360, upload-time = "2025-03-05T20:01:50.938Z" }, + { url = "https://files.pythonhosted.org/packages/89/fb/250f5533ec468ba6327055b7d98b9df056fb1ce623b8b6aaafb30b55d02e/websockets-15.0.1-cp310-cp310-win32.whl", hash = "sha256:1234d4ef35db82f5446dca8e35a7da7964d02c127b095e172e54397fb6a6c256", size = 176388, upload-time = "2025-03-05T20:01:52.213Z" }, + { url = "https://files.pythonhosted.org/packages/1c/46/aca7082012768bb98e5608f01658ff3ac8437e563eca41cf068bd5849a5e/websockets-15.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:39c1fec2c11dc8d89bba6b2bf1556af381611a173ac2b511cf7231622058af41", size = 176830, upload-time = "2025-03-05T20:01:53.922Z" }, + { url = "https://files.pythonhosted.org/packages/9f/32/18fcd5919c293a398db67443acd33fde142f283853076049824fc58e6f75/websockets-15.0.1-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:823c248b690b2fd9303ba00c4f66cd5e2d8c3ba4aa968b2779be9532a4dad431", size = 175423, upload-time = "2025-03-05T20:01:56.276Z" }, + { url = "https://files.pythonhosted.org/packages/76/70/ba1ad96b07869275ef42e2ce21f07a5b0148936688c2baf7e4a1f60d5058/websockets-15.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:678999709e68425ae2593acf2e3ebcbcf2e69885a5ee78f9eb80e6e371f1bf57", size = 173082, upload-time = "2025-03-05T20:01:57.563Z" }, + { url = "https://files.pythonhosted.org/packages/86/f2/10b55821dd40eb696ce4704a87d57774696f9451108cff0d2824c97e0f97/websockets-15.0.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:d50fd1ee42388dcfb2b3676132c78116490976f1300da28eb629272d5d93e905", size = 173330, upload-time = "2025-03-05T20:01:59.063Z" }, + { url = "https://files.pythonhosted.org/packages/a5/90/1c37ae8b8a113d3daf1065222b6af61cc44102da95388ac0018fcb7d93d9/websockets-15.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d99e5546bf73dbad5bf3547174cd6cb8ba7273062a23808ffea025ecb1cf8562", size = 182878, upload-time = "2025-03-05T20:02:00.305Z" }, + { url = "https://files.pythonhosted.org/packages/8e/8d/96e8e288b2a41dffafb78e8904ea7367ee4f891dafc2ab8d87e2124cb3d3/websockets-15.0.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:66dd88c918e3287efc22409d426c8f729688d89a0c587c88971a0faa2c2f3792", size = 181883, upload-time = "2025-03-05T20:02:03.148Z" }, + { url = "https://files.pythonhosted.org/packages/93/1f/5d6dbf551766308f6f50f8baf8e9860be6182911e8106da7a7f73785f4c4/websockets-15.0.1-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8dd8327c795b3e3f219760fa603dcae1dcc148172290a8ab15158cf85a953413", size = 182252, upload-time = "2025-03-05T20:02:05.29Z" }, + { url = "https://files.pythonhosted.org/packages/d4/78/2d4fed9123e6620cbf1706c0de8a1632e1a28e7774d94346d7de1bba2ca3/websockets-15.0.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:8fdc51055e6ff4adeb88d58a11042ec9a5eae317a0a53d12c062c8a8865909e8", size = 182521, upload-time = "2025-03-05T20:02:07.458Z" }, + { url = "https://files.pythonhosted.org/packages/e7/3b/66d4c1b444dd1a9823c4a81f50231b921bab54eee2f69e70319b4e21f1ca/websockets-15.0.1-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:693f0192126df6c2327cce3baa7c06f2a117575e32ab2308f7f8216c29d9e2e3", size = 181958, upload-time = "2025-03-05T20:02:09.842Z" }, + { url = "https://files.pythonhosted.org/packages/08/ff/e9eed2ee5fed6f76fdd6032ca5cd38c57ca9661430bb3d5fb2872dc8703c/websockets-15.0.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:54479983bd5fb469c38f2f5c7e3a24f9a4e70594cd68cd1fa6b9340dadaff7cf", size = 181918, upload-time = "2025-03-05T20:02:11.968Z" }, + { url = "https://files.pythonhosted.org/packages/d8/75/994634a49b7e12532be6a42103597b71098fd25900f7437d6055ed39930a/websockets-15.0.1-cp311-cp311-win32.whl", hash = "sha256:16b6c1b3e57799b9d38427dda63edcbe4926352c47cf88588c0be4ace18dac85", size = 176388, upload-time = "2025-03-05T20:02:13.32Z" }, + { url = "https://files.pythonhosted.org/packages/98/93/e36c73f78400a65f5e236cd376713c34182e6663f6889cd45a4a04d8f203/websockets-15.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:27ccee0071a0e75d22cb35849b1db43f2ecd3e161041ac1ee9d2352ddf72f065", size = 176828, upload-time = "2025-03-05T20:02:14.585Z" }, + { url = "https://files.pythonhosted.org/packages/51/6b/4545a0d843594f5d0771e86463606a3988b5a09ca5123136f8a76580dd63/websockets-15.0.1-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:3e90baa811a5d73f3ca0bcbf32064d663ed81318ab225ee4f427ad4e26e5aff3", size = 175437, upload-time = "2025-03-05T20:02:16.706Z" }, + { url = "https://files.pythonhosted.org/packages/f4/71/809a0f5f6a06522af902e0f2ea2757f71ead94610010cf570ab5c98e99ed/websockets-15.0.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:592f1a9fe869c778694f0aa806ba0374e97648ab57936f092fd9d87f8bc03665", size = 173096, upload-time = "2025-03-05T20:02:18.832Z" }, + { url = "https://files.pythonhosted.org/packages/3d/69/1a681dd6f02180916f116894181eab8b2e25b31e484c5d0eae637ec01f7c/websockets-15.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:0701bc3cfcb9164d04a14b149fd74be7347a530ad3bbf15ab2c678a2cd3dd9a2", size = 173332, upload-time = "2025-03-05T20:02:20.187Z" }, + { url = "https://files.pythonhosted.org/packages/a6/02/0073b3952f5bce97eafbb35757f8d0d54812b6174ed8dd952aa08429bcc3/websockets-15.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e8b56bdcdb4505c8078cb6c7157d9811a85790f2f2b3632c7d1462ab5783d215", size = 183152, upload-time = "2025-03-05T20:02:22.286Z" }, + { url = "https://files.pythonhosted.org/packages/74/45/c205c8480eafd114b428284840da0b1be9ffd0e4f87338dc95dc6ff961a1/websockets-15.0.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0af68c55afbd5f07986df82831c7bff04846928ea8d1fd7f30052638788bc9b5", size = 182096, upload-time = "2025-03-05T20:02:24.368Z" }, + { url = "https://files.pythonhosted.org/packages/14/8f/aa61f528fba38578ec553c145857a181384c72b98156f858ca5c8e82d9d3/websockets-15.0.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:64dee438fed052b52e4f98f76c5790513235efaa1ef7f3f2192c392cd7c91b65", size = 182523, upload-time = "2025-03-05T20:02:25.669Z" }, + { url = "https://files.pythonhosted.org/packages/ec/6d/0267396610add5bc0d0d3e77f546d4cd287200804fe02323797de77dbce9/websockets-15.0.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:d5f6b181bb38171a8ad1d6aa58a67a6aa9d4b38d0f8c5f496b9e42561dfc62fe", size = 182790, upload-time = "2025-03-05T20:02:26.99Z" }, + { url = "https://files.pythonhosted.org/packages/02/05/c68c5adbf679cf610ae2f74a9b871ae84564462955d991178f95a1ddb7dd/websockets-15.0.1-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:5d54b09eba2bada6011aea5375542a157637b91029687eb4fdb2dab11059c1b4", size = 182165, upload-time = "2025-03-05T20:02:30.291Z" }, + { url = "https://files.pythonhosted.org/packages/29/93/bb672df7b2f5faac89761cb5fa34f5cec45a4026c383a4b5761c6cea5c16/websockets-15.0.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:3be571a8b5afed347da347bfcf27ba12b069d9d7f42cb8c7028b5e98bbb12597", size = 182160, upload-time = "2025-03-05T20:02:31.634Z" }, + { url = "https://files.pythonhosted.org/packages/ff/83/de1f7709376dc3ca9b7eeb4b9a07b4526b14876b6d372a4dc62312bebee0/websockets-15.0.1-cp312-cp312-win32.whl", hash = "sha256:c338ffa0520bdb12fbc527265235639fb76e7bc7faafbb93f6ba80d9c06578a9", size = 176395, upload-time = "2025-03-05T20:02:33.017Z" }, + { url = "https://files.pythonhosted.org/packages/7d/71/abf2ebc3bbfa40f391ce1428c7168fb20582d0ff57019b69ea20fa698043/websockets-15.0.1-cp312-cp312-win_amd64.whl", hash = "sha256:fcd5cf9e305d7b8338754470cf69cf81f420459dbae8a3b40cee57417f4614a7", size = 176841, upload-time = "2025-03-05T20:02:34.498Z" }, + { url = "https://files.pythonhosted.org/packages/02/9e/d40f779fa16f74d3468357197af8d6ad07e7c5a27ea1ca74ceb38986f77a/websockets-15.0.1-pp310-pypy310_pp73-macosx_10_15_x86_64.whl", hash = "sha256:0c9e74d766f2818bb95f84c25be4dea09841ac0f734d1966f415e4edfc4ef1c3", size = 173109, upload-time = "2025-03-05T20:03:17.769Z" }, + { url = "https://files.pythonhosted.org/packages/bc/cd/5b887b8585a593073fd92f7c23ecd3985cd2c3175025a91b0d69b0551372/websockets-15.0.1-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:1009ee0c7739c08a0cd59de430d6de452a55e42d6b522de7aa15e6f67db0b8e1", size = 173343, upload-time = "2025-03-05T20:03:19.094Z" }, + { url = "https://files.pythonhosted.org/packages/fe/ae/d34f7556890341e900a95acf4886833646306269f899d58ad62f588bf410/websockets-15.0.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:76d1f20b1c7a2fa82367e04982e708723ba0e7b8d43aa643d3dcd404d74f1475", size = 174599, upload-time = "2025-03-05T20:03:21.1Z" }, + { url = "https://files.pythonhosted.org/packages/71/e6/5fd43993a87db364ec60fc1d608273a1a465c0caba69176dd160e197ce42/websockets-15.0.1-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f29d80eb9a9263b8d109135351caf568cc3f80b9928bccde535c235de55c22d9", size = 174207, upload-time = "2025-03-05T20:03:23.221Z" }, + { url = "https://files.pythonhosted.org/packages/2b/fb/c492d6daa5ec067c2988ac80c61359ace5c4c674c532985ac5a123436cec/websockets-15.0.1-pp310-pypy310_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b359ed09954d7c18bbc1680f380c7301f92c60bf924171629c5db97febb12f04", size = 174155, upload-time = "2025-03-05T20:03:25.321Z" }, + { url = "https://files.pythonhosted.org/packages/68/a1/dcb68430b1d00b698ae7a7e0194433bce4f07ded185f0ee5fb21e2a2e91e/websockets-15.0.1-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:cad21560da69f4ce7658ca2cb83138fb4cf695a2ba3e475e0559e05991aa8122", size = 176884, upload-time = "2025-03-05T20:03:27.934Z" }, + { url = "https://files.pythonhosted.org/packages/fa/a8/5b41e0da817d64113292ab1f8247140aac61cbf6cfd085d6a0fa77f4984f/websockets-15.0.1-py3-none-any.whl", hash = "sha256:f7a866fbc1e97b5c617ee4116daaa09b722101d4a3c170c787450ba409f9736f", size = 169743, upload-time = "2025-03-05T20:03:39.41Z" }, +] + [[package]] name = "widgetsnbextension" version = "4.0.15" diff --git a/visualizing_embeddings.ipynb b/visualizing_embeddings.ipynb deleted file mode 100644 index 8120038..0000000 --- a/visualizing_embeddings.ipynb +++ /dev/null @@ -1,287 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "id": "60aaf07f-3f1d-414b-bbed-f1e0caea4e13", - "metadata": {}, - "source": [ - "# Making embeddings from real data\n", - "\n", - "This notebook demonstrates how to make embeddings with the Galileo models using real data (exported by our GEE exporter).\n", - "\n", - "Our GEE exporter is called using the following script:\n", - "```python\n", - "from datetime import date\n", - "\n", - "from src.data import EarthEngineExporter\n", - "from src.data.earthengine import EEBoundingBox\n", - "\n", - "# to export points\n", - "EarthEngineExporter(dest_bucket=\"bucket_name\").export_for_latlons(df)\n", - "# to export a bounding box\n", - "bbox = EEBoundingBox(min_lat=49.017835,min_lon-123.303680,max_lat=49.389519,max_lon-122.792816)\n", - "EarthEngineExporter(dest_bucket=\"bucket_name\").export_for_bbox(bbox, start_date=date(2024, 1, 1), end_date=(2025, 1, 1))\n", - "```" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "3cb38115-94c6-4e4f-b876-ae48aebb1777", - "metadata": {}, - "outputs": [], - "source": [ - "%matplotlib inline\n", - "import matplotlib.pyplot as plt\n", - "from pathlib import Path\n", - "from tqdm import tqdm\n", - "from sklearn.decomposition import PCA\n", - "from sklearn.cluster import KMeans\n", - "\n", - "import torch \n", - "import numpy as np\n", - "\n", - "from einops import rearrange\n", - "\n", - "\n", - "from src.galileo import Encoder\n", - "from src.data.dataset import DatasetOutput, Normalizer, Dataset\n", - "from src.utils import config_dir\n", - "from src.data.config import NORMALIZATION_DICT_FILENAME, DATA_FOLDER\n", - "from src.masking import MaskedOutput" - ] - }, - { - "cell_type": "markdown", - "id": "247715f1-0f56-4de1-a1a8-2453332c3ea7", - "metadata": {}, - "source": [ - "First, we'll load a dataset output using one of the example training tifs in `data/tifs`. We also normalize it using the same normalization stats we used during training." - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "7bbb836a-1887-4ef5-ae25-8772a1607724", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "dict_keys([13, 16, 6, 18])\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Warning 1: TIFFReadDirectory:Sum of Photometric type-related color channels and ExtraSamples doesn't match SamplesPerPixel. Defining non-color channels as ExtraSamples.\n" - ] - } - ], - "source": [ - "normalizing_dict = Dataset.load_normalization_values(\n", - " path=config_dir / NORMALIZATION_DICT_FILENAME\n", - ")\n", - "normalizer = Normalizer(std=True, normalizing_dicts=normalizing_dict)\n", - "\n", - "dataset_output = Dataset._tif_to_array(\n", - " Path(\"data/tifs/min_lat=-27.6721_min_lon=25.6796_max_lat=-27.663_max_lon=25.6897_dates=2022-01-01_2023-12-31.tif\")\n", - ").normalize(normalizer)" - ] - }, - { - "cell_type": "markdown", - "id": "a97ddcfb-8c3f-4fbe-b7ac-c600a143b772", - "metadata": {}, - "source": [ - "This tif captures the Vaal river near the [Bloemhof dam](https://en.wikipedia.org/wiki/Bloemhof_Dam). \n", - "We can visualize the S2-RGB bands from the first timestep:" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "233bc605-dc48-4420-affa-2b3f12ff04e8", - "metadata": {}, - "outputs": [ - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAdUAAAGhCAYAAAA3Ci4gAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZ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4TxKcuSer0e7dmzx/LNI1syob7v+3T++edP/Kr68pIbHZ/p6Bi50fGZjo6Rm60+PvPz8xvabkv4VBVFURRlK6APVUVRFEWpiS39UG00GvR7v/d71Gg0znVXnpDo+ExHx8iNjs90dIzcPNnGZ0u+qKQoiqIoT0S29C9VRVEURXkioQ9VRVEURakJfagqiqIoSk3oQ1VRFEVRamLLPlRvvvlmuvDCC6nZbNKll15Kd91117nu0jnj4MGD9PznP59mZ2dp586d9OpXv5ruu+8+sc1oNKKrr76atm/fTjMzM3T55ZfT8vLyOerxueW9730veZ5H11577eTfdHyIHn74YfrVX/1V2r59O7VaLXrWs55FX/va1ybry7KkG2+8kXbv3k2tVosOHDhA999//zns8dkjz3O64YYbaN++fdRqtehpT3sa/f7v/77IBftkG58vf/nL9MpXvpL27NlDnufRbbfdJtZvZDxOnDhBV155Jc3NzdHCwgK97nWvo7W1tbN4FI8D5RbkU5/6VBnHcfnf//t/L//xH/+xfP3rX18uLCyUy8vL57pr54TLLrusvPXWW8t77723/OY3v1n+/M//fHnBBReUa2trk21+4zd+o9y7d2956NCh8mtf+1r5whe+sHzRi150Dnt9brjrrrvKCy+8sPzpn/7p8s1vfvPk35/s43PixInyqU99avlrv/Zr5eHDh8vvf//75ec///nye9/73mSb9773veX8/Hx52223ld/61rfKf/fv/l25b9++cjgcnsOenx3e/e53l9u3by8/97nPlQ888ED56U9/upyZmSn/63/9r5Ntnmzj89d//dfl7/7u75Z/8Rd/URJR+ZnPfEas38h4vOxlLyuf/exnl1/96lfLv/u7vyt/8id/svyVX/mVs3wk9bIlH6oveMELyquvvnqynOd5uWfPnvLgwYPnsFdPHI4ePVoSUXnHHXeUZVmWKysrZRRF5ac//enJNt/5zndKIirvvPPOc9XNs06v1ysvuuii8gtf+EL5sz/7s5OHqo5PWf7O7/xO+ZKXvKRyfVEU5a5du8r//J//8+TfVlZWykajUf7Zn/3Z2ejiOeUVr3hF+eu//uvi317zmteUV155ZVmWOj74UN3IeHz7298uiai8++67J9v8zd/8Tel5Xvnwww+ftb7XzZYL/yZJQvfccw8dOHBg8m++79OBAwfozjvvPIc9e+KwurpKRETbtm0jIqJ77rmH0jQVY3bxxRfTBRdc8KQas6uvvppe8YpXiHEg0vEhIvqrv/oruuSSS+iXfumXaOfOnfTc5z6X/uRP/mSy/oEHHqAjR46IMZqfn6dLL730STFGL3rRi+jQoUP03e9+l4iIvvWtb9FXvvIVevnLX05EOj7IRsbjzjvvpIWFBbrkkksm2xw4cIB836fDhw+f9T7XxZZLqH/s2DHK85yWlpbEvy8tLdE//dM/naNePXEoioKuvfZaevGLX0zPfOYziYjoyJEjFMcxLSwsiG2XlpboyJEj56CXZ59PfepT9PWvf53uvvtua52OD9H3v/99+vCHP0zXXXcd/af/9J/o7rvvpt/6rd+iOI7pqquumozDetfdk2GM3va2t1G326WLL76YgiCgPM/p3e9+N1155ZVERE/68UE2Mh5HjhyhnTt3ivVhGNK2bdu29JhtuYeq4ubqq6+me++9l77yla+c6648YXjooYfozW9+M33hC1+gZrN5rrvzhKQoCrrkkkvoPe95DxERPfe5z6V7772XbrnlFrrqqqvOce/OPX/+539On/jEJ+iTn/wk/dRP/RR985vfpGuvvZb27Nmj46MItlz4d8eOHRQEgfVm5vLyMu3atesc9eqJwTXXXEOf+9zn6G//9m9FId1du3ZRkiS0srIitn+yjNk999xDR48epZ/5mZ+hMAwpDEO644476AMf+ACFYUhLS0tP6vEhItq9ezc94xnPEP/29Kc/nR588EEiosk4PFmvu9/+7d+mt73tbXTFFVfQs571LPoP/+E/0Fve8hY6ePAgEen4IBsZj127dtHRo0fF+izL6MSJE1t6zLbcQzWOY3re855Hhw4dmvxbURR06NAh2r9//zns2bmjLEu65ppr6DOf+Qx98YtfpH379on1z3ve8yiKIjFm9913Hz344INPijF76UtfSv/wD/9A3/zmNyf/XXLJJXTllVdOPj+Zx4eI6MUvfrFlw/rud79LT33qU4mIaN++fbRr1y4xRt1ulw4fPvykGKPBYGAVpw6CgIqiICIdH2Qj47F//35aWVmhe+65Z7LNF7/4RSqKgi699NKz3ufaONdvSv0ofOpTnyobjUb50Y9+tPz2t79dvuENbygXFhbKI0eOnOuunRN+8zd/s5yfny+/9KUvlY8++ujkv8FgMNnmN37jN8oLLrig/OIXv1h+7WtfK/fv31/u37//HPb63MLf/i1LHZ+77rqrDMOwfPe7313ef//95Sc+8Ymy3W6X/+N//I/JNu9973vLhYWF8i//8i/Lv//7vy9f9apX/Yu2jHCuuuqq8ilPecrEUvMXf/EX5Y4dO8q3vvWtk22ebOPT6/XKb3zjG+U3vvGNkojKP/zDPyy/8Y1vlD/4wQ/KstzYeLzsZS8rn/vc55aHDx8uv/KVr5QXXXSRWmrOFR/84AfLCy64oIzjuHzBC15QfvWrXz3XXTpnENG6/916662TbYbDYfnGN76xXFxcLNvtdvmLv/iL5aOPPnruOn2OwYeqjk9Zfvazny2f+cxnlo1Go7z44ovLj3zkI2J9URTlDTfcUC4tLZWNRqN86UtfWt53333nqLdnl263W775zW8uL7jggrLZbJY/8RM/Uf7u7/5uOR6PJ9s82cbnb//2b9e971x11VVlWW5sPI4fP17+yq/8SjkzM1POzc2Vr33ta8ter3cOjqY+tPSboiiKotTEltNUFUVRFOWJij5UFUVRFKUm9KGqKIqiKDWhD1VFURRFqQl9qCqKoihKTehDVVEURVFqQh+qiqIoilIT+lBVFEVRlJrQh6qiKIqi1IQ+VBVFURSlJvShqiiKoig1oQ9VRVEURamJ/w9Vt1s3nOIOgQAAAABJRU5ErkJggg==", - "text/plain": [ - "
" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "plt.clf()\n", - "plt.imshow(dataset_output.space_time_x[:, :, 0, [4, 3, 2]].astype(np.float32))\n", - "plt.show()" - ] - }, - { - "cell_type": "markdown", - "id": "ca58defd-99ec-4341-ad13-afbf00d7586d", - "metadata": {}, - "source": [ - "We'll use the nano model (which is conveniently stored in git) to make these embeddings." - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "47c649e3-7732-4493-a717-67ea59d332cb", - "metadata": {}, - "outputs": [], - "source": [ - "model = Encoder.load_from_folder(DATA_FOLDER / \"models/nano\")" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "id": "e36d12bd-6b85-41bb-9153-5de5fc19d80a", - "metadata": {}, - "outputs": [], - "source": [ - "def make_embeddings(\n", - " model: Encoder,\n", - " datasetoutput: DatasetOutput,\n", - " window_size: int,\n", - " patch_size: int,\n", - " batch_size: int = 128,\n", - " device: torch.device=torch.device(\"cpu\"),\n", - ") -> np.ndarray:\n", - " model.eval()\n", - " output_embeddings_list = []\n", - " for i in tqdm(datasetoutput.in_pixel_batches(batch_size=batch_size, window_size=window_size)):\n", - " masked_output = MaskedOutput.from_datasetoutput(i, device=device)\n", - " with torch.no_grad():\n", - " output_embeddings_list.append(model.average_tokens(*model(\n", - " masked_output.space_time_x.float(),\n", - " masked_output.space_x.float(),\n", - " masked_output.time_x.float(),\n", - " masked_output.static_x.float(),\n", - " masked_output.space_time_mask,\n", - " masked_output.space_mask,\n", - " # lets mask inputs which will be the same for\n", - " # all pixels in the DatasetOutput\n", - " torch.ones_like(masked_output.time_mask),\n", - " torch.ones_like(masked_output.static_mask),\n", - " masked_output.months.long(),\n", - " patch_size=patch_size)[:-1]).cpu().numpy())\n", - " output_embeddings = np.concatenate(output_embeddings_list, axis=0)\n", - " # reshape the embeddings to H, W, D\n", - " # first - how many \"height batches\" and \"width batches\" did we get?\n", - " h_b = datasetoutput.space_time_x.shape[0] // window_size\n", - " w_b = datasetoutput.space_time_x.shape[1] // window_size\n", - " return rearrange(output_embeddings, \"(h_b w_b) d -> h_b w_b d\", h_b=h_b, w_b=w_b)" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "id": "671ff5d5-5b17-4bae-8f75-b9add99653ac", - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "91it [00:31, 2.92it/s]\n" - ] - } - ], - "source": [ - "embeddings = make_embeddings(model, dataset_output, 1, 1, 128)\n", - "embeddings_flat = rearrange(embeddings, \"h w d -> (h w) d\")\n" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "id": "f03c9580", - "metadata": {}, - "outputs": [], - "source": [ - "labels = KMeans(n_clusters=3).fit_predict(embeddings_flat)\n", - "labels = rearrange(labels, \"(h w) -> h w\", h=embeddings.shape[0], w=embeddings.shape[1])" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "id": "e8105ac7", - "metadata": {}, - "outputs": [], - "source": [ - "embeddings_pca = PCA(n_components=3).fit_transform(embeddings_flat)\n", - "embeddings_reduced = rearrange(embeddings_pca, \"(h w) d -> h w d\", h=embeddings.shape[0], w=embeddings.shape[1])" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "id": "a66614e7", - "metadata": {}, - "outputs": [ - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAdUAAAGhCAYAAAA3Ci4gAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/H5lhTAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAmaklEQVR4nO3de3BU9f3/8VfCZROFJAWHTVKJppb5gpWqFY0RpxfNFC+1UJlaOmmHWkdaDVbITC20giMVg/ZGUSq106JOobROK61Oi+OEFuo0BIiXSqVAR6ZQ7Ya2NCwXCTT7+f3Rur9sgE129332nLP7fMxkxj179uz7fHbxPZ/3ez/nlDjnnAAAQM5K/Q4AAIBCQVIFAMAISRUAACMkVQAAjJBUAQAwQlIFAMAISRUAACMkVQAAjJBUAQAwQlIFAMCIr0l15cqVOv/881VWVqaGhgZt3brVz3AAAMiJb0n1pz/9qVpbW3XffffppZde0sUXX6xp06bpwIEDfoUEAEBOSvy6oH5DQ4Muv/xyPfroo5KkRCKh8ePH66677tKCBQvSvjaRSOitt97S6NGjVVJSko9wAQBFyjmnw4cPq7a2VqWl6eeiw/MUU4oTJ06oq6tLCxcuTG4rLS1VU1OTOjo6Ttm/t7dXvb29yc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9/dNOnTy/oJSP9zZ4927373e9OLqn5xS9+4c455xx3zz33JPcptvE5fPiwe/nll93LL7/sJLlvf/vb7uWXX3Z//etfnXNDG4/rrrvOXXrppa6zs9O9+OKLbsKECSyp8csjjzzi6urq3MiRI90VV1zhtmzZ4ndIvpF02r/Vq1cn93n77bfdnXfe6d71rne5s846y33iE59wf//73/0L2mcDkyrj49yzzz7rLrroIheJRNzEiRPd448/nvJ8IpFwixYtctFo1EUiEXfttde6Xbt2+RRtfsXjcXf33Xe7uro6V1ZW5t7znve4r33ta663tze5T7GNz29/+9vT/n9n9uzZzrmhjce//vUv9+lPf9qNGjXKVVRUuFtvvdUdPnzYh7Oxw63fAAAwErqeKgAAQUVSBQDACEkVAAAjJFUAAIyQVAEAMEJSBQDACEkVAAAjJFUAAIyQVAEAMEJSBQDACEkVAAAjJFUAAIz8Pzr1TqwkrXDpAAAAAElFTkSuQmCC", - "text/plain": [ - "
" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAdUAAAGhCAYAAAA3Ci4gAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/H5lhTAAAACXBIWXMAAA9hAAAPYQGoP6dpAABKQElEQVR4nO2dfXAe1XX/j+QXSX6RFJtYsoINauoZQyBAMBgB06agqSEMheBJ64zTcQgDTbAJxjMhuMHO0AACmiYUcHDJpAamEBqmwQn8GjOMSEyZGtmYl4ZADBk8wYFILnHkx6+y0bO/P6ge3T3Wc+6eu2ef1SN9PzMaP/vs3Xvv3r2718/57jmnJoqiiAAAAACQmtq8OwAAAACMFbCoAgAAAEZgUQUAAACMwKIKAAAAGIFFFQAAADACiyoAAABgBBZVAAAAwAgsqgAAAIARWFQBAAAAI7CoAgAAAEbkuqiuW7eOTjzxRKqvr6eFCxfS1q1b8+wOAAAAkIrcFtV///d/p1WrVtE3v/lNeumll+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LSoYnyi6Otf/3p0/vnnl91fLBaj1tbW6B//8R9L3/X390d1dXXRD3/4w0p0MVcuueSS6Etf+lLsuyuuuCJaunRpFEUYH76oJhmP119/PSKiaNu2baUyP/vZz6Kampro3XffrVjfrak68++RI0do+/bt1NnZWfqutraWOjs7acuWLTn2bPSwd+9eIiKaMWMGERFt376djh49Ghuz+fPn09y5c8fVmC1fvpwuueSS2DgQYXyIiH7605/SggUL6HOf+xzNmjWLzjjjDPr+979f2r9z507q7e2NjVFTUxMtXLhwXIzRueeeS93d3fTmm28SEdGrr75Kzz//PF188cVEhPHhJBmPLVu2UHNzMy1YsKBUprOzk2pra6mnp6fifbai6gLqv//++zQ4OEgtLS2x71taWujXv/51Tr0aPRSLRVq5ciWdd955dMoppxARUW9vL02ePJmam5tjZVtaWqi3tzeHXlaexx57jF566SXatm3bMfswPkRvv/023X///bRq1Sr6+7//e9q2bRt99atfpcmTJ9OyZctK4zDSfTcexuimm26iQqFA8+fPpwkTJtDg4CDddttttHTpUiKicT8+nCTj0dvbS7NmzYrtnzhxIs2YMaOqx6zqFlUgs3z5cnrttdfo+eefz7sro4Zdu3bR9ddfT8888wzV19fn3Z1RSbFYpAULFtDtt99ORERnnHEGvfbaa7R+/XpatmxZzr3Lnx/96Ef0yCOP0KOPPkqf+MQn6JVXXqGVK1dSW1sbxgfEqDrz73HHHUcTJkw45s3Mvr4+am1tzalXo4MVK1bQU089RT//+c9jiXRbW1vpyJEj1N/fHys/XsZs+/bttHv3bvrUpz5FEydOpIkTJ9LmzZvpnnvuoYkTJ1JLS8u4Hh8iotmzZ9PJJ58c++6kk06id955h4ioNA7j9b772te+RjfddBMtWbKETj31VPrbv/1buuGGG6irq4uIMD6cJOPR2tpKu3fvju3/4IMPaM+ePVU9ZlW3qE6ePJnOPPNM6u7uLn1XLBapu7ubOjo6cuxZfkRRRCtWrKAnnniCnn32WWpvb4/tP/PMM2nSpEmxMduxYwe9884742LMLrzwQvrlL39Jr7zySulvwYIFtHTp0tLn8Tw+RETnnXfeMW5Yb775Jp1wwglERNTe3k6tra2xMSoUCtTT0zMuxujgwYPHJKeeMGECFYtFIsL4cJKMR0dHB/X399P27dtLZZ599lkqFou0cOHCivfZjLzflArhsccei+rq6qIHH3wwev3116Nrrrkmam5ujnp7e/PuWi585StfiZqamqJf/OIX0e9///vS38GDB0tlvvzlL0dz586Nnn322ejFF1+MOjo6oo6Ojhx7nS/u279RhPHZunVrNHHixOi2226L3nrrreiRRx6JpkyZEv3bv/1bqcwdd9wRNTc3Rz/5yU+i//mf/4kuu+yyMe0y4rJs2bLoYx/7WMml5sc//nF03HHHRTfeeGOpzHgbn3379kUvv/xy9PLLL0dEFH3nO9+JXn755ei3v/1tFEXJxuOiiy6KzjjjjKinpyd6/vnno3nz5sGlJi/uvffeaO7cudHkyZOjs88+O3rhhRfy7lJuENGIfxs2bCiVOXToUHTttddGH/nIR6IpU6ZEn/3sZ6Pf//73+XU6Z/iiivGJoieffDI65ZRTorq6umj+/PnRAw88ENtfLBajNWvWRC0tLVFdXV104YUXRjt27Mipt5WlUChE119/fTR37tyovr4++pM/+ZPoG9/4RjQwMFAqM97G5+c///mIz51ly5ZFUZRsPP7whz9En//856Np06ZFjY2N0ZVXXhnt27cvh7OxA6nfAAAAACOqTlMFAAAARitYVAEAAAAjsKgCAAAARmBRBQAAAIzAogoAAAAYgUUVAAAAMAKLKgAAAGAEFlUAAADACCyqAAAAgBFYVAEAAAAjsKgCAAAARmBRBQAAAIz4/x8xF6pOX8L4AAAAAElFTkSuQmCC", - "text/plain": [ - "
" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "plt.figure()\n", - "plt.imshow(labels, cmap='tab10', vmin=0, vmax=9)\n", - "plt.show()\n", - "plt.close()\n", - "\n", - "plt.figure()\n", - "plt.imshow(embeddings_reduced[:,:,0], cmap=\"bwr\", vmin=-1, vmax=1)\n", - "plt.show()\n", - "plt.close()" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.12.8" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/visualizing_embeddings.py b/visualizing_embeddings.py new file mode 100644 index 0000000..6f3ccf0 --- /dev/null +++ b/visualizing_embeddings.py @@ -0,0 +1,207 @@ +import marimo + +__generated_with = "0.9.30" +app = marimo.App(width="medium") + + +@app.cell +def intro(): + """ + # Making embeddings from real data + + This notebook demonstrates how to make embeddings with the Galileo models using real data (exported by our GEE exporter). + + Our GEE exporter is called using the following script: + ```python + from datetime import date + + from src.data import EarthEngineExporter + from src.data.earthengine import EEBoundingBox + + # to export points + EarthEngineExporter(dest_bucket="bucket_name").export_for_latlons(df) + # to export a bounding box + bbox = EEBoundingBox(min_lat=49.017835,min_lon-123.303680,max_lat=49.389519,max_lon-122.792816) + EarthEngineExporter(dest_bucket="bucket_name").export_for_bbox(bbox, start_date=date(2024, 1, 1), end_date=(2025, 1, 1)) + ``` + """ + return + + +@app.cell +def imports(): + from pathlib import Path + + import matplotlib.pyplot as plt + import numpy as np + import torch + from einops import rearrange + from sklearn.cluster import KMeans + from sklearn.decomposition import PCA + from tqdm import tqdm + + from src.data.config import DATA_FOLDER, NORMALIZATION_DICT_FILENAME + from src.data.dataset import Dataset, DatasetOutput, Normalizer + from src.galileo import Encoder + from src.masking import MaskedOutput + from src.utils import config_dir + + return ( + DATA_FOLDER, + Dataset, + DatasetOutput, + Encoder, + KMeans, + MaskedOutput, + NORMALIZATION_DICT_FILENAME, + Normalizer, + PCA, + Path, + config_dir, + np, + plt, + rearrange, + torch, + tqdm, + ) + + +@app.cell +def load_data(Dataset, NORMALIZATION_DICT_FILENAME, Normalizer, Path, config_dir): + """ + First, we'll load a dataset output using one of the example training tifs in `data/tifs`. We also normalize it using the same normalization stats we used during training. + """ + normalizing_dict = Dataset.load_normalization_values( + path=config_dir / NORMALIZATION_DICT_FILENAME + ) + normalizer = Normalizer(std=True, normalizing_dicts=normalizing_dict) + + dataset_output = Dataset._tif_to_array( + Path( + "data/tifs/min_lat=-27.6721_min_lon=25.6796_max_lat=-27.663_max_lon=25.6897_dates=2022-01-01_2023-12-31.tif" + ) + ).normalize(normalizer) + return dataset_output, normalizer, normalizing_dict + + +@app.cell +def visualize_data(dataset_output, np, plt): + """ + This tif captures the Vaal river near the [Bloemhof dam](https://en.wikipedia.org/wiki/Bloemhof_Dam). + We can visualize the S2-RGB bands from the first timestep: + """ + plt.clf() + plt.imshow(dataset_output.space_time_x[:, :, 0, [4, 3, 2]].astype(np.float32)) + plt.show() + return + + +@app.cell +def load_model(DATA_FOLDER, Encoder): + """ + We'll use the nano model (which is conveniently stored in git) to make these embeddings. + """ + model = Encoder.load_from_folder(DATA_FOLDER / "models/nano") + return (model,) + + +@app.cell +def define_embedding_function(Encoder, DatasetOutput, MaskedOutput, np, rearrange, torch, tqdm): + from typing import Any + + def make_embeddings( + model: Any, + datasetoutput: Any, + window_size: int, + patch_size: int, + batch_size: int = 128, + device: Any = None, + ) -> Any: + if device is None: + device = torch.device("cpu") + model.eval() + output_embeddings_list = [] + for i in tqdm( + datasetoutput.in_pixel_batches(batch_size=batch_size, window_size=window_size) + ): + masked_output = MaskedOutput.from_datasetoutput(i, device=device) + with torch.no_grad(): + output_embeddings_list.append( + model.average_tokens( + *model( + masked_output.space_time_x.float(), + masked_output.space_x.float(), + masked_output.time_x.float(), + masked_output.static_x.float(), + masked_output.space_time_mask, + masked_output.space_mask, + # lets mask inputs which will be the same for + # all pixels in the DatasetOutput + torch.ones_like(masked_output.time_mask), + torch.ones_like(masked_output.static_mask), + masked_output.months.long(), + patch_size=patch_size, + )[:-1] + ) + .cpu() + .numpy() + ) + output_embeddings = np.concatenate(output_embeddings_list, axis=0) + # reshape the embeddings to H, W, D + # first - how many "height batches" and "width batches" did we get? + h_b = datasetoutput.space_time_x.shape[0] // window_size + w_b = datasetoutput.space_time_x.shape[1] // window_size + return rearrange(output_embeddings, "(h_b w_b) d -> h_b w_b d", h_b=h_b, w_b=w_b) + + return (make_embeddings,) + + +@app.cell +def generate_embeddings(dataset_output, make_embeddings, model, rearrange): + embeddings = make_embeddings(model, dataset_output, 1, 1, 128) + embeddings_flat = rearrange(embeddings, "h w d -> (h w) d") + return embeddings, embeddings_flat + + +@app.cell +def cluster_embeddings(KMeans, embeddings, embeddings_flat, rearrange): + labels = KMeans(n_clusters=3).fit_predict(embeddings_flat) + labels = rearrange(labels, "(h w) -> h w", h=embeddings.shape[0], w=embeddings.shape[1]) + return (labels,) + + +@app.cell +def reduce_dimensions(PCA, embeddings, embeddings_flat, rearrange): + embeddings_pca = PCA(n_components=3).fit_transform(embeddings_flat) + embeddings_reduced = rearrange( + embeddings_pca, "(h w) d -> h w d", h=embeddings.shape[0], w=embeddings.shape[1] + ) + return embeddings_pca, embeddings_reduced + + +@app.cell +def plot_results(embeddings_reduced, labels, plt): + # Plot the K-means clustering results + plt.figure(figsize=(12, 4)) + + plt.subplot(1, 3, 1) + plt.imshow(labels, cmap="tab10") + plt.title("K-means Clustering (3 clusters)") + plt.colorbar() + + # Plot the PCA-reduced embeddings as RGB + plt.subplot(1, 3, 2) + # Normalize to 0-1 range for display + embeddings_normalized = (embeddings_reduced - embeddings_reduced.min()) / ( + embeddings_reduced.max() - embeddings_reduced.min() + ) + plt.imshow(embeddings_normalized) + plt.title("PCA-reduced embeddings (RGB)") + + plt.tight_layout() + plt.show() + return (embeddings_normalized,) + + +if __name__ == "__main__": + app.run() From 94f273845851c8e96a1cdc6c73158b98995bff47 Mon Sep 17 00:00:00 2001 From: Robin Fievet Date: Wed, 7 Jan 2026 10:18:52 -0500 Subject: [PATCH 2/8] adding comments to see progress --- visualizing_embeddings.py | 191 ++++++++++++++++++++++++++++++++------ 1 file changed, 161 insertions(+), 30 deletions(-) diff --git a/visualizing_embeddings.py b/visualizing_embeddings.py index 6f3ccf0..5f78991 100644 --- a/visualizing_embeddings.py +++ b/visualizing_embeddings.py @@ -30,6 +30,7 @@ def intro(): @app.cell def imports(): + print("🚀 STARTING: Importing libraries...") from pathlib import Path import matplotlib.pyplot as plt @@ -46,6 +47,10 @@ def imports(): from src.masking import MaskedOutput from src.utils import config_dir + print("✅ SUCCESS: All libraries imported successfully!") + print(f"📊 Using PyTorch version: {torch.__version__}") + print(f"📊 Using NumPy version: {np.__version__}") + return ( DATA_FOLDER, Dataset, @@ -71,16 +76,39 @@ def load_data(Dataset, NORMALIZATION_DICT_FILENAME, Normalizer, Path, config_dir """ First, we'll load a dataset output using one of the example training tifs in `data/tifs`. We also normalize it using the same normalization stats we used during training. """ + print("🔄 STEP 1: Loading normalization values...") normalizing_dict = Dataset.load_normalization_values( path=config_dir / NORMALIZATION_DICT_FILENAME ) + print(f"✅ Loaded normalization dict with {len(normalizing_dict)} entries") + print(f"📁 Config directory: {config_dir}") + print(f"📄 Normalization file: {NORMALIZATION_DICT_FILENAME}") + + print("🔄 Creating normalizer...") normalizer = Normalizer(std=True, normalizing_dicts=normalizing_dict) + print("✅ Normalizer created successfully") + + print("🔄 Loading TIF file...") + tif_path = Path( + "data/tifs/min_lat=-27.6721_min_lon=25.6796_max_lat=-27.663_max_lon=25.6897_dates=2022-01-01_2023-12-31.tif" + ) + print(f"📁 TIF path: {tif_path}") + print(f"📊 TIF exists: {tif_path.exists()}") + + dataset_output = Dataset._tif_to_array(tif_path).normalize(normalizer) + print("✅ TIF loaded and normalized successfully!") + print(f"📊 Dataset output type: {type(dataset_output)}") + print(f"📊 Space-time data shape: {dataset_output.space_time_x.shape}") + print( + f"📊 Space data shape: {dataset_output.space_x.shape if hasattr(dataset_output, 'space_x') else 'N/A'}" + ) + print( + f"📊 Time data shape: {dataset_output.time_x.shape if hasattr(dataset_output, 'time_x') else 'N/A'}" + ) + print( + f"📊 Static data shape: {dataset_output.static_x.shape if hasattr(dataset_output, 'static_x') else 'N/A'}" + ) - dataset_output = Dataset._tif_to_array( - Path( - "data/tifs/min_lat=-27.6721_min_lon=25.6796_max_lat=-27.663_max_lon=25.6897_dates=2022-01-01_2023-12-31.tif" - ) - ).normalize(normalizer) return dataset_output, normalizer, normalizing_dict @@ -90,9 +118,17 @@ def visualize_data(dataset_output, np, plt): This tif captures the Vaal river near the [Bloemhof dam](https://en.wikipedia.org/wiki/Bloemhof_Dam). We can visualize the S2-RGB bands from the first timestep: """ + print("🔄 STEP 2: Visualizing S2-RGB bands...") + print("📊 Extracting RGB bands [4, 3, 2] from timestep 0") + rgb_data = dataset_output.space_time_x[:, :, 0, [4, 3, 2]].astype(np.float32) + print(f"📊 RGB data shape: {rgb_data.shape}") + print(f"📊 RGB data range: [{rgb_data.min():.3f}, {rgb_data.max():.3f}]") + plt.clf() - plt.imshow(dataset_output.space_time_x[:, :, 0, [4, 3, 2]].astype(np.float32)) + plt.imshow(rgb_data) + plt.title("S2-RGB bands from first timestep") plt.show() + print("✅ RGB visualization complete!") return @@ -101,7 +137,16 @@ def load_model(DATA_FOLDER, Encoder): """ We'll use the nano model (which is conveniently stored in git) to make these embeddings. """ - model = Encoder.load_from_folder(DATA_FOLDER / "models/nano") + print("🔄 STEP 3: Loading Galileo nano model...") + model_path = DATA_FOLDER / "models/nano" + print(f"📁 Model path: {model_path}") + print(f"📊 Model path exists: {model_path.exists()}") + + model = Encoder.load_from_folder(model_path) + print("✅ Model loaded successfully!") + print(f"📊 Model type: {type(model)}") + print(f"📊 Model device: {next(model.parameters()).device}") + print(f"📊 Model parameters: {sum(p.numel() for p in model.parameters()):,}") return (model,) @@ -109,6 +154,8 @@ def load_model(DATA_FOLDER, Encoder): def define_embedding_function(Encoder, DatasetOutput, MaskedOutput, np, rearrange, torch, tqdm): from typing import Any + print("🔄 STEP 4: Defining embedding function...") + def make_embeddings( model: Any, datasetoutput: Any, @@ -117,89 +164,173 @@ def make_embeddings( batch_size: int = 128, device: Any = None, ) -> Any: + print("🔄 Starting embedding generation...") + print(f"📊 Window size: {window_size}") + print(f"📊 Patch size: {patch_size}") + print(f"📊 Batch size: {batch_size}") + print(f"📊 Device: {device}") + if device is None: device = torch.device("cpu") model.eval() + print("✅ Model set to evaluation mode") + output_embeddings_list = [] + batch_count = 0 + for i in tqdm( datasetoutput.in_pixel_batches(batch_size=batch_size, window_size=window_size) ): + batch_count += 1 + if batch_count % 10 == 0: + print(f"🔄 Processing batch {batch_count}...") + masked_output = MaskedOutput.from_datasetoutput(i, device=device) with torch.no_grad(): - output_embeddings_list.append( - model.average_tokens( - *model( - masked_output.space_time_x.float(), - masked_output.space_x.float(), - masked_output.time_x.float(), - masked_output.static_x.float(), - masked_output.space_time_mask, - masked_output.space_mask, - # lets mask inputs which will be the same for - # all pixels in the DatasetOutput - torch.ones_like(masked_output.time_mask), - torch.ones_like(masked_output.static_mask), - masked_output.months.long(), - patch_size=patch_size, - )[:-1] - ) - .cpu() - .numpy() + model_output = model( + masked_output.space_time_x.float(), + masked_output.space_x.float(), + masked_output.time_x.float(), + masked_output.static_x.float(), + masked_output.space_time_mask, + masked_output.space_mask, + # lets mask inputs which will be the same for + # all pixels in the DatasetOutput + torch.ones_like(masked_output.time_mask), + torch.ones_like(masked_output.static_mask), + masked_output.months.long(), + patch_size=patch_size, ) + + embeddings = model.average_tokens(*model_output[:-1]).cpu().numpy() + output_embeddings_list.append(embeddings) + + print(f"✅ Processed {batch_count} batches total") + print("🔄 Concatenating embeddings...") + output_embeddings = np.concatenate(output_embeddings_list, axis=0) + print(f"📊 Concatenated embeddings shape: {output_embeddings.shape}") + # reshape the embeddings to H, W, D # first - how many "height batches" and "width batches" did we get? h_b = datasetoutput.space_time_x.shape[0] // window_size w_b = datasetoutput.space_time_x.shape[1] // window_size - return rearrange(output_embeddings, "(h_b w_b) d -> h_b w_b d", h_b=h_b, w_b=w_b) + print(f"📊 Reshaping: height_batches={h_b}, width_batches={w_b}") + + reshaped_embeddings = rearrange( + output_embeddings, "(h_b w_b) d -> h_b w_b d", h_b=h_b, w_b=w_b + ) + print(f"📊 Final embeddings shape: {reshaped_embeddings.shape}") + + return reshaped_embeddings + + print("✅ Embedding function defined successfully!") return (make_embeddings,) @app.cell def generate_embeddings(dataset_output, make_embeddings, model, rearrange): + print("🔄 STEP 5: Generating embeddings...") + print("⏱️ This may take a while...") + embeddings = make_embeddings(model, dataset_output, 1, 1, 128) + print(f"✅ Embeddings generated! Shape: {embeddings.shape}") + + print("🔄 Flattening embeddings for clustering...") embeddings_flat = rearrange(embeddings, "h w d -> (h w) d") + print(f"📊 Flattened embeddings shape: {embeddings_flat.shape}") + print(f"📊 Embedding dimension: {embeddings_flat.shape[1]}") + print(f"📊 Number of pixels: {embeddings_flat.shape[0]}") + print("✅ Embeddings ready for analysis!") + return embeddings, embeddings_flat @app.cell -def cluster_embeddings(KMeans, embeddings, embeddings_flat, rearrange): - labels = KMeans(n_clusters=3).fit_predict(embeddings_flat) +def cluster_embeddings(KMeans, embeddings, embeddings_flat, np, rearrange): + print("🔄 STEP 6: Performing K-means clustering...") + print("📊 Using 3 clusters") + + kmeans = KMeans(n_clusters=3) + print("🔄 Fitting K-means model...") + labels = kmeans.fit_predict(embeddings_flat) + print("✅ K-means clustering complete!") + print(f"📊 Labels shape: {labels.shape}") + print(f"📊 Unique labels: {np.unique(labels)}") + print(f"📊 Label counts: {np.bincount(labels)}") + + print("🔄 Reshaping labels to image format...") labels = rearrange(labels, "(h w) -> h w", h=embeddings.shape[0], w=embeddings.shape[1]) + print(f"📊 Reshaped labels shape: {labels.shape}") + print("✅ K-means clustering analysis complete!") + return (labels,) @app.cell def reduce_dimensions(PCA, embeddings, embeddings_flat, rearrange): - embeddings_pca = PCA(n_components=3).fit_transform(embeddings_flat) + print("🔄 STEP 7: Performing PCA dimensionality reduction...") + print("📊 Reducing to 3 components for RGB visualization") + + pca = PCA(n_components=3) + print("🔄 Fitting PCA model...") + embeddings_pca = pca.fit_transform(embeddings_flat) + print("✅ PCA complete!") + print(f"📊 PCA embeddings shape: {embeddings_pca.shape}") + print(f"📊 Explained variance ratio: {pca.explained_variance_ratio_}") + print(f"📊 Total explained variance: {pca.explained_variance_ratio_.sum():.3f}") + + print("🔄 Reshaping PCA embeddings to image format...") embeddings_reduced = rearrange( embeddings_pca, "(h w) d -> h w d", h=embeddings.shape[0], w=embeddings.shape[1] ) + print(f"📊 Reshaped PCA embeddings shape: {embeddings_reduced.shape}") + print("✅ PCA dimensionality reduction complete!") + return embeddings_pca, embeddings_reduced @app.cell def plot_results(embeddings_reduced, labels, plt): + print("🔄 STEP 8: Creating visualizations...") + # Plot the K-means clustering results plt.figure(figsize=(12, 4)) + print("📊 Visualization 1: K-means clustering results") plt.subplot(1, 3, 1) plt.imshow(labels, cmap="tab10") plt.title("K-means Clustering (3 clusters)") plt.colorbar() + print("✅ K-means visualization complete!") # Plot the PCA-reduced embeddings as RGB + print("📊 Visualization 2: PCA-reduced embeddings as RGB") plt.subplot(1, 3, 2) # Normalize to 0-1 range for display embeddings_normalized = (embeddings_reduced - embeddings_reduced.min()) / ( embeddings_reduced.max() - embeddings_reduced.min() ) + print( + f"📊 PCA RGB range: [{embeddings_normalized.min():.3f}, {embeddings_normalized.max():.3f}]" + ) + plt.imshow(embeddings_normalized) plt.title("PCA-reduced embeddings (RGB)") + print("✅ PCA visualization complete!") plt.tight_layout() plt.show() + + print("🎉 ALL STEPS COMPLETED SUCCESSFULLY!") + print("📊 Summary:") + print(f" - Generated embeddings with shape: {embeddings_reduced.shape}") + print(" - Performed K-means clustering with 3 clusters") + print(" - Reduced dimensionality with PCA") + print(" - Created 2 visualizations") + print("🎯 The Marimo notebook has run successfully with detailed logging!") + return (embeddings_normalized,) From 1fea2e64fb4706b39514ab7c030b261a36e95a18 Mon Sep 17 00:00:00 2001 From: Robin Fievet Date: Wed, 7 Jan 2026 11:29:31 -0500 Subject: [PATCH 3/8] adding the visualisation and fix lint --- .gitignore | 1 - .pre-commit-config.yaml | 2 +- __marimo__/visualizing_embeddings.ipynb | 809 ++++++++++++++++++++++++ mypy.ini | 2 +- src/eval/cropharvest/datasets.py | 2 +- visualizing_embeddings.py | 29 +- 6 files changed, 826 insertions(+), 19 deletions(-) create mode 100644 __marimo__/visualizing_embeddings.ipynb diff --git a/.gitignore b/.gitignore index 033488d..2c9c089 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ __pycache__ # data needs to be explicitly added data/* .ipynb_checkpoints -__marimo__/ baseline_weights models slurm diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f3199c6..98c3969 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: hooks: - id: mypy additional_dependencies: [types-requests] - exclude: ^(venv|notebooks|anysat)/ + exclude: ^src/eval/(baseline_models|cropharvest)/ - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 diff --git a/__marimo__/visualizing_embeddings.ipynb b/__marimo__/visualizing_embeddings.ipynb new file mode 100644 index 0000000..85ec93d --- /dev/null +++ b/__marimo__/visualizing_embeddings.ipynb @@ -0,0 +1,809 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "Hbol", + "metadata": { + "marimo": { + "name": "intro" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
'\\n# Making embeddings from real data\\n\\nThis notebook demonstrates how to make embeddings with the Galileo models using real data (exported by our GEE exporter).\\n\\nOur GEE exporter is called using the following script:\\n```python\\nfrom datetime import date\\n\\nfrom src.data import EarthEngineExporter\\nfrom src.data.earthengine import EEBoundingBox\\n\\n# to export points\\nEarthEngineExporter(dest_bucket="bucket_name").export_for_latlons(df)\\n# to export a bounding box\\nbbox = EEBoundingBox(min_lat=49.017835,min_lon-123.303680,max_lat=49.389519,max_lon-122.792816)\\nEarthEngineExporter(dest_bucket="bucket_name").export_for_bbox(bbox, start_date=date(2024, 1, 1), end_date=(2025, 1, 1))\\n```\\n'
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "\"\"\"\n", + "# Making embeddings from real data\n", + "\n", + "This notebook demonstrates how to make embeddings with the Galileo models using real data (exported by our GEE exporter).\n", + "\n", + "Our GEE exporter is called using the following script:\n", + "```python\n", + "from datetime import date\n", + "\n", + "from src.data import EarthEngineExporter\n", + "from src.data.earthengine import EEBoundingBox\n", + "\n", + "# to export points\n", + "EarthEngineExporter(dest_bucket=\"bucket_name\").export_for_latlons(df)\n", + "# to export a bounding box\n", + "bbox = EEBoundingBox(min_lat=49.017835,min_lon-123.303680,max_lat=49.389519,max_lon-122.792816)\n", + "EarthEngineExporter(dest_bucket=\"bucket_name\").export_for_bbox(bbox, start_date=date(2024, 1, 1), end_date=(2025, 1, 1))\n", + "```\n", + "\"\"\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "MJUe", + "metadata": { + "marimo": { + "name": "imports" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "🚀 STARTING: Importing libraries...\n", + "✅ SUCCESS: All libraries imported successfully!\n", + "📊 Using PyTorch version: 2.2.1\n", + "📊 Using NumPy version: 1.26.4\n" + ] + } + ], + "source": [ + "print(\"🚀 STARTING: Importing libraries...\")\n", + "from pathlib import Path\n", + "\n", + "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "import torch\n", + "from einops import rearrange\n", + "from sklearn.cluster import KMeans\n", + "from sklearn.decomposition import PCA\n", + "from tqdm import tqdm\n", + "\n", + "from src.data.config import DATA_FOLDER, NORMALIZATION_DICT_FILENAME\n", + "from src.data.dataset import Dataset, Normalizer\n", + "from src.galileo import Encoder\n", + "from src.masking import MaskedOutput\n", + "from src.utils import config_dir\n", + "\n", + "print(\"✅ SUCCESS: All libraries imported successfully!\")\n", + "print(f\"📊 Using PyTorch version: {torch.__version__}\")\n", + "print(f\"📊 Using NumPy version: {np.__version__}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "vblA", + "metadata": { + "marimo": { + "name": "load_data" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "🔄 STEP 1: Loading normalization values...\n", + "✅ Loaded normalization dict with 6 entries\n", + "📁 Config directory: /Users/rfievet3/projects/CSSE/galileo/config\n", + "📄 Normalization file: normalization.json\n", + "🔄 Creating normalizer...\n", + "✅ Normalizer created successfully\n", + "🔄 Loading TIF file...\n", + "📁 TIF path: data/tifs/min_lat=-27.6721_min_lon=25.6796_max_lat=-27.663_max_lon=25.6897_dates=2022-01-01_2023-12-31.tif\n", + "📊 TIF exists: True\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Warning 1: TIFFReadDirectory:Sum of Photometric type-related color channels and ExtraSamples doesn't match SamplesPerPixel. Defining non-color channels as ExtraSamples.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "✅ TIF loaded and normalized successfully!\n", + "📊 Dataset output type: \n", + "📊 Space-time data shape: (102, 114, 24, 13)\n", + "📊 Space data shape: (102, 114, 16)\n", + "📊 Time data shape: (24, 6)\n", + "📊 Static data shape: (18,)\n" + ] + } + ], + "source": [ + "\"\"\"\n", + "First, we'll load a dataset output using one of the example training tifs in `data/tifs`. We also normalize it using the same normalization stats we used during training.\n", + "\"\"\"\n", + "print(\"🔄 STEP 1: Loading normalization values...\")\n", + "normalizing_dict = Dataset.load_normalization_values(\n", + " path=config_dir / NORMALIZATION_DICT_FILENAME\n", + ")\n", + "print(f\"✅ Loaded normalization dict with {len(normalizing_dict)} entries\")\n", + "print(f\"📁 Config directory: {config_dir}\")\n", + "print(f\"📄 Normalization file: {NORMALIZATION_DICT_FILENAME}\")\n", + "\n", + "print(\"🔄 Creating normalizer...\")\n", + "normalizer = Normalizer(std=True, normalizing_dicts=normalizing_dict)\n", + "print(\"✅ Normalizer created successfully\")\n", + "\n", + "print(\"🔄 Loading TIF file...\")\n", + "tif_path = Path(\n", + " \"data/tifs/min_lat=-27.6721_min_lon=25.6796_max_lat=-27.663_max_lon=25.6897_dates=2022-01-01_2023-12-31.tif\"\n", + ")\n", + "print(f\"📁 TIF path: {tif_path}\")\n", + "print(f\"📊 TIF exists: {tif_path.exists()}\")\n", + "\n", + "dataset_output = Dataset._tif_to_array(tif_path).normalize(normalizer)\n", + "print(\"✅ TIF loaded and normalized successfully!\")\n", + "print(f\"📊 Dataset output type: {type(dataset_output)}\")\n", + "print(f\"📊 Space-time data shape: {dataset_output.space_time_x.shape}\")\n", + "print(\n", + " f\"📊 Space data shape: {dataset_output.space_x.shape if hasattr(dataset_output, 'space_x') else 'N/A'}\"\n", + ")\n", + "print(\n", + " f\"📊 Time data shape: {dataset_output.time_x.shape if hasattr(dataset_output, 'time_x') else 'N/A'}\"\n", + ")\n", + "print(\n", + " f\"📊 Static data shape: {dataset_output.static_x.shape if hasattr(dataset_output, 'static_x') else 'N/A'}\"\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "bkHC", + "metadata": { + "marimo": { + "name": "visualize_data" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "🔄 STEP 2: Visualizing S2-RGB bands...\n", + "📊 Extracting RGB bands [4, 3, 2] from timestep 0\n", + "📊 RGB data shape: (102, 114, 3)\n", + "📊 RGB data range: [0.306, 0.826]\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "✅ RGB visualization complete!\n" + ] + } + ], + "source": [ + "\"\"\"\n", + "This tif captures the Vaal river near the [Bloemhof dam](https://en.wikipedia.org/wiki/Bloemhof_Dam).\n", + "We can visualize the S2-RGB bands from the first timestep:\n", + "\"\"\"\n", + "print(\"🔄 STEP 2: Visualizing S2-RGB bands...\")\n", + "print(\"📊 Extracting RGB bands [4, 3, 2] from timestep 0\")\n", + "rgb_data = dataset_output.space_time_x[:, :, 0, [4, 3, 2]].astype(np.float32)\n", + "print(f\"📊 RGB data shape: {rgb_data.shape}\")\n", + "print(f\"📊 RGB data range: [{rgb_data.min():.3f}, {rgb_data.max():.3f}]\")\n", + "\n", + "plt.clf()\n", + "plt.imshow(rgb_data)\n", + "plt.title(\"S2-RGB bands from first timestep\")\n", + "plt.show()\n", + "print(\"✅ RGB visualization complete!\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "lEQa", + "metadata": { + "marimo": { + "name": "load_model" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "🔄 STEP 3: Loading Galileo nano model...\n", + "📁 Model path: /Users/rfievet3/projects/CSSE/galileo/data/models/nano\n", + "📊 Model path exists: True\n", + "✅ Model loaded successfully!\n", + "📊 Model type: \n", + "📊 Model device: cpu\n", + "📊 Model parameters: 1,037,856\n" + ] + } + ], + "source": [ + "\"\"\"\n", + "We'll use the nano model (which is conveniently stored in git) to make these embeddings.\n", + "\"\"\"\n", + "print(\"🔄 STEP 3: Loading Galileo nano model...\")\n", + "model_path = DATA_FOLDER / \"models/nano\"\n", + "print(f\"📁 Model path: {model_path}\")\n", + "print(f\"📊 Model path exists: {model_path.exists()}\")\n", + "\n", + "model = Encoder.load_from_folder(model_path)\n", + "print(\"✅ Model loaded successfully!\")\n", + "print(f\"📊 Model type: {type(model)}\")\n", + "print(f\"📊 Model device: {next(model.parameters()).device}\")\n", + "print(f\"📊 Model parameters: {sum(p.numel() for p in model.parameters()):,}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "PKri", + "metadata": { + "marimo": { + "name": "define_embedding_function" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "🔄 STEP 4: Defining embedding function...\n", + "✅ Embedding function defined successfully!\n" + ] + } + ], + "source": [ + "from typing import Any\n", + "\n", + "print(\"🔄 STEP 4: Defining embedding function...\")\n", + "\n", + "def make_embeddings(\n", + " model: Any,\n", + " datasetoutput: Any,\n", + " window_size: int,\n", + " patch_size: int,\n", + " batch_size: int = 128,\n", + " device: Any = None,\n", + ") -> Any:\n", + " print(\"🔄 Starting embedding generation...\")\n", + " print(f\"📊 Window size: {window_size}\")\n", + " print(f\"📊 Patch size: {patch_size}\")\n", + " print(f\"📊 Batch size: {batch_size}\")\n", + " print(f\"📊 Device: {device}\")\n", + "\n", + " if device is None:\n", + " device = torch.device(\"cpu\")\n", + " model.eval()\n", + " print(\"✅ Model set to evaluation mode\")\n", + "\n", + " output_embeddings_list = []\n", + " batch_count = 0\n", + "\n", + " for i in tqdm(\n", + " datasetoutput.in_pixel_batches(batch_size=batch_size, window_size=window_size)\n", + " ):\n", + " batch_count += 1\n", + " if batch_count % 10 == 0:\n", + " print(f\"🔄 Processing batch {batch_count}...\")\n", + "\n", + " masked_output = MaskedOutput.from_datasetoutput(i, device=device)\n", + " with torch.no_grad():\n", + " model_output = model(\n", + " masked_output.space_time_x.float(),\n", + " masked_output.space_x.float(),\n", + " masked_output.time_x.float(),\n", + " masked_output.static_x.float(),\n", + " masked_output.space_time_mask,\n", + " masked_output.space_mask,\n", + " # lets mask inputs which will be the same for\n", + " # all pixels in the DatasetOutput\n", + " torch.ones_like(masked_output.time_mask),\n", + " torch.ones_like(masked_output.static_mask),\n", + " masked_output.months.long(),\n", + " patch_size=patch_size,\n", + " )\n", + "\n", + " embeddings = model.average_tokens(*model_output[:-1]).cpu().numpy()\n", + " output_embeddings_list.append(embeddings)\n", + "\n", + " print(f\"✅ Processed {batch_count} batches total\")\n", + " print(\"🔄 Concatenating embeddings...\")\n", + "\n", + " output_embeddings = np.concatenate(output_embeddings_list, axis=0)\n", + " print(f\"📊 Concatenated embeddings shape: {output_embeddings.shape}\")\n", + "\n", + " # reshape the embeddings to H, W, D\n", + " # first - how many \"height batches\" and \"width batches\" did we get?\n", + " h_b = datasetoutput.space_time_x.shape[0] // window_size\n", + " w_b = datasetoutput.space_time_x.shape[1] // window_size\n", + "\n", + " print(f\"📊 Reshaping: height_batches={h_b}, width_batches={w_b}\")\n", + "\n", + " reshaped_embeddings = rearrange(\n", + " output_embeddings, \"(h_b w_b) d -> h_b w_b d\", h_b=h_b, w_b=w_b\n", + " )\n", + " print(f\"📊 Final embeddings shape: {reshaped_embeddings.shape}\")\n", + "\n", + " return reshaped_embeddings\n", + "\n", + "print(\"✅ Embedding function defined successfully!\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "Xref", + "metadata": { + "marimo": { + "name": "generate_embeddings" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "🔄 STEP 5: Generating embeddings...\n", + "⏱️ This may take a while...\n", + "🔄 Starting embedding generation...\n", + "📊 Window size: 1\n", + "📊 Patch size: 1\n", + "📊 Batch size: 128\n", + "📊 Device: None\n", + "✅ Model set to evaluation mode\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\r", + "0it [00:00, ?it/s]\r", + "1it [00:00, 1.18it/s]\r", + "2it [00:01, 1.40it/s]\r", + "3it [00:01, 1.65it/s]\r", + "4it [00:02, 1.70it/s]\r", + "5it [00:02, 1.84it/s]\r", + "6it [00:03, 1.94it/s]\r", + "7it [00:03, 2.02it/s]\r", + "8it [00:04, 2.07it/s]\r", + "9it [00:04, 2.08it/s]" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "🔄 Processing batch 10...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\r", + "10it [00:05, 2.05it/s]\r", + "11it [00:05, 1.92it/s]\r", + "12it [00:06, 1.92it/s]\r", + "13it [00:06, 1.96it/s]\r", + "14it [00:07, 2.02it/s]\r", + "15it [00:07, 2.06it/s]\r", + "16it [00:08, 2.09it/s]\r", + "17it [00:08, 2.09it/s]\r", + "18it [00:09, 2.12it/s]\r", + "19it [00:09, 2.14it/s]" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "🔄 Processing batch 20...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\r", + "20it [00:10, 2.14it/s]\r", + "21it [00:10, 2.15it/s]\r", + "22it [00:11, 2.15it/s]\r", + "23it [00:11, 2.15it/s]\r", + "24it [00:12, 2.17it/s]\r", + "25it [00:12, 2.17it/s]\r", + "26it [00:12, 2.18it/s]\r", + "27it [00:13, 2.12it/s]\r", + "28it [00:13, 2.13it/s]\r", + "29it [00:14, 2.12it/s]" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "🔄 Processing batch 30...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\r", + "30it [00:14, 2.13it/s]\r", + "31it [00:15, 2.12it/s]\r", + "32it [00:15, 2.13it/s]\r", + "33it [00:16, 2.13it/s]\r", + "34it [00:16, 2.13it/s]\r", + "35it [00:17, 2.12it/s]\r", + "36it [00:17, 2.12it/s]\r", + "37it [00:18, 2.12it/s]\r", + "38it [00:18, 2.13it/s]\r", + "39it [00:19, 2.12it/s]" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "🔄 Processing batch 40...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\r", + "40it [00:19, 2.12it/s]\r", + "41it [00:20, 2.13it/s]\r", + "42it [00:20, 2.13it/s]\r", + "43it [00:20, 2.14it/s]\r", + "44it [00:21, 2.14it/s]\r", + "45it [00:21, 2.16it/s]\r", + "46it [00:22, 2.16it/s]\r", + "47it [00:22, 2.12it/s]\r", + "48it [00:23, 2.10it/s]\r", + "49it [00:23, 2.08it/s]" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "🔄 Processing batch 50...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\r", + "50it [00:24, 2.10it/s]\r", + "51it [00:24, 2.11it/s]\r", + "52it [00:25, 2.13it/s]\r", + "53it [00:25, 2.11it/s]\r", + "54it [00:26, 2.12it/s]\r", + "55it [00:26, 2.11it/s]\r", + "56it [00:27, 2.12it/s]\r", + "57it [00:27, 2.12it/s]\r", + "58it [00:28, 2.13it/s]\r", + "59it [00:28, 2.13it/s]" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "🔄 Processing batch 60...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\r", + "60it [00:28, 2.12it/s]\r", + "61it [00:29, 2.13it/s]\r", + "62it [00:29, 2.13it/s]\r", + "63it [00:30, 2.14it/s]\r", + "64it [00:30, 2.13it/s]\r", + "65it [00:31, 2.14it/s]\r", + "66it [00:31, 2.14it/s]\r", + "67it [00:32, 1.99it/s]\r", + "68it [00:32, 2.03it/s]\r", + "69it [00:33, 2.06it/s]" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "🔄 Processing batch 70...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\r", + "70it [00:33, 2.09it/s]\r", + "71it [00:34, 2.13it/s]\r", + "72it [00:34, 2.14it/s]\r", + "73it [00:35, 2.16it/s]\r", + "74it [00:35, 2.16it/s]\r", + "75it [00:36, 2.10it/s]\r", + "76it [00:36, 2.02it/s]\r", + "77it [00:37, 2.02it/s]\r", + "78it [00:37, 2.06it/s]\r", + "79it [00:38, 2.08it/s]" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "🔄 Processing batch 80...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\r", + "80it [00:38, 2.09it/s]\r", + "81it [00:38, 2.12it/s]\r", + "82it [00:39, 2.14it/s]\r", + "83it [00:39, 2.12it/s]\r", + "84it [00:40, 2.14it/s]\r", + "85it [00:40, 2.15it/s]\r", + "86it [00:41, 2.17it/s]\r", + "87it [00:41, 2.17it/s]\r", + "88it [00:42, 2.17it/s]\r", + "89it [00:42, 2.16it/s]" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "🔄 Processing batch 90...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\r", + "90it [00:43, 2.18it/s]\r", + "91it [00:43, 2.26it/s]\r", + "91it [00:43, 2.09it/s]\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "✅ Processed 91 batches total\n", + "🔄 Concatenating embeddings...\n", + "📊 Concatenated embeddings shape: (11628, 128)\n", + "📊 Reshaping: height_batches=102, width_batches=114\n", + "📊 Final embeddings shape: (102, 114, 128)\n", + "✅ Embeddings generated! Shape: (102, 114, 128)\n", + "🔄 Flattening embeddings for clustering...\n", + "📊 Flattened embeddings shape: (11628, 128)\n", + "📊 Embedding dimension: 128\n", + "📊 Number of pixels: 11628\n", + "✅ Embeddings ready for analysis!\n" + ] + } + ], + "source": [ + "print(\"🔄 STEP 5: Generating embeddings...\")\n", + "print(\"⏱️ This may take a while...\")\n", + "\n", + "embeddings = make_embeddings(model, dataset_output, 1, 1, 128)\n", + "print(f\"✅ Embeddings generated! Shape: {embeddings.shape}\")\n", + "\n", + "print(\"🔄 Flattening embeddings for clustering...\")\n", + "embeddings_flat = rearrange(embeddings, \"h w d -> (h w) d\")\n", + "print(f\"📊 Flattened embeddings shape: {embeddings_flat.shape}\")\n", + "print(f\"📊 Embedding dimension: {embeddings_flat.shape[1]}\")\n", + "print(f\"📊 Number of pixels: {embeddings_flat.shape[0]}\")\n", + "print(\"✅ Embeddings ready for analysis!\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "SFPL", + "metadata": { + "marimo": { + "name": "cluster_embeddings" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "🔄 STEP 6: Performing K-means clustering...\n", + "📊 Using 3 clusters\n", + "🔄 Fitting K-means model...\n", + "✅ K-means clustering complete!\n", + "📊 Labels shape: (11628,)\n", + "📊 Unique labels: [0 1 2]\n", + "📊 Label counts: [4122 7024 482]\n", + "🔄 Reshaping labels to image format...\n", + "📊 Reshaped labels shape: (102, 114)\n", + "✅ K-means clustering analysis complete!\n" + ] + } + ], + "source": [ + "print(\"🔄 STEP 6: Performing K-means clustering...\")\n", + "print(\"📊 Using 3 clusters\")\n", + "\n", + "kmeans = KMeans(n_clusters=3)\n", + "print(\"🔄 Fitting K-means model...\")\n", + "labels = kmeans.fit_predict(embeddings_flat)\n", + "print(\"✅ K-means clustering complete!\")\n", + "print(f\"📊 Labels shape: {labels.shape}\")\n", + "print(f\"📊 Unique labels: {np.unique(labels)}\")\n", + "print(f\"📊 Label counts: {np.bincount(labels)}\")\n", + "\n", + "print(\"🔄 Reshaping labels to image format...\")\n", + "labels = rearrange(labels, \"(h w) -> h w\", h=embeddings.shape[0], w=embeddings.shape[1])\n", + "print(f\"📊 Reshaped labels shape: {labels.shape}\")\n", + "print(\"✅ K-means clustering analysis complete!\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "BYtC", + "metadata": { + "marimo": { + "name": "reduce_dimensions" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "🔄 STEP 7: Performing PCA dimensionality reduction...\n", + "📊 Reducing to 3 components for RGB visualization\n", + "🔄 Fitting PCA model...\n", + "✅ PCA complete!\n", + "📊 PCA embeddings shape: (11628, 3)\n", + "📊 Explained variance ratio: [0.90551436 0.03274911 0.02369779]\n", + "📊 Total explained variance: 0.962\n", + "🔄 Reshaping PCA embeddings to image format...\n", + "📊 Reshaped PCA embeddings shape: (102, 114, 3)\n", + "✅ PCA dimensionality reduction complete!\n" + ] + } + ], + "source": [ + "print(\"🔄 STEP 7: Performing PCA dimensionality reduction...\")\n", + "print(\"📊 Reducing to 3 components for RGB visualization\")\n", + "\n", + "pca = PCA(n_components=3)\n", + "print(\"🔄 Fitting PCA model...\")\n", + "embeddings_pca = pca.fit_transform(embeddings_flat)\n", + "print(\"✅ PCA complete!\")\n", + "print(f\"📊 PCA embeddings shape: {embeddings_pca.shape}\")\n", + "print(f\"📊 Explained variance ratio: {pca.explained_variance_ratio_}\")\n", + "print(f\"📊 Total explained variance: {pca.explained_variance_ratio_.sum():.3f}\")\n", + "\n", + "print(\"🔄 Reshaping PCA embeddings to image format...\")\n", + "embeddings_reduced = rearrange(\n", + " embeddings_pca, \"(h w) d -> h w d\", h=embeddings.shape[0], w=embeddings.shape[1]\n", + ")\n", + "print(f\"📊 Reshaped PCA embeddings shape: {embeddings_reduced.shape}\")\n", + "print(\"✅ PCA dimensionality reduction complete!\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "RGSE", + "metadata": { + "marimo": { + "name": "plot_results" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "🔄 STEP 8: Creating visualizations...\n", + "📊 Visualization 1: K-means clustering results\n", + "✅ K-means visualization complete!\n", + "📊 Visualization 2: PCA-reduced embeddings as RGB\n", + "📊 PCA RGB range: [0.000, 1.000]\n", + "✅ PCA visualization complete!\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "🎉 ALL STEPS COMPLETED SUCCESSFULLY!\n", + "📊 Summary:\n", + " - Generated embeddings with shape: (102, 114, 3)\n", + " - Performed K-means clustering with 3 clusters\n", + " - Reduced dimensionality with PCA\n", + " - Created 2 visualizations\n", + "🎯 The Marimo notebook has run successfully with detailed logging!\n" + ] + } + ], + "source": [ + "print(\"🔄 STEP 8: Creating visualizations...\")\n", + "\n", + "# Plot the K-means clustering results\n", + "plt.figure(figsize=(12, 4))\n", + "\n", + "print(\"📊 Visualization 1: K-means clustering results\")\n", + "plt.subplot(1, 3, 1)\n", + "plt.imshow(labels, cmap=\"tab10\")\n", + "plt.title(\"K-means Clustering (3 clusters)\")\n", + "plt.colorbar()\n", + "print(\"✅ K-means visualization complete!\")\n", + "\n", + "# Plot the PCA-reduced embeddings as RGB\n", + "print(\"📊 Visualization 2: PCA-reduced embeddings as RGB\")\n", + "plt.subplot(1, 3, 2)\n", + "# Normalize to 0-1 range for display\n", + "embeddings_normalized = (embeddings_reduced - embeddings_reduced.min()) / (\n", + " embeddings_reduced.max() - embeddings_reduced.min()\n", + ")\n", + "print(\n", + " f\"📊 PCA RGB range: [{embeddings_normalized.min():.3f}, {embeddings_normalized.max():.3f}]\"\n", + ")\n", + "\n", + "plt.imshow(embeddings_normalized)\n", + "plt.title(\"PCA-reduced embeddings (RGB)\")\n", + "print(\"✅ PCA visualization complete!\")\n", + "\n", + "plt.tight_layout()\n", + "plt.show()\n", + "\n", + "print(\"🎉 ALL STEPS COMPLETED SUCCESSFULLY!\")\n", + "print(\"📊 Summary:\")\n", + "print(f\" - Generated embeddings with shape: {embeddings_reduced.shape}\")\n", + "print(\" - Performed K-means clustering with 3 clusters\")\n", + "print(\" - Reduced dimensionality with PCA\")\n", + "print(\" - Created 2 visualizations\")\n", + "print(\"🎯 The Marimo notebook has run successfully with detailed logging!\")" + ] + } + ], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/mypy.ini b/mypy.ini index 78293a9..5067990 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,5 +1,5 @@ [mypy] -exclude = venv|notebooks|anysat +exclude = venv|notebooks|src/eval/baseline_models|src/eval/cropharvest ignore_missing_imports = True [mypy-yaml.*] diff --git a/src/eval/cropharvest/datasets.py b/src/eval/cropharvest/datasets.py index 3861267..c974671 100644 --- a/src/eval/cropharvest/datasets.py +++ b/src/eval/cropharvest/datasets.py @@ -548,7 +548,7 @@ def sample(self, k: int, deterministic: bool = False) -> Tuple[np.ndarray, np.nd # returns a list of [pos_index, neg_index, pos_index, neg_index, ...] indices = [val for pair in zip(pos_indices, neg_indices) for val in pair] - output_x, output_y = zip(*[self[i] for i in indices]) + output_x, output_y = zip(*[self[i] for i in indices]) # type: ignore x = np.stack(output_x, axis=0) return x, np.array(output_y) diff --git a/visualizing_embeddings.py b/visualizing_embeddings.py index 5f78991..bdc2a13 100644 --- a/visualizing_embeddings.py +++ b/visualizing_embeddings.py @@ -1,7 +1,7 @@ import marimo -__generated_with = "0.9.30" -app = marimo.App(width="medium") +__generated_with = "0.18.4" +app = marimo.App(width="medium", auto_download=["ipynb"]) @app.cell @@ -42,7 +42,7 @@ def imports(): from tqdm import tqdm from src.data.config import DATA_FOLDER, NORMALIZATION_DICT_FILENAME - from src.data.dataset import Dataset, DatasetOutput, Normalizer + from src.data.dataset import Dataset, Normalizer from src.galileo import Encoder from src.masking import MaskedOutput from src.utils import config_dir @@ -50,11 +50,9 @@ def imports(): print("✅ SUCCESS: All libraries imported successfully!") print(f"📊 Using PyTorch version: {torch.__version__}") print(f"📊 Using NumPy version: {np.__version__}") - return ( DATA_FOLDER, Dataset, - DatasetOutput, Encoder, KMeans, MaskedOutput, @@ -72,7 +70,13 @@ def imports(): @app.cell -def load_data(Dataset, NORMALIZATION_DICT_FILENAME, Normalizer, Path, config_dir): +def load_data( + Dataset, + NORMALIZATION_DICT_FILENAME, + Normalizer, + Path, + config_dir, +): """ First, we'll load a dataset output using one of the example training tifs in `data/tifs`. We also normalize it using the same normalization stats we used during training. """ @@ -108,8 +112,7 @@ def load_data(Dataset, NORMALIZATION_DICT_FILENAME, Normalizer, Path, config_dir print( f"📊 Static data shape: {dataset_output.static_x.shape if hasattr(dataset_output, 'static_x') else 'N/A'}" ) - - return dataset_output, normalizer, normalizing_dict + return (dataset_output,) @app.cell @@ -151,7 +154,7 @@ def load_model(DATA_FOLDER, Encoder): @app.cell -def define_embedding_function(Encoder, DatasetOutput, MaskedOutput, np, rearrange, torch, tqdm): +def define_embedding_function(MaskedOutput, np, rearrange, torch, tqdm): from typing import Any print("🔄 STEP 4: Defining embedding function...") @@ -243,7 +246,6 @@ def generate_embeddings(dataset_output, make_embeddings, model, rearrange): print(f"📊 Embedding dimension: {embeddings_flat.shape[1]}") print(f"📊 Number of pixels: {embeddings_flat.shape[0]}") print("✅ Embeddings ready for analysis!") - return embeddings, embeddings_flat @@ -264,7 +266,6 @@ def cluster_embeddings(KMeans, embeddings, embeddings_flat, np, rearrange): labels = rearrange(labels, "(h w) -> h w", h=embeddings.shape[0], w=embeddings.shape[1]) print(f"📊 Reshaped labels shape: {labels.shape}") print("✅ K-means clustering analysis complete!") - return (labels,) @@ -287,8 +288,7 @@ def reduce_dimensions(PCA, embeddings, embeddings_flat, rearrange): ) print(f"📊 Reshaped PCA embeddings shape: {embeddings_reduced.shape}") print("✅ PCA dimensionality reduction complete!") - - return embeddings_pca, embeddings_reduced + return (embeddings_reduced,) @app.cell @@ -330,8 +330,7 @@ def plot_results(embeddings_reduced, labels, plt): print(" - Reduced dimensionality with PCA") print(" - Created 2 visualizations") print("🎯 The Marimo notebook has run successfully with detailed logging!") - - return (embeddings_normalized,) + return if __name__ == "__main__": From 4e79fc6581829d841ec6c45602e3d9016ebc0f0d Mon Sep 17 00:00:00 2001 From: Robin Fievet Date: Mon, 12 Jan 2026 11:46:08 -0500 Subject: [PATCH 4/8] fix lint --- .env.example | 7 + .gitignore | 3 + .pre-commit-config.yaml | 2 +- copernicus_marimo.py | 921 ++++++++++++++++++++++++ mypy.ini | 2 +- pyproject.toml | 2 + src/data/copernicus/__init__.py | 31 + src/data/copernicus/client.py | 344 +++++++++ src/data/copernicus/image_processing.py | 272 +++++++ src/data/copernicus/s1.py | 343 +++++++++ src/data/copernicus/s2.py | 480 ++++++++++++ src/data/copernicus/utils.py | 200 +++++ src/data/copernicus/visualization.py | 367 ++++++++++ uv.lock | 13 + 14 files changed, 2985 insertions(+), 2 deletions(-) create mode 100644 .env.example create mode 100644 copernicus_marimo.py create mode 100644 src/data/copernicus/__init__.py create mode 100644 src/data/copernicus/client.py create mode 100644 src/data/copernicus/image_processing.py create mode 100644 src/data/copernicus/s1.py create mode 100644 src/data/copernicus/s2.py create mode 100644 src/data/copernicus/utils.py create mode 100644 src/data/copernicus/visualization.py diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..8d08bba --- /dev/null +++ b/.env.example @@ -0,0 +1,7 @@ +# Copernicus Data Space Ecosystem credentials +# Get these from: https://dataspace.copernicus.eu/ +# 1. Create an account +# 2. Go to User Settings > API Keys +# 3. Create a new API key pair +COPERNICUS_CLIENT_ID=your_client_id_here +COPERNICUS_CLIENT_SECRET=your_client_secret_here diff --git a/.gitignore b/.gitignore index 2c9c089..6d410c1 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,6 @@ imgs .coverage coverage.xml htmlcov/ + +# Environment variables +.env diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 98c3969..2747469 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: hooks: - id: mypy additional_dependencies: [types-requests] - exclude: ^src/eval/(baseline_models|cropharvest)/ + exclude: ^(src/eval/(baseline_models|cropharvest)/|.*_marimo\.py|copernicus_marimo\.py) - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 diff --git a/copernicus_marimo.py b/copernicus_marimo.py new file mode 100644 index 0000000..44bd314 --- /dev/null +++ b/copernicus_marimo.py @@ -0,0 +1,921 @@ +import marimo + +__generated_with = "0.10.6" +app = marimo.App(width="full") + + +@app.cell +def __(): + import marimo as mo + + mo.md( + r""" + # 🛰️ Copernicus Satellite Data Explorer + + **Interactive demonstration of satellite data fetching with visual map display** + + This notebook demonstrates: + - 🔐 Authentication with Copernicus Data Space Ecosystem + - 🛰️ Fetching Sentinel-1 (SAR) and Sentinel-2 (optical) data + - 🗺️ **Visual map display** of downloaded satellite imagery + - 💾 Intelligent caching system + - 📊 Detailed metadata analysis + + **Target Area**: Luxembourg (49.114982°N, 6.155827°E) - 800m × 800m + """ + ) + return (mo,) + + +@app.cell +def __(): + # Setup and imports + print("🔧 SETTING UP COPERNICUS SATELLITE DATA EXPLORER") + print("=" * 60) + + import json + import sys + from datetime import datetime, timedelta + from pathlib import Path + + import matplotlib.pyplot as plt + import numpy as np + import pandas as pd + + sys.path.append("src") + + print("✅ Core libraries imported") + print("✅ Visualization libraries ready for map display") + print("✅ Source path configured") + + return Path, datetime, json, np, pd, plt, sys, timedelta + + +@app.cell +def __(): + # Target area configuration + print("\n🎯 CONFIGURING TARGET AREA") + print("=" * 40) + + center_lat = 49.114982 + center_lon = 6.155827 + + print("📍 Target location: Luxembourg") + print(f" • Latitude: {center_lat:.6f}°N") + print(f" • Longitude: {center_lon:.6f}°E") + + # Calculate 800m x 800m bounding box + lat_offset = 0.8 / 111 + lon_offset = 0.8 / 69.5 + + target_bbox = [ + center_lon - lon_offset, + center_lat - lat_offset, + center_lon + lon_offset, + center_lat + lat_offset, + ] + + print(f"\n📐 Bounding box: {target_bbox}") + print("📊 Expected at 10m resolution: 80×80 pixels") + + return center_lat, center_lon, target_bbox + + +@app.cell +@app.cell +def __(): + from datetime import datetime, timedelta + + # Date range configuration + print("\n📅 CONFIGURING DATE RANGE") + print("=" * 35) + + end_dt = datetime.now() - timedelta(days=30) + start_dt = end_dt - timedelta(days=14) + date_start = start_dt.strftime("%Y-%m-%d") + date_end = end_dt.strftime("%Y-%m-%d") + + print(f"🗓️ Search period: {date_start} to {date_end}") + print(f"⏱️ Duration: {(end_dt - start_dt).days} days") + print("💡 Recent but processed data for best availability") + + return date_end, date_start + + +@app.cell +def __(): + from datetime import datetime + + # Initialize Copernicus client + print("\n🔧 INITIALIZING COPERNICUS CLIENT") + print("=" * 45) + + from src.data.copernicus import CopernicusClient + + try: + copernicus_client = CopernicusClient() + auth_token = copernicus_client._get_access_token() + + print("✅ Client created successfully!") + print(f"📁 Cache: {copernicus_client.cache_dir}") + print(f"🎫 Token: {auth_token[:20]}...{auth_token[-10:]}") + print(f"⏰ Expires: {datetime.fromtimestamp(copernicus_client._token_expires_at)}") + + client_ready = True + + except Exception as error: + print(f"❌ Setup failed: {error}") + print("💡 Check .env file with COPERNICUS_CLIENT_ID and COPERNICUS_CLIENT_SECRET") + client_ready = False + copernicus_client = None + + return CopernicusClient, client_ready, copernicus_client + + +@app.cell +def __(client_ready, copernicus_client, date_end, date_start, json, target_bbox): + # Fetch Sentinel-2 data + print("🔵 FETCHING SENTINEL-2 OPTICAL IMAGERY") + print("=" * 50) + + if client_ready: + print("🛰️ About Sentinel-2:") + print(" • Twin satellites providing optical/multispectral imaging") + print(" • 13 spectral bands from visible to shortwave infrared") + print(" • 10m, 20m, 60m spatial resolution depending on band") + print(" • 5-day revisit time with both satellites") + + print("\n🔍 Search parameters:") + print(" • Area: Luxembourg (800m × 800m)") + print(f" • Dates: {date_start} to {date_end}") + print(" • Product: S2MSI1C (Level-1C)") + print(" • Resolution: 10m") + print(" • Max clouds: 50%") + + try: + s2_files = copernicus_client.fetch_s2( + bbox=target_bbox, + start_date=date_start, + end_date=date_end, + resolution=10, + max_cloud_cover=50, + product_type="S2MSI1C", + download_data=True, # ENABLE ACTUAL DOWNLOADS + interactive=False, # No prompts in notebook + ) + + print("\n💡 DOWNLOAD STATUS:") + print("=" * 30) + print("🔄 Attempting to download actual satellite imagery") + print("📊 This will show real Luxembourg satellite data") + print("⚠️ Note: Downloads are ~500MB per product") + print("🎯 Target: Luxembourg coordinates for actual imagery") + + print(f"\n✅ Found {len(s2_files)} Sentinel-2 products") + + if s2_files: + print("\n📊 PRODUCT DETAILS:") + for s2_idx, s2_file_path in enumerate(s2_files[:3], 1): + print(f"\n🛰️ Product {s2_idx}: {s2_file_path.name}") + + if s2_file_path.suffix == ".json": + try: + with open(s2_file_path) as s2_file_handle: + s2_metadata = json.load(s2_file_handle) + + prod_id = s2_metadata.get("product_id", "N/A") + prod_name = s2_metadata.get("product_name", "N/A") + + print(f" 🆔 ID: {prod_id}") + print(f" 📛 Name: {prod_name}") + + # Parse date + s2_content_date = s2_metadata.get("content_date", {}) + acq_start = s2_content_date.get("Start", "N/A") + if acq_start != "N/A": + acq_date = acq_start[:10] + acq_time = acq_start[11:19] + print(f" 📅 Acquired: {acq_date} at {acq_time} UTC") + + # Available bands + print(" 📡 Key bands available:") + print(" • B02 (490nm) Blue - 10m") + print(" • B03 (560nm) Green - 10m") + print(" • B04 (665nm) Red - 10m") + print(" • B08 (842nm) NIR - 10m") + print(" • + 9 more spectral bands") + + except Exception as e: + print(f" ❌ Error reading metadata: {e}") + else: + print("⚠️ No products found - try different parameters") + + except Exception as fetch_error: + print(f"❌ Fetch failed: {fetch_error}") + s2_files = [] + else: + print("❌ Client not ready") + s2_files = [] + + return (s2_files,) + + +@app.cell +def __(client_ready, copernicus_client, date_end, date_start, json, target_bbox): + # Fetch Sentinel-1 data + print("🔴 FETCHING SENTINEL-1 SAR IMAGERY") + print("=" * 45) + + if client_ready: + print("🛰️ About Sentinel-1:") + print(" • Twin satellites providing SAR (radar) imaging") + print(" • C-band frequency (~5.4 GHz)") + print(" • All-weather, day/night capability") + print(" • Penetrates clouds and light rain") + print(" • 6-day revisit time with both satellites") + + print("\n🔍 SAR search parameters:") + print(" • Area: Luxembourg (800m × 800m)") + print(f" • Dates: {date_start} to {date_end}") + print(" • Product: GRD (Ground Range Detected)") + print(" • Polarization: VV,VH (dual-pol)") + print(" • Orbit: ASCENDING (evening pass)") + + try: + s1_files = copernicus_client.fetch_s1( + bbox=target_bbox, + start_date=date_start, + end_date=date_end, + product_type="GRD", + polarization="VV,VH", + orbit_direction="ASCENDING", + ) + + print(f"\n✅ Found {len(s1_files)} Sentinel-1 products") + + if s1_files: + print("\n📊 SAR PRODUCT DETAILS:") + for s1_idx, s1_file_path in enumerate(s1_files[:3], 1): + print(f"\n🛰️ SAR Product {s1_idx}: {s1_file_path.name}") + + if s1_file_path.suffix == ".json": + try: + with open(s1_file_path) as s1_file_handle: + s1_sar_metadata = json.load(s1_file_handle) + + sar_id = s1_sar_metadata.get("product_id", "N/A") + sar_name = s1_sar_metadata.get("product_name", "N/A") + + print(f" 🆔 ID: {sar_id}") + print(f" 📛 Name: {sar_name}") + + # Determine satellite + if "S1A" in sar_name: + satellite = "Sentinel-1A" + elif "S1B" in sar_name: + satellite = "Sentinel-1B" + else: + satellite = "Sentinel-1" + print(f" 🛰️ Satellite: {satellite}") + + # Parse date + sar_content = s1_sar_metadata.get("content_date", {}) + sar_start = sar_content.get("Start", "N/A") + if sar_start != "N/A": + sar_date = sar_start[:10] + sar_time = sar_start[11:19] + print(f" 📅 Acquired: {sar_date} at {sar_time} UTC") + + print(" 📡 SAR capabilities:") + print(" • VV: Water detection, soil moisture") + print(" • VH: Vegetation structure, crops") + print(" • Weather independent imaging") + + except Exception as e: + print(f" ❌ Error reading SAR metadata: {e}") + else: + print("⚠️ No SAR products found") + print("💡 Common for recent dates - SAR processing takes longer") + + except Exception as sar_error: + print(f"❌ SAR fetch failed: {sar_error}") + s1_files = [] + else: + print("❌ Client not ready") + s1_files = [] + + return (s1_files,) + + +@app.cell +def __(center_lat, center_lon, mo, np, plt, s2_files, target_bbox): + # Visual map display with Copernicus metadata + sample imagery + print("🗺️ CREATING COMPREHENSIVE SATELLITE DATA VISUALIZATION") + print("=" * 65) + + print("📍 Generating interactive map...") + print(f" • Center: {center_lat:.6f}°N, {center_lon:.6f}°E") + print(" • Target area: 800m × 800m") + print(" • Copernicus metadata + sample imagery demonstration") + + # Import required libraries + try: + from pathlib import Path as PathLib + + import rasterio + + print("✅ Rasterio imported for satellite imagery processing") + + # Check if we have downloaded S2 ZIP files (actual imagery) + downloaded_s2_files = [f for f in s2_files if f.suffix == ".zip"] + metadata_s2_files = [f for f in s2_files if f.suffix == ".json"] + + print("📊 Data status:") + print(f" • Downloaded imagery: {len(downloaded_s2_files)} ZIP files") + print(f" • Metadata files: {len(metadata_s2_files)} JSON files") + + # Always create a consistent figure structure + if downloaded_s2_files: + print("🎯 PROCESSING ACTUAL LUXEMBOURG SATELLITE IMAGERY") + + # Create figure with downloaded imagery + num_images = min(len(downloaded_s2_files), 2) # Show up to 2 images + fig, axes = plt.subplots(1, num_images + 1, figsize=(8 * (num_images + 1), 10)) + + # Ensure axes is always a list for consistent indexing + if num_images + 1 == 1: + axes = [axes] # Single subplot case + elif not hasattr(axes, "__len__"): + axes = [axes] # Fallback for single axis + + # FIRST PANEL: Coverage map + ax_coverage = axes[0] + + else: + print("📋 SHOWING METADATA + SAMPLE IMAGERY") + + # Create figure with three panels as before + fig, axes = plt.subplots(1, 3, figsize=(24, 8)) + + # axes is always an array for 3 subplots, so we can index directly + ax_coverage = axes[0] + + # PANEL 1: Coverage map with Copernicus metadata + print("🗺️ Creating coverage map with Copernicus metadata...") + + # Map extent with padding + padding = 0.01 + map_extent = [ + target_bbox[0] - padding, + target_bbox[2] + padding, + target_bbox[1] - padding, + target_bbox[3] + padding, + ] + + # Create coordinate grid + lons = np.linspace(map_extent[0], map_extent[1], 100) + lats = np.linspace(map_extent[2], map_extent[3], 100) + lon_grid, lat_grid = np.meshgrid(lons, lats) + + # Background terrain pattern + elevation = np.sin(lon_grid * 100) * np.cos(lat_grid * 100) * 0.1 + ax_coverage.contourf(lon_grid, lat_grid, elevation, levels=20, cmap="terrain", alpha=0.3) + + # Plot target bounding box + bbox_lons = [ + target_bbox[0], + target_bbox[2], + target_bbox[2], + target_bbox[0], + target_bbox[0], + ] + bbox_lats = [ + target_bbox[1], + target_bbox[1], + target_bbox[3], + target_bbox[3], + target_bbox[1], + ] + ax_coverage.plot( + bbox_lons, bbox_lats, "r-", linewidth=3, label="Target Area (800m × 800m)" + ) + ax_coverage.fill(bbox_lons, bbox_lats, "red", alpha=0.2) + + # Center point + ax_coverage.plot(center_lon, center_lat, "ro", markersize=10, label="Luxembourg Center") + + # Satellite coverage from Copernicus + if s2_files: + coverage_lons = [ + target_bbox[0] - 0.005, + target_bbox[2] + 0.005, + target_bbox[2] + 0.005, + target_bbox[0] - 0.005, + target_bbox[0] - 0.005, + ] + coverage_lats = [ + target_bbox[1] - 0.005, + target_bbox[1] - 0.005, + target_bbox[3] + 0.005, + target_bbox[3] + 0.005, + target_bbox[1] - 0.005, + ] + ax_coverage.plot( + coverage_lons, + coverage_lats, + "b--", + linewidth=2, + alpha=0.7, + label=f"Copernicus Products ({len(s2_files)} found)", + ) + + # Customize coverage map + ax_coverage.set_xlabel("Longitude (°E)", fontsize=12) + ax_coverage.set_ylabel("Latitude (°N)", fontsize=12) + ax_coverage.set_title( + "Luxembourg Target Area\nCopernicus Coverage", fontsize=14, fontweight="bold" + ) + ax_coverage.grid(True, alpha=0.3) + ax_coverage.legend(loc="upper right") + + # Add Luxembourg info box + lux_info = f"Luxembourg Data:\n• Lat: {center_lat:.4f}°N\n• Lon: {center_lon:.4f}°E\n• Area: 800m × 800m\n• Products: {len(s2_files)}" + ax_coverage.text( + 0.02, + 0.98, + lux_info, + transform=ax_coverage.transAxes, + fontsize=10, + verticalalignment="top", + bbox=dict(boxstyle="round,pad=0.5", facecolor="lightblue", alpha=0.8), + ) + + # PROCESS DOWNLOADED LUXEMBOURG IMAGERY - SHOW ACTUAL IMAGES + if downloaded_s2_files: + print("🛰️ Processing downloaded Luxembourg satellite imagery...") + + # Process each downloaded ZIP file + for idx, s2_zip_file in enumerate(downloaded_s2_files[:2]): # Limit to 2 + if idx + 1 >= len(axes): + break # Skip if not enough axes + + ax_img = axes[idx + 1] + + try: + import tempfile + import zipfile + from pathlib import Path as PathLib + + print(f" 📦 Processing: {s2_zip_file.name}") + + # Extract and process Sentinel-2 ZIP file to show ACTUAL imagery + with tempfile.TemporaryDirectory() as temp_dir: + temp_path = PathLib(temp_dir) + + # Extract ZIP file + with zipfile.ZipFile(s2_zip_file, "r") as zip_ref: + zip_ref.extractall(temp_path) + + # Find SAFE directory (Sentinel-2 format) + safe_dirs = list(temp_path.glob("*.SAFE")) + if safe_dirs: + safe_dir = safe_dirs[0] + + # Find 10m resolution bands in IMG_DATA directory + img_data_dir = safe_dir / "GRANULE" + granule_dirs = list(img_data_dir.glob("*")) + + if granule_dirs: + granule_dir = granule_dirs[0] + img_dir = granule_dir / "IMG_DATA" + + # Look for RGB bands with correct naming pattern + band_files = {} + for band in ["B02", "B03", "B04"]: # Blue, Green, Red + # Try multiple naming patterns + patterns = [ + f"*_{band}_10m.jp2", # Standard pattern + f"*_{band}.jp2", # Alternative pattern + f"*{band}.jp2", # Simple pattern + ] + + for pattern in patterns: + band_matches = list(img_dir.glob(pattern)) + if band_matches: + band_files[band] = band_matches[0] + print(f" Found {band}: {band_matches[0].name}") + break + + if len(band_files) >= 3: + print(" Creating RGB composite from Luxembourg imagery...") + + # Create RGB composite from actual satellite data + rgb_bands = [] + band_order = [ + "B04", + "B03", + "B02", + ] # Red, Green, Blue for RGB display + + for band_name in band_order: + if band_name in band_files: + with rasterio.open(band_files[band_name]) as src: + band_data = src.read(1) + + # Get geospatial info from first band + if len(rgb_bands) == 0: + _ = ( + src.transform + ) # Store transform (unused but available) + bounds = src.bounds + crs = src.crs + print(f" Image bounds: {bounds}") + + rgb_bands.append(band_data) + + if len(rgb_bands) == 3: + # Stack and normalize bands for display + rgb_array = np.stack(rgb_bands, axis=0) + rgb_normalized = np.zeros_like(rgb_array, dtype=np.float32) + + for i in range(3): + band = rgb_array[i] + # Use percentile normalization for better contrast + valid_pixels = band[band > 0] + if len(valid_pixels) > 0: + p2, p98 = np.percentile(valid_pixels, [2, 98]) + if p98 > p2: + rgb_normalized[i] = np.clip( + (band - p2) / (p98 - p2), 0, 1 + ) + else: + rgb_normalized[i] = ( + band / band.max() + if band.max() > 0 + else band + ) + + # Display the ACTUAL Luxembourg satellite image + rgb_display = np.transpose(rgb_normalized, (1, 2, 0)) + + # Convert UTM bounds to WGS84 for proper display + from rasterio.warp import transform_bounds + + # Transform bounds from UTM to WGS84 + wgs84_bounds = transform_bounds( + crs, + "EPSG:4326", + bounds.left, + bounds.bottom, + bounds.right, + bounds.top, + ) + + extent = [ + wgs84_bounds[0], + wgs84_bounds[2], + wgs84_bounds[1], + wgs84_bounds[3], + ] + print(f" WGS84 bounds: {wgs84_bounds}") + + # Show the actual satellite imagery + ax_img.imshow(rgb_display, extent=extent, aspect="auto") + + # Add target area overlay on the satellite image + bbox_lons = [ + target_bbox[0], + target_bbox[2], + target_bbox[2], + target_bbox[0], + target_bbox[0], + ] + bbox_lats = [ + target_bbox[1], + target_bbox[1], + target_bbox[3], + target_bbox[3], + target_bbox[1], + ] + ax_img.plot( + bbox_lons, + bbox_lats, + "red", + linewidth=3, + alpha=0.8, + label="Target Area", + ) + + # Zoom to Luxembourg area (with some padding) + padding = 0.02 + ax_img.set_xlim( + target_bbox[0] - padding, target_bbox[2] + padding + ) + ax_img.set_ylim( + target_bbox[1] - padding, target_bbox[3] + padding + ) + + # Customize plot + ax_img.set_xlabel("Longitude (°E)", fontsize=12) + ax_img.set_ylabel("Latitude (°N)", fontsize=12) + ax_img.set_title( + f"Luxembourg Satellite Image #{idx+1}\n{s2_zip_file.name[:40]}...", + fontsize=11, + fontweight="bold", + ) + ax_img.grid(True, alpha=0.3, color="white") + ax_img.legend() + + print( + " ✅ ACTUAL Luxembourg RGB satellite image displayed!" + ) + continue + + # If we couldn't find RGB bands, show info + ax_img.text( + 0.5, + 0.5, + f"Found {len(band_files)} bands\nLooking for RGB bands...", + ha="center", + va="center", + transform=ax_img.transAxes, + fontsize=12, + ) + ax_img.set_title("Processing Bands...", fontsize=12) + else: + ax_img.text( + 0.5, + 0.5, + "No granule directories found", + ha="center", + va="center", + transform=ax_img.transAxes, + fontsize=12, + ) + ax_img.set_title("Extraction Issue", fontsize=12) + else: + ax_img.text( + 0.5, + 0.5, + "No SAFE directory found in ZIP", + ha="center", + va="center", + transform=ax_img.transAxes, + fontsize=12, + ) + ax_img.set_title("ZIP Structure Issue", fontsize=12) + + except Exception as e: + print(f" ❌ Error processing {s2_zip_file.name}: {e}") + ax_img.text( + 0.5, + 0.5, + f"Error extracting imagery:\n{str(e)[:100]}...", + ha="center", + va="center", + transform=ax_img.transAxes, + fontsize=10, + ) + ax_img.set_title("Processing Error", fontsize=12) + + print("✅ Luxembourg satellite imagery processing complete!") + + else: + # FALLBACK: Show metadata only + pass + + print("📊 Creating Copernicus metadata visualization...") + + # Determine which axis to use for metadata display + if hasattr(axes, "__len__") and len(axes) >= 2: + ax_metadata = axes[1] + else: + ax_metadata = ax_coverage # Fallback to coverage axis if only one panel + + if s2_files: + # Read metadata from one of the files + metadata_file = s2_files[0] + if metadata_file.suffix == ".json": + try: + import json as json_lib + + with open(metadata_file) as f: + viz_metadata = json_lib.load(f) + + # Create a text visualization of the metadata + ax_metadata.axis("off") # Remove axes for text display + + # Format metadata for display + display_text = "🛰️ COPERNICUS METADATA\n" + "=" * 30 + "\n\n" + + if "product_name" in viz_metadata: + product_name = viz_metadata["product_name"] + display_text += f"📛 Product: {product_name[:40]}...\n\n" + + if "content_date" in viz_metadata: + viz_content_date = viz_metadata.get("content_date", {}) + if isinstance(viz_content_date, dict) and "Start" in viz_content_date: + date_str = viz_content_date["Start"][:10] + time_str = viz_content_date["Start"][11:19] + display_text += f"📅 Acquired: {date_str}\n" + display_text += f"⏰ Time: {time_str} UTC\n\n" + + display_text += "📡 Bands Available:\n" + display_text += " • B02 (490nm) Blue - 10m\n" + display_text += " • B03 (560nm) Green - 10m\n" + display_text += " • B04 (665nm) Red - 10m\n" + display_text += " • B08 (842nm) NIR - 10m\n" + display_text += " • + 9 more spectral bands\n\n" + + if "download_url" in viz_metadata: + display_text += "🔗 Download URL:\n" + display_text += " Available via Copernicus API\n\n" + + display_text += "💾 Status: Metadata cached\n" + display_text += "📊 Ready for download/processing" + + # Display the text + ax_metadata.text( + 0.05, + 0.95, + display_text, + transform=ax_metadata.transAxes, + fontsize=11, + verticalalignment="top", + fontfamily="monospace", + bbox=dict(boxstyle="round,pad=1", facecolor="white", alpha=0.9), + ) + + ax_metadata.set_title( + "Copernicus Product Metadata\n(From Live API)", + fontsize=14, + fontweight="bold", + ) + + print("✅ Copernicus metadata visualization created") + + except Exception as e: + ax_metadata.text( + 0.5, + 0.5, + f"Error reading\nCopernicus metadata:\n{e}", + ha="center", + va="center", + transform=ax_metadata.transAxes, + fontsize=12, + ) + ax_metadata.set_title("Metadata Error", fontsize=14) + else: + ax_metadata.text( + 0.5, + 0.5, + "No Copernicus\nmetadata available", + ha="center", + va="center", + transform=ax_metadata.transAxes, + fontsize=14, + ) + ax_metadata.set_title("No Metadata", fontsize=14) + else: + ax_metadata.text( + 0.5, + 0.5, + "No Copernicus products\nfound for this area\nand date range", + ha="center", + va="center", + transform=ax_metadata.transAxes, + fontsize=14, + ) + ax_metadata.set_title("No Products Found", fontsize=14) + + # Skip sample imagery - focus on actual Luxembourg data + print("🎯 Focusing on actual Luxembourg satellite data from Copernicus") + + plt.tight_layout() + + print("✅ Luxembourg satellite data visualization created!") + print(" • LEFT: Luxembourg coverage map with target area") + print(" • CENTER: Downloaded Luxembourg Sentinel-2 data") + print(" • RIGHT: Additional Luxembourg satellite products") + + except ImportError as e: + print(f"❌ Missing dependencies: {e}") + + # Create simple fallback + fig, ax1 = plt.subplots(1, 1, figsize=(12, 10)) + ax1.text( + 0.5, + 0.5, + "Installing satellite imagery\nprocessing dependencies...", + ha="center", + va="center", + transform=ax1.transAxes, + fontsize=16, + ) + ax1.set_title("Setting Up Satellite Processing", fontsize=14) + + mo.as_html(fig) + + return fig + + +@app.cell +def __(client_ready, copernicus_client, date_end, date_start, target_bbox): + # Cache performance test + print("💾 CACHE PERFORMANCE TEST") + print("=" * 35) + + if client_ready: + import time + + cache_dir = copernicus_client.cache_dir + print(f"📁 Cache directory: {cache_dir}") + + if cache_dir.exists(): + cache_files = list(cache_dir.rglob("*")) + cache_size = sum(f.stat().st_size for f in cache_files if f.is_file()) + print(f"📊 Cache: {len(cache_files)} files, {cache_size:,} bytes") + + print("\n🎯 Testing cache performance...") + start_time = time.time() + + try: + cached_results = copernicus_client.fetch_s2( + bbox=target_bbox, + start_date=date_start, + end_date=date_end, + resolution=10, + max_cloud_cover=50, + product_type="S2MSI1C", + download_data=True, # Same as main fetch + interactive=False, # No prompts for cache test + ) + + duration = time.time() - start_time + + print(f"⏱️ Completed in {duration:.4f} seconds") + print(f"📦 Products: {len(cached_results)}") + + if duration < 0.1: + print("🚀 CACHE HIT! (Lightning fast)") + print("💡 No API calls - instant retrieval") + else: + print("🌐 API CALL (First time)") + print("💡 Results cached for future requests") + + except Exception as cache_error: + print(f"❌ Cache test failed: {cache_error}") + else: + print("❌ Client not ready") + + return + + +@app.cell +def __(client_ready, s1_files, s2_files): + # Final summary + print("📊 MISSION SUMMARY") + print("=" * 30) + + if client_ready: + s2_count = len(s2_files) if "s2_files" in locals() and s2_files else 0 + s1_count = len(s1_files) if "s1_files" in locals() and s1_files else 0 + total = s2_count + s1_count + + print("🎯 RESULTS:") + print(f" 🔵 Sentinel-2 (Optical): {s2_count} products") + print(f" 🔴 Sentinel-1 (SAR): {s1_count} products") + print(f" 📦 Total: {total} satellite products") + + print("\n✅ CAPABILITIES DEMONSTRATED:") + print(" 🔐 OAuth2 authentication") + print(" 🛰️ Multi-satellite data discovery") + print(" 🗺️ Visual map display") + print(" 💾 Intelligent caching") + print(" 📊 Metadata analysis") + + print("\n🌟 APPLICATIONS ENABLED:") + print(" 🌾 Agriculture: Crop monitoring") + print(" 🌊 Water: Quality assessment") + print(" 🏙️ Urban: Development tracking") + print(" 🌲 Environment: Forest monitoring") + + print("\n🚀 READY FOR GALILEO INTEGRATION!") + print(" 📍 Luxembourg: 800m × 800m") + print(f" 📦 Products: {total} discovered") + print(" 🎯 Resolution: 10m (80×80 pixels)") + + if total > 0: + visual = " " + "🔵" * s2_count + "🔴" * s1_count + print(f"\n📈 Visual: {visual}") + print(" Legend: 🔵=Sentinel-2, 🔴=Sentinel-1") + + else: + print("❌ Authentication failed") + print("💡 Check .env credentials") + + return + + +if __name__ == "__main__": + app.run() diff --git a/mypy.ini b/mypy.ini index 5067990..cade36c 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,5 +1,5 @@ [mypy] -exclude = venv|notebooks|src/eval/baseline_models|src/eval/cropharvest +exclude = venv|notebooks|src/eval/baseline_models|src/eval/cropharvest|.*_marimo\.py|copernicus_marimo\.py ignore_missing_imports = True [mypy-yaml.*] diff --git a/pyproject.toml b/pyproject.toml index bee060f..056af02 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,6 +41,8 @@ dependencies = [ "satlaspretrain-models", "timm", "breizhcrops", + "requests>=2.25.0", + "python-dotenv>=0.19.0", ] [project.optional-dependencies] diff --git a/src/data/copernicus/__init__.py b/src/data/copernicus/__init__.py new file mode 100644 index 0000000..d1b315c --- /dev/null +++ b/src/data/copernicus/__init__.py @@ -0,0 +1,31 @@ +"""Copernicus Data Space Ecosystem client for fetching Sentinel-1 and Sentinel-2 data.""" + +from .client import CopernicusClient +from .image_processing import ( + create_false_color_composite, + extract_rgb_composite, + get_available_bands, + get_image_statistics, +) +from .visualization import ( + create_band_analysis_plot, + create_comparison_plot, + create_coverage_map, + create_metadata_summary, + display_satellite_image, +) + +__all__ = [ + "CopernicusClient", + # Image processing + "extract_rgb_composite", + "get_available_bands", + "create_false_color_composite", + "get_image_statistics", + # Visualization + "create_coverage_map", + "display_satellite_image", + "create_comparison_plot", + "create_metadata_summary", + "create_band_analysis_plot", +] diff --git a/src/data/copernicus/client.py b/src/data/copernicus/client.py new file mode 100644 index 0000000..19b2083 --- /dev/null +++ b/src/data/copernicus/client.py @@ -0,0 +1,344 @@ +"""Main Copernicus Data Space Ecosystem client. + +This module provides the main CopernicusClient class that handles: +- OAuth2 authentication with Copernicus Data Space Ecosystem +- Caching of downloaded products and metadata +- Coordination between Sentinel-1 and Sentinel-2 specific modules +- Error handling and retry logic for API requests +""" + +import os +import time +from pathlib import Path +from typing import Any, Dict, List, Optional, Union + +import requests +from dotenv import load_dotenv + +# Import the specific handlers for each satellite type +from .s1 import fetch_s1_products +from .s2 import fetch_s2_products +from .utils import ensure_cache_dir, validate_bbox, validate_date_range + + +class CopernicusClient: + """Main client for fetching Sentinel-1 and Sentinel-2 data from Copernicus Data Space Ecosystem. + + This client handles: + 1. OAuth2 authentication with automatic token refresh + 2. Caching of search results and product metadata + 3. Input validation for bounding boxes and date ranges + 4. Coordination between S1 and S2 specific fetch operations + + The client uses the free Copernicus Data Space Ecosystem API, which replaced + the old Copernicus Open Access Hub in 2023. + """ + + # API endpoints for Copernicus Data Space Ecosystem + BASE_URL = "https://catalogue.dataspace.copernicus.eu/odata/v1" # Main catalog API + TOKEN_URL = "https://identity.dataspace.copernicus.eu/auth/realms/CDSE/protocol/openid-connect/token" # OAuth endpoint + + def __init__( + self, + cache_dir: Union[str, Path] = "data/cache/copernicus", + load_dotenv_file: bool = True, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + ) -> None: + """Initialize the Copernicus client with authentication and caching setup. + + Args: + cache_dir: Directory where downloaded files and metadata will be cached. + Defaults to "data/cache/copernicus" relative to current directory. + load_dotenv_file: Whether to automatically load credentials from .env file. + Set to False if you're providing credentials directly. + client_id: OAuth client ID. If None, will try to load from COPERNICUS_CLIENT_ID env var. + client_secret: OAuth client secret. If None, will try to load from COPERNICUS_CLIENT_SECRET env var. + + Raises: + ValueError: If credentials cannot be found in environment variables or parameters. + """ + # Convert cache directory to Path object and ensure it exists + self.cache_dir: Path = Path(cache_dir) + ensure_cache_dir(self.cache_dir) + + # Load environment variables from .env file if requested + # This looks for a .env file in the current directory + if load_dotenv_file: + load_dotenv() + + # Get credentials from parameters or environment variables + # Parameters take precedence over environment variables + client_id_from_env: Optional[str] = client_id or os.getenv("COPERNICUS_CLIENT_ID") + client_secret_from_env: Optional[str] = client_secret or os.getenv( + "COPERNICUS_CLIENT_SECRET" + ) + + # Validate that we have the required credentials + if not client_id_from_env or not client_secret_from_env: + raise ValueError( + "Copernicus credentials not found. Set COPERNICUS_CLIENT_ID and " + "COPERNICUS_CLIENT_SECRET environment variables or pass them directly." + ) + + self.client_id: str = client_id_from_env + self.client_secret: str = client_secret_from_env + + # OAuth token management - these will be set when we first authenticate + self._access_token: Optional[str] = None # The actual Bearer token + self._token_expires_at: float = 0 # Unix timestamp when token expires + + # Create a persistent HTTP session for connection pooling and cookie management + self.session: requests.Session = requests.Session() + + def _get_access_token(self) -> str: + """Get a valid OAuth access token, refreshing if necessary. + + This method implements token caching - it only requests a new token if: + 1. We don't have a token yet, OR + 2. The current token is about to expire (within 5 minutes) + + The Copernicus API uses OAuth2 "client credentials" flow, which means + we exchange our client_id and client_secret for a temporary access token. + + Returns: + A valid Bearer token string that can be used in API requests. + + Raises: + requests.HTTPError: If the token request fails (e.g., invalid credentials). + """ + # Check if we already have a valid token that hasn't expired + if self._access_token and time.time() < self._token_expires_at: + return self._access_token + + # Request a new token using OAuth2 client credentials flow + # This is the standard way to authenticate machine-to-machine API access + data = { + "grant_type": "client_credentials", # OAuth2 flow type + "client_id": self.client_id, # Your registered client ID + "client_secret": self.client_secret, # Your registered client secret + } + + # Make the token request + response = self.session.post(self.TOKEN_URL, data=data) + response.raise_for_status() # Raise exception if request failed + + # Parse the response to get token information + token_data = response.json() + self._access_token = token_data["access_token"] # The actual token string + + # Calculate when this token expires and set expiry with 5 minute buffer + # This prevents us from using a token that might expire during a request + expires_in = token_data.get("expires_in", 3600) # Default to 1 hour if not specified + self._token_expires_at = time.time() + expires_in - 300 # Subtract 5 minutes (300 seconds) + + # At this point we're guaranteed to have a valid token + assert self._access_token is not None + return self._access_token + + def _make_request( + self, url: str, params: Optional[Dict[str, Any]] = None, **kwargs: Any + ) -> requests.Response: + """Make an authenticated HTTP request with automatic retry logic. + + This method handles: + 1. Adding the OAuth Bearer token to request headers + 2. Automatic token refresh if we get a 401 Unauthorized response + 3. Exponential backoff retry logic for transient failures + + Args: + url: The full URL to make the request to + params: Query parameters to include in the request + **kwargs: Additional arguments passed to requests.get() + + Returns: + The HTTP response object + + Raises: + requests.HTTPError: If the request fails after all retries + RuntimeError: If maximum retries are exceeded + """ + # Prepare headers, ensuring we don't overwrite any existing headers + headers: Dict[str, str] = kwargs.pop("headers", {}) + headers["Authorization"] = f"Bearer {self._get_access_token()}" + + # Retry logic with exponential backoff + max_retries: int = 3 + for attempt in range(max_retries): + try: + # Make the actual HTTP request + response: requests.Response = self.session.get( + url, params=params, headers=headers, **kwargs + ) + + # Handle token expiration - if we get 401, refresh token and retry + if response.status_code == 401: # Unauthorized - token likely expired + print("Token expired, refreshing...") + self._access_token = None # Force token refresh + headers["Authorization"] = f"Bearer {self._get_access_token()}" + continue # Retry the request with new token + + # Raise exception for other HTTP errors (4xx, 5xx) + response.raise_for_status() + return response + + except requests.exceptions.RequestException as e: + # If this was our last attempt, give up + if attempt == max_retries - 1: + raise + + # Calculate wait time with exponential backoff: 2^attempt seconds + wait_time: int = 2**attempt # 1s, 2s, 4s for attempts 0, 1, 2 + print( + f"Request failed (attempt {attempt + 1}/{max_retries}), retrying in {wait_time}s: {e}" + ) + time.sleep(wait_time) + + # This should never be reached due to the raise in the except block above + raise RuntimeError("Max retries exceeded") + + def fetch_s2( + self, + bbox: List[float], + start_date: str, + end_date: str, + *, + resolution: int = 10, + max_cloud_cover: float = 100.0, + product_type: str = "S2MSI1C", + download_data: bool = True, + interactive: bool = True, + ) -> List[Path]: + """Fetch Sentinel-2 products for a given area and time period. + + This method searches for Sentinel-2 satellite imagery that covers the specified + bounding box during the given date range. It handles caching automatically, + so repeated requests with the same parameters will return cached results. + + Args: + bbox: Bounding box as [min_longitude, min_latitude, max_longitude, max_latitude] + in WGS84 coordinate system (EPSG:4326). Example: [25.6796, -27.6721, 25.6897, -27.663] + start_date: Start date in YYYY-MM-DD format, e.g., "2022-01-01" + end_date: End date in YYYY-MM-DD format, e.g., "2022-01-31" + resolution: Spatial resolution in meters. Options are: + - 10: Highest resolution (10m per pixel) - good for detailed analysis + - 20: Medium resolution (20m per pixel) - good balance of detail and coverage + - 60: Lowest resolution (60m per pixel) - good for large area analysis + max_cloud_cover: Maximum acceptable cloud cover percentage (0-100). + Lower values = clearer images but fewer results. + 100 = accept any cloud cover level. + product_type: Type of Sentinel-2 product: + - "S2MSI1C": Level-1C (top-of-atmosphere reflectance, not atmospherically corrected) + - "S2MSI2A": Level-2A (bottom-of-atmosphere reflectance, atmospherically corrected) + download_data: If True, download actual satellite imagery. If False, only fetch metadata. + interactive: If True, prompt user for download confirmation when products are found. + + Returns: + List of Path objects pointing to downloaded imagery files or metadata files. + + Raises: + ValueError: If input parameters are invalid (e.g., invalid bbox coordinates, + unsupported resolution, invalid date format, etc.) + """ + # Validate all input parameters before proceeding + # This catches common errors early and provides helpful error messages + validate_bbox(bbox) # Check bbox format and coordinate bounds + validate_date_range(start_date, end_date) # Check date format and ordering + + # Validate resolution parameter + if resolution not in [10, 20, 60]: + raise ValueError("resolution must be 10, 20, or 60 meters") + + # Validate cloud cover parameter + if not 0 <= max_cloud_cover <= 100: + raise ValueError("max_cloud_cover must be between 0 and 100") + + # Delegate the actual work to the S2-specific module + # This keeps the client class focused on coordination and validation + return fetch_s2_products( + client=self, # Pass self so S2 module can use our authentication and caching + bbox=bbox, + start_date=start_date, + end_date=end_date, + resolution=resolution, + max_cloud_cover=max_cloud_cover, + product_type=product_type, + download_data=download_data, + interactive=interactive, + ) + + def fetch_s1( + self, + bbox: List[float], + start_date: str, + end_date: str, + *, + product_type: str = "GRD", + polarization: str = "VV,VH", + orbit_direction: str = "ASCENDING", + ) -> List[Path]: + """Fetch Sentinel-1 products for a given area and time period. + + This method searches for Sentinel-1 SAR (Synthetic Aperture Radar) imagery + that covers the specified bounding box during the given date range. + SAR imagery works day/night and through clouds, making it complementary to optical imagery. + + Args: + bbox: Bounding box as [min_longitude, min_latitude, max_longitude, max_latitude] + in WGS84 coordinate system (EPSG:4326). Example: [25.6796, -27.6721, 25.6897, -27.663] + start_date: Start date in YYYY-MM-DD format, e.g., "2022-01-01" + end_date: End date in YYYY-MM-DD format, e.g., "2022-01-31" + product_type: Type of Sentinel-1 product: + - "GRD": Ground Range Detected (most common, preprocessed and ready to use) + - "SLC": Single Look Complex (raw data, requires more processing) + - "OCN": Ocean products (specialized for ocean analysis) + polarization: Radar polarization modes to include: + - "VV": Vertical transmit, Vertical receive + - "VH": Vertical transmit, Horizontal receive + - "HH": Horizontal transmit, Horizontal receive + - "HV": Horizontal transmit, Vertical receive + - "VV,VH": Both VV and VH (most common for land applications) + Different polarizations reveal different surface properties. + orbit_direction: Satellite orbit direction: + - "ASCENDING": Satellite moving from south to north + - "DESCENDING": Satellite moving from north to south + Different directions can show different aspects of terrain. + + Returns: + List of Path objects pointing to downloaded files or metadata files. + Currently returns metadata JSON files; future versions will download actual imagery. + + Raises: + ValueError: If input parameters are invalid (e.g., invalid bbox coordinates, + unsupported product type, invalid polarization, etc.) + """ + # Validate all input parameters before proceeding + validate_bbox(bbox) # Check bbox format and coordinate bounds + validate_date_range(start_date, end_date) # Check date format and ordering + + # Validate product type parameter + if product_type not in ["GRD", "SLC", "OCN"]: + raise ValueError("product_type must be GRD, SLC, or OCN") + + # Validate polarization parameter + # Split by comma and check each polarization mode + valid_pols: set[str] = {"VV", "VH", "HH", "HV"} + requested_pols: set[str] = set(pol.strip() for pol in polarization.split(",")) + if not requested_pols.issubset(valid_pols): + raise ValueError(f"Invalid polarization. Must be subset of {valid_pols}") + + # Validate orbit direction parameter + if orbit_direction not in ["ASCENDING", "DESCENDING"]: + raise ValueError("orbit_direction must be ASCENDING or DESCENDING") + + # Delegate the actual work to the S1-specific module + # This keeps the client class focused on coordination and validation + return fetch_s1_products( + client=self, # Pass self so S1 module can use our authentication and caching + bbox=bbox, + start_date=start_date, + end_date=end_date, + product_type=product_type, + polarization=polarization, + orbit_direction=orbit_direction, + ) diff --git a/src/data/copernicus/image_processing.py b/src/data/copernicus/image_processing.py new file mode 100644 index 0000000..b6a5157 --- /dev/null +++ b/src/data/copernicus/image_processing.py @@ -0,0 +1,272 @@ +"""Image processing utilities for Copernicus satellite data. + +This module provides high-level functions for extracting and processing +satellite imagery from downloaded Copernicus products, particularly Sentinel-2 data. +""" + +import tempfile +import zipfile +from pathlib import Path +from typing import Dict, List, Optional, Tuple + +import numpy as np +import rasterio +from rasterio.warp import transform_bounds + + +def extract_rgb_composite( + zip_file_path: Path, bands: Optional[List[str]] = None, normalize: bool = True +) -> Optional[Dict]: + """Extract RGB composite from Sentinel-2 ZIP file. + + Args: + zip_file_path: Path to Sentinel-2 ZIP file + bands: List of band names to extract (default: ['B04', 'B03', 'B02'] for RGB) + normalize: Whether to apply percentile normalization for display + + Returns: + Dictionary containing: + - 'rgb_array': RGB image array (H, W, 3) + - 'bounds_wgs84': Geographic bounds in WGS84 coordinates + - 'bounds_utm': Original UTM bounds + - 'crs': Coordinate reference system + - 'metadata': Additional metadata + + Returns None if extraction fails. + """ + if bands is None: + bands = ["B04", "B03", "B02"] # Red, Green, Blue for natural color + + try: + with tempfile.TemporaryDirectory() as temp_dir: + temp_path = Path(temp_dir) + + # Extract ZIP file + with zipfile.ZipFile(zip_file_path, "r") as zip_ref: + zip_ref.extractall(temp_path) + + # Find SAFE directory (Sentinel-2 format) + safe_dirs = list(temp_path.glob("*.SAFE")) + if not safe_dirs: + print(f"No SAFE directory found in {zip_file_path.name}") + return None + + safe_dir = safe_dirs[0] + + # Find IMG_DATA directory + img_data_dir = safe_dir / "GRANULE" + granule_dirs = list(img_data_dir.glob("*")) + + if not granule_dirs: + print(f"No granule directories found in {zip_file_path.name}") + return None + + granule_dir = granule_dirs[0] + img_dir = granule_dir / "IMG_DATA" + + # Find band files + band_files = {} + for band in bands: + # Try multiple naming patterns + patterns = [ + f"*_{band}_10m.jp2", # Standard pattern + f"*_{band}.jp2", # Alternative pattern + f"*{band}.jp2", # Simple pattern + ] + + for pattern in patterns: + band_matches = list(img_dir.glob(pattern)) + if band_matches: + band_files[band] = band_matches[0] + break + + if len(band_files) < len(bands): + print(f"Only found {len(band_files)}/{len(bands)} bands in {zip_file_path.name}") + return None + + # Read bands and create composite + rgb_bands = [] + bounds = None + crs = None + + for band in bands: + if band in band_files: + with rasterio.open(band_files[band]) as src: + band_data = src.read(1) + + # Get geospatial info from first band + if bounds is None: + bounds = src.bounds + crs = src.crs + + rgb_bands.append(band_data) + + if len(rgb_bands) != len(bands): + return None + + # Stack bands into RGB array + rgb_array = np.stack(rgb_bands, axis=0) + + # Apply normalization if requested + if normalize: + rgb_normalized = np.zeros_like(rgb_array, dtype=np.float32) + + for i in range(len(bands)): + band_data = rgb_array[i] + valid_pixels = band_data[band_data > 0] + + if len(valid_pixels) > 0: + # Use percentile normalization for better contrast + p2, p98 = np.percentile(valid_pixels, [2, 98]) + if p98 > p2: + rgb_normalized[i] = np.clip((band_data - p2) / (p98 - p2), 0, 1) + else: + band_max = float(band_data.max()) if band_data.max() > 0 else 1.0 + rgb_normalized[i] = band_data / band_max + else: + rgb_normalized[i] = band_data + + rgb_array = rgb_normalized + + # Convert to display format (H, W, C) + rgb_display = np.transpose(rgb_array, (1, 2, 0)) + + # Convert bounds to WGS84 + if bounds is not None: + bounds_wgs84 = transform_bounds( + crs, "EPSG:4326", bounds.left, bounds.bottom, bounds.right, bounds.top + ) + else: + bounds_wgs84 = None + + return { + "rgb_array": rgb_display, + "bounds_wgs84": bounds_wgs84, + "bounds_utm": bounds, + "crs": str(crs), + "metadata": { + "bands": bands, + "shape": rgb_display.shape, + "zip_file": zip_file_path.name, + "safe_dir": safe_dir.name, + }, + } + + except Exception as e: + print(f"Error extracting RGB from {zip_file_path.name}: {e}") + return None + + +def get_available_bands(zip_file_path: Path) -> List[str]: + """Get list of available bands in a Sentinel-2 ZIP file. + + Args: + zip_file_path: Path to Sentinel-2 ZIP file + + Returns: + List of available band names (e.g., ['B01', 'B02', 'B03', ...]) + """ + try: + with tempfile.TemporaryDirectory() as temp_dir: + temp_path = Path(temp_dir) + + # Extract ZIP file + with zipfile.ZipFile(zip_file_path, "r") as zip_ref: + zip_ref.extractall(temp_path) + + # Find SAFE directory + safe_dirs = list(temp_path.glob("*.SAFE")) + if not safe_dirs: + return [] + + safe_dir = safe_dirs[0] + + # Find IMG_DATA directory + img_data_dir = safe_dir / "GRANULE" + granule_dirs = list(img_data_dir.glob("*")) + + if not granule_dirs: + return [] + + granule_dir = granule_dirs[0] + img_dir = granule_dir / "IMG_DATA" + + # Find all JP2 files and extract band names + jp2_files = list(img_dir.glob("*.jp2")) + bands = [] + + for jp2_file in jp2_files: + # Extract band name from filename (e.g., T31UGQ_20251129T103309_B02.jp2 -> B02) + name = jp2_file.name + if "_B" in name: + band_part = name.split("_B")[1] + band_name = "B" + band_part.split(".")[0] + if band_name not in bands: + bands.append(band_name) + + return sorted(bands) + + except Exception as e: + print(f"Error getting bands from {zip_file_path.name}: {e}") + return [] + + +def create_false_color_composite( + zip_file_path: Path, bands: Optional[List[str]] = None +) -> Optional[Dict]: + """Create false color composite (NIR, Red, Green) for vegetation analysis. + + Args: + zip_file_path: Path to Sentinel-2 ZIP file + bands: List of band names (default: ['B08', 'B04', 'B03'] for NIR-R-G) + + Returns: + Same format as extract_rgb_composite but with false color bands + """ + if bands is None: + bands = ["B08", "B04", "B03"] # NIR, Red, Green for vegetation + + return extract_rgb_composite(zip_file_path, bands=bands, normalize=True) + + +def get_image_statistics(rgb_data: Dict) -> Dict: + """Calculate statistics for RGB image data. + + Args: + rgb_data: Output from extract_rgb_composite + + Returns: + Dictionary with image statistics + """ + if rgb_data is None: + return {} + + rgb_array = rgb_data["rgb_array"] + + stats = { + "shape": rgb_array.shape, + "dtype": str(rgb_array.dtype), + "min_values": rgb_array.min(axis=(0, 1)).tolist(), + "max_values": rgb_array.max(axis=(0, 1)).tolist(), + "mean_values": rgb_array.mean(axis=(0, 1)).tolist(), + "std_values": rgb_array.std(axis=(0, 1)).tolist(), + "bounds_wgs84": rgb_data["bounds_wgs84"], + "coverage_area_km2": _calculate_area_km2(rgb_data["bounds_wgs84"]), + } + + return stats + + +def _calculate_area_km2(bounds_wgs84: Tuple[float, float, float, float]) -> float: + """Calculate approximate area in km² from WGS84 bounds.""" + # Simple approximation - more accurate methods would use proper geodesic calculations + lon_diff = bounds_wgs84[2] - bounds_wgs84[0] # max_lon - min_lon + lat_diff = bounds_wgs84[3] - bounds_wgs84[1] # max_lat - min_lat + + # Approximate conversion (varies by latitude) + avg_lat = (bounds_wgs84[1] + bounds_wgs84[3]) / 2 + km_per_degree_lon = 111.32 * np.cos(np.radians(avg_lat)) + km_per_degree_lat = 110.54 + + area_km2 = (lon_diff * km_per_degree_lon) * (lat_diff * km_per_degree_lat) + return area_km2 diff --git a/src/data/copernicus/s1.py b/src/data/copernicus/s1.py new file mode 100644 index 0000000..8d66b1a --- /dev/null +++ b/src/data/copernicus/s1.py @@ -0,0 +1,343 @@ +"""Sentinel-1 data fetching logic. + +This module handles the specific details of searching for and fetching Sentinel-1 SAR imagery. +Sentinel-1 provides Synthetic Aperture Radar (SAR) data that works day/night and through clouds, +making it complementary to optical imagery from Sentinel-2. + +Key features: +- Searches Copernicus catalog for SAR products with specific polarizations and orbit directions +- Filters by product type (GRD, SLC, OCN) and radar polarization modes +- Creates metadata files for discovered products (actual download to be implemented later) +- Implements caching to avoid repeated API calls for the same requests + +SAR Background: +- SAR uses microwave radiation to image the Earth's surface +- Different polarizations (VV, VH, HH, HV) reveal different surface properties +- Orbit direction affects the viewing angle and shadow patterns +""" + +import json +from pathlib import Path +from typing import TYPE_CHECKING, Any, Dict, List, Optional, Set + +from .utils import bbox_to_wkt, build_cache_key, sanitize_filename + +# Use TYPE_CHECKING to avoid circular imports while still getting type hints +if TYPE_CHECKING: + from .client import CopernicusClient + + +def fetch_s1_products( + client: "CopernicusClient", + bbox: List[float], + start_date: str, + end_date: str, + product_type: str, + polarization: str, + orbit_direction: str, +) -> List[Path]: + """Fetch Sentinel-1 products for given parameters. + + This is the main entry point for Sentinel-1 SAR data fetching. It handles the complete workflow: + 1. Check if results are already cached + 2. If not cached, search the Copernicus catalog for matching SAR products + 3. Create metadata files for found products (actual download to be implemented later) + 4. Cache the results for future requests + + Args: + client: CopernicusClient instance providing authentication and caching infrastructure + bbox: [min_lon, min_lat, max_lon, max_lat] in WGS84 coordinate system + start_date: Start date in YYYY-MM-DD format + end_date: End date in YYYY-MM-DD format + product_type: SAR product type: + - "GRD": Ground Range Detected (most common, preprocessed) + - "SLC": Single Look Complex (raw data, requires more processing) + - "OCN": Ocean products (specialized for ocean analysis) + polarization: Radar polarization modes (e.g., "VV,VH"): + - "VV": Vertical transmit, Vertical receive + - "VH": Vertical transmit, Horizontal receive + - "HH": Horizontal transmit, Horizontal receive + - "HV": Horizontal transmit, Vertical receive + orbit_direction: Satellite orbit direction: + - "ASCENDING": Moving from south to north + - "DESCENDING": Moving from north to south + + Returns: + List of Path objects pointing to metadata files for discovered products. + Each file contains product information including download URLs and metadata. + + Note: + Currently creates metadata files instead of downloading full products. + This allows the system to work while full download functionality is developed. + """ + # Build a unique cache key based on all parameters that affect the result + # SAR products have different parameters than optical imagery + cache_key = build_cache_key( + "s1", # Prefix to identify this as Sentinel-1 data + bbox=bbox, + start_date=start_date, + end_date=end_date, + product_type=product_type, + polarization=polarization, + orbit_direction=orbit_direction, + ) + + # Cache file stores both the search results and file paths + cache_file = client.cache_dir / f"{cache_key}.json" + + # Check if we already have cached results for this exact request + if cache_file.exists(): + print(f"Loading S1 products from cache: {cache_file}") + with open(cache_file) as f: + cached_data: Dict[str, Any] = json.load(f) + + # Verify that all cached files still exist on disk + # If files were deleted, we need to re-create them + cached_paths: List[Path] = [Path(p) for p in cached_data["file_paths"]] + if all(p.exists() for p in cached_paths): + return cached_paths # Cache hit - return existing results + else: + print("Some cached files missing, re-downloading...") + # Fall through to re-fetch the data + + # Search the Copernicus catalog for SAR products matching our criteria + products: List[Dict[str, Any]] = _search_s1_products( + client, bbox, start_date, end_date, product_type, polarization, orbit_direction + ) + + # Handle case where no products were found + if not products: + print(f"No S1 products found for bbox={bbox}, dates={start_date} to {end_date}") + return [] + + print(f"Found {len(products)} S1 products") + + # Create metadata files for the found products + # We limit to first 3 products for testing to avoid overwhelming the system + downloaded_paths: List[Path] = [] + for i, product in enumerate(products[:3]): # Limit to first 3 for testing + # Create a metadata file instead of downloading the full product (multi-GB files) + metadata_file: Optional[Path] = _create_product_metadata(client, product, i) + if metadata_file: + downloaded_paths.append(metadata_file) + + # Cache the results for future requests + # Store both the original search parameters and the resulting file paths + cache_data: Dict[str, Any] = { + "parameters": { + "bbox": bbox, + "start_date": start_date, + "end_date": end_date, + "product_type": product_type, + "polarization": polarization, + "orbit_direction": orbit_direction, + }, + "products": products, # Full product metadata from API + "file_paths": [str(p) for p in downloaded_paths], # Paths to created files + } + + # Write cache data to disk + with open(cache_file, "w") as f: + json.dump(cache_data, f, indent=2) + + print(f"Created metadata for {len(downloaded_paths)} S1 products, cached to {cache_file}") + return downloaded_paths + + +def _search_s1_products( + client: "CopernicusClient", + bbox: List[float], + start_date: str, + end_date: str, + product_type: str, + polarization: str, + orbit_direction: str, +) -> List[Dict[str, Any]]: + """Search for Sentinel-1 products using the Copernicus OData API. + + This function constructs and executes a search query against the Copernicus catalog + specifically for Sentinel-1 SAR products. SAR products have different metadata + and filtering requirements compared to optical imagery. + + Args: + client: CopernicusClient for making authenticated API requests + bbox: Bounding box coordinates + start_date: Start date for temporal filtering + end_date: End date for temporal filtering + product_type: SAR product type (GRD, SLC, OCN) + polarization: Radar polarization modes + orbit_direction: Satellite orbit direction + + Returns: + List of product dictionaries containing metadata for each found SAR product. + Each dictionary includes product ID, name, dates, attributes, polarization info, etc. + """ + # Convert bounding box to WKT (Well-Known Text) format required by the API + wkt_geometry: str = bbox_to_wkt(bbox) + + # Build OData query filter with multiple conditions + # All conditions must be true (AND logic) for a product to match + filter_parts: List[str] = [ + # Filter by collection: only Sentinel-1 products + "Collection/Name eq 'SENTINEL-1'", + # Filter by date range: product acquisition date must be within our range + f"ContentDate/Start ge {start_date}T00:00:00.000Z", # Greater than or equal to start + f"ContentDate/Start le {end_date}T23:59:59.999Z", # Less than or equal to end + # Filter by spatial intersection: product footprint must overlap our bounding box + f"OData.CSC.Intersects(area=geography'SRID=4326;{wkt_geometry}')", + ] + + # Add product type filter based on SAR processing level + if product_type == "GRD": + # Ground Range Detected: Most common, preprocessed and geocoded + filter_parts.append("contains(Name,'GRD')") + elif product_type == "SLC": + # Single Look Complex: Raw SAR data in slant range geometry + filter_parts.append("contains(Name,'SLC')") + elif product_type == "OCN": + # Ocean products: Specialized products for ocean wind and wave analysis + filter_parts.append("contains(Name,'OCN')") + + # Add orbit direction filter + # This affects the viewing geometry and shadow patterns + filter_parts.append(f"contains(Name,'{orbit_direction}')") + + # Combine all filter conditions with AND logic + filter_query: str = " and ".join(filter_parts) + + # Set up query parameters for the OData API + params: Dict[str, Any] = { + "$filter": filter_query, # The filter conditions we built above + "$orderby": "ContentDate/Start asc", # Sort by acquisition date (oldest first) + "$top": 100, # Limit results to 100 products (reduced for testing) + } + + # Construct the full API URL + url: str = f"{client.BASE_URL}/Products" + + print(f"Searching S1 products with filter: {filter_query}") + + # Make the authenticated API request + response = client._make_request(url, params=params) + data: Dict[str, Any] = response.json() + + # Extract the list of products from the API response + products: List[Dict[str, Any]] = data.get("value", []) + + # Apply polarization filtering + # SAR products can have different polarization combinations + filtered_products: List[Dict[str, Any]] = [] + requested_pols: Set[str] = set(pol.strip() for pol in polarization.split(",")) + + for product in products: + # Extract available polarizations from product metadata + product_pols: Set[str] = _extract_polarization(product) + + # Include product if: + # 1. No specific polarizations requested (empty set), OR + # 2. Product has all requested polarizations + if not requested_pols or requested_pols.issubset(product_pols): + filtered_products.append(product) + + return filtered_products + + +def _extract_polarization(product: Dict[str, Any]) -> Set[str]: + """Extract polarization information from SAR product metadata. + + SAR products can have different polarization combinations (VV, VH, HH, HV). + This information is stored in the product attributes or can be inferred from the name. + + Args: + product: Product dictionary from the API response + + Returns: + Set of polarization strings (e.g., {"VV", "VH"}) + """ + # First, try to extract from product Attributes (most reliable) + attributes: List[Dict[str, Any]] = product.get("Attributes", []) + for attr in attributes: + if attr.get("Name") == "polarisation": + pol_value: str = attr.get("Value", "") + # Parse polarization string - can be "VV VH" or "VV,VH" format + pols_list: List[str] = pol_value.replace(",", " ").split() + return set(pols_list) + + # Fallback: try to extract from product name + # SAR product names often contain polarization information + name: str = product.get("Name", "") + pols: Set[str] = set() + + # Check for each possible polarization in the product name + for pol in ["VV", "VH", "HH", "HV"]: + if pol in name: + pols.add(pol) + + return pols + + +def _create_product_metadata( + client: "CopernicusClient", + product: Dict[str, Any], + index: int, +) -> Optional[Path]: + """Create a metadata file for a Sentinel-1 product instead of downloading the full product. + + This function creates a JSON file containing all the important information about + a Sentinel-1 SAR product. This serves as a placeholder until full download functionality + is implemented, and provides all the information needed for future processing. + + Args: + client: CopernicusClient for accessing cache directory + product: Product dictionary from the API search results + index: Product index (used as fallback for naming) + + Returns: + Path to the created metadata file, or None if creation failed + """ + # Extract product identifiers, with fallbacks for missing data + product_id: str = product.get("Id", f"unknown_{index}") + product_name: str = product.get("Name", f"S1_product_{index}") + + # Create a safe filename by sanitizing the product name + # Add metadata suffix to make purpose clear + safe_name: str = sanitize_filename(product_name) + filename: str = f"{safe_name}_metadata.json" + + # Determine file path within the cache directory + # Use s1/ subdirectory to organize by satellite type + file_path: Path = client.cache_dir / "s1" / filename + + # Create the subdirectory if it doesn't exist + file_path.parent.mkdir(parents=True, exist_ok=True) + + # Check if metadata file already exists + if file_path.exists(): + print(f"S1 metadata already cached: {filename}") + return file_path + + print(f"Creating S1 metadata: {filename}") + + # Create comprehensive metadata dictionary + # This includes all information needed for future processing + metadata: Dict[str, Any] = { + "product_id": product_id, # Unique identifier for API requests + "product_name": product_name, # Human-readable product name + "content_date": product.get("ContentDate", {}), # Acquisition date/time + "attributes": product.get("Attributes", []), # All product attributes (polarization, etc.) + "footprint": product.get("Footprint", ""), # Geographic footprint as WKT + "download_url": f"{client.BASE_URL}/Products({product_id})/$value", # Direct download URL + "note": "This is metadata only. Actual product download not implemented yet.", + } + + try: + # Write metadata to JSON file with pretty formatting + with open(file_path, "w") as f: + json.dump(metadata, f, indent=2) + + print(f"Created metadata: {filename}") + return file_path + + except Exception as e: + print(f"Failed to create metadata {filename}: {e}") + return None diff --git a/src/data/copernicus/s2.py b/src/data/copernicus/s2.py new file mode 100644 index 0000000..e1c04d6 --- /dev/null +++ b/src/data/copernicus/s2.py @@ -0,0 +1,480 @@ +"""Sentinel-2 data fetching logic. + +This module handles the specific details of searching for and fetching Sentinel-2 optical imagery. +Sentinel-2 provides high-resolution multispectral imagery useful for land monitoring, agriculture, +and environmental applications. + +Key features: +- Searches Copernicus catalog using OData API queries +- Filters by cloud cover, product type, and spatial/temporal criteria +- Creates metadata files for discovered products (actual download to be implemented later) +- Implements caching to avoid repeated API calls for the same requests +""" + +import json +from pathlib import Path +from typing import TYPE_CHECKING, Any, Dict, List, Optional + +from .utils import bbox_to_wkt, build_cache_key, sanitize_filename + +# Use TYPE_CHECKING to avoid circular imports while still getting type hints +if TYPE_CHECKING: + from .client import CopernicusClient + + +def fetch_s2_products( + client: "CopernicusClient", + bbox: List[float], + start_date: str, + end_date: str, + resolution: int, + max_cloud_cover: float, + product_type: str, + download_data: bool = True, + interactive: bool = True, +) -> List[Path]: + """Fetch Sentinel-2 products for given parameters. + + This is the main entry point for Sentinel-2 data fetching. It handles the complete workflow: + 1. Check if results are already cached + 2. If not cached, search the Copernicus catalog for matching products + 3. Optionally prompt user for download confirmation + 4. Download actual satellite imagery or create metadata files + 5. Cache the results for future requests + + Args: + client: CopernicusClient instance providing authentication and caching infrastructure + bbox: [min_lon, min_lat, max_lon, max_lat] in WGS84 coordinate system + start_date: Start date in YYYY-MM-DD format + end_date: End date in YYYY-MM-DD format + resolution: Spatial resolution in meters (10, 20, or 60) + max_cloud_cover: Maximum cloud cover percentage (0-100) + product_type: Product type ("S2MSI1C" for Level-1C or "S2MSI2A" for Level-2A) + download_data: If True, download actual satellite imagery. If False, only metadata. + interactive: If True, prompt user for download confirmation when products are found. + + Returns: + List of Path objects pointing to downloaded imagery files or metadata files. + """ + # Build a unique cache key based on all parameters that affect the result + # This ensures that requests with identical parameters will hit the cache + cache_key = build_cache_key( + "s2", # Prefix to identify this as Sentinel-2 data + bbox=bbox, + start_date=start_date, + end_date=end_date, + resolution=resolution, + max_cloud_cover=max_cloud_cover, + product_type=product_type, + download_data=download_data, # Include download mode in cache key + ) + + # Cache file stores both the search results and file paths + cache_file = client.cache_dir / f"{cache_key}.json" + + # Check if we already have cached results for this exact request + if cache_file.exists(): + print(f"Loading S2 products from cache: {cache_file}") + with open(cache_file) as f: + cached_data: Dict[str, Any] = json.load(f) + + # Verify that all cached files still exist on disk + cached_paths: List[Path] = [Path(p) for p in cached_data["file_paths"]] + if all(p.exists() for p in cached_paths): + return cached_paths # Cache hit - return existing results + else: + print("Some cached files missing, re-downloading...") + # Fall through to re-fetch the data + + # Also check for cache with different download_data setting + # This allows us to reuse product searches but change download behavior + alt_cache_key = build_cache_key( + "s2", + bbox=bbox, + start_date=start_date, + end_date=end_date, + resolution=resolution, + max_cloud_cover=max_cloud_cover, + product_type=product_type, + download_data=not download_data, # Check opposite setting + ) + alt_cache_file = client.cache_dir / f"{alt_cache_key}.json" + + if alt_cache_file.exists(): + print(f"Found products in alternate cache: {alt_cache_file}") + with open(alt_cache_file) as f: + alt_cached_data: Dict[str, Any] = json.load(f) + + # Reuse the product list but process with current download_data setting + products = alt_cached_data.get("products", []) + if products: + print(f"Reusing {len(products)} products from alternate cache") + else: + # Search the Copernicus catalog for products matching our criteria + products = _search_s2_products( + client, bbox, start_date, end_date, max_cloud_cover, product_type + ) + else: + # Search the Copernicus catalog for products matching our criteria + products = _search_s2_products( + client, bbox, start_date, end_date, max_cloud_cover, product_type + ) + + # Handle case where no products were found + if not products: + print(f"No S2 products found for bbox={bbox}, dates={start_date} to {end_date}") + return [] + + print(f"Found {len(products)} S2 products") + + # Interactive user confirmation if requested + if interactive and products: + print("\n🛰️ DOWNLOAD CONFIRMATION") + print("=" * 40) + print(f"Found {len(products)} Sentinel-2 products:") + + for i, product in enumerate(products[:5], 1): # Show first 5 + name = product.get("Name", "Unknown") + size_mb = product.get("ContentLength", 0) / (1024 * 1024) + print(f" {i}. {name} ({size_mb:.1f} MB)") + + if len(products) > 5: + print(f" ... and {len(products) - 5} more products") + + total_size_gb = sum(p.get("ContentLength", 0) for p in products) / (1024**3) + print(f"\nTotal size: {total_size_gb:.2f} GB") + + if download_data: + print("Mode: Download actual satellite imagery") + response = input(f"\nDownload all {len(products)} products? [Y/n]: ").strip().lower() + if response and response not in ["y", "yes"]: + print("Download cancelled by user") + return [] + else: + print("Mode: Metadata only (no actual imagery download)") + + # Process products (download or create metadata) + downloaded_paths: List[Path] = [] + + if download_data: + print("\n📥 DOWNLOADING SATELLITE IMAGERY") + print("=" * 45) + + for i, product in enumerate(products[:3], 1): # Limit to 3 for demo + print(f"\n🛰️ Downloading product {i}/{min(3, len(products))}") + + downloaded_file = _download_s2_product(client, product, resolution, i - 1) + if downloaded_file: + downloaded_paths.append(downloaded_file) + print(f"✅ Downloaded: {downloaded_file.name}") + else: + print(f"❌ Failed to download product {i}") + else: + print("\n📋 CREATING METADATA FILES") + print("=" * 35) + + # Create metadata files for the found products + for i, product in enumerate(products[:3]): # Limit to first 3 for testing + metadata_file: Optional[Path] = _create_product_metadata( + client, product, resolution, i + ) + if metadata_file: + downloaded_paths.append(metadata_file) + + # Cache the results for future requests + cache_data: Dict[str, Any] = { + "parameters": { + "bbox": bbox, + "start_date": start_date, + "end_date": end_date, + "resolution": resolution, + "max_cloud_cover": max_cloud_cover, + "product_type": product_type, + "download_data": download_data, + }, + "products": products, # Full product metadata from API + "file_paths": [str(p) for p in downloaded_paths], # Paths to created files + } + + # Write cache data to disk + with open(cache_file, "w") as f: + json.dump(cache_data, f, indent=2) + + action = "Downloaded" if download_data else "Created metadata for" + print(f"\n✅ {action} {len(downloaded_paths)} S2 products, cached to {cache_file}") + return downloaded_paths + + +def _search_s2_products( + client: "CopernicusClient", + bbox: List[float], + start_date: str, + end_date: str, + max_cloud_cover: float, + product_type: str, +) -> List[Dict[str, Any]]: + """Search for Sentinel-2 products using the Copernicus OData API. + + This function constructs and executes a search query against the Copernicus catalog. + The catalog uses OData (Open Data Protocol) for structured queries. + + Args: + client: CopernicusClient for making authenticated API requests + bbox: Bounding box coordinates + start_date: Start date for temporal filtering + end_date: End date for temporal filtering + max_cloud_cover: Maximum acceptable cloud cover percentage + product_type: Sentinel-2 product type to search for + + Returns: + List of product dictionaries containing metadata for each found product. + Each dictionary includes product ID, name, dates, attributes, etc. + """ + # Convert bounding box to WKT (Well-Known Text) format required by the API + wkt_geometry: str = bbox_to_wkt(bbox) + + # Build OData query filter with multiple conditions + # All conditions must be true (AND logic) for a product to match + filter_parts: List[str] = [ + # Filter by collection: only Sentinel-2 products + "Collection/Name eq 'SENTINEL-2'", + # Filter by date range: product acquisition date must be within our range + f"ContentDate/Start ge {start_date}T00:00:00.000Z", # Greater than or equal to start + f"ContentDate/Start le {end_date}T23:59:59.999Z", # Less than or equal to end + # Filter by spatial intersection: product footprint must overlap our bounding box + f"OData.CSC.Intersects(area=geography'SRID=4326;{wkt_geometry}')", + ] + + # Add product type filter based on processing level + if product_type == "S2MSI1C": + # Level-1C: Top-of-atmosphere reflectance (not atmospherically corrected) + filter_parts.append("contains(Name,'MSIL1C')") + elif product_type == "S2MSI2A": + # Level-2A: Bottom-of-atmosphere reflectance (atmospherically corrected) + filter_parts.append("contains(Name,'MSIL2A')") + + # Combine all filter conditions with AND logic + filter_query: str = " and ".join(filter_parts) + + # Set up query parameters for the OData API + params: Dict[str, Any] = { + "$filter": filter_query, # The filter conditions we built above + "$orderby": "ContentDate/Start asc", # Sort by acquisition date (oldest first) + "$top": 100, # Limit results to 100 products (reduced for testing) + } + + # Construct the full API URL + url: str = f"{client.BASE_URL}/Products" + + print(f"Searching S2 products with filter: {filter_query}") + + # Make the authenticated API request + response = client._make_request(url, params=params) + data: Dict[str, Any] = response.json() + + # Extract the list of products from the API response + products: List[Dict[str, Any]] = data.get("value", []) + + # Apply cloud cover filtering + # Note: Not all products have cloud cover metadata, so we filter what we can + filtered_products: List[Dict[str, Any]] = [] + for product in products: + # Try to extract cloud cover percentage from product attributes + cloud_cover: Optional[float] = _extract_cloud_cover(product) + + # Include product if: + # 1. No cloud cover info available (cloud_cover is None), OR + # 2. Cloud cover is within acceptable range + if cloud_cover is None or cloud_cover <= max_cloud_cover: + filtered_products.append(product) + + return filtered_products + + +def _extract_cloud_cover(product: Dict[str, Any]) -> Optional[float]: + """Extract cloud cover percentage from product metadata. + + Cloud cover information is stored in the product's Attributes array. + Not all products have this information available. + + Args: + product: Product dictionary from the API response + + Returns: + Cloud cover percentage as float (0-100), or None if not available + """ + # Look through the product's attributes for cloud cover information + attributes: List[Dict[str, Any]] = product.get("Attributes", []) + for attr in attributes: + if attr.get("Name") == "cloudCover": + try: + # Convert the string value to float + return float(attr.get("Value", 0)) + except (ValueError, TypeError): + # If conversion fails, treat as missing data + pass + + # Return None if cloud cover information is not available + return None + + +def _create_product_metadata( + client: "CopernicusClient", + product: Dict[str, Any], + resolution: int, + index: int, +) -> Optional[Path]: + """Create a metadata file for a Sentinel-2 product instead of downloading the full product. + + This function creates a JSON file containing all the important information about + a Sentinel-2 product. This serves as a placeholder until full download functionality + is implemented, and provides all the information needed for future processing. + + Args: + client: CopernicusClient for accessing cache directory + product: Product dictionary from the API search results + resolution: Requested resolution (used in filename) + index: Product index (used as fallback for naming) + + Returns: + Path to the created metadata file, or None if creation failed + """ + # Extract product identifiers, with fallbacks for missing data + product_id: str = product.get("Id", f"unknown_{index}") + product_name: str = product.get("Name", f"S2_product_{index}") + + # Create a safe filename by sanitizing the product name + # Add resolution and metadata suffix to make purpose clear + safe_name: str = sanitize_filename(product_name) + filename: str = f"{safe_name}_R{resolution}m_metadata.json" + + # Determine file path within the cache directory + # Use s2/ subdirectory to organize by satellite type + file_path: Path = client.cache_dir / "s2" / filename + + # Create the subdirectory if it doesn't exist + file_path.parent.mkdir(parents=True, exist_ok=True) + + # Check if metadata file already exists + if file_path.exists(): + print(f"S2 metadata already cached: {filename}") + return file_path + + print(f"Creating S2 metadata: {filename}") + + # Create comprehensive metadata dictionary + # This includes all information needed for future processing + metadata: Dict[str, Any] = { + "product_id": product_id, # Unique identifier for API requests + "product_name": product_name, # Human-readable product name + "resolution": resolution, # Requested spatial resolution + "content_date": product.get("ContentDate", {}), # Acquisition date/time + "attributes": product.get("Attributes", []), # All product attributes (cloud cover, etc.) + "footprint": product.get("Footprint", ""), # Geographic footprint as WKT + "download_url": f"{client.BASE_URL}/Products({product_id})/$value", # Direct download URL + "note": "This is metadata only. Actual product download not implemented yet.", + } + + try: + # Write metadata to JSON file with pretty formatting + with open(file_path, "w") as f: + json.dump(metadata, f, indent=2) + + print(f"Created metadata: {filename}") + return file_path + + except Exception as e: + print(f"Failed to create metadata {filename}: {e}") + return None + + +def _download_s2_product( + client: "CopernicusClient", + product: Dict[str, Any], + resolution: int, + index: int, +) -> Optional[Path]: + """Download actual Sentinel-2 satellite imagery. + + This function downloads the complete satellite product from Copernicus Data Space Ecosystem. + Products are typically 500MB-1GB in size and contain multiple spectral bands. + + Args: + client: CopernicusClient for authentication and cache directory + product: Product dictionary from the API search results + resolution: Requested resolution (used in filename) + index: Product index (used as fallback for naming) + + Returns: + Path to the downloaded file, or None if download failed + """ + import requests + from tqdm import tqdm + + # Extract product identifiers + product_id: str = product.get("Id", f"unknown_{index}") + product_name: str = product.get("Name", f"S2_product_{index}") + content_length: int = product.get("ContentLength", 0) + + # Create safe filename + safe_name: str = sanitize_filename(product_name) + filename: str = f"{safe_name}_R{resolution}m.zip" + + # Determine file path within cache directory + file_path: Path = client.cache_dir / "s2" / filename + file_path.parent.mkdir(parents=True, exist_ok=True) + + # Check if file already exists + if file_path.exists() and file_path.stat().st_size > 0: + print(f"✅ Already downloaded: {filename}") + return file_path + + # Construct download URL - use the correct download endpoint + download_url = ( + f"https://download.dataspace.copernicus.eu/odata/v1/Products({product_id})/$value" + ) + + print(f"📥 Downloading: {product_name}") + print(f" Size: {content_length / (1024*1024):.1f} MB") + print(f" URL: {download_url}") + + try: + # Get access token for authentication + token = client._get_access_token() + headers = { + "Authorization": f"Bearer {token}", + "User-Agent": "Galileo-Copernicus-Client/1.0", + } + + # Start download with streaming + response = requests.get(download_url, headers=headers, stream=True, timeout=300) + response.raise_for_status() + + # Get actual content length from response headers + total_size = int(response.headers.get("content-length", content_length)) + + # Download with progress bar + with open(file_path, "wb") as f: + with tqdm( + total=total_size, unit="B", unit_scale=True, desc=f"Downloading {filename[:30]}..." + ) as pbar: + for chunk in response.iter_content(chunk_size=8192): + if chunk: + f.write(chunk) + pbar.update(len(chunk)) + + print(f"✅ Download complete: {filename}") + return file_path + + except requests.exceptions.RequestException as e: + print(f"❌ Download failed: {e}") + # Clean up partial download + if file_path.exists(): + file_path.unlink() + return None + except Exception as e: + print(f"❌ Unexpected error during download: {e}") + # Clean up partial download + if file_path.exists(): + file_path.unlink() + return None diff --git a/src/data/copernicus/utils.py b/src/data/copernicus/utils.py new file mode 100644 index 0000000..8658d39 --- /dev/null +++ b/src/data/copernicus/utils.py @@ -0,0 +1,200 @@ +"""Utility functions for Copernicus data fetching. + +This module contains helper functions used throughout the Copernicus data fetching system: +- Input validation for bounding boxes and dates +- Cache key generation for deterministic caching +- File system utilities for safe file operations +- Coordinate system conversions for API queries +""" + +import hashlib +import re +from datetime import datetime +from pathlib import Path +from typing import Any, List, Tuple + + +def validate_bbox(bbox: List[float]) -> None: + """Validate bounding box format and coordinate values. + + A bounding box defines a rectangular area on Earth's surface using latitude and longitude. + This function ensures the bbox is properly formatted and contains valid coordinates. + + Args: + bbox: List of 4 floats representing [min_longitude, min_latitude, max_longitude, max_latitude] + All coordinates should be in WGS84 (EPSG:4326) coordinate system. + Example: [25.6796, -27.6721, 25.6897, -27.663] represents a small area in South Africa. + + Raises: + ValueError: If bbox format is wrong or coordinates are invalid. + Provides specific error messages for different validation failures. + """ + # Check basic format: must be a list with exactly 4 numbers + if not isinstance(bbox, list) or len(bbox) != 4: + raise ValueError("bbox must be a list of 4 floats: [min_lon, min_lat, max_lon, max_lat]") + + # Extract coordinates for readability + min_lon, min_lat, max_lon, max_lat = bbox + + # Validate longitude bounds: must be between -180 and +180 degrees + # Longitude lines run north-south; -180/+180 is the International Date Line + if not (-180 <= min_lon <= 180) or not (-180 <= max_lon <= 180): + raise ValueError("Longitude must be between -180 and 180") + + # Validate latitude bounds: must be between -90 and +90 degrees + # Latitude lines run east-west; -90 is South Pole, +90 is North Pole + if not (-90 <= min_lat <= 90) or not (-90 <= max_lat <= 90): + raise ValueError("Latitude must be between -90 and 90") + + # Validate coordinate ordering: min values must be less than max values + # This ensures we have a valid rectangle, not an inverted one + if min_lon >= max_lon: + raise ValueError("min_lon must be less than max_lon") + + if min_lat >= max_lat: + raise ValueError("min_lat must be less than max_lat") + + +def validate_date(date_str: str) -> datetime: + """Validate and parse a date string in YYYY-MM-DD format. + + This function ensures dates are in the correct format and represent valid calendar dates. + + Args: + date_str: Date string in ISO format, e.g., "2022-01-01", "2023-12-31" + + Returns: + datetime object representing the parsed date + + Raises: + ValueError: If date format is invalid or represents an impossible date + (e.g., "2022-13-01" for month 13, or "2022-02-30" for Feb 30th) + """ + try: + # Use strptime to parse the date string with strict format checking + # This will raise ValueError if format doesn't match exactly or date is invalid + return datetime.strptime(date_str, "%Y-%m-%d") + except ValueError as e: + # Re-raise with more helpful error message + raise ValueError(f"Date must be in YYYY-MM-DD format: {e}") + + +def validate_date_range(start_date: str, end_date: str) -> Tuple[datetime, datetime]: + """Validate a date range ensuring start comes before end. + + This function validates both individual dates and their logical relationship. + + Args: + start_date: Start date in YYYY-MM-DD format, e.g., "2022-01-01" + end_date: End date in YYYY-MM-DD format, e.g., "2022-12-31" + + Returns: + Tuple of (start_datetime, end_datetime) objects + + Raises: + ValueError: If either date is invalid or start_date is not before end_date + """ + # Validate each date individually first + start_dt: datetime = validate_date(start_date) + end_dt: datetime = validate_date(end_date) + + # Ensure logical ordering: start must come before end + if start_dt >= end_dt: + raise ValueError("start_date must be before end_date") + + return start_dt, end_dt + + +def build_cache_key(prefix: str, **params: Any) -> str: + """Build a deterministic cache key from request parameters. + + This function creates a unique, deterministic identifier for caching purposes. + The same parameters will always produce the same cache key, enabling reliable cache hits. + + Args: + prefix: Cache key prefix to identify the type of data (e.g., 's1', 's2') + **params: All parameters that affect the request result. These are hashed together + to create a unique identifier. Examples: bbox, start_date, end_date, resolution, etc. + + Returns: + A cache key string in format: "{prefix}_{hash}" where hash is a 16-character hex string + Example: "s2_abc123def456789a" for Sentinel-2 data with specific parameters + """ + # Sort parameters by key name to ensure deterministic ordering + # This is crucial: {"a": 1, "b": 2} and {"b": 2, "a": 1} must produce the same hash + param_str: str = "_".join(f"{k}={v}" for k, v in sorted(params.items())) + + # Use SHA-256 hash for cryptographic security and collision resistance + # Take only first 16 characters for brevity while maintaining uniqueness + hash_obj = hashlib.sha256(param_str.encode()) + return f"{prefix}_{hash_obj.hexdigest()[:16]}" + + +def sanitize_filename(filename: str) -> str: + """Sanitize a filename for safe filesystem storage. + + This function removes or replaces characters that are invalid in filenames + on various operating systems (Windows, macOS, Linux). + + Args: + filename: Original filename that may contain invalid characters + Example: "S2A_MSIL1C_20220101T123456:789_N0400.SAFE" + + Returns: + Sanitized filename safe for all major filesystems + Example: "S2A_MSIL1C_20220101T123456_789_N0400.SAFE" + """ + # Replace invalid characters with underscores + # These characters are problematic on Windows: < > : " / \ | ? * + # We replace them all for cross-platform compatibility + return re.sub(r'[<>:"/\\|?*]', "_", filename) + + +def ensure_cache_dir(cache_dir: Path) -> None: + """Ensure cache directory exists, creating it if necessary. + + This function safely creates the cache directory structure, including + any parent directories that don't exist. + + Args: + cache_dir: Path object representing the cache directory + """ + # Create directory and all parent directories if they don't exist + # parents=True: create parent directories as needed + # exist_ok=True: don't raise error if directory already exists + cache_dir.mkdir(parents=True, exist_ok=True) + + +def bbox_to_wkt(bbox: List[float]) -> str: + """Convert bounding box to Well-Known Text (WKT) polygon format. + + WKT is a standard format for representing geometric shapes in spatial databases. + The Copernicus API uses WKT polygons for spatial queries. + + Args: + bbox: Bounding box as [min_lon, min_lat, max_lon, max_lat] + Example: [25.6796, -27.6721, 25.6897, -27.663] + + Returns: + WKT polygon string representing the bounding box rectangle + Example: "POLYGON((25.6796 -27.6721, 25.6897 -27.6721, 25.6897 -27.663, 25.6796 -27.663, 25.6796 -27.6721))" + + Note: + The polygon is created by connecting the four corners of the rectangle in order: + 1. Bottom-left (min_lon, min_lat) + 2. Bottom-right (max_lon, min_lat) + 3. Top-right (max_lon, max_lat) + 4. Top-left (min_lon, max_lat) + 5. Back to bottom-left to close the polygon + """ + min_lon: float = bbox[0] + min_lat: float = bbox[1] + max_lon: float = bbox[2] + max_lat: float = bbox[3] + + # Create a closed polygon by listing all corner points + # Note: WKT format is "longitude latitude" (x y), not "latitude longitude" + return ( + f"POLYGON(({min_lon} {min_lat}, {max_lon} {min_lat}, " + f"{max_lon} {max_lat}, {min_lon} {max_lat}, {min_lon} {min_lat}))" + ) diff --git a/src/data/copernicus/visualization.py b/src/data/copernicus/visualization.py new file mode 100644 index 0000000..2c621be --- /dev/null +++ b/src/data/copernicus/visualization.py @@ -0,0 +1,367 @@ +"""Visualization utilities for Copernicus satellite data. + +This module provides high-level plotting functions for displaying +satellite imagery, coverage maps, and analysis results. +""" + +from pathlib import Path +from typing import List, Optional, Tuple + +import matplotlib.pyplot as plt +import numpy as np + +from .image_processing import extract_rgb_composite, get_image_statistics + + +def create_coverage_map( + target_bbox: List[float], + center_lat: float, + center_lon: float, + s2_files: List[Path], + ax: Optional[plt.Axes] = None, + title: str = "Satellite Coverage Map", +) -> plt.Axes: + """Create a coverage map showing target area and available products. + + Args: + target_bbox: [min_lon, min_lat, max_lon, max_lat] in WGS84 + center_lat: Center latitude + center_lon: Center longitude + s2_files: List of available Sentinel-2 files + ax: Matplotlib axes (creates new if None) + title: Plot title + + Returns: + Matplotlib axes object + """ + if ax is None: + fig, ax = plt.subplots(1, 1, figsize=(10, 8)) + + # Map extent with padding + padding = 0.01 + map_extent = [ + target_bbox[0] - padding, + target_bbox[2] + padding, + target_bbox[1] - padding, + target_bbox[3] + padding, + ] + + # Create coordinate grid for background + lons = np.linspace(map_extent[0], map_extent[1], 100) + lats = np.linspace(map_extent[2], map_extent[3], 100) + lon_grid, lat_grid = np.meshgrid(lons, lats) + + # Background terrain pattern + elevation = np.sin(lon_grid * 100) * np.cos(lat_grid * 100) * 0.1 + ax.contourf(lon_grid, lat_grid, elevation, levels=20, cmap="terrain", alpha=0.3) + + # Plot target bounding box + bbox_lons = [target_bbox[0], target_bbox[2], target_bbox[2], target_bbox[0], target_bbox[0]] + bbox_lats = [target_bbox[1], target_bbox[1], target_bbox[3], target_bbox[3], target_bbox[1]] + ax.plot(bbox_lons, bbox_lats, "r-", linewidth=3, label="Target Area") + ax.fill(bbox_lons, bbox_lats, "red", alpha=0.2) + + # Center point + ax.plot(center_lon, center_lat, "ro", markersize=10, label="Center Point") + + # Satellite coverage + if s2_files: + coverage_lons = [ + target_bbox[0] - 0.005, + target_bbox[2] + 0.005, + target_bbox[2] + 0.005, + target_bbox[0] - 0.005, + target_bbox[0] - 0.005, + ] + coverage_lats = [ + target_bbox[1] - 0.005, + target_bbox[1] - 0.005, + target_bbox[3] + 0.005, + target_bbox[3] + 0.005, + target_bbox[1] - 0.005, + ] + ax.plot( + coverage_lons, + coverage_lats, + "b--", + linewidth=2, + alpha=0.7, + label=f"Copernicus Products ({len(s2_files)} found)", + ) + + # Customize plot + ax.set_xlabel("Longitude (°E)", fontsize=12) + ax.set_ylabel("Latitude (°N)", fontsize=12) + ax.set_title(title, fontsize=14, fontweight="bold") + ax.grid(True, alpha=0.3) + ax.legend(loc="upper right") + + # Add info box + area_km = ((target_bbox[2] - target_bbox[0]) * 111.32 * np.cos(np.radians(center_lat))) * ( + (target_bbox[3] - target_bbox[1]) * 110.54 + ) + + info_text = ( + f"Target Area:\n" + f"• Lat: {center_lat:.4f}°N\n" + f"• Lon: {center_lon:.4f}°E\n" + f"• Area: ~{area_km:.1f} km²\n" + f"• Products: {len(s2_files)}" + ) + + ax.text( + 0.02, + 0.98, + info_text, + transform=ax.transAxes, + fontsize=10, + verticalalignment="top", + bbox=dict(boxstyle="round,pad=0.5", facecolor="lightblue", alpha=0.8), + ) + + return ax + + +def display_satellite_image( + zip_file_path: Path, + target_bbox: List[float], + ax: Optional[plt.Axes] = None, + bands: Optional[List[str]] = None, + title: Optional[str] = None, +) -> Optional[plt.Axes]: + """Display satellite image from ZIP file with target area overlay. + + Args: + zip_file_path: Path to Sentinel-2 ZIP file + target_bbox: [min_lon, min_lat, max_lon, max_lat] in WGS84 + ax: Matplotlib axes (creates new if None) + bands: Band names for composite (default: RGB) + title: Plot title (auto-generated if None) + + Returns: + Matplotlib axes object, or None if processing failed + """ + # Extract RGB composite + rgb_data = extract_rgb_composite(zip_file_path, bands=bands) + if rgb_data is None: + return None + + if ax is None: + fig, ax = plt.subplots(1, 1, figsize=(10, 8)) + + # Display the satellite image + bounds = rgb_data["bounds_wgs84"] + extent = (bounds[0], bounds[2], bounds[1], bounds[3]) # (min_lon, max_lon, min_lat, max_lat) + + ax.imshow(rgb_data["rgb_array"], extent=extent, aspect="auto") + + # Add target area overlay + bbox_lons = [target_bbox[0], target_bbox[2], target_bbox[2], target_bbox[0], target_bbox[0]] + bbox_lats = [target_bbox[1], target_bbox[1], target_bbox[3], target_bbox[3], target_bbox[1]] + ax.plot(bbox_lons, bbox_lats, "red", linewidth=3, alpha=0.8, label="Target Area") + + # Zoom to target area with padding + padding = 0.02 + ax.set_xlim(target_bbox[0] - padding, target_bbox[2] + padding) + ax.set_ylim(target_bbox[1] - padding, target_bbox[3] + padding) + + # Customize plot + ax.set_xlabel("Longitude (°E)", fontsize=12) + ax.set_ylabel("Latitude (°N)", fontsize=12) + + if title is None: + title = f"Satellite Image\n{zip_file_path.name[:40]}..." + ax.set_title(title, fontsize=11, fontweight="bold") + + ax.grid(True, alpha=0.3, color="white") + ax.legend() + + return ax + + +def create_comparison_plot( + zip_files: List[Path], + target_bbox: List[float], + center_lat: float, + center_lon: float, + figsize: Tuple[int, int] = (20, 8), +) -> plt.Figure: + """Create a comparison plot with coverage map and satellite images. + + Args: + zip_files: List of Sentinel-2 ZIP files + target_bbox: [min_lon, min_lat, max_lon, max_lat] in WGS84 + center_lat: Center latitude + center_lon: Center longitude + figsize: Figure size (width, height) + + Returns: + Matplotlib figure object + """ + num_images = min(len(zip_files), 2) # Limit to 2 satellite images + num_panels = num_images + 1 # Coverage map + satellite images + + fig, axes = plt.subplots(1, num_panels, figsize=figsize) + + # Ensure axes is always a list + if num_panels == 1: + axes = [axes] + elif not hasattr(axes, "__len__"): + axes = [axes] + + # Panel 1: Coverage map + create_coverage_map( + target_bbox, center_lat, center_lon, zip_files, ax=axes[0], title="Target Area Coverage" + ) + + # Panels 2+: Satellite images + for idx, zip_file in enumerate(zip_files[:num_images]): + ax_img = axes[idx + 1] + + result = display_satellite_image( + zip_file, + target_bbox, + ax=ax_img, + title=f"Satellite Image #{idx+1}\n{zip_file.name[:40]}...", + ) + + if result is None: + # Show error message if processing failed + ax_img.text( + 0.5, + 0.5, + f"Error processing\n{zip_file.name}", + ha="center", + va="center", + transform=ax_img.transAxes, + fontsize=12, + bbox=dict(boxstyle="round", facecolor="lightcoral"), + ) + ax_img.set_title("Processing Error", fontsize=12) + ax_img.axis("off") + + plt.tight_layout() + return fig + + +def create_metadata_summary(zip_files: List[Path], ax: Optional[plt.Axes] = None) -> plt.Axes: + """Create a text summary of satellite data metadata. + + Args: + zip_files: List of Sentinel-2 ZIP files + ax: Matplotlib axes (creates new if None) + + Returns: + Matplotlib axes object + """ + if ax is None: + fig, ax = plt.subplots(1, 1, figsize=(10, 8)) + + ax.axis("off") + + if not zip_files: + ax.text( + 0.5, + 0.5, + "No satellite products found", + ha="center", + va="center", + transform=ax.transAxes, + fontsize=14, + ) + ax.set_title("No Data Available", fontsize=14) + return ax + + # Create metadata summary + summary_text = "SATELLITE DATA SUMMARY\n" + "=" * 30 + "\n\n" + + for idx, zip_file in enumerate(zip_files[:3], 1): # Show first 3 + size_mb = zip_file.stat().st_size / (1024 * 1024) + + summary_text += f"Product {idx}:\n" + summary_text += f" File: {zip_file.name[:50]}...\n" + summary_text += f" Size: {size_mb:.1f} MB\n" + + # Try to get image statistics + rgb_data = extract_rgb_composite(zip_file) + if rgb_data: + stats = get_image_statistics(rgb_data) + summary_text += f" Resolution: {stats['shape'][0]}×{stats['shape'][1]} pixels\n" + summary_text += f" Coverage: {stats['coverage_area_km2']:.1f} km²\n" + + summary_text += "\n" + + if len(zip_files) > 3: + summary_text += f"... and {len(zip_files) - 3} more products\n\n" + + summary_text += f"Total Products: {len(zip_files)}\n" + total_size_gb = sum(f.stat().st_size for f in zip_files) / (1024**3) + summary_text += f"Total Size: {total_size_gb:.2f} GB" + + # Display the text + ax.text( + 0.05, + 0.95, + summary_text, + transform=ax.transAxes, + fontsize=11, + verticalalignment="top", + fontfamily="monospace", + bbox=dict(boxstyle="round,pad=1", facecolor="white", alpha=0.9), + ) + + ax.set_title("Copernicus Data Summary", fontsize=14, fontweight="bold") + + return ax + + +def create_band_analysis_plot( + zip_file_path: Path, bands_to_show: Optional[List[List[str]]] = None +) -> plt.Figure: + """Create a multi-panel plot showing different band combinations. + + Args: + zip_file_path: Path to Sentinel-2 ZIP file + bands_to_show: List of band combinations to display + + Returns: + Matplotlib figure object + """ + if bands_to_show is None: + bands_to_show = [ + ["B04", "B03", "B02"], # Natural color (RGB) + ["B08", "B04", "B03"], # False color (NIR-R-G) + ["B12", "B11", "B04"], # SWIR composite + ] + + fig, axes = plt.subplots(1, len(bands_to_show), figsize=(6 * len(bands_to_show), 6)) + + if len(bands_to_show) == 1: + axes = [axes] + + titles = ["Natural Color (RGB)", "False Color (NIR)", "SWIR Composite"] + + for idx, bands in enumerate(bands_to_show): + rgb_data = extract_rgb_composite(zip_file_path, bands=bands) + + if rgb_data: + bounds = rgb_data["bounds_wgs84"] + extent = [bounds[0], bounds[2], bounds[1], bounds[3]] + + axes[idx].imshow(rgb_data["rgb_array"], extent=extent, aspect="auto") + axes[idx].set_title(f'{titles[idx]}\n{"-".join(bands)}', fontweight="bold") + axes[idx].set_xlabel("Longitude (°E)") + axes[idx].set_ylabel("Latitude (°N)") + else: + axes[idx].text( + 0.5, + 0.5, + f'Error processing\n{"-".join(bands)}', + ha="center", + va="center", + transform=axes[idx].transAxes, + ) + axes[idx].set_title("Processing Error") + + plt.tight_layout() + return fig diff --git a/uv.lock b/uv.lock index 343685c..e17c407 100644 --- a/uv.lock +++ b/uv.lock @@ -759,7 +759,9 @@ dependencies = [ { name = "geopandas" }, { name = "h5py" }, { name = "numpy" }, + { name = "python-dotenv" }, { name = "rasterio" }, + { name = "requests" }, { name = "rioxarray" }, { name = "satlaspretrain-models" }, { name = "scikit-learn" }, @@ -800,7 +802,9 @@ requires-dist = [ { name = "mypy", marker = "extra == 'dev'", specifier = "==1.8.0" }, { name = "numpy", specifier = "==1.26.4" }, { name = "pre-commit", marker = "extra == 'dev'", specifier = "==3.6.0" }, + { name = "python-dotenv", specifier = ">=0.19.0" }, { name = "rasterio", specifier = "==1.3.10" }, + { name = "requests", specifier = ">=2.25.0" }, { name = "rioxarray", specifier = "==0.15.1" }, { name = "ruff", marker = "extra == 'dev'", specifier = "==0.2.0" }, { name = "satlaspretrain-models" }, @@ -2592,6 +2596,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/ec/57/56b9bcc3c9c6a792fcbaf139543cee77261f3651ca9da0c93f5c1221264b/python_dateutil-2.9.0.post0-py2.py3-none-any.whl", hash = "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427", size = 229892, upload-time = "2024-03-01T18:36:18.57Z" }, ] +[[package]] +name = "python-dotenv" +version = "1.2.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/f0/26/19cadc79a718c5edbec86fd4919a6b6d3f681039a2f6d66d14be94e75fb9/python_dotenv-1.2.1.tar.gz", hash = "sha256:42667e897e16ab0d66954af0e60a9caa94f0fd4ecf3aaf6d2d260eec1aa36ad6", size = 44221, upload-time = "2025-10-26T15:12:10.434Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/14/1b/a298b06749107c305e1fe0f814c6c74aea7b2f1e10989cb30f544a1b3253/python_dotenv-1.2.1-py3-none-any.whl", hash = "sha256:b81ee9561e9ca4004139c6cbba3a238c32b03e4894671e181b671e8cb8425d61", size = 21230, upload-time = "2025-10-26T15:12:09.109Z" }, +] + [[package]] name = "python-json-logger" version = "4.0.0" From 3ed337e2f81dba1ab0f551c7429fbb35f53e6f55 Mon Sep 17 00:00:00 2001 From: Robin Fievet Date: Wed, 14 Jan 2026 11:33:24 -0500 Subject: [PATCH 5/8] small marimo fix --- copernicus_marimo.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/copernicus_marimo.py b/copernicus_marimo.py index 44bd314..1b42d15 100644 --- a/copernicus_marimo.py +++ b/copernicus_marimo.py @@ -82,10 +82,7 @@ def __(): @app.cell -@app.cell -def __(): - from datetime import datetime, timedelta - +def __(datetime, timedelta): # Date range configuration print("\n📅 CONFIGURING DATE RANGE") print("=" * 35) @@ -103,9 +100,7 @@ def __(): @app.cell -def __(): - from datetime import datetime - +def __(client_ready, copernicus_client, datetime): # Initialize Copernicus client print("\n🔧 INITIALIZING COPERNICUS CLIENT") print("=" * 45) From e32bba3e779fd5617d3b22e0b7315f9d5edda6d8 Mon Sep 17 00:00:00 2001 From: Robin Fievet Date: Wed, 14 Jan 2026 16:54:57 -0500 Subject: [PATCH 6/8] finish S1-S2 client --- src/data/copernicus/indices.py | 470 +++++++++++++++++++++++++++++++++ src/data/copernicus/quality.py | 200 ++++++++++++++ 2 files changed, 670 insertions(+) create mode 100644 src/data/copernicus/indices.py create mode 100644 src/data/copernicus/quality.py diff --git a/src/data/copernicus/indices.py b/src/data/copernicus/indices.py new file mode 100644 index 0000000..927dd94 --- /dev/null +++ b/src/data/copernicus/indices.py @@ -0,0 +1,470 @@ +"""Spectral indices calculation for Sentinel-2 data. + +This module provides functions to calculate common vegetation and water indices +from Sentinel-2 multispectral imagery. These indices enhance specific features +and are widely used in remote sensing applications. +""" + +import tempfile +import zipfile +from pathlib import Path +from typing import Dict, Optional + +import numpy as np +import rasterio + + +def _extract_band(zip_file_path: Path, band_name: str) -> Optional[np.ndarray]: + """Extract a single band from Sentinel-2 ZIP file. + + Helper function to read individual spectral bands. + + Args: + zip_file_path: Path to Sentinel-2 ZIP file + band_name: Band identifier (e.g., 'B04', 'B08', 'B11') + + Returns: + Band data as numpy array, or None if extraction fails + """ + try: + with tempfile.TemporaryDirectory() as temp_dir: + temp_path = Path(temp_dir) + + with zipfile.ZipFile(zip_file_path, "r") as zip_ref: + zip_ref.extractall(temp_path) + + safe_dirs = list(temp_path.glob("*.SAFE")) + if not safe_dirs: + return None + + safe_dir = safe_dirs[0] + img_data_dir = safe_dir / "GRANULE" + granule_dirs = list(img_data_dir.glob("*")) + + if not granule_dirs: + return None + + granule_dir = granule_dirs[0] + img_dir = granule_dir / "IMG_DATA" + + # Try multiple naming patterns + patterns = [ + f"*_{band_name}_10m.jp2", + f"*_{band_name}_20m.jp2", + f"*_{band_name}.jp2", + f"*{band_name}.jp2", + ] + + for pattern in patterns: + band_matches = list(img_dir.glob(pattern)) + if band_matches: + with rasterio.open(band_matches[0]) as src: + return src.read(1).astype(np.float32) + + return None + + except Exception as e: + print(f"Error extracting band {band_name}: {e}") + return None + + +def calculate_ndvi(zip_file_path: Path, bbox: Optional[list] = None) -> Optional[Dict]: + """Calculate NDVI (Normalized Difference Vegetation Index). + + WHAT IS NDVI: + NDVI measures vegetation health and density using the difference between + near-infrared (NIR) and red light reflectance. + + WHY IT WORKS: + - Healthy vegetation reflects a lot of NIR light (invisible to humans) + This is because plant cells scatter NIR to avoid overheating + - Healthy vegetation absorbs red light (for photosynthesis via chlorophyll) + - Dead/stressed vegetation reflects less NIR and more red + + FORMULA: + NDVI = (NIR - Red) / (NIR + Red) + + For Sentinel-2: + - NIR = Band 8 (B08, 842nm wavelength, 10m resolution) + - Red = Band 4 (B04, 665nm wavelength, 10m resolution) + + VALUE INTERPRETATION: + - -1 to 0: Water, snow, clouds, bare soil, rock + - 0 to 0.2: Sparse vegetation, bare soil, urban areas + - 0.2 to 0.5: Moderate vegetation (grassland, shrubs, crops) + - 0.5 to 0.8: Dense vegetation (forests, mature crops) + - 0.8 to 1.0: Very dense vegetation (tropical rainforest) + + APPLICATIONS: + - Crop health monitoring + - Vegetation mapping + - Drought detection + - Deforestation monitoring + - Agricultural yield prediction + + Args: + zip_file_path: Path to Sentinel-2 ZIP file + bbox: Optional bounding box [min_lon, min_lat, max_lon, max_lat] to crop result + + Returns: + Dictionary containing: + - 'ndvi': NDVI array with values from -1 to 1 + - 'metadata': Information about calculation + + Example: + >>> ndvi_data = calculate_ndvi(s2_file) + >>> ndvi = ndvi_data['ndvi'] + >>> print(f"NDVI range: {ndvi.min():.2f} to {ndvi.max():.2f}") + >>> print(f"Mean vegetation: {ndvi.mean():.2f}") + >>> # Classify vegetation density + >>> dense_veg = (ndvi > 0.5).sum() / ndvi.size * 100 + >>> print(f"Dense vegetation: {dense_veg:.1f}% of area") + """ + # Extract NIR band (B08) + # NIR = Near-Infrared, wavelength ~842nm, 10m resolution + # Healthy plants reflect ~50% of NIR light to avoid overheating + nir = _extract_band(zip_file_path, "B08") + if nir is None: + print("Failed to extract NIR band (B08)") + return None + + # Extract Red band (B04) + # Red light, wavelength ~665nm, 10m resolution + # Plants absorb red light for photosynthesis (chlorophyll absorption peak) + red = _extract_band(zip_file_path, "B04") + if red is None: + print("Failed to extract Red band (B04)") + return None + + # Calculate NDVI using normalized difference + # Normalization (dividing by sum) keeps values between -1 and 1 + # This makes NDVI comparable across different sensors and dates + # Add small epsilon to avoid division by zero + ndvi = (nir - red) / (nir + red + 1e-8) + + # Clip to valid range (handles numerical errors) + ndvi = np.clip(ndvi, -1, 1) + + return { + "ndvi": ndvi, + "metadata": { + "index": "NDVI", + "formula": "(NIR - Red) / (NIR + Red)", + "bands_used": ["B08 (NIR)", "B04 (Red)"], + "range": "[-1, 1]", + "shape": ndvi.shape, + }, + } + + +def calculate_ndwi(zip_file_path: Path, bbox: Optional[list] = None) -> Optional[Dict]: + """Calculate NDWI (Normalized Difference Water Index). + + WHAT IS NDWI: + NDWI enhances water features and suppresses vegetation and soil. + It's used to detect and monitor water bodies, wetlands, and soil moisture. + + WHY IT WORKS: + - Water strongly absorbs NIR light (appears dark in NIR) + - Water reflects green light (why water looks blue/green) + - This creates strong contrast between water and land + + FORMULA: + NDWI = (Green - NIR) / (Green + NIR) + + For Sentinel-2: + - Green = Band 3 (B03, 560nm wavelength, 10m resolution) + - NIR = Band 8 (B08, 842nm wavelength, 10m resolution) + + VALUE INTERPRETATION: + - > 0.3: Water bodies (lakes, rivers, ocean) + - 0.0 to 0.3: Wetlands, moist soil + - -0.3 to 0.0: Dry soil, sparse vegetation + - < -0.3: Dense vegetation, built-up areas + + APPLICATIONS: + - Water body mapping + - Flood extent monitoring + - Wetland detection + - Irrigation monitoring + - Drought assessment + + Args: + zip_file_path: Path to Sentinel-2 ZIP file + bbox: Optional bounding box to crop result + + Returns: + Dictionary with 'ndwi' array and metadata + + Example: + >>> ndwi_data = calculate_ndwi(s2_file) + >>> ndwi = ndwi_data['ndwi'] + >>> # Identify water pixels + >>> water_mask = ndwi > 0.3 + >>> water_area_pct = water_mask.sum() / water_mask.size * 100 + >>> print(f"Water coverage: {water_area_pct:.1f}%") + """ + # Extract Green band (B03) + green = _extract_band(zip_file_path, "B03") + if green is None: + print("Failed to extract Green band (B03)") + return None + + # Extract NIR band (B08) + nir = _extract_band(zip_file_path, "B08") + if nir is None: + print("Failed to extract NIR band (B08)") + return None + + # Calculate NDWI + # Note: Formula is (Green - NIR), opposite of NDVI + # This makes water positive and vegetation negative + ndwi = (green - nir) / (green + nir + 1e-8) + ndwi = np.clip(ndwi, -1, 1) + + return { + "ndwi": ndwi, + "metadata": { + "index": "NDWI", + "formula": "(Green - NIR) / (Green + NIR)", + "bands_used": ["B03 (Green)", "B08 (NIR)"], + "range": "[-1, 1]", + "shape": ndwi.shape, + }, + } + + +def calculate_evi(zip_file_path: Path, bbox: Optional[list] = None) -> Optional[Dict]: + """Calculate EVI (Enhanced Vegetation Index). + + WHAT IS EVI: + EVI is an improved version of NDVI that: + - Reduces atmospheric effects (haze, aerosols) + - Reduces soil background effects + - Is more sensitive in high biomass regions + + WHY IT'S BETTER THAN NDVI: + - NDVI saturates in dense vegetation (all values near 1.0) + - EVI continues to increase with vegetation density + - EVI works better in tropical regions with dense canopy + + FORMULA: + EVI = 2.5 * (NIR - Red) / (NIR + 6*Red - 7.5*Blue + 1) + + For Sentinel-2: + - NIR = Band 8 (B08, 842nm) + - Red = Band 4 (B04, 665nm) + - Blue = Band 2 (B02, 490nm) + + VALUE INTERPRETATION: + - < 0.2: Bare soil, water, snow + - 0.2 to 0.4: Sparse vegetation + - 0.4 to 0.6: Moderate vegetation + - > 0.6: Dense vegetation + + APPLICATIONS: + - Tropical forest monitoring + - High biomass vegetation studies + - Agricultural monitoring in dense crops + - Global vegetation monitoring (MODIS EVI product) + + Args: + zip_file_path: Path to Sentinel-2 ZIP file + bbox: Optional bounding box to crop result + + Returns: + Dictionary with 'evi' array and metadata + """ + # Extract required bands + nir = _extract_band(zip_file_path, "B08") + red = _extract_band(zip_file_path, "B04") + blue = _extract_band(zip_file_path, "B02") + + if nir is None or red is None or blue is None: + print("Failed to extract required bands for EVI") + return None + + # Calculate EVI with standard coefficients + # Coefficients: G=2.5, C1=6, C2=7.5, L=1 + # These are empirically derived for optimal performance + evi = 2.5 * (nir - red) / (nir + 6 * red - 7.5 * blue + 1 + 1e-8) + + # EVI typically ranges from -1 to 1, but can exceed in rare cases + evi = np.clip(evi, -1, 1) + + return { + "evi": evi, + "metadata": { + "index": "EVI", + "formula": "2.5 * (NIR - Red) / (NIR + 6*Red - 7.5*Blue + 1)", + "bands_used": ["B08 (NIR)", "B04 (Red)", "B02 (Blue)"], + "range": "[-1, 1]", + "shape": evi.shape, + }, + } + + +def calculate_savi( + zip_file_path: Path, L: float = 0.5, bbox: Optional[list] = None +) -> Optional[Dict]: + """Calculate SAVI (Soil Adjusted Vegetation Index). + + WHAT IS SAVI: + SAVI minimizes soil brightness influences on vegetation indices. + It's particularly useful in areas with sparse vegetation where + soil background significantly affects the signal. + + WHY IT'S NEEDED: + - NDVI is affected by soil color and brightness + - In sparse vegetation, soil dominates the pixel + - SAVI adds a soil brightness correction factor (L) + + FORMULA: + SAVI = ((NIR - Red) / (NIR + Red + L)) * (1 + L) + + For Sentinel-2: + - NIR = Band 8 (B08, 842nm) + - Red = Band 4 (B04, 665nm) + - L = Soil brightness correction factor + + L PARAMETER: + - L = 0: Equivalent to NDVI (high vegetation cover) + - L = 0.5: Intermediate (default, works for most cases) + - L = 1: Maximum soil adjustment (very sparse vegetation) + + VALUE INTERPRETATION: + Similar to NDVI but less affected by soil: + - < 0.2: Bare soil, water + - 0.2 to 0.4: Sparse vegetation + - 0.4 to 0.6: Moderate vegetation + - > 0.6: Dense vegetation + + APPLICATIONS: + - Arid and semi-arid regions + - Early crop growth monitoring + - Rangeland assessment + - Areas with exposed soil + + Args: + zip_file_path: Path to Sentinel-2 ZIP file + L: Soil brightness correction factor (0 to 1, default 0.5) + bbox: Optional bounding box to crop result + + Returns: + Dictionary with 'savi' array and metadata + """ + # Extract required bands + nir = _extract_band(zip_file_path, "B08") + red = _extract_band(zip_file_path, "B04") + + if nir is None or red is None: + print("Failed to extract required bands for SAVI") + return None + + # Calculate SAVI with soil adjustment factor + savi = ((nir - red) / (nir + red + L + 1e-8)) * (1 + L) + savi = np.clip(savi, -1, 1) + + return { + "savi": savi, + "metadata": { + "index": "SAVI", + "formula": f"((NIR - Red) / (NIR + Red + {L})) * (1 + {L})", + "bands_used": ["B08 (NIR)", "B04 (Red)"], + "L_factor": L, + "range": "[-1, 1]", + "shape": savi.shape, + }, + } + + +def calculate_nbr(zip_file_path: Path, bbox: Optional[list] = None) -> Optional[Dict]: + """Calculate NBR (Normalized Burn Ratio). + + WHAT IS NBR: + NBR is designed to highlight burned areas and assess burn severity. + It uses the difference between NIR and SWIR bands. + + WHY IT WORKS: + - Healthy vegetation: High NIR reflectance, low SWIR reflectance + - Burned areas: Low NIR reflectance, high SWIR reflectance + - This creates strong contrast between burned and unburned areas + + FORMULA: + NBR = (NIR - SWIR) / (NIR + SWIR) + + For Sentinel-2: + - NIR = Band 8 (B08, 842nm, 10m resolution) + - SWIR = Band 12 (B12, 2190nm, 20m resolution) + + VALUE INTERPRETATION: + - > 0.4: Healthy vegetation + - 0.1 to 0.4: Moderate vegetation + - -0.1 to 0.1: Recently burned or bare soil + - < -0.1: Severely burned areas + + BURN SEVERITY (using dNBR = pre-fire NBR - post-fire NBR): + - dNBR > 0.66: High severity + - dNBR 0.44-0.66: Moderate-high severity + - dNBR 0.27-0.44: Moderate-low severity + - dNBR 0.10-0.27: Low severity + - dNBR < 0.10: Unburned + + APPLICATIONS: + - Wildfire mapping + - Burn severity assessment + - Post-fire recovery monitoring + - Fire damage estimation + + Args: + zip_file_path: Path to Sentinel-2 ZIP file + bbox: Optional bounding box to crop result + + Returns: + Dictionary with 'nbr' array and metadata + + Example: + >>> # Calculate NBR for pre-fire and post-fire images + >>> nbr_pre = calculate_nbr(s2_file_before_fire) + >>> nbr_post = calculate_nbr(s2_file_after_fire) + >>> # Calculate difference (dNBR) to assess burn severity + >>> dnbr = nbr_pre['nbr'] - nbr_post['nbr'] + >>> high_severity = (dnbr > 0.66).sum() / dnbr.size * 100 + >>> print(f"High severity burn: {high_severity:.1f}% of area") + """ + # Extract NIR band (B08) + nir = _extract_band(zip_file_path, "B08") + if nir is None: + print("Failed to extract NIR band (B08)") + return None + + # Extract SWIR band (B12) + # SWIR = Shortwave Infrared, wavelength ~2190nm, 20m resolution + # Sensitive to moisture content and burned areas + swir = _extract_band(zip_file_path, "B12") + if swir is None: + print("Failed to extract SWIR band (B12)") + return None + + # Resample SWIR to match NIR resolution if needed + # B12 is 20m, B08 is 10m - need to upsample B12 + if swir.shape != nir.shape: + from scipy.ndimage import zoom + + zoom_factor = (nir.shape[0] / swir.shape[0], nir.shape[1] / swir.shape[1]) + swir = zoom(swir, zoom_factor, order=1) # Bilinear interpolation + + # Calculate NBR + nbr = (nir - swir) / (nir + swir + 1e-8) + nbr = np.clip(nbr, -1, 1) + + return { + "nbr": nbr, + "metadata": { + "index": "NBR", + "formula": "(NIR - SWIR) / (NIR + SWIR)", + "bands_used": ["B08 (NIR)", "B12 (SWIR)"], + "range": "[-1, 1]", + "shape": nbr.shape, + }, + } diff --git a/src/data/copernicus/quality.py b/src/data/copernicus/quality.py new file mode 100644 index 0000000..9a5611a --- /dev/null +++ b/src/data/copernicus/quality.py @@ -0,0 +1,200 @@ +"""Quality control utilities for Copernicus satellite data. + +This module provides functions for quality assessment and masking of satellite imagery, +particularly cloud masking for Sentinel-2 optical data. +""" + +import tempfile +import zipfile +from pathlib import Path +from typing import Optional + +import numpy as np +import rasterio + + +def extract_cloud_mask(zip_file_path: Path) -> Optional[np.ndarray]: + """Extract cloud mask from Sentinel-2 Scene Classification Layer (SCL). + + WHAT IS THE SCL BAND: + The Scene Classification Layer (SCL) is a quality band included with Sentinel-2 + Level-2A products. It classifies each pixel into categories like cloud, shadow, + vegetation, water, etc. This is generated by the Sen2Cor atmospheric correction + algorithm. + + WHY CLOUD MASKING MATTERS: + Clouds obscure the ground and make optical imagery unusable for analysis. + Cloud masking allows you to: + - Identify which pixels contain valid ground observations + - Exclude cloudy pixels from analysis + - Find the clearest images in a time series + - Create cloud-free composites by combining multiple images + + SCL CLASSIFICATION VALUES: + The SCL band uses integer values to classify each pixel: + - 0 = No Data (missing or invalid) + - 1 = Saturated or defective pixel + - 2 = Dark area (very low reflectance, topographic shadow) + - 3 = Cloud shadow + - 4 = Vegetation (CLEAR - keep this) + - 5 = Not vegetated (bare soil, rock) (CLEAR - keep this) + - 6 = Water (CLEAR - keep this) + - 7 = Unclassified + - 8 = Cloud medium probability (MASK OUT) + - 9 = Cloud high probability (MASK OUT) + - 10 = Thin cirrus (high altitude ice clouds) (MASK OUT) + - 11 = Snow or ice (usually MASK OUT, depends on application) + + MASKING STRATEGY: + We create a binary mask where: + - 1 (True) = Clear pixel, safe to use (classes 4, 5, 6) + - 0 (False) = Problematic pixel, should be masked (clouds, shadows, etc.) + + Args: + zip_file_path: Path to Sentinel-2 Level-2A ZIP file + Note: Level-1C products don't have SCL band! + Example: S2A_MSIL2A_20220101T123456_..._.zip + + Returns: + Binary mask array where: + - 1 = Clear pixel (vegetation, bare soil, water) + - 0 = Masked pixel (cloud, shadow, snow, etc.) + Shape: (height, width) matching the 20m resolution bands + Returns None if extraction fails or SCL band not found + + Example: + >>> mask = extract_cloud_mask(s2_l2a_file) + >>> print(f"Clear pixels: {mask.sum() / mask.size * 100:.1f}%") + >>> # Apply mask to RGB image + >>> rgb_masked = rgb_image.copy() + >>> rgb_masked[mask == 0] = 0 # Set cloudy pixels to black + """ + try: + with tempfile.TemporaryDirectory() as temp_dir: + temp_path = Path(temp_dir) + + # Extract ZIP file + with zipfile.ZipFile(zip_file_path, "r") as zip_ref: + zip_ref.extractall(temp_path) + + # Find SAFE directory + safe_dirs = list(temp_path.glob("*.SAFE")) + if not safe_dirs: + print(f"No SAFE directory found in {zip_file_path.name}") + return None + + safe_dir = safe_dirs[0] + + # Check if this is a Level-2A product (has SCL band) + # Level-1C products don't have SCL + if "MSIL1C" in safe_dir.name: + print( + f"Warning: {zip_file_path.name} is Level-1C (no SCL band). " + "Cloud masking requires Level-2A products." + ) + return None + + # Find IMG_DATA directory + img_data_dir = safe_dir / "GRANULE" + granule_dirs = list(img_data_dir.glob("*")) + + if not granule_dirs: + print(f"No granule directories found in {zip_file_path.name}") + return None + + granule_dir = granule_dirs[0] + + # SCL band is in IMG_DATA/R20m/ subdirectory (20m resolution) + img_dir_20m = granule_dir / "IMG_DATA" / "R20m" + if not img_dir_20m.exists(): + # Try alternative structure (older products) + img_dir_20m = granule_dir / "IMG_DATA" + + # Find SCL band file + # Naming pattern: T31UGQ_20220101T123456_SCL_20m.jp2 + scl_patterns = [ + "*_SCL_20m.jp2", # Standard pattern + "*_SCL.jp2", # Alternative pattern + "*SCL*.jp2", # Fallback pattern + ] + + scl_file = None + for pattern in scl_patterns: + scl_matches = list(img_dir_20m.glob(pattern)) + if scl_matches: + scl_file = scl_matches[0] + break + + if scl_file is None: + print(f"SCL band not found in {zip_file_path.name}") + print(f"Available files: {list(img_dir_20m.glob('*.jp2'))}") + return None + + # Read SCL band + with rasterio.open(scl_file) as src: + scl_data = src.read(1) # Read first (and only) band + + # Create binary mask based on SCL classification + # Clear pixels: vegetation (4), not vegetated (5), water (6) + # These are the classes where we can see the ground clearly + clear_classes = [4, 5, 6] + + # Initialize mask as all zeros (all masked) + mask = np.zeros_like(scl_data, dtype=np.uint8) + + # Set clear pixels to 1 + for clear_class in clear_classes: + mask[scl_data == clear_class] = 1 + + # Calculate cloud coverage statistics for user feedback + total_pixels = mask.size + clear_pixels = mask.sum() + cloud_coverage = (1 - clear_pixels / total_pixels) * 100 + + print(f"Cloud coverage: {cloud_coverage:.1f}% (based on SCL classification)") + + return mask + + except Exception as e: + print(f"Error extracting cloud mask from {zip_file_path.name}: {e}") + import traceback + + traceback.print_exc() + return None + + +def apply_cloud_mask_to_image( + image_array: np.ndarray, cloud_mask: np.ndarray, fill_value: float = 0.0 +) -> np.ndarray: + """Apply cloud mask to an image array. + + This function sets cloudy pixels to a fill value (typically 0 or NaN). + + Args: + image_array: Image array to mask, shape (H, W) or (H, W, C) + cloud_mask: Binary mask where 1=clear, 0=cloudy, shape (H, W) + fill_value: Value to use for masked pixels (0.0 for black, np.nan for NaN) + + Returns: + Masked image array with same shape as input + + Example: + >>> rgb_masked = apply_cloud_mask_to_image(rgb_array, cloud_mask, fill_value=0.0) + >>> # Or use NaN for numerical analysis + >>> rgb_masked = apply_cloud_mask_to_image(rgb_array, cloud_mask, fill_value=np.nan) + """ + # Create a copy to avoid modifying original + masked_image = image_array.copy() + + # Handle different array dimensions + if image_array.ndim == 2: + # Single band image (H, W) + masked_image[cloud_mask == 0] = fill_value + elif image_array.ndim == 3: + # Multi-band image (H, W, C) + # Broadcast mask across all channels + masked_image[cloud_mask == 0, :] = fill_value + else: + raise ValueError(f"Unsupported image dimensions: {image_array.ndim}") + + return masked_image From 1d756605c06d05fc625b461ea04101d69b453c74 Mon Sep 17 00:00:00 2001 From: Robin Fievet Date: Wed, 14 Jan 2026 20:06:38 -0500 Subject: [PATCH 7/8] add script to download S1/S2 test data and implement quality assessment --- scripts/README.md | 103 +++++ scripts/download_test_data.py | 171 +++++++ src/data/copernicus/__init__.py | 25 ++ src/data/copernicus/client.py | 120 ++++- src/data/copernicus/download_utils.py | 164 +++++++ src/data/copernicus/image_processing.py | 462 ++++++++++++++++++- src/data/copernicus/quality.py | 227 ++++++++++ src/data/copernicus/s1.py | 373 +++++++++++++-- src/data/copernicus/s2.py | 95 ++-- src/data/copernicus/visualization.py | 210 ++++++++- tests/test_copernicus_integration.py | 574 ++++++++++++++++++++++++ 11 files changed, 2440 insertions(+), 84 deletions(-) create mode 100644 scripts/README.md create mode 100755 scripts/download_test_data.py create mode 100644 src/data/copernicus/download_utils.py create mode 100644 tests/test_copernicus_integration.py diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 0000000..2a81bb4 --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,103 @@ +# Test Data Scripts + +## Overview + +This directory contains scripts for managing test data for the Copernicus client integration tests. + +## Download Test Data + +The `download_test_data.py` script downloads real Sentinel-1 and Sentinel-2 products to use as test fixtures. + +### Prerequisites + +1. Copernicus Data Space credentials (free registration at https://dataspace.copernicus.eu/) +2. Credentials in `.env` file: + ```bash + COPERNICUS_CLIENT_ID=your_client_id + COPERNICUS_CLIENT_SECRET=your_client_secret + ``` +3. ~3-4 GB free disk space + +### Usage + +```bash +# Download test data (run once) +uv run python scripts/download_test_data.py +``` + +This will: +- Download 2 Sentinel-1 products (~1.2-1.7 GB each) +- Download 1 Sentinel-2 product (~500-800 MB) +- Save products to `data/cache/copernicus/s1/` and `data/cache/copernicus/s2/` +- Create metadata file `data/test_fixtures/test_data_metadata.json` + +### Test Location + +The script downloads data for an agricultural area in the Netherlands: +- Location: 52.0°N, 5.5°E +- S2 Area: ~5km × 5km +- S1 Area: ~100km × 100km (larger due to S1 swath width) +- Time period: January-July 2024 + +This location was chosen because: +- Agricultural area (good for testing NDVI, crop monitoring) +- Reliable S1/S2 coverage +- Good data availability +- Flat terrain (easier to process) + +### Running Tests + +Once test data is downloaded, run the integration tests: + +```bash +# Run all integration tests +uv run python -m pytest tests/test_copernicus_integration.py -v + +# Run specific test +uv run python -m pytest tests/test_copernicus_integration.py::TestCopernicusIntegration::test_s2_rgb_extraction -v +``` + +### Troubleshooting + +**No products found:** +- Try different dates (the script uses January-July 2024) +- Check cloud cover threshold for S2 +- Verify location has satellite coverage + +**Download fails:** +- Check credentials in `.env` (use CLIENT_ID and CLIENT_SECRET, not USERNAME/PASSWORD) +- Verify internet connection +- Check Copernicus Data Space status +- Large files may take 1-2 minutes each + +**Tests skip:** +- Run `download_test_data.py` first +- Check that files exist in `data/cache/copernicus/s1/` and `data/cache/copernicus/s2/` +- Verify `test_data_metadata.json` exists + +### Updating Test Data + +To download fresh test data: + +```bash +# Remove old cache +rm -rf data/cache/copernicus/ + +# Download new data +uv run python scripts/download_test_data.py +``` + +### Data Management + +Test fixtures are gitignored (via `data/*` in `.gitignore`). Each developer downloads their own test data locally. + +**Disk usage:** +- S1 products: ~1.2-1.7 GB each (2 products = ~3 GB) +- S2 product: ~500-800 MB +- Total: ~3.5-4.5 GB + +To clean up: +```bash +rm -rf data/cache/copernicus/ +rm -rf data/test_fixtures/ +``` diff --git a/scripts/download_test_data.py b/scripts/download_test_data.py new file mode 100755 index 0000000..c9e46c6 --- /dev/null +++ b/scripts/download_test_data.py @@ -0,0 +1,171 @@ +#!/usr/bin/env python3 +"""Download sample Copernicus data for testing. + +This script downloads one S1 and one S2 product to use as test fixtures. +Run once to populate test data, then use those files for all subsequent tests. + +Usage: + uv run python scripts/download_test_data.py + +Requirements: + - .env file with COPERNICUS_USERNAME and COPERNICUS_PASSWORD + - Internet connection + - ~1-2 GB free disk space +""" + +import json +import os +from datetime import datetime +from pathlib import Path + +from dotenv import load_dotenv + +from src.data.copernicus.client import CopernicusClient + + +def main(): + """Download test data for S1 and S2.""" + # Load environment variables from .env file + load_dotenv() + # Setup + test_data_dir = Path("data/test_fixtures") + test_data_dir.mkdir(parents=True, exist_ok=True) + + # Check credentials + client_id = os.getenv("COPERNICUS_CLIENT_ID") + client_secret = os.getenv("COPERNICUS_CLIENT_SECRET") + + if not client_id or not client_secret: + print("ERROR: Missing credentials in .env file") + print("Please set COPERNICUS_CLIENT_ID and COPERNICUS_CLIENT_SECRET") + print() + print("Get free credentials at: https://dataspace.copernicus.eu/") + return 1 + + print("=" * 60) + print("COPERNICUS TEST DATA DOWNLOADER") + print("=" * 60) + print(f"Output directory: {test_data_dir.absolute()}") + print() + + # Initialize client + client = CopernicusClient(client_id=client_id, client_secret=client_secret) + + # Test location: Agricultural area in Netherlands + # Good S1/S2 coverage, flat terrain, agricultural land + center_lat = 52.0 + center_lon = 5.5 + + # Use fixed bboxes that we know have data + s2_bbox = [5.463417359335974, 51.97747747747748, 5.536582640664026, 52.02252252252252] + s1_bbox = [5.0, 51.5, 6.0, 52.5] # Larger bbox that we know has S1 data + + print(f"Test location: {center_lat}°N, {center_lon}°E") + print("S2 bounding box: ~5km x 5km") + print("S1 bounding box: ~100km x 100km (larger for S1 coverage)") + print(f"S2 bbox coords: {s2_bbox}") + print(f"S1 bbox coords: {s1_bbox}") + print() + + # Metadata to save + metadata = { + "downloaded_at": datetime.now().isoformat(), + "location": { + "lat": center_lat, + "lon": center_lon, + "s2_bbox": s2_bbox, + "s1_bbox": s1_bbox, + }, + "products": {}, + } + + # ======================================================================== + # Download Sentinel-2 product + # ======================================================================== + print("=" * 60) + print("DOWNLOADING SENTINEL-2 PRODUCT") + print("=" * 60) + + try: + s2_files = client.fetch_s2( + bbox=s2_bbox, + start_date="2024-07-01", + end_date="2024-07-15", + max_cloud_cover=20, + download_data=True, + interactive=False, + max_products=2, + ) + + if not s2_files: + print("WARNING: No S2 products found. Try different dates/location.") + else: + print(f"✓ Downloaded {len(s2_files)} S2 products") + for s2_file in s2_files: + metadata["products"][f"s2_{s2_file.stem}"] = { + "file": s2_file.name, + "size_mb": s2_file.stat().st_size / 1024**2, + } + + except Exception as e: + print(f"ERROR downloading S2: {e}") + + print() + + # ======================================================================== + # Download Sentinel-1 product + # ======================================================================== + print("=" * 60) + print("DOWNLOADING SENTINEL-1 PRODUCT") + print("=" * 60) + + try: + s1_files = client.fetch_s1( + bbox=s1_bbox, + start_date="2024-01-01", + end_date="2024-07-31", + product_type="GRD", + orbit_direction="ASCENDING", + acquisition_mode="IW", + download_data=True, + max_products=2, + ) + + if not s1_files: + print("WARNING: No S1 products found. Try different dates/location.") + else: + print(f"✓ Downloaded {len(s1_files)} S1 products") + for s1_file in s1_files: + metadata["products"][f"s1_{s1_file.stem}"] = { + "file": s1_file.name, + "size_mb": s1_file.stat().st_size / 1024**2, + } + + except Exception as e: + print(f"ERROR downloading S1: {e}") + + print() + + # ======================================================================== + # Save metadata + # ======================================================================== + metadata_file = test_data_dir / "test_data_metadata.json" + with open(metadata_file, "w") as f: + json.dump(metadata, f, indent=2) + + print("=" * 60) + print("DOWNLOAD COMPLETE") + print("=" * 60) + print(f"Metadata saved to: {metadata_file}") + print() + print("Downloaded products:") + for sensor, info in metadata["products"].items(): + print(f" {sensor.upper()}: {info['file']} ({info['size_mb']:.1f} MB)") + print() + print("You can now run tests using these files as fixtures.") + + return 0 + + +if __name__ == "__main__": + exit(main()) diff --git a/src/data/copernicus/__init__.py b/src/data/copernicus/__init__.py index d1b315c..261ca83 100644 --- a/src/data/copernicus/__init__.py +++ b/src/data/copernicus/__init__.py @@ -3,15 +3,27 @@ from .client import CopernicusClient from .image_processing import ( create_false_color_composite, + crop_to_bbox, extract_rgb_composite, + extract_sar_composite, get_available_bands, get_image_statistics, ) +from .indices import ( + calculate_evi, + calculate_nbr, + calculate_ndvi, + calculate_ndwi, + calculate_savi, +) +from .quality import apply_cloud_mask_to_image, extract_cloud_mask from .visualization import ( create_band_analysis_plot, create_comparison_plot, create_coverage_map, create_metadata_summary, + create_sar_comparison_plot, + display_sar_image, display_satellite_image, ) @@ -19,13 +31,26 @@ "CopernicusClient", # Image processing "extract_rgb_composite", + "extract_sar_composite", + "crop_to_bbox", "get_available_bands", "create_false_color_composite", "get_image_statistics", + # Quality control + "extract_cloud_mask", + "apply_cloud_mask_to_image", + # Spectral indices + "calculate_ndvi", + "calculate_ndwi", + "calculate_evi", + "calculate_savi", + "calculate_nbr", # Visualization "create_coverage_map", "display_satellite_image", + "display_sar_image", "create_comparison_plot", + "create_sar_comparison_plot", "create_metadata_summary", "create_band_analysis_plot", ] diff --git a/src/data/copernicus/client.py b/src/data/copernicus/client.py index 19b2083..87ec16b 100644 --- a/src/data/copernicus/client.py +++ b/src/data/copernicus/client.py @@ -208,6 +208,7 @@ def fetch_s2( product_type: str = "S2MSI1C", download_data: bool = True, interactive: bool = True, + max_products: int = 3, ) -> List[Path]: """Fetch Sentinel-2 products for a given area and time period. @@ -232,6 +233,10 @@ def fetch_s2( - "S2MSI2A": Level-2A (bottom-of-atmosphere reflectance, atmospherically corrected) download_data: If True, download actual satellite imagery. If False, only fetch metadata. interactive: If True, prompt user for download confirmation when products are found. + max_products: Maximum number of products to download/process. + Default: 3 (prevents accidental huge downloads) + Set to higher value or None for unlimited + Example: max_products=10 for 10 products Returns: List of Path objects pointing to downloaded imagery files or metadata files. @@ -265,6 +270,7 @@ def fetch_s2( product_type=product_type, download_data=download_data, interactive=interactive, + max_products=max_products, ) def fetch_s1( @@ -276,6 +282,9 @@ def fetch_s1( product_type: str = "GRD", polarization: str = "VV,VH", orbit_direction: str = "ASCENDING", + acquisition_mode: str = "IW", + download_data: bool = True, + max_products: int = 3, ) -> List[Path]: """Fetch Sentinel-1 products for a given area and time period. @@ -303,10 +312,98 @@ def fetch_s1( - "ASCENDING": Satellite moving from south to north - "DESCENDING": Satellite moving from north to south Different directions can show different aspects of terrain. + acquisition_mode: SAR acquisition mode (default: "IW") + + WHAT IS ACQUISITION MODE: + Sentinel-1 SAR can operate in different imaging modes, + like a camera with different lenses. Each mode trades + off between coverage area and resolution. + + AVAILABLE MODES: + - "IW" (Interferometric Wide Swath): DEFAULT + Coverage: 250km wide, Resolution: 10m + Use: General land monitoring (95% of cases) + Best for: Agriculture, forests, urban areas, most ML applications + + - "EW" (Extra Wide Swath): + Coverage: 400km wide, Resolution: 40m + Use: Ocean monitoring, polar regions, wide area surveillance + Best for: Maritime surveillance, ice sheets, large-scale monitoring + + - "SM" (Strip Map): + Coverage: 80km wide, Resolution: 5m + Use: Emergency response, detailed monitoring + Best for: Disasters, high-detail urban mapping, infrastructure + + - "WV" (Wave Mode): + Coverage: 20km samples, Resolution: 5m + Use: Ocean wave studies (very specialized) + Best for: Ocean wave height/direction analysis + + WHAT CHANGES WITH MODE: + ✅ Resolution (how detailed the image is) + IW=10m, EW=40m, SM=5m, WV=5m + ✅ Coverage area (how wide the swath is) + IW=250km, EW=400km, SM=80km, WV=20km samples + ✅ Image size (number of pixels) + Higher resolution = more pixels for same area + + WHAT DOESN'T CHANGE: + ❌ Polarizations (always VV, VH or HH, HV) + ❌ Data format (always 2-channel array) + ❌ Visualization (same grayscale SAR display) + ❌ Processing code (same functions work for all modes) + ❌ Backscatter values (same dB range -30 to 0) + + VISUAL COMPARISON: + Satellite flying → + + EW Mode: ████████████████████████████████ (400km, lower res) + IW Mode: ████████████████████ (250km, good res) ← DEFAULT + SM Mode: ██████████ (80km, high res) + WV Mode: ██ ██ ██ ██ (samples only) + + FOR GALILEO ML: + - Use IW mode (default) for consistency across your dataset + - Don't mix modes in the same training set (different resolutions) + - IW provides the best balance of coverage and resolution + - Most Sentinel-1 data available is IW mode (95%+ of acquisitions) + + WHEN TO USE EACH MODE: + - IW: Default choice, works for 95% of use cases + Land monitoring, agriculture, forestry, urban areas + - EW: When you need very wide coverage and resolution isn't critical + Ocean monitoring, polar ice, maritime surveillance + - SM: When you need maximum detail in a smaller area + Emergency response, disaster mapping, detailed infrastructure + - WV: Only for specialized ocean wave analysis + Rarely used for general remote sensing + + Example: + >>> # Default (IW) - works for 95% of cases + >>> s1_files = client.fetch_s1(bbox, start_date, end_date) + >>> + >>> # Ocean monitoring - use EW for wide coverage + >>> s1_files = client.fetch_s1(bbox, start_date, end_date, + ... acquisition_mode="EW") + >>> + >>> # Disaster response - use SM for high detail + >>> s1_files = client.fetch_s1(bbox, start_date, end_date, + ... acquisition_mode="SM") + >>> + >>> # Ocean wave analysis - use WV (specialized) + >>> s1_files = client.fetch_s1(bbox, start_date, end_date, + ... acquisition_mode="WV") + download_data: If True, download actual SAR imagery (1-2GB per product). + If False, only fetch metadata (few KB per product). + Default: True + max_products: Maximum number of products to download/process. + Default: 3 (prevents accidental huge downloads) + Set to higher value or None for unlimited + Example: max_products=10 for 10 products Returns: - List of Path objects pointing to downloaded files or metadata files. - Currently returns metadata JSON files; future versions will download actual imagery. + List of Path objects pointing to downloaded ZIP files or metadata JSON files. Raises: ValueError: If input parameters are invalid (e.g., invalid bbox coordinates, @@ -331,6 +428,22 @@ def fetch_s1( if orbit_direction not in ["ASCENDING", "DESCENDING"]: raise ValueError("orbit_direction must be ASCENDING or DESCENDING") + # Validate acquisition mode parameter + if acquisition_mode not in ["IW", "EW", "SM", "WV"]: + raise ValueError( + f"acquisition_mode must be IW, EW, SM, or WV. Got: {acquisition_mode}\n" + "\n" + "Available modes:\n" + " IW (default): 250km coverage, 10m resolution - general land monitoring\n" + " Best for agriculture, forests, urban areas (95% of use cases)\n" + " EW: 400km coverage, 40m resolution - ocean/polar regions\n" + " Best for maritime surveillance, ice sheets, wide area monitoring\n" + " SM: 80km coverage, 5m resolution - emergency response\n" + " Best for disasters, high-detail urban mapping, infrastructure\n" + " WV: 20km samples, 5m resolution - ocean waves only\n" + " Specialized for ocean wave height/direction analysis\n" + ) + # Delegate the actual work to the S1-specific module # This keeps the client class focused on coordination and validation return fetch_s1_products( @@ -341,4 +454,7 @@ def fetch_s1( product_type=product_type, polarization=polarization, orbit_direction=orbit_direction, + acquisition_mode=acquisition_mode, + download_data=download_data, + max_products=max_products, ) diff --git a/src/data/copernicus/download_utils.py b/src/data/copernicus/download_utils.py new file mode 100644 index 0000000..8a045f4 --- /dev/null +++ b/src/data/copernicus/download_utils.py @@ -0,0 +1,164 @@ +"""Robust download utilities for large Copernicus satellite products. + +This module provides download functions that handle: +- Token expiration during long downloads +- Network interruptions with automatic retry +- Partial download resumption +- Progress tracking for multi-GB files +""" + +import time +from pathlib import Path +from typing import TYPE_CHECKING + +import requests +from tqdm import tqdm + +if TYPE_CHECKING: + from .client import CopernicusClient + + +def download_with_retry( + client: "CopernicusClient", + url: str, + output_path: Path, + total_size: int, + max_retries: int = 3, + chunk_size: int = 8192, +) -> bool: + """Download a file with automatic retry and token refresh. + + This function handles large file downloads (1-10 GB) that may take longer + than the OAuth token lifetime (~10 minutes). It refreshes the token + periodically and retries on failures. + + Key features: + - Token refresh every 5 minutes during download + - Automatic retry with exponential backoff on failures + - Resume partial downloads using HTTP Range requests + - Progress bar for user feedback + + Args: + client: CopernicusClient for authentication + url: Download URL (typically ends with /$value) + output_path: Where to save the downloaded file + total_size: Expected file size in bytes + max_retries: Maximum number of retry attempts (default: 3) + chunk_size: Download chunk size in bytes (default: 8KB) + + Returns: + True if download succeeded, False otherwise + + Example: + >>> success = download_with_retry( + ... client, download_url, Path("product.zip"), 1500000000 + ... ) + >>> if success: + ... print("Download complete!") + """ + # Track download progress + bytes_downloaded = 0 + retry_count = 0 + last_token_refresh = time.time() + token_refresh_interval = 300 # Refresh token every 5 minutes + + # Create parent directory if needed + output_path.parent.mkdir(parents=True, exist_ok=True) + + # Check if partial download exists + if output_path.exists(): + bytes_downloaded = output_path.stat().st_size + if bytes_downloaded >= total_size: + print(f"✅ Already downloaded: {output_path.name}") + return True + print(f"📥 Resuming download from {bytes_downloaded / 1024**2:.1f} MB") + + while retry_count <= max_retries: + try: + # Refresh token if needed (before starting/resuming download) + current_time = time.time() + if current_time - last_token_refresh > token_refresh_interval: + print("🔄 Refreshing authentication token...") + client._get_access_token() # Force token refresh + last_token_refresh = current_time + + # Get fresh token for this attempt + token = client._get_access_token() + headers = { + "Authorization": f"Bearer {token}", + "User-Agent": "Galileo-Copernicus-Client/1.0", + } + + # Add Range header for resume capability + if bytes_downloaded > 0: + headers["Range"] = f"bytes={bytes_downloaded}-" + + # Start download with streaming + response = requests.get(url, headers=headers, stream=True, timeout=300) + + # Handle resume responses + if response.status_code == 206: # Partial Content (resume) + print(f"✓ Server supports resume, continuing from byte {bytes_downloaded}") + elif response.status_code == 200: # Full content + if bytes_downloaded > 0: + print("⚠️ Server doesn't support resume, restarting download") + bytes_downloaded = 0 + if output_path.exists(): + output_path.unlink() + else: + response.raise_for_status() + + # Open file in append mode if resuming, write mode otherwise + mode = "ab" if bytes_downloaded > 0 else "wb" + + # Download with progress bar + with open(output_path, mode) as f: + with tqdm( + total=total_size, + initial=bytes_downloaded, + unit="B", + unit_scale=True, + desc=f"Downloading {output_path.name[:40]}", + ) as pbar: + for chunk in response.iter_content(chunk_size=chunk_size): + if chunk: + f.write(chunk) + chunk_len = len(chunk) + bytes_downloaded += chunk_len + pbar.update(chunk_len) + + # Check if we need to refresh token during download + current_time = time.time() + if current_time - last_token_refresh > token_refresh_interval: + # Token might expire soon, but we can't refresh mid-stream + # Just note it for the next retry if this fails + last_token_refresh = current_time + + # Verify download completed + if bytes_downloaded >= total_size: + print(f"✅ Download complete: {output_path.name}") + return True + else: + print(f"⚠️ Download incomplete: {bytes_downloaded}/{total_size} bytes") + retry_count += 1 + continue + + except requests.exceptions.RequestException as e: + retry_count += 1 + if retry_count > max_retries: + print(f"❌ Download failed after {max_retries} retries: {e}") + return False + + # Exponential backoff: wait 2^retry seconds + wait_time = 2**retry_count + print(f"⚠️ Download error: {e}") + print(f"🔄 Retrying in {wait_time} seconds... (attempt {retry_count}/{max_retries})") + time.sleep(wait_time) + continue + + except Exception as e: + print(f"❌ Unexpected error during download: {e}") + return False + + print(f"❌ Download failed after {max_retries} retries") + return False diff --git a/src/data/copernicus/image_processing.py b/src/data/copernicus/image_processing.py index b6a5157..d025f47 100644 --- a/src/data/copernicus/image_processing.py +++ b/src/data/copernicus/image_processing.py @@ -1,7 +1,9 @@ """Image processing utilities for Copernicus satellite data. This module provides high-level functions for extracting and processing -satellite imagery from downloaded Copernicus products, particularly Sentinel-2 data. +satellite imagery from downloaded Copernicus products, including: +- Sentinel-2 optical imagery (RGB composites, false color) +- Sentinel-1 SAR imagery (radar backscatter) """ import tempfile @@ -15,7 +17,10 @@ def extract_rgb_composite( - zip_file_path: Path, bands: Optional[List[str]] = None, normalize: bool = True + zip_file_path: Path, + bands: Optional[List[str]] = None, + normalize: bool = True, + bbox: Optional[List[float]] = None, ) -> Optional[Dict]: """Extract RGB composite from Sentinel-2 ZIP file. @@ -23,10 +28,23 @@ def extract_rgb_composite( zip_file_path: Path to Sentinel-2 ZIP file bands: List of band names to extract (default: ['B04', 'B03', 'B02'] for RGB) normalize: Whether to apply percentile normalization for display + bbox: Optional bounding box [min_lon, min_lat, max_lon, max_lat] to crop to + ⚠️ IMPORTANT: This reduces MEMORY usage, not ZIP file size! + The full ZIP is still downloaded (API limitation). Cropping happens + AFTER extraction, reducing the returned array size by 99%+ for small areas. + + Example: Without bbox, returns 1.4 GB array (full 110km tile) + With bbox, returns 77 KB array (800m × 800m area) + + Use this when: + - Processing many images (saves memory) + - Training ML models (only need small patches) + - Time series analysis (consistent small area) Returns: Dictionary containing: - 'rgb_array': RGB image array (H, W, 3) + Size depends on bbox: full tile or cropped area - 'bounds_wgs84': Geographic bounds in WGS84 coordinates - 'bounds_utm': Original UTM bounds - 'crs': Coordinate reference system @@ -139,6 +157,20 @@ def extract_rgb_composite( else: bounds_wgs84 = None + # Apply bbox cropping if requested + # ⚠️ IMPORTANT: This reduces MEMORY usage, not ZIP file size! + # The full 700MB ZIP was already downloaded. We're now extracting + # only the pixels we need from the full tile that's in memory. + # This saves 99%+ memory and makes processing much faster. + if bbox is not None and bounds_wgs84 is not None: + print(f"Cropping to bbox: {bbox}") + rgb_display = crop_to_bbox(rgb_display, bounds_wgs84, bbox) + if rgb_display is None: + print("Cropping failed, returning None") + return None + # Update bounds to reflect cropped area + bounds_wgs84 = tuple(bbox) + return { "rgb_array": rgb_display, "bounds_wgs84": bounds_wgs84, @@ -270,3 +302,429 @@ def _calculate_area_km2(bounds_wgs84: Tuple[float, float, float, float]) -> floa area_km2 = (lon_diff * km_per_degree_lon) * (lat_diff * km_per_degree_lat) return area_km2 + + +def extract_sar_composite( + zip_file_path: Path, + polarizations: Optional[List[str]] = None, + to_db: bool = True, + bbox: Optional[List[float]] = None, +) -> Optional[Dict]: + """Extract SAR backscatter composite from Sentinel-1 ZIP file. + + WHAT IS SAR (SYNTHETIC APERTURE RADAR): + SAR is an active radar sensor that sends microwave pulses to Earth and measures + the reflected signal (backscatter). Unlike optical sensors (Sentinel-2), SAR: + - Works day and night (doesn't need sunlight) + - Penetrates clouds and rain (microwaves pass through) + - Measures surface roughness and structure + + WHAT IS BACKSCATTER: + Backscatter is the radar signal reflected back to the satellite. The strength depends on: + - Surface roughness: Smooth surfaces (water) = low backscatter (dark) + Rough surfaces (buildings, vegetation) = high backscatter (bright) + - Moisture content: Wet surfaces reflect more than dry surfaces + - Viewing geometry: Angle of radar beam affects return signal + + WHAT ARE POLARIZATIONS: + Radar can transmit and receive in different orientations: + - VV: Vertical transmit, Vertical receive + Good for: Water detection, urban areas, bare soil + Sensitive to: Surface roughness, soil moisture + - VH: Vertical transmit, Horizontal receive (cross-polarization) + Good for: Vegetation monitoring, crop classification + Sensitive to: Volume scattering from vegetation canopy + + WHY CONVERT TO DECIBELS (dB): + Raw SAR data has huge dynamic range (0.0001 to 10000+). Converting to dB: + - Compresses the range for better visualization + - Makes values more interpretable (-30 dB to +10 dB typical range) + - Formula: dB = 10 * log10(linear_value) + + Args: + zip_file_path: Path to Sentinel-1 ZIP file (GRD product) + Example: S1A_IW_GRDH_1SDV_20220101T123456_..._.zip + polarizations: List of polarizations to extract (default: ['VV', 'VH']) + Options: 'VV', 'VH', 'HH', 'HV' (availability depends on product) + to_db: If True, convert backscatter to decibels (dB) for better visualization + If False, keep linear scale (sigma0 values) + bbox: Optional bounding box [min_lon, min_lat, max_lon, max_lat] to crop to + ⚠️ IMPORTANT: This reduces MEMORY usage, not ZIP file size! + The full 1-2GB SAR ZIP is still downloaded (API limitation). Cropping + happens AFTER extraction, reducing the returned array size by 99%+ for + small areas. + + Example: Without bbox, returns ~1.4 GB array (full 110km tile) + With bbox, returns ~77 KB array (800m × 800m area) + + Use this when: + - Processing many SAR images (saves memory) + - Training ML models (only need small patches) + - Time series analysis (consistent small area) + + Returns: + Dictionary containing: + - 'sar_array': SAR backscatter array (H, W, num_polarizations) + Values in dB if to_db=True, else linear sigma0 + - 'polarizations': List of polarization names in order + - 'bounds_wgs84': Geographic bounds [min_lon, min_lat, max_lon, max_lat] + - 'bounds_utm': Original UTM bounds + - 'crs': Coordinate reference system + - 'metadata': Additional metadata (resolution, product name, etc.) + + Returns None if extraction fails. + + Example: + >>> sar_data = extract_sar_composite(s1_zip_file) + >>> print(sar_data['sar_array'].shape) # (height, width, 2) for VV+VH + >>> print(sar_data['polarizations']) # ['VV', 'VH'] + >>> print(f"VV range: {sar_data['sar_array'][:,:,0].min():.1f} to {sar_data['sar_array'][:,:,0].max():.1f} dB") + """ + if polarizations is None: + polarizations = ["VV", "VH"] # Most common dual-polarization combination + + try: + with tempfile.TemporaryDirectory() as temp_dir: + temp_path = Path(temp_dir) + + # Extract ZIP file + # Sentinel-1 products are distributed as ZIP files containing: + # - measurement/ folder with GeoTIFF files for each polarization + # - annotation/ folder with XML metadata + # - preview/ folder with quicklook images + with zipfile.ZipFile(zip_file_path, "r") as zip_ref: + zip_ref.extractall(temp_path) + + # Find SAFE directory (Sentinel-1 format) + # SAFE = Standard Archive Format for Europe + # Directory name contains product metadata: platform, mode, type, date, etc. + safe_dirs = list(temp_path.glob("*.SAFE")) + if not safe_dirs: + print(f"No SAFE directory found in {zip_file_path.name}") + return None + + safe_dir = safe_dirs[0] + + # Find measurement directory containing the actual SAR data + # GRD products have measurement/ folder with GeoTIFF files + measurement_dir = safe_dir / "measurement" + if not measurement_dir.exists(): + print(f"No measurement directory found in {zip_file_path.name}") + return None + + # Find polarization files + # Files are named like: s1a-iw-grd-vv-20220101t123456-...-.tiff + pol_files = {} + for pol in polarizations: + # Try multiple naming patterns (lowercase and uppercase) + patterns = [ + f"*-{pol.lower()}-*.tiff", # Standard pattern: ...-vv-...tiff + f"*-{pol.upper()}-*.tiff", # Uppercase variant + f"*{pol.lower()}.tiff", # Simple pattern + f"*{pol.upper()}.tiff", # Simple uppercase + ] + + for pattern in patterns: + pol_matches = list(measurement_dir.glob(pattern)) + if pol_matches: + pol_files[pol] = pol_matches[0] + break + + if not pol_files: + print(f"No polarization files found in {zip_file_path.name}") + print(f"Available files: {list(measurement_dir.glob('*.tiff'))}") + return None + + # Read polarization bands and create composite + sar_bands = [] + bounds = None + crs = None + resolution = None + + for pol in polarizations: + if pol in pol_files: + with rasterio.open(pol_files[pol]) as src: + # Read the backscatter data + # Values are typically in linear scale (sigma0) + band_data = src.read(1).astype(np.float32) + + # Get geospatial info from first band + if bounds is None: + bounds = src.bounds + crs = src.crs + resolution = src.res # (x_resolution, y_resolution) in meters + + # Convert to dB if requested + # dB scale is more intuitive for visualization and analysis + if to_db: + # Add small epsilon to avoid log(0) = -inf + # Typical SAR values range from 0.0001 to 10 + # In dB: -40 dB to +10 dB + band_data_db = 10 * np.log10(band_data + 1e-10) + + # Clip extreme values for better visualization + # Values below -30 dB are typically noise + # Values above +10 dB are rare (very strong scatterers) + band_data_db = np.clip(band_data_db, -30, 10) + sar_bands.append(band_data_db) + else: + sar_bands.append(band_data) + + if not sar_bands: + return None + + # Stack bands into multi-polarization array + # Shape: (num_polarizations, height, width) + sar_array = np.stack(sar_bands, axis=0) + + # Convert to display format (H, W, C) + # This matches the format used for optical imagery + sar_display = np.transpose(sar_array, (1, 2, 0)) + + # Convert bounds to WGS84 for consistency with S2 functions + if bounds is not None and crs is not None: + bounds_wgs84 = transform_bounds( + crs, "EPSG:4326", bounds.left, bounds.bottom, bounds.right, bounds.top + ) + else: + bounds_wgs84 = None + + # Apply bbox cropping if requested + # ⚠️ IMPORTANT: This reduces MEMORY usage, not ZIP file size! + # The full 1-2GB SAR ZIP was already downloaded. We're now extracting + # only the pixels we need from the full tile that's in memory. + # This saves 99%+ memory and makes processing much faster. + if bbox is not None and bounds_wgs84 is not None: + print(f"Cropping SAR to bbox: {bbox}") + sar_display = crop_to_bbox(sar_display, bounds_wgs84, bbox) + if sar_display is None: + print("SAR cropping failed, returning None") + return None + # Update bounds to reflect cropped area + bounds_wgs84 = tuple(bbox) + + return { + "sar_array": sar_display, + "polarizations": [pol for pol in polarizations if pol in pol_files], + "bounds_wgs84": bounds_wgs84, + "bounds_utm": bounds, + "crs": str(crs), + "metadata": { + "shape": sar_display.shape, + "resolution_m": resolution, + "zip_file": zip_file_path.name, + "safe_dir": safe_dir.name, + "scale": "dB" if to_db else "linear", + }, + } + + except Exception as e: + print(f"Error extracting SAR from {zip_file_path.name}: {e}") + import traceback + + traceback.print_exc() + return None + + +def crop_to_bbox( + image_array: np.ndarray, + image_bounds: Tuple[float, float, float, float], + target_bbox: List[float], + image_crs: str = "EPSG:4326", +) -> Optional[np.ndarray]: + """Crop satellite image to user's requested bounding box. + + ⚠️ IMPORTANT: WHAT THIS FUNCTION DOES AND DOESN'T SAVE ⚠️ + + WHAT THIS SAVES: + ✅ Memory/RAM usage (99%+ reduction) + ✅ Processing time (operations on smaller arrays are faster) + ✅ Downstream storage (if you save the extracted arrays) + + WHAT THIS DOESN'T SAVE: + ❌ ZIP file download size (still downloads full 500MB-2GB file) + ❌ Disk space for cached ZIPs (ZIPs are stored as-is) + ❌ Download time (must download entire tile from API) + + WHEN CROPPING HAPPENS: + 1. Download full ZIP file (700 MB) ← NO CROPPING + 2. Extract bands from ZIP (load full 110km tile into memory) ← NO CROPPING + 3. Apply this crop function (extract 800m subset) ← CROPPING HAPPENS HERE + 4. Return cropped array (77 KB) ← HUGE MEMORY SAVINGS + + WHY YOU CAN'T CROP THE ZIP: + The Copernicus API doesn't support partial tile downloads. You must download + the entire 110km × 110km tile even if you only need 800m × 800m. This is a + limitation of how satellite data is organized and distributed. + + SATELLITE TILE SYSTEM EXPLANATION: + + Copernicus organizes data into fixed tiles covering Earth: + + ┌─────────────────────────────────────┐ + │ Tile T31UGQ (110km × 110km) │ ← Full tile downloaded from API + │ │ (700 MB ZIP file) + │ ┌──┐ ← User's 800m area │ ← What user actually wants + │ └──┘ │ (77 KB after cropping) + │ │ + └─────────────────────────────────────┘ + + MEMORY SAVINGS EXAMPLE: + - User requests 800m × 800m area (0.64 km²) + - API returns entire 110km × 110km tile (12,100 km²) + - That's 18,906× more data than needed! + + WITHOUT CROPPING: + - Full tile in memory: 10,980 × 10,980 × 3 = 362 million values + - Memory usage: ~1.4 GB for float32 array + + WITH CROPPING: + - Cropped area: 80 × 80 × 3 = 19,200 values + - Memory usage: ~77 KB for float32 array + - Reduction: 18,750× smaller (99.995% less memory!) + + WHEN TO USE CROPPING: + ✅ Training ML models (only need small patches) + ✅ Processing many images (save memory) + ✅ Time series analysis (consistent small area) + ✅ Interactive applications (fast response) + + WHEN NOT TO USE CROPPING: + ❌ Exploring data (want to see full context) + ❌ Large area analysis (need the full tile) + ❌ Mosaicking (combining multiple tiles) + + HOW IT WORKS: + 1. Convert geographic coordinates (lat/lon degrees) to pixel coordinates (row/col) + 2. Calculate which pixels fall within the target bounding box + 3. Extract only those pixels from the full image array + 4. Return the cropped subset + + COORDINATE SYSTEMS: + - WGS84 (EPSG:4326): Latitude/longitude in degrees + Example: [6.15, 49.11, 6.16, 49.12] = 800m × 800m in Luxembourg + - UTM: Universal Transverse Mercator in meters + Example: [293000, 5442000, 293800, 5442800] = same area in UTM zone 31N + - Pixels: Row/column indices in image array + Example: [5400, 2100, 5480, 2180] = 80 × 80 pixel subset + + Args: + image_array: Full tile image data with shape: + - (H, W) for single band (grayscale) + - (H, W, C) for multi-band (RGB, multi-spectral) + Example: (10980, 10980, 3) for 110km tile at 10m resolution + image_bounds: Geographic bounds of full tile [min_lon, min_lat, max_lon, max_lat] + in WGS84 coordinates (degrees) + Example: [6.0, 49.0, 7.0, 50.0] for Luxembourg region + target_bbox: User's requested area [min_lon, min_lat, max_lon, max_lat] + in WGS84 coordinates (degrees) + Example: [6.15, 49.11, 6.16, 49.12] for 800m × 800m area + image_crs: Coordinate reference system of the image + Default: "EPSG:4326" (WGS84 lat/lon) + Sentinel-2: Usually UTM (e.g., "EPSG:32631" for zone 31N) + Sentinel-1: Usually UTM + + Returns: + Cropped image array containing only the requested area: + - Shape: (crop_height, crop_width) or (crop_height, crop_width, C) + - Example: (80, 80, 3) for 800m × 800m at 10m resolution + Returns None if cropping fails (bbox outside image bounds, etc.) + + Example: + >>> # Full Sentinel-2 tile: 110km × 110km at 10m resolution + >>> full_image = np.random.rand(10980, 10980, 3) # 120 million pixels + >>> image_bounds = [6.0, 49.0, 7.0, 50.0] # Full tile bounds + >>> target_bbox = [6.15, 49.11, 6.16, 49.12] # 800m × 800m area + >>> + >>> cropped = crop_to_bbox(full_image, image_bounds, target_bbox) + >>> print(cropped.shape) # (80, 80, 3) - only 6,400 pixels! + >>> print(f"Size reduction: {full_image.size / cropped.size:.0f}×") # 18,750× + """ + try: + # Extract bounds for clarity + # Image bounds: the full tile's geographic extent + img_min_lon, img_min_lat, img_max_lon, img_max_lat = image_bounds + + # Target bounds: the user's requested area + tgt_min_lon, tgt_min_lat, tgt_max_lon, tgt_max_lat = target_bbox + + # Check if target bbox is within image bounds + # If target is completely outside image, we can't crop + if ( + tgt_max_lon < img_min_lon + or tgt_min_lon > img_max_lon + or tgt_max_lat < img_min_lat + or tgt_min_lat > img_max_lat + ): + print("Target bbox is outside image bounds, cannot crop") + return None + + # Get image dimensions + # Handle both 2D (H, W) and 3D (H, W, C) arrays + if image_array.ndim == 2: + height, width = image_array.shape + elif image_array.ndim == 3: + height, width, channels = image_array.shape + else: + print(f"Unsupported image array dimensions: {image_array.ndim}") + return None + + # COORDINATE CONVERSION: Geographic (lat/lon) → Pixel (row/col) + # + # Satellite images are stored as pixel arrays, but users specify areas + # in geographic coordinates (latitude/longitude). We need to convert. + # + # The conversion formula: + # pixel_x = (lon - min_lon) / (max_lon - min_lon) * width + # pixel_y = (max_lat - lat) / (max_lat - min_lat) * height + # + # Note: Y-axis is flipped! In images, row 0 is at the top (north), + # but in geographic coordinates, latitude increases upward (north). + + # Calculate pixel coordinates for target bbox corners + # X-axis (longitude → column): increases left to right + x_min_pixel = int((tgt_min_lon - img_min_lon) / (img_max_lon - img_min_lon) * width) + x_max_pixel = int((tgt_max_lon - img_min_lon) / (img_max_lon - img_min_lon) * width) + + # Y-axis (latitude → row): FLIPPED! Row 0 is north (max_lat) + # We subtract from max_lat because image rows increase downward + y_min_pixel = int((img_max_lat - tgt_max_lat) / (img_max_lat - img_min_lat) * height) + y_max_pixel = int((img_max_lat - tgt_min_lat) / (img_max_lat - img_min_lat) * height) + + # Clamp pixel coordinates to valid range [0, dimension) + # This handles cases where target bbox slightly exceeds image bounds + x_min_pixel = max(0, min(x_min_pixel, width - 1)) + x_max_pixel = max(0, min(x_max_pixel, width)) + y_min_pixel = max(0, min(y_min_pixel, height - 1)) + y_max_pixel = max(0, min(y_max_pixel, height)) + + # Ensure we have a valid crop region (at least 1 pixel) + if x_max_pixel <= x_min_pixel or y_max_pixel <= y_min_pixel: + print("Invalid crop region: target bbox too small or outside image") + return None + + # Extract the subset of pixels within target bbox + # Array slicing: [row_start:row_end, col_start:col_end] + if image_array.ndim == 2: + cropped = image_array[y_min_pixel:y_max_pixel, x_min_pixel:x_max_pixel] + else: # ndim == 3 + cropped = image_array[y_min_pixel:y_max_pixel, x_min_pixel:x_max_pixel, :] + + # Log the size reduction for user feedback + original_pixels = image_array.shape[0] * image_array.shape[1] + cropped_pixels = cropped.shape[0] * cropped.shape[1] + reduction_factor = original_pixels / cropped_pixels if cropped_pixels > 0 else 0 + + print( + f"Cropped from {image_array.shape[:2]} to {cropped.shape[:2]} " + f"({reduction_factor:.1f}× reduction)" + ) + + return cropped + + except Exception as e: + print(f"Error cropping image: {e}") + import traceback + + traceback.print_exc() + return None diff --git a/src/data/copernicus/quality.py b/src/data/copernicus/quality.py index 9a5611a..c7346d7 100644 --- a/src/data/copernicus/quality.py +++ b/src/data/copernicus/quality.py @@ -198,3 +198,230 @@ def apply_cloud_mask_to_image( raise ValueError(f"Unsupported image dimensions: {image_array.ndim}") return masked_image + + +def assess_s2_quality(zip_file_path: Path) -> dict: + """Assess overall quality of Sentinel-2 product. + + This function provides a comprehensive quality assessment of an S2 product, + including cloud coverage, data completeness, and an overall usability score. + + WHAT IT ASSESSES: + 1. Cloud coverage: Percentage of pixels obscured by clouds/shadows + 2. Data completeness: Whether all expected bands are present + 3. Overall score: Combined metric (0-1) indicating product quality + 4. Usability: Boolean recommendation on whether to use this product + + QUALITY THRESHOLDS: + - Excellent: < 10% cloud cover (score > 0.9) + - Good: 10-30% cloud cover (score 0.7-0.9) + - Fair: 30-50% cloud cover (score 0.5-0.7) + - Poor: > 50% cloud cover (score < 0.5) + + Args: + zip_file_path: Path to Sentinel-2 ZIP file (Level-2A preferred for SCL band) + + Returns: + Dictionary with quality metrics: + { + "overall_score": float, # 0-1, higher is better + "cloud_coverage": float, # Percentage (0-100) + "data_completeness": float, # Percentage (0-100) + "usable": bool, # True if quality is acceptable + "quality_level": str, # "excellent", "good", "fair", "poor" + "notes": list[str] # Any warnings or issues + } + + Example: + >>> quality = assess_s2_quality(s2_file) + >>> if quality["usable"]: + ... print(f"Good quality: {quality['overall_score']:.2f}") + ... process_image(s2_file) + >>> else: + ... print(f"Poor quality: {quality['cloud_coverage']:.1f}% clouds") + """ + notes = [] + + # Extract cloud mask + cloud_mask = extract_cloud_mask(zip_file_path) + + if cloud_mask is None: + # Could not extract cloud mask (Level-1C or error) + notes.append("Cloud mask extraction failed - may be Level-1C product") + return { + "overall_score": 0.5, # Neutral score when we can't assess + "cloud_coverage": None, + "data_completeness": 100.0, # Assume complete if file exists + "usable": True, # Still usable, just can't assess clouds + "quality_level": "unknown", + "notes": notes, + } + + # Calculate cloud coverage + total_pixels = cloud_mask.size + clear_pixels = cloud_mask.sum() + cloud_coverage = (1 - clear_pixels / total_pixels) * 100 + + # Data completeness (simplified - just check if we got a mask) + # In a full implementation, would check for all expected bands + data_completeness = 100.0 + + # Calculate overall score + # Score is primarily based on cloud coverage + # 0% clouds = 1.0 score, 100% clouds = 0.0 score + cloud_score = 1.0 - (cloud_coverage / 100.0) + + # Overall score combines cloud score with data completeness + overall_score = cloud_score * (data_completeness / 100.0) + + # Determine quality level + if cloud_coverage < 10: + quality_level = "excellent" + elif cloud_coverage < 30: + quality_level = "good" + elif cloud_coverage < 50: + quality_level = "fair" + else: + quality_level = "poor" + + # Determine usability (threshold at 50% cloud cover) + usable = cloud_coverage < 50.0 + + if cloud_coverage > 30: + notes.append(f"High cloud coverage: {cloud_coverage:.1f}%") + + return { + "overall_score": overall_score, + "cloud_coverage": cloud_coverage, + "data_completeness": data_completeness, + "usable": usable, + "quality_level": quality_level, + "notes": notes, + } + + +def assess_s1_quality(zip_file_path: Path) -> dict: + """Assess overall quality of Sentinel-1 SAR product. + + This function provides a quality assessment of an S1 SAR product. + SAR data doesn't have clouds, but can have other quality issues. + + WHAT IT ASSESSES: + 1. Data completeness: Whether all expected polarizations are present + 2. File integrity: Whether the ZIP file is valid and complete + 3. Overall score: Combined metric (0-1) indicating product quality + 4. Usability: Boolean recommendation on whether to use this product + + SAR QUALITY CONSIDERATIONS: + - SAR doesn't have cloud issues (works through clouds) + - Main issues: missing bursts, calibration problems, acquisition gaps + - For now, we do basic checks; advanced checks would require reading data + + Args: + zip_file_path: Path to Sentinel-1 ZIP file (SAFE format) + + Returns: + Dictionary with quality metrics: + { + "overall_score": float, # 0-1, higher is better + "data_completeness": float, # Percentage (0-100) + "usable": bool, # True if quality is acceptable + "quality_level": str, # "excellent", "good", "fair", "poor" + "notes": list[str] # Any warnings or issues + } + + Example: + >>> quality = assess_s1_quality(s1_file) + >>> if quality["usable"]: + ... print(f"Good quality SAR: {quality['overall_score']:.2f}") + ... process_sar(s1_file) + """ + notes = [] + + try: + # Check if ZIP file is valid + with zipfile.ZipFile(zip_file_path, "r") as zip_ref: + # Test ZIP integrity + bad_file = zip_ref.testzip() + if bad_file: + notes.append(f"Corrupted file in ZIP: {bad_file}") + return { + "overall_score": 0.0, + "data_completeness": 0.0, + "usable": False, + "quality_level": "poor", + "notes": notes, + } + + # Check for expected files + file_list = zip_ref.namelist() + + # Look for measurement files (actual SAR data) + measurement_files = [ + f for f in file_list if "/measurement/" in f and f.endswith(".tiff") + ] + + if not measurement_files: + notes.append("No measurement files found") + data_completeness = 0.0 + else: + # Expect 2 polarizations (VV and VH) for IW mode + # Some products may have only 1 polarization + expected_pols = 2 + actual_pols = len(measurement_files) + data_completeness = min(100.0, (actual_pols / expected_pols) * 100.0) + + if actual_pols < expected_pols: + notes.append( + f"Only {actual_pols} polarization(s) found (expected {expected_pols})" + ) + + # Check for manifest file + manifest_files = [f for f in file_list if "manifest.safe" in f.lower()] + if not manifest_files: + notes.append("Manifest file missing") + data_completeness *= 0.9 # Reduce score + + # Calculate overall score + # For SAR, score is primarily based on data completeness + overall_score = data_completeness / 100.0 + + # Determine quality level + if data_completeness >= 95: + quality_level = "excellent" + elif data_completeness >= 80: + quality_level = "good" + elif data_completeness >= 60: + quality_level = "fair" + else: + quality_level = "poor" + + # Determine usability (threshold at 60% completeness) + usable = data_completeness >= 60.0 + + return { + "overall_score": overall_score, + "data_completeness": data_completeness, + "usable": usable, + "quality_level": quality_level, + "notes": notes, + } + + except zipfile.BadZipFile: + notes.append("Invalid or corrupted ZIP file") + return { + "overall_score": 0.0, + "data_completeness": 0.0, + "usable": False, + "quality_level": "poor", + "notes": notes, + } + except Exception as e: + notes.append(f"Error assessing quality: {str(e)}") + return { + "overall_score": 0.0, + "data_completeness": 0.0, + "usable": False, + "quality_level": "poor", + "notes": notes, + } diff --git a/src/data/copernicus/s1.py b/src/data/copernicus/s1.py index 8d66b1a..d3a8a15 100644 --- a/src/data/copernicus/s1.py +++ b/src/data/copernicus/s1.py @@ -35,40 +35,153 @@ def fetch_s1_products( product_type: str, polarization: str, orbit_direction: str, + acquisition_mode: str = "IW", + download_data: bool = True, + max_products: int = 3, ) -> List[Path]: """Fetch Sentinel-1 products for given parameters. This is the main entry point for Sentinel-1 SAR data fetching. It handles the complete workflow: 1. Check if results are already cached 2. If not cached, search the Copernicus catalog for matching SAR products - 3. Create metadata files for found products (actual download to be implemented later) + 3. Download actual SAR imagery or create metadata files 4. Cache the results for future requests Args: client: CopernicusClient instance providing authentication and caching infrastructure bbox: [min_lon, min_lat, max_lon, max_lat] in WGS84 coordinate system + Example: [6.15, 49.11, 6.16, 49.12] for 800m x 800m area in Luxembourg start_date: Start date in YYYY-MM-DD format + Example: "2024-01-01" end_date: End date in YYYY-MM-DD format + Example: "2024-01-31" product_type: SAR product type: - - "GRD": Ground Range Detected (most common, preprocessed) - - "SLC": Single Look Complex (raw data, requires more processing) - - "OCN": Ocean products (specialized for ocean analysis) + - "GRD": Ground Range Detected (most common, preprocessed and geocoded) + Best for most applications, ready to use + - "SLC": Single Look Complex (raw data in slant range geometry) + Requires more processing, used for interferometry + - "OCN": Ocean products (specialized for ocean wind/wave analysis) polarization: Radar polarization modes (e.g., "VV,VH"): - - "VV": Vertical transmit, Vertical receive - - "VH": Vertical transmit, Horizontal receive - - "HH": Horizontal transmit, Horizontal receive - - "HV": Horizontal transmit, Vertical receive + - "VV": Vertical transmit, Vertical receive (good for water, urban) + - "VH": Vertical transmit, Horizontal receive (good for vegetation) + - "HH": Horizontal transmit, Horizontal receive (less common) + - "HV": Horizontal transmit, Vertical receive (less common) + Most land applications use "VV,VH" (dual polarization) orbit_direction: Satellite orbit direction: - - "ASCENDING": Moving from south to north - - "DESCENDING": Moving from north to south + - "ASCENDING": Moving from south to north (evening pass) + - "DESCENDING": Moving from north to south (morning pass) + Different directions show different aspects of terrain + acquisition_mode: SAR acquisition mode (default: "IW") + + WHAT IS ACQUISITION MODE: + Sentinel-1 SAR can operate in different imaging modes, + like a camera with different lenses. Each mode trades + off between coverage area and resolution. + + AVAILABLE MODES: + - "IW" (Interferometric Wide Swath): DEFAULT + Coverage: 250km wide, Resolution: 10m + Use: General land monitoring (95% of cases) + Best for: Agriculture, forests, urban areas, most ML applications + + - "EW" (Extra Wide Swath): + Coverage: 400km wide, Resolution: 40m + Use: Ocean monitoring, polar regions, wide area surveillance + Best for: Maritime surveillance, ice sheets, large-scale monitoring + + - "SM" (Strip Map): + Coverage: 80km wide, Resolution: 5m + Use: Emergency response, detailed monitoring + Best for: Disasters, high-detail urban mapping, infrastructure + + - "WV" (Wave Mode): + Coverage: 20km samples, Resolution: 5m + Use: Ocean wave studies (very specialized) + Best for: Ocean wave height/direction analysis + + WHAT CHANGES WITH MODE: + ✅ Resolution (how detailed the image is) + IW=10m, EW=40m, SM=5m, WV=5m + ✅ Coverage area (how wide the swath is) + IW=250km, EW=400km, SM=80km, WV=20km samples + ✅ Image size (number of pixels) + Higher resolution = more pixels for same area + + WHAT DOESN'T CHANGE: + ❌ Polarizations (always VV, VH or HH, HV) + ❌ Data format (always 2-channel array) + ❌ Visualization (same grayscale SAR display) + ❌ Processing code (same functions work for all modes) + ❌ Backscatter values (same dB range -30 to 0) + + VISUAL COMPARISON: + Satellite flying → + + EW Mode: ████████████████████████████████ (400km, lower res) + IW Mode: ████████████████████ (250km, good res) ← DEFAULT + SM Mode: ██████████ (80km, high res) + WV Mode: ██ ██ ██ ██ (samples only) + + FOR GALILEO ML: + - Use IW mode (default) for consistency across your dataset + - Don't mix modes in the same training set (different resolutions) + - IW provides the best balance of coverage and resolution + - Most Sentinel-1 data available is IW mode (95%+ of acquisitions) + + WHEN TO USE EACH MODE: + - IW: Default choice, works for 95% of use cases + Land monitoring, agriculture, forestry, urban areas + - EW: When you need very wide coverage and resolution isn't critical + Ocean monitoring, polar ice, maritime surveillance + - SM: When you need maximum detail in a smaller area + Emergency response, disaster mapping, detailed infrastructure + - WV: Only for specialized ocean wave analysis + Rarely used for general remote sensing + + Example: + >>> # Default (IW) - works for 95% of cases + >>> s1_files = client.fetch_s1(bbox, start_date, end_date) + >>> + >>> # Ocean monitoring - use EW for wide coverage + >>> s1_files = client.fetch_s1(bbox, start_date, end_date, + ... acquisition_mode="EW") + >>> + >>> # Disaster response - use SM for high detail + >>> s1_files = client.fetch_s1(bbox, start_date, end_date, + ... acquisition_mode="SM") + >>> + >>> # Ocean wave analysis - use WV (specialized) + >>> s1_files = client.fetch_s1(bbox, start_date, end_date, + ... acquisition_mode="WV") + download_data: If True, download actual SAR imagery (1-2GB per product) + If False, only create metadata files (few KB per product) + Default: True + max_products: Maximum number of products to download/process + Default: 3 (prevents accidental huge downloads) + Set to None for unlimited (use with caution!) + + WHY LIMIT: + - Each S1 product is 1-2GB + - 10 products = 10-20GB disk space + - Downloads can take hours + + Example: For 1 year of data over small area, + you might get 70+ products (one every 5 days). + Default limit prevents overwhelming your system. Returns: - List of Path objects pointing to metadata files for discovered products. - Each file contains product information including download URLs and metadata. - - Note: - Currently creates metadata files instead of downloading full products. - This allows the system to work while full download functionality is developed. + List of Path objects pointing to downloaded ZIP files or metadata JSON files. + Each ZIP contains SAR backscatter data in GeoTIFF format. + + Example: + >>> client = CopernicusClient() + >>> files = client.fetch_s1( + ... bbox=[6.15, 49.11, 6.16, 49.12], + ... start_date="2024-01-01", + ... end_date="2024-01-31", + ... download_data=True + ... ) + >>> print(f"Downloaded {len(files)} SAR products") """ # Build a unique cache key based on all parameters that affect the result # SAR products have different parameters than optical imagery @@ -80,6 +193,8 @@ def fetch_s1_products( product_type=product_type, polarization=polarization, orbit_direction=orbit_direction, + acquisition_mode=acquisition_mode, # Include acquisition mode in cache key + download_data=download_data, # Include download mode in cache key ) # Cache file stores both the search results and file paths @@ -102,7 +217,14 @@ def fetch_s1_products( # Search the Copernicus catalog for SAR products matching our criteria products: List[Dict[str, Any]] = _search_s1_products( - client, bbox, start_date, end_date, product_type, polarization, orbit_direction + client, + bbox, + start_date, + end_date, + product_type, + polarization, + orbit_direction, + acquisition_mode, ) # Handle case where no products were found @@ -112,14 +234,39 @@ def fetch_s1_products( print(f"Found {len(products)} S1 products") - # Create metadata files for the found products - # We limit to first 3 products for testing to avoid overwhelming the system + # Apply max_products limit if specified + # This prevents accidental huge downloads (each product is 1-2GB) + if max_products is not None and len(products) > max_products: + print(f"⚠️ Limiting to first {max_products} products (found {len(products)} total)") + print(" To download more, use max_products parameter:") + print(f" client.fetch_s1(..., max_products={len(products)})") + products = products[:max_products] + + # Process products (download or create metadata) downloaded_paths: List[Path] = [] - for i, product in enumerate(products[:3]): # Limit to first 3 for testing - # Create a metadata file instead of downloading the full product (multi-GB files) - metadata_file: Optional[Path] = _create_product_metadata(client, product, i) - if metadata_file: - downloaded_paths.append(metadata_file) + + if download_data: + print("\n📥 DOWNLOADING SAR IMAGERY") + print("=" * 40) + + for i, product in enumerate(products, 1): + print(f"\n🛰️ Downloading product {i}/{len(products)}") + + downloaded_file = _download_s1_product(client, product, i - 1) + if downloaded_file: + downloaded_paths.append(downloaded_file) + print(f"✅ Downloaded: {downloaded_file.name}") + else: + print(f"❌ Failed to download product {i}") + else: + print("\n📋 CREATING METADATA FILES") + print("=" * 35) + + # Create metadata files for the found products + for i, product in enumerate(products): + metadata_file: Optional[Path] = _create_product_metadata(client, product, i) + if metadata_file: + downloaded_paths.append(metadata_file) # Cache the results for future requests # Store both the original search parameters and the resulting file paths @@ -131,6 +278,8 @@ def fetch_s1_products( "product_type": product_type, "polarization": polarization, "orbit_direction": orbit_direction, + "acquisition_mode": acquisition_mode, + "download_data": download_data, }, "products": products, # Full product metadata from API "file_paths": [str(p) for p in downloaded_paths], # Paths to created files @@ -140,7 +289,8 @@ def fetch_s1_products( with open(cache_file, "w") as f: json.dump(cache_data, f, indent=2) - print(f"Created metadata for {len(downloaded_paths)} S1 products, cached to {cache_file}") + action = "Downloaded" if download_data else "Created metadata for" + print(f"\n✅ {action} {len(downloaded_paths)} S1 products, cached to {cache_file}") return downloaded_paths @@ -152,6 +302,7 @@ def _search_s1_products( product_type: str, polarization: str, orbit_direction: str, + acquisition_mode: str, ) -> List[Dict[str, Any]]: """Search for Sentinel-1 products using the Copernicus OData API. @@ -167,6 +318,7 @@ def _search_s1_products( product_type: SAR product type (GRD, SLC, OCN) polarization: Radar polarization modes orbit_direction: Satellite orbit direction + acquisition_mode: SAR acquisition mode (IW, EW, SM, WV) Returns: List of product dictionaries containing metadata for each found SAR product. @@ -199,8 +351,19 @@ def _search_s1_products( filter_parts.append("contains(Name,'OCN')") # Add orbit direction filter - # This affects the viewing geometry and shadow patterns - filter_parts.append(f"contains(Name,'{orbit_direction}')") + # Note: Orbit direction is NOT in the product name, it's in the Attributes + # We'll filter this after getting results, not in the OData query + # filter_parts.append(f"contains(Name,'{orbit_direction}')") # This doesn't work! + + # Add acquisition mode filter + # S1 product names contain the mode: S1A_IW_GRDH_... or S1A_EW_GRDH_... + # This filters products by their imaging mode (IW, EW, SM, WV) + # Example product name: S1A_IW_GRDH_1SDV_20220101T123456_20220101T123521_041234_04E567_1234 + # ^^ + # acquisition mode appears here + # Note: Some products have the mode without underscore separator + if acquisition_mode: + filter_parts.append(f"contains(Name,'{acquisition_mode}')") # Combine all filter conditions with AND logic filter_query: str = " and ".join(filter_parts) @@ -210,17 +373,33 @@ def _search_s1_products( "$filter": filter_query, # The filter conditions we built above "$orderby": "ContentDate/Start asc", # Sort by acquisition date (oldest first) "$top": 100, # Limit results to 100 products (reduced for testing) + "$expand": "Attributes", # CRITICAL: Expand Attributes to get polarization, orbit, etc. } # Construct the full API URL url: str = f"{client.BASE_URL}/Products" print(f"Searching S1 products with filter: {filter_query}") + print(f"Query params: {params}") # Make the authenticated API request response = client._make_request(url, params=params) data: Dict[str, Any] = response.json() + # Debug: print response + print(f"API Response status: {response.status_code}") + print(f"API Response URL: {response.url}") # Check if $expand is in URL + print(f"API Response keys: {list(data.keys())}") + if "value" in data: + print(f"Number of products in response: {len(data['value'])}") + if len(data["value"]) > 0: + first_product = data["value"][0] + print(f"First product has Attributes: {'Attributes' in first_product}") + if "Attributes" in first_product: + print(f"Number of Attributes: {len(first_product['Attributes'])}") + if "error" in data: + print(f"API Error: {data['error']}") + # Extract the list of products from the API response products: List[Dict[str, Any]] = data.get("value", []) @@ -233,6 +412,13 @@ def _search_s1_products( # Extract available polarizations from product metadata product_pols: Set[str] = _extract_polarization(product) + # Check orbit direction (if specified) + # Orbit direction is in Attributes, not in the product name + if orbit_direction: + product_orbit = _extract_orbit_direction(product) + if product_orbit and product_orbit.upper() != orbit_direction.upper(): + continue # Skip products with wrong orbit direction + # Include product if: # 1. No specific polarizations requested (empty set), OR # 2. Product has all requested polarizations @@ -242,6 +428,31 @@ def _search_s1_products( return filtered_products +def _extract_orbit_direction(product: Dict[str, Any]) -> Optional[str]: + """Extract orbit direction from SAR product metadata. + + Args: + product: Product dictionary from the API response + + Returns: + Orbit direction string ("ASCENDING" or "DESCENDING"), or None if not found + """ + # Check Attributes for orbitDirection + attributes: List[Dict[str, Any]] = product.get("Attributes", []) + for attr in attributes: + if attr.get("Name") == "orbitDirection": + return attr.get("Value", "").upper() + + # Fallback: check if it's in the product name (some products have it) + name = product.get("Name", "") + if "ASCENDING" in name.upper(): + return "ASCENDING" + if "DESCENDING" in name.upper(): + return "DESCENDING" + + return None + + def _extract_polarization(product: Dict[str, Any]) -> Set[str]: """Extract polarization information from SAR product metadata. @@ -257,10 +468,12 @@ def _extract_polarization(product: Dict[str, Any]) -> Set[str]: # First, try to extract from product Attributes (most reliable) attributes: List[Dict[str, Any]] = product.get("Attributes", []) for attr in attributes: - if attr.get("Name") == "polarisation": + attr_name = attr.get("Name", "") + # Check for various polarization attribute names + if attr_name in ["polarisation", "polarisationChannels", "polarizationChannels"]: pol_value: str = attr.get("Value", "") - # Parse polarization string - can be "VV VH" or "VV,VH" format - pols_list: List[str] = pol_value.replace(",", " ").split() + # Parse polarization string - can be "VV VH", "VV,VH", or "VV&VH" format + pols_list: List[str] = pol_value.replace(",", " ").replace("&", " ").split() return set(pols_list) # Fallback: try to extract from product name @@ -341,3 +554,103 @@ def _create_product_metadata( except Exception as e: print(f"Failed to create metadata {filename}: {e}") return None + + +def _download_s1_product( + client: "CopernicusClient", + product: Dict[str, Any], + index: int, +) -> Optional[Path]: + """Download actual Sentinel-1 SAR satellite imagery. + + This function downloads the complete SAR product from Copernicus Data Space Ecosystem. + Sentinel-1 products are typically 1-2GB in size and contain radar backscatter data. + + WHAT IS SENTINEL-1: + Sentinel-1 is a radar (SAR - Synthetic Aperture Radar) satellite that: + - Works day and night (doesn't need sunlight like optical satellites) + - Penetrates clouds (radar waves pass through clouds and rain) + - Measures surface roughness (smooth surfaces = dark, rough surfaces = bright) + - Provides all-weather monitoring capability + + WHAT'S IN A SENTINEL-1 PRODUCT: + - Radar backscatter images in different polarizations (VV, VH) + - Calibration data for converting to physical units (sigma0, gamma0) + - Metadata about acquisition geometry and processing + - Typically 1-2GB per product (larger than Sentinel-2) + + HOW S1 DIFFERS FROM S2: + - S1 = Radar (active sensor, sends and receives microwaves) + - S2 = Optical (passive sensor, measures reflected sunlight) + - S1 has polarizations (VV, VH) not spectral bands (B01-B12) + - S1 file structure uses .tiff files, not .jp2 files + - S1 products are larger (1-2GB vs 500MB-1GB for S2) + + Args: + client: CopernicusClient for authentication and cache directory + product: Product dictionary from the API search results containing: + - Id: Unique product identifier for download + - Name: Product name (e.g., S1A_IW_GRDH_1SDV_20220101T123456...) + - ContentLength: File size in bytes + index: Product index (used as fallback for naming if product info missing) + + Returns: + Path to the downloaded ZIP file, or None if download failed + + Example: + >>> product = {"Id": "abc123", "Name": "S1A_IW_GRDH_...", "ContentLength": 1500000000} + >>> path = _download_s1_product(client, product, 0) + >>> print(path) # data/cache/copernicus/s1/S1A_IW_GRDH_....zip + """ + from .download_utils import download_with_retry + + # Extract product identifiers from API response + # These uniquely identify the SAR product we want to download + product_id: str = product.get("Id", f"unknown_{index}") + product_name: str = product.get("Name", f"S1_product_{index}") + content_length: int = product.get("ContentLength", 0) # File size in bytes + + # Create safe filename for filesystem storage + # Remove characters that are invalid on Windows/macOS/Linux + safe_name: str = sanitize_filename(product_name) + filename: str = f"{safe_name}.zip" # S1 products are distributed as ZIP files + + # Determine file path within cache directory + # Organize by satellite type: s1/ for Sentinel-1, s2/ for Sentinel-2 + file_path: Path = client.cache_dir / "s1" / filename + file_path.parent.mkdir(parents=True, exist_ok=True) # Create s1/ directory if needed + + # Check if file already exists and has content + # This avoids re-downloading multi-GB files unnecessarily + if file_path.exists() and file_path.stat().st_size >= content_length: + print(f"✅ Already downloaded: {filename}") + return file_path + + # Construct download URL using the Copernicus download endpoint + # The /$value suffix tells the API to return the actual file content + # instead of just metadata about the product + download_url = ( + f"https://download.dataspace.copernicus.eu/odata/v1/Products({product_id})/$value" + ) + + print(f"📥 Downloading: {product_name}") + print(f" Size: {content_length / (1024*1024):.1f} MB") + print(" Type: Sentinel-1 SAR (Synthetic Aperture Radar)") + print(f" URL: {download_url}") + + # Use robust download with retry and token refresh + success = download_with_retry( + client=client, + url=download_url, + output_path=file_path, + total_size=content_length, + max_retries=3, + ) + + if success: + return file_path + else: + # Clean up failed download + if file_path.exists(): + file_path.unlink() + return None diff --git a/src/data/copernicus/s2.py b/src/data/copernicus/s2.py index e1c04d6..17fb21f 100644 --- a/src/data/copernicus/s2.py +++ b/src/data/copernicus/s2.py @@ -32,6 +32,7 @@ def fetch_s2_products( product_type: str, download_data: bool = True, interactive: bool = True, + max_products: int = 3, ) -> List[Path]: """Fetch Sentinel-2 products for given parameters. @@ -52,6 +53,18 @@ def fetch_s2_products( product_type: Product type ("S2MSI1C" for Level-1C or "S2MSI2A" for Level-2A) download_data: If True, download actual satellite imagery. If False, only metadata. interactive: If True, prompt user for download confirmation when products are found. + max_products: Maximum number of products to download/process + Default: 3 (prevents accidental huge downloads) + Set to None for unlimited (use with caution!) + + WHY LIMIT: + - Each S2 product is 500MB-1GB + - 10 products = 5-10GB disk space + - Downloads can take hours + + Example: For 1 year of data over small area, + you might get 70+ products (one every 5 days). + Default limit prevents overwhelming your system. Returns: List of Path objects pointing to downloaded imagery files or metadata files. @@ -127,26 +140,37 @@ def fetch_s2_products( print(f"Found {len(products)} S2 products") + # Apply max_products limit if specified + # This prevents accidental huge downloads (each product is 500MB-1GB) + products_to_process = products + if max_products is not None and len(products) > max_products: + print(f"⚠️ Limiting to first {max_products} products (found {len(products)} total)") + print(" To download more, use max_products parameter:") + print(f" client.fetch_s2(..., max_products={len(products)})") + products_to_process = products[:max_products] + # Interactive user confirmation if requested - if interactive and products: + if interactive and products_to_process: print("\n🛰️ DOWNLOAD CONFIRMATION") print("=" * 40) print(f"Found {len(products)} Sentinel-2 products:") - for i, product in enumerate(products[:5], 1): # Show first 5 + for i, product in enumerate(products_to_process[:5], 1): # Show first 5 name = product.get("Name", "Unknown") size_mb = product.get("ContentLength", 0) / (1024 * 1024) print(f" {i}. {name} ({size_mb:.1f} MB)") - if len(products) > 5: - print(f" ... and {len(products) - 5} more products") + if len(products_to_process) > 5: + print(f" ... and {len(products_to_process) - 5} more products") - total_size_gb = sum(p.get("ContentLength", 0) for p in products) / (1024**3) + total_size_gb = sum(p.get("ContentLength", 0) for p in products_to_process) / (1024**3) print(f"\nTotal size: {total_size_gb:.2f} GB") if download_data: print("Mode: Download actual satellite imagery") - response = input(f"\nDownload all {len(products)} products? [Y/n]: ").strip().lower() + response = ( + input(f"\nDownload {len(products_to_process)} products? [Y/n]: ").strip().lower() + ) if response and response not in ["y", "yes"]: print("Download cancelled by user") return [] @@ -160,8 +184,8 @@ def fetch_s2_products( print("\n📥 DOWNLOADING SATELLITE IMAGERY") print("=" * 45) - for i, product in enumerate(products[:3], 1): # Limit to 3 for demo - print(f"\n🛰️ Downloading product {i}/{min(3, len(products))}") + for i, product in enumerate(products_to_process, 1): + print(f"\n🛰️ Downloading product {i}/{len(products_to_process)}") downloaded_file = _download_s2_product(client, product, resolution, i - 1) if downloaded_file: @@ -174,7 +198,7 @@ def fetch_s2_products( print("=" * 35) # Create metadata files for the found products - for i, product in enumerate(products[:3]): # Limit to first 3 for testing + for i, product in enumerate(products_to_process): metadata_file: Optional[Path] = _create_product_metadata( client, product, resolution, i ) @@ -408,8 +432,7 @@ def _download_s2_product( Returns: Path to the downloaded file, or None if download failed """ - import requests - from tqdm import tqdm + from .download_utils import download_with_retry # Extract product identifiers product_id: str = product.get("Id", f"unknown_{index}") @@ -425,7 +448,7 @@ def _download_s2_product( file_path.parent.mkdir(parents=True, exist_ok=True) # Check if file already exists - if file_path.exists() and file_path.stat().st_size > 0: + if file_path.exists() and file_path.stat().st_size >= content_length: print(f"✅ Already downloaded: {filename}") return file_path @@ -438,43 +461,19 @@ def _download_s2_product( print(f" Size: {content_length / (1024*1024):.1f} MB") print(f" URL: {download_url}") - try: - # Get access token for authentication - token = client._get_access_token() - headers = { - "Authorization": f"Bearer {token}", - "User-Agent": "Galileo-Copernicus-Client/1.0", - } - - # Start download with streaming - response = requests.get(download_url, headers=headers, stream=True, timeout=300) - response.raise_for_status() - - # Get actual content length from response headers - total_size = int(response.headers.get("content-length", content_length)) - - # Download with progress bar - with open(file_path, "wb") as f: - with tqdm( - total=total_size, unit="B", unit_scale=True, desc=f"Downloading {filename[:30]}..." - ) as pbar: - for chunk in response.iter_content(chunk_size=8192): - if chunk: - f.write(chunk) - pbar.update(len(chunk)) - - print(f"✅ Download complete: {filename}") - return file_path + # Use robust download with retry and token refresh + success = download_with_retry( + client=client, + url=download_url, + output_path=file_path, + total_size=content_length, + max_retries=3, + ) - except requests.exceptions.RequestException as e: - print(f"❌ Download failed: {e}") - # Clean up partial download - if file_path.exists(): - file_path.unlink() - return None - except Exception as e: - print(f"❌ Unexpected error during download: {e}") - # Clean up partial download + if success: + return file_path + else: + # Clean up failed download if file_path.exists(): file_path.unlink() return None diff --git a/src/data/copernicus/visualization.py b/src/data/copernicus/visualization.py index 2c621be..cb38f89 100644 --- a/src/data/copernicus/visualization.py +++ b/src/data/copernicus/visualization.py @@ -1,7 +1,9 @@ """Visualization utilities for Copernicus satellite data. This module provides high-level plotting functions for displaying -satellite imagery, coverage maps, and analysis results. +satellite imagery, coverage maps, and analysis results for both: +- Sentinel-2 optical imagery (RGB, false color) +- Sentinel-1 SAR imagery (radar backscatter) """ from pathlib import Path @@ -10,7 +12,7 @@ import matplotlib.pyplot as plt import numpy as np -from .image_processing import extract_rgb_composite, get_image_statistics +from .image_processing import extract_rgb_composite, extract_sar_composite, get_image_statistics def create_coverage_map( @@ -365,3 +367,207 @@ def create_band_analysis_plot( plt.tight_layout() return fig + + +def display_sar_image( + zip_file_path: Path, + target_bbox: Optional[List[float]] = None, + ax: Optional[plt.Axes] = None, + polarization: str = "VV", + title: Optional[str] = None, + cmap: str = "gray", +) -> Optional[plt.Axes]: + """Display Sentinel-1 SAR image with optional target area overlay. + + WHAT YOU'LL SEE IN A SAR IMAGE: + SAR images show surface roughness and structure, not color like optical images: + - BRIGHT (white): Rough surfaces, buildings, ships, vegetation + - DARK (black): Smooth surfaces, calm water, roads, bare soil + - MEDIUM (gray): Mixed surfaces, agricultural fields, forests + + INTERPRETING SAR BACKSCATTER: + - Water bodies: Very dark (smooth surface reflects radar away) + - Urban areas: Very bright (buildings create strong corner reflections) + - Forests: Medium-bright (volume scattering from tree canopy) + - Agricultural fields: Varies by crop type, growth stage, and moisture + - Mountains: Bright on radar-facing slopes, dark on opposite slopes + + SPECKLE NOISE: + SAR images have a grainy "salt and pepper" appearance called speckle. + This is inherent to radar imaging (interference of radar waves) and not + a sensor defect. Speckle filtering can reduce this but may blur features. + + Args: + zip_file_path: Path to Sentinel-1 ZIP file (GRD product) + Example: S1A_IW_GRDH_1SDV_20220101T123456_..._.zip + target_bbox: Optional [min_lon, min_lat, max_lon, max_lat] to overlay + If provided, draws red box showing area of interest + ax: Matplotlib axes (creates new figure if None) + polarization: Which polarization to display ('VV' or 'VH') + VV: Better for water, urban, soil moisture + VH: Better for vegetation, crop monitoring + title: Plot title (auto-generated if None) + cmap: Matplotlib colormap for display + 'gray': Standard grayscale (most common for SAR) + 'viridis': Color scale (can help see subtle variations) + 'RdYlBu_r': Diverging colormap + + Returns: + Matplotlib axes object, or None if processing failed + + Example: + >>> # Display VV polarization + >>> display_sar_image(s1_file, target_bbox, polarization='VV') + >>> + >>> # Display VH polarization with color scale + >>> display_sar_image(s1_file, target_bbox, polarization='VH', cmap='viridis') + """ + # Extract SAR composite with both polarizations + # We extract both but only display the requested one + sar_data = extract_sar_composite(zip_file_path, polarizations=["VV", "VH"]) + if sar_data is None: + print(f"Failed to extract SAR data from {zip_file_path.name}") + return None + + if ax is None: + fig, ax = plt.subplots(1, 1, figsize=(10, 8)) + + # Get the requested polarization + # sar_array shape: (H, W, num_polarizations) + polarizations = sar_data["polarizations"] + if polarization not in polarizations: + print(f"Polarization {polarization} not found. Available: {polarizations}") + # Fall back to first available polarization + polarization = polarizations[0] + print(f"Using {polarization} instead") + + pol_idx = polarizations.index(polarization) + sar_image = sar_data["sar_array"][:, :, pol_idx] + + # Display the SAR image + # Bounds define the geographic extent of the image + bounds = sar_data["bounds_wgs84"] + extent = (bounds[0], bounds[2], bounds[1], bounds[3]) # (min_lon, max_lon, min_lat, max_lat) + + # Display with appropriate colormap + # vmin/vmax set the display range for dB values + im = ax.imshow( + sar_image, + extent=extent, + aspect="auto", + cmap=cmap, + vmin=-25, # Typical minimum for visualization (very dark) + vmax=0, # Typical maximum for visualization (bright) + ) + + # Add colorbar to show backscatter scale + plt.colorbar(im, ax=ax, label=f"{polarization} Backscatter (dB)") + + # Add target area overlay if provided + if target_bbox is not None: + bbox_lons = [ + target_bbox[0], + target_bbox[2], + target_bbox[2], + target_bbox[0], + target_bbox[0], + ] + bbox_lats = [ + target_bbox[1], + target_bbox[1], + target_bbox[3], + target_bbox[3], + target_bbox[1], + ] + ax.plot(bbox_lons, bbox_lats, "red", linewidth=3, alpha=0.8, label="Target Area") + + # Zoom to target area with padding + padding = 0.02 + ax.set_xlim(target_bbox[0] - padding, target_bbox[2] + padding) + ax.set_ylim(target_bbox[1] - padding, target_bbox[3] + padding) + + # Customize plot + ax.set_xlabel("Longitude (°E)", fontsize=12) + ax.set_ylabel("Latitude (°N)", fontsize=12) + + if title is None: + # Create informative title with key metadata + resolution = sar_data["metadata"].get("resolution_m", (None, None)) + res_str = f"{resolution[0]:.0f}m" if resolution[0] else "unknown" + title = ( + f"Sentinel-1 SAR - {polarization} Polarization\n" + f"{zip_file_path.name[:50]}... (Resolution: {res_str})" + ) + ax.set_title(title, fontsize=11, fontweight="bold") + + ax.grid(True, alpha=0.3, color="yellow") + if target_bbox is not None: + ax.legend() + + # Add interpretation guide as text box + interpretation = ( + "SAR Interpretation:\n" + "• Bright = Rough surfaces\n" + "• Dark = Smooth surfaces\n" + "• Water = Very dark\n" + "• Urban = Very bright" + ) + ax.text( + 0.02, + 0.98, + interpretation, + transform=ax.transAxes, + fontsize=9, + verticalalignment="top", + bbox=dict(boxstyle="round,pad=0.5", facecolor="lightyellow", alpha=0.8), + ) + + return ax + + +def create_sar_comparison_plot( + zip_file_path: Path, + target_bbox: Optional[List[float]] = None, + figsize: Tuple[int, int] = (16, 6), +) -> plt.Figure: + """Create side-by-side comparison of VV and VH polarizations. + + This visualization helps understand how different polarizations reveal + different surface properties: + - VV: Emphasizes surface roughness, good for water/urban detection + - VH: Emphasizes volume scattering, good for vegetation monitoring + + Args: + zip_file_path: Path to Sentinel-1 ZIP file + target_bbox: Optional bounding box to overlay + figsize: Figure size (width, height) + + Returns: + Matplotlib figure object with two subplots + + Example: + >>> fig = create_sar_comparison_plot(s1_file, target_bbox) + >>> plt.show() + """ + fig, axes = plt.subplots(1, 2, figsize=figsize) + + # Display VV polarization + display_sar_image( + zip_file_path, + target_bbox, + ax=axes[0], + polarization="VV", + title="VV Polarization\n(Surface Scattering)", + ) + + # Display VH polarization + display_sar_image( + zip_file_path, + target_bbox, + ax=axes[1], + polarization="VH", + title="VH Polarization\n(Volume Scattering)", + ) + + plt.tight_layout() + return fig diff --git a/tests/test_copernicus_integration.py b/tests/test_copernicus_integration.py new file mode 100644 index 0000000..800882f --- /dev/null +++ b/tests/test_copernicus_integration.py @@ -0,0 +1,574 @@ +"""Integration tests for Copernicus data client using real downloaded data. + +OVERVIEW: +These tests verify the complete Copernicus data pipeline using actual satellite products: +- Sentinel-2 (optical): RGB composites, spectral indices (NDVI, NDWI) +- Sentinel-1 (SAR): Backscatter extraction, polarization handling + +The tests use real downloaded products (not mocked data) to ensure the client works +with actual Copernicus Data Space Ecosystem files. + +PREREQUISITES: +1. Download test data first: + uv run python scripts/download_test_data.py + +2. This creates: + - data/cache/copernicus/s1/*.zip (Sentinel-1 SAR products) + - data/cache/copernicus/s2/*.zip (Sentinel-2 optical products) + - data/test_fixtures/test_data_metadata.json (metadata) + +USAGE: + # Run all tests + uv run python -m pytest tests/test_copernicus_integration.py -v + + # Run specific test + uv run python -m pytest tests/test_copernicus_integration.py::TestCopernicusIntegration::test_s2_rgb_extraction -v + + # Run with output + uv run python -m pytest tests/test_copernicus_integration.py -v -s + +TEST ORGANIZATION: +- Sentinel-2 Tests: Optical imagery processing (RGB, indices, statistics) +- Sentinel-1 Tests: SAR imagery processing (polarizations, backscatter) +- Cross-sensor Tests: Metadata and data availability checks +""" + +import json +import unittest +from pathlib import Path + +import numpy as np + +from src.data.copernicus.image_processing import ( + extract_rgb_composite, + extract_sar_composite, + get_image_statistics, +) +from src.data.copernicus.indices import calculate_ndvi, calculate_ndwi +from src.data.copernicus.quality import assess_s1_quality, assess_s2_quality + + +class TestCopernicusIntegration(unittest.TestCase): + """Integration tests using real downloaded Copernicus data. + + These tests verify that the Copernicus client can: + 1. Read actual satellite products from Copernicus Data Space + 2. Extract bands and create composites + 3. Calculate spectral indices + 4. Handle both optical (S2) and SAR (S1) data + + All tests use real downloaded data, not mocked responses. + """ + + @classmethod + def setUpClass(cls): + """Load test data metadata and verify files exist. + + This runs once before all tests. It: + 1. Checks if test data has been downloaded + 2. Loads metadata about downloaded products + 3. Locates S1 and S2 files in the cache directory + + If test data is missing, all tests will be skipped with a helpful message. + """ + cls.cache_dir = Path("data/cache/copernicus") + cls.metadata_file = Path("data/test_fixtures/test_data_metadata.json") + + if not cls.metadata_file.exists(): + raise unittest.SkipTest( + "Test data not found. Run: uv run python scripts/download_test_data.py" + ) + + with open(cls.metadata_file) as f: + cls.metadata = json.load(f) + + # Find S2 and S1 files from metadata + # We take the first available product of each type + cls.s2_file = None + cls.s1_file = None + + for product_key, product_info in cls.metadata["products"].items(): + if product_key.startswith("s2_") and cls.s2_file is None: + file_path = cls.cache_dir / "s2" / product_info["file"] + if file_path.exists(): + cls.s2_file = file_path + + for product_key, product_info in cls.metadata["products"].items(): + if product_key.startswith("s1_") and cls.s1_file is None: + file_path = cls.cache_dir / "s1" / product_info["file"] + if file_path.exists(): + cls.s1_file = file_path + + # ======================================================================== + # Sentinel-2 Tests (Optical Imagery) + # ======================================================================== + # These tests verify optical imagery processing from Sentinel-2. + # S2 provides 13 spectral bands from visible to SWIR wavelengths. + + def test_s2_rgb_extraction(self): + """Test RGB composite extraction from S2 product. + + WHAT THIS TESTS: + - Reading S2 ZIP files + - Extracting B04 (Red), B03 (Green), B02 (Blue) bands + - Creating normalized RGB composite (0-1 range) + - Extracting geospatial metadata (bounds, CRS) + + WHY IT MATTERS: + RGB composites are the most common visualization for optical imagery. + This verifies the basic ability to read and process S2 data. + """ + if self.s2_file is None: + self.skipTest("S2 test data not available") + + rgb_data = extract_rgb_composite(self.s2_file) + + # Verify structure + self.assertIsNotNone(rgb_data, "RGB extraction failed") + self.assertIn("rgb_array", rgb_data) + self.assertIn("bounds_wgs84", rgb_data) + self.assertIn("metadata", rgb_data) + + # Check array shape and type + rgb_array = rgb_data["rgb_array"] + self.assertEqual(rgb_array.ndim, 3, "RGB should be 3D array [H, W, C]") + self.assertEqual(rgb_array.shape[2], 3, "RGB should have 3 channels") + self.assertTrue(np.issubdtype(rgb_array.dtype, np.floating), "Should be float type") + + # Check value range (should be normalized 0-1) + self.assertGreaterEqual(rgb_array.min(), 0.0, "RGB values should be >= 0") + self.assertLessEqual(rgb_array.max(), 1.0, "RGB values should be <= 1") + + print(f"✓ S2 RGB extraction: {rgb_array.shape}") + + def test_s2_false_color(self): + """Test false color composite (NIR-R-G) extraction. + + WHAT THIS TESTS: + - Custom band selection (not just RGB) + - NIR band (B08) extraction + - Composite creation with arbitrary bands + + WHY IT MATTERS: + False color composites (NIR-Red-Green) highlight vegetation in red, + making it easier to identify healthy vegetation. This tests the ability + to create custom band combinations beyond standard RGB. + """ + if self.s2_file is None: + self.skipTest("S2 test data not available") + + false_color = extract_rgb_composite(self.s2_file, bands=["B08", "B04", "B03"]) + + self.assertIsNotNone(false_color, "False color extraction failed") + self.assertEqual(false_color["rgb_array"].shape[2], 3, "Should have 3 channels") + + print(f"✓ S2 false color: {false_color['rgb_array'].shape}") + + def test_s2_ndvi_calculation(self): + """Test NDVI calculation from S2 bands. + + WHAT THIS TESTS: + - Extracting NIR (B08) and Red (B04) bands + - Computing NDVI = (NIR - Red) / (NIR + Red) + - Handling division by zero + - Validating NDVI range [-1, 1] + + WHY IT MATTERS: + NDVI (Normalized Difference Vegetation Index) is the most widely used + vegetation index in remote sensing. It indicates vegetation health and + density. This is a critical capability for agricultural monitoring. + + EXPECTED VALUES: + - Water/clouds: < 0 + - Bare soil: 0 - 0.2 + - Sparse vegetation: 0.2 - 0.5 + - Dense vegetation: 0.5 - 1.0 + """ + if self.s2_file is None: + self.skipTest("S2 test data not available") + + ndvi_data = calculate_ndvi(self.s2_file) + + # Verify structure + self.assertIsNotNone(ndvi_data, "NDVI calculation failed") + self.assertIn("ndvi", ndvi_data) + self.assertIn("metadata", ndvi_data) + + ndvi = ndvi_data["ndvi"] + self.assertEqual(ndvi.ndim, 2, "NDVI should be 2D array [H, W]") + + # NDVI range should be -1 to 1 (mathematical constraint) + self.assertGreaterEqual(ndvi.min(), -1.0, "NDVI minimum should be >= -1") + self.assertLessEqual(ndvi.max(), 1.0, "NDVI maximum should be <= 1") + + # Check for reasonable vegetation values + # Note: NDVI values can be very low in winter, urban areas, or water bodies + positive_pixels = np.sum(ndvi > 0.0) + self.assertGreater(positive_pixels, 0, "Should have some positive NDVI pixels") + + print( + f"✓ S2 NDVI: range [{ndvi.min():.3f}, {ndvi.max():.3f}], " + f"{positive_pixels} positive pixels" + ) + + def test_s2_ndwi_calculation(self): + """Test NDWI calculation from S2 bands. + + WHAT THIS TESTS: + - Extracting Green (B03) and NIR (B08) bands + - Computing NDWI = (Green - NIR) / (Green + NIR) + - Validating NDWI range [-1, 1] + + WHY IT MATTERS: + NDWI (Normalized Difference Water Index) highlights water bodies and + measures water content in vegetation. Useful for: + - Detecting water bodies (rivers, lakes, floods) + - Monitoring irrigation + - Assessing vegetation water stress + + EXPECTED VALUES: + - Water bodies: > 0.3 + - Wet vegetation: 0 - 0.3 + - Dry vegetation/soil: < 0 + """ + if self.s2_file is None: + self.skipTest("S2 test data not available") + + ndwi_data = calculate_ndwi(self.s2_file) + + # Verify structure + self.assertIsNotNone(ndwi_data, "NDWI calculation failed") + self.assertIn("ndwi", ndwi_data) + + ndwi = ndwi_data["ndwi"] + self.assertEqual(ndwi.ndim, 2, "NDWI should be 2D array [H, W]") + + # NDWI range should be -1 to 1 (mathematical constraint) + self.assertGreaterEqual(ndwi.min(), -1.0, "NDWI minimum should be >= -1") + self.assertLessEqual(ndwi.max(), 1.0, "NDWI maximum should be <= 1") + + print(f"✓ S2 NDWI: range [{ndwi.min():.3f}, {ndwi.max():.3f}]") + + def test_s2_statistics(self): + """Test image statistics calculation. + + WHAT THIS TESTS: + - Computing basic statistics (min, max, mean, std) + - Calculating coverage area from geospatial bounds + - Extracting metadata (shape, dtype, bounds) + + WHY IT MATTERS: + Statistics help assess data quality and understand the scene: + - Coverage area: verify expected geographic extent + - Value ranges: detect saturation or missing data + - Mean/std: understand scene brightness and contrast + """ + if self.s2_file is None: + self.skipTest("S2 test data not available") + + rgb_data = extract_rgb_composite(self.s2_file) + stats = get_image_statistics(rgb_data) + + # Verify expected fields + self.assertIn("shape", stats) + self.assertIn("coverage_area_km2", stats) + + # Verify reasonable values + self.assertGreater(stats["coverage_area_km2"], 0, "Coverage area should be positive") + + print(f"✓ S2 stats: {stats['shape']}, {stats['coverage_area_km2']:.1f} km²") + + def test_s2_quality_assessment(self): + """Test S2 quality assessment (cloud cover, data completeness). + + WHAT THIS TESTS: + - Cloud mask extraction from SCL band + - Cloud coverage percentage calculation + - Data completeness check + - Overall quality score computation + + WHY IT MATTERS: + Quality assessment helps filter out unusable images before processing. + High cloud cover can make optical imagery useless for analysis. + + NOTE: This test may skip if the S2 product is Level-1C (no SCL band). + Level-2A products are required for cloud masking. + """ + if self.s2_file is None: + self.skipTest("S2 test data not available") + + quality = assess_s2_quality(self.s2_file) + + # Verify structure + self.assertIsNotNone(quality, "Quality assessment failed") + self.assertIn("overall_score", quality) + self.assertIn("data_completeness", quality) + self.assertIn("usable", quality) + self.assertIn("quality_level", quality) + + # Check score range + self.assertGreaterEqual(quality["overall_score"], 0.0, "Score should be >= 0") + self.assertLessEqual(quality["overall_score"], 1.0, "Score should be <= 1") + + # Check data completeness + self.assertGreaterEqual(quality["data_completeness"], 0.0) + self.assertLessEqual(quality["data_completeness"], 100.0) + + print( + f"✓ S2 quality: {quality['quality_level']} " + f"(score={quality['overall_score']:.2f}, " + f"clouds={quality.get('cloud_coverage', 'N/A')}%)" + ) + if quality["notes"]: + print(f" Notes: {', '.join(quality['notes'])}") + + # ======================================================================== + # Sentinel-1 Tests (SAR Imagery) + # ======================================================================== + # These tests verify SAR imagery processing from Sentinel-1. + # S1 provides radar backscatter in VV and VH polarizations. + + def test_s1_sar_extraction(self): + """Test SAR composite extraction from S1 product. + + WHAT THIS TESTS: + - Reading S1 ZIP files (SAFE format) + - Extracting VV and VH polarization TIFFs + - Converting to dB scale (10 * log10(intensity)) + - Extracting geospatial metadata + + WHY IT MATTERS: + SAR data is fundamentally different from optical: + - Works day/night and through clouds + - Measures surface roughness, not reflectance + - Requires different processing (dB conversion, speckle filtering) + + This verifies basic SAR data reading capability. + """ + if self.s1_file is None: + self.skipTest("S1 test data not available") + + sar_data = extract_sar_composite(self.s1_file) + + # Verify structure + self.assertIsNotNone(sar_data, "SAR extraction failed") + self.assertIn("sar_array", sar_data) + self.assertIn("bounds_wgs84", sar_data) + self.assertIn("polarizations", sar_data) + self.assertIn("metadata", sar_data) + + # Check array shape + sar_array = sar_data["sar_array"] + self.assertEqual(sar_array.ndim, 3, "SAR should be 3D array [H, W, Polarizations]") + + # Check polarizations + polarizations = sar_data["polarizations"] + self.assertGreater(len(polarizations), 0, "Should have at least one polarization") + self.assertEqual( + sar_array.shape[2], + len(polarizations), + "Number of channels should match number of polarizations", + ) + + # Check dB values (typical range -30 to 10 dB for land surfaces) + # Extended range to -50 to 20 to handle edge cases + self.assertGreater(sar_array.min(), -50, "Backscatter too low (likely error)") + self.assertLess(sar_array.max(), 20, "Backscatter too high (likely error)") + + print(f"✓ S1 SAR extraction: {sar_array.shape}, polarizations: {polarizations}") + + def test_s1_vv_polarization(self): + """Test VV polarization extraction. + + WHAT THIS TESTS: + - Selective polarization extraction (VV only) + - Correct channel ordering + + WHY IT MATTERS: + VV polarization (Vertical transmit, Vertical receive) is sensitive to: + - Surface roughness + - Soil moisture + - Urban structures + + Often used alone for specific applications like flood detection. + """ + if self.s1_file is None: + self.skipTest("S1 test data not available") + + sar_data = extract_sar_composite(self.s1_file, polarizations=["VV"]) + + self.assertIsNotNone(sar_data) + self.assertIn("VV", sar_data["polarizations"]) + self.assertEqual(len(sar_data["polarizations"]), 1, "Should have only VV") + + print(f"✓ S1 VV polarization: {sar_data['sar_array'].shape}") + + def test_s1_vh_polarization(self): + """Test VH polarization extraction. + + WHAT THIS TESTS: + - Selective polarization extraction (VH only) + - Cross-polarization handling + + WHY IT MATTERS: + VH polarization (Vertical transmit, Horizontal receive) is sensitive to: + - Volume scattering (vegetation canopy) + - Crop type discrimination + - Forest biomass + + Cross-polarization is key for vegetation monitoring. + """ + if self.s1_file is None: + self.skipTest("S1 test data not available") + + sar_data = extract_sar_composite(self.s1_file, polarizations=["VH"]) + + self.assertIsNotNone(sar_data) + self.assertIn("VH", sar_data["polarizations"]) + self.assertEqual(len(sar_data["polarizations"]), 1, "Should have only VH") + + print(f"✓ S1 VH polarization: {sar_data['sar_array'].shape}") + + def test_s1_backscatter_statistics(self): + """Test SAR backscatter statistics. + + WHAT THIS TESTS: + - Backscatter value ranges for each polarization + - Statistical distribution (mean, std) + - Data validity (no NaN, no extreme outliers) + + WHY IT MATTERS: + Backscatter statistics help assess: + - Data quality (extreme values indicate errors) + - Scene characteristics (urban vs rural, wet vs dry) + - Calibration correctness + + TYPICAL VALUES (dB): + - Water: -25 to -15 (smooth surface, low backscatter) + - Vegetation: -15 to -5 (volume scattering) + - Urban: -5 to 5 (strong corner reflectors) + - Bare soil: -10 to 0 (depends on roughness and moisture) + """ + if self.s1_file is None: + self.skipTest("S1 test data not available") + + sar_data = extract_sar_composite(self.s1_file) + + # Calculate statistics for each polarization + for i, pol in enumerate(sar_data["polarizations"]): + backscatter = sar_data["sar_array"][:, :, i] + + mean_db = np.mean(backscatter) + std_db = np.std(backscatter) + + # Typical backscatter values (relaxed range for real data) + # Real scenes can have higher values due to urban areas or corner reflectors + self.assertGreater(mean_db, -30, f"{pol} mean too low (likely error)") + self.assertLess(mean_db, 15, f"{pol} mean too high (likely error)") + self.assertGreater(std_db, 0, f"{pol} should have variation") + + print(f"✓ S1 {pol} backscatter: mean={mean_db:.2f} dB, std={std_db:.2f} dB") + + def test_s1_quality_assessment(self): + """Test S1 quality assessment (data completeness, file integrity). + + WHAT THIS TESTS: + - ZIP file integrity + - Presence of measurement files (polarizations) + - Manifest file existence + - Overall quality score computation + + WHY IT MATTERS: + SAR data can have acquisition gaps or file corruption issues. + Quality assessment helps identify problematic products before processing. + + NOTE: SAR doesn't have cloud issues (works through clouds), but can + have missing bursts or incomplete polarizations. + """ + if self.s1_file is None: + self.skipTest("S1 test data not available") + + quality = assess_s1_quality(self.s1_file) + + # Verify structure + self.assertIsNotNone(quality, "Quality assessment failed") + self.assertIn("overall_score", quality) + self.assertIn("data_completeness", quality) + self.assertIn("usable", quality) + self.assertIn("quality_level", quality) + + # Check score range + self.assertGreaterEqual(quality["overall_score"], 0.0, "Score should be >= 0") + self.assertLessEqual(quality["overall_score"], 1.0, "Score should be <= 1") + + # Check data completeness + self.assertGreaterEqual(quality["data_completeness"], 0.0) + self.assertLessEqual(quality["data_completeness"], 100.0) + + print( + f"✓ S1 quality: {quality['quality_level']} " + f"(score={quality['overall_score']:.2f}, " + f"completeness={quality['data_completeness']:.0f}%)" + ) + if quality["notes"]: + print(f" Notes: {', '.join(quality['notes'])}") + + # ======================================================================== + # Cross-sensor Tests + # ======================================================================== + # These tests verify metadata and data availability across sensors. + + def test_both_sensors_available(self): + """Test that both S1 and S2 data are available. + + WHAT THIS TESTS: + - Download script successfully fetched both sensor types + - Files are accessible and not corrupted + + WHY IT MATTERS: + Many applications combine optical and SAR data for better results: + - SAR provides all-weather monitoring + - Optical provides spectral information + - Together they enable robust multi-sensor analysis + """ + self.assertIsNotNone(self.s2_file, "S2 test data missing - run download script") + self.assertIsNotNone(self.s1_file, "S1 test data missing - run download script") + + print(f"✓ Both sensors available: S1 ({self.s1_file.name}) and S2 ({self.s2_file.name})") + + def test_metadata_consistency(self): + """Test that metadata is consistent and complete. + + WHAT THIS TESTS: + - Metadata file structure + - Required fields present + - Location information valid + + WHY IT MATTERS: + Metadata helps track: + - When data was downloaded + - Geographic location of test data + - Product identifiers for debugging + """ + self.assertIn("location", self.metadata) + self.assertIn("products", self.metadata) + self.assertIn("downloaded_at", self.metadata) + + location = self.metadata["location"] + self.assertIn("lat", location) + self.assertIn("lon", location) + + # Verify reasonable coordinates (not 0,0 or extreme values) + self.assertGreater(abs(location["lat"]), 0, "Latitude should not be 0") + self.assertGreater(abs(location["lon"]), 0, "Longitude should not be 0") + self.assertLessEqual(abs(location["lat"]), 90, "Latitude should be <= 90") + self.assertLessEqual(abs(location["lon"]), 180, "Longitude should be <= 180") + + print( + f"✓ Metadata consistent: {location['lat']}°N, {location['lon']}°E, " + f"{len(self.metadata['products'])} products" + ) + + +if __name__ == "__main__": + unittest.main(verbosity=2) From e1eecd456f5283cbdedfc7826b94cf7900ee3cb4 Mon Sep 17 00:00:00 2001 From: Robin Fievet Date: Thu, 15 Jan 2026 13:17:50 -0500 Subject: [PATCH 8/8] lint fix --- src/data/copernicus/download_utils.py | 35 +++++++++++-------------- src/data/copernicus/image_processing.py | 10 ++++--- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/src/data/copernicus/download_utils.py b/src/data/copernicus/download_utils.py index 8a045f4..0617ea4 100644 --- a/src/data/copernicus/download_utils.py +++ b/src/data/copernicus/download_utils.py @@ -29,15 +29,20 @@ def download_with_retry( """Download a file with automatic retry and token refresh. This function handles large file downloads (1-10 GB) that may take longer - than the OAuth token lifetime (~10 minutes). It refreshes the token - periodically and retries on failures. + than the OAuth token lifetime (~10 minutes). It uses HTTP Range requests + to resume downloads and refreshes tokens between retry attempts. Key features: - - Token refresh every 5 minutes during download + - Fresh token for each download attempt - Automatic retry with exponential backoff on failures - Resume partial downloads using HTTP Range requests - Progress bar for user feedback + IMPORTANT: For downloads longer than token lifetime (~10 min), the download + will fail and automatically retry with a fresh token, resuming from where + it left off using HTTP Range requests. This is more reliable than trying + to refresh mid-stream. + Args: client: CopernicusClient for authentication url: Download URL (typically ends with /$value) @@ -59,8 +64,6 @@ def download_with_retry( # Track download progress bytes_downloaded = 0 retry_count = 0 - last_token_refresh = time.time() - token_refresh_interval = 300 # Refresh token every 5 minutes # Create parent directory if needed output_path.parent.mkdir(parents=True, exist_ok=True) @@ -75,14 +78,8 @@ def download_with_retry( while retry_count <= max_retries: try: - # Refresh token if needed (before starting/resuming download) - current_time = time.time() - if current_time - last_token_refresh > token_refresh_interval: - print("🔄 Refreshing authentication token...") - client._get_access_token() # Force token refresh - last_token_refresh = current_time - - # Get fresh token for this attempt + # Always get a fresh token for each attempt + # This ensures we have a valid token even if previous attempt took a long time token = client._get_access_token() headers = { "Authorization": f"Bearer {token}", @@ -105,6 +102,11 @@ def download_with_retry( bytes_downloaded = 0 if output_path.exists(): output_path.unlink() + elif response.status_code == 401: # Token expired during download + print("🔄 Token expired, refreshing and retrying...") + client._access_token = None # Force token refresh + retry_count += 1 + continue else: response.raise_for_status() @@ -127,13 +129,6 @@ def download_with_retry( bytes_downloaded += chunk_len pbar.update(chunk_len) - # Check if we need to refresh token during download - current_time = time.time() - if current_time - last_token_refresh > token_refresh_interval: - # Token might expire soon, but we can't refresh mid-stream - # Just note it for the next retry if this fails - last_token_refresh = current_time - # Verify download completed if bytes_downloaded >= total_size: print(f"✅ Download complete: {output_path.name}") diff --git a/src/data/copernicus/image_processing.py b/src/data/copernicus/image_processing.py index d025f47..5541148 100644 --- a/src/data/copernicus/image_processing.py +++ b/src/data/copernicus/image_processing.py @@ -164,10 +164,11 @@ def extract_rgb_composite( # This saves 99%+ memory and makes processing much faster. if bbox is not None and bounds_wgs84 is not None: print(f"Cropping to bbox: {bbox}") - rgb_display = crop_to_bbox(rgb_display, bounds_wgs84, bbox) - if rgb_display is None: + cropped_result = crop_to_bbox(rgb_display, bounds_wgs84, bbox) + if cropped_result is None: print("Cropping failed, returning None") return None + rgb_display = cropped_result # Update bounds to reflect cropped area bounds_wgs84 = tuple(bbox) @@ -496,10 +497,11 @@ def extract_sar_composite( # This saves 99%+ memory and makes processing much faster. if bbox is not None and bounds_wgs84 is not None: print(f"Cropping SAR to bbox: {bbox}") - sar_display = crop_to_bbox(sar_display, bounds_wgs84, bbox) - if sar_display is None: + cropped_result = crop_to_bbox(sar_display, bounds_wgs84, bbox) + if cropped_result is None: print("SAR cropping failed, returning None") return None + sar_display = cropped_result # Update bounds to reflect cropped area bounds_wgs84 = tuple(bbox)