Skip to content

Commit

Permalink
Change examples to use new authentification methods
Browse files Browse the repository at this point in the history
  • Loading branch information
rle-earthdaily committed Jul 4, 2024
1 parent e983d99 commit cbdd6ac
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 113 deletions.
10 changes: 4 additions & 6 deletions examples/compare_scale_s2.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
# Import librairies
# -------------------------------------------

from earthdaily import earthdatastore, datasets
import geopandas as gpd
from matplotlib import pyplot as plt
from earthdaily import EarthDataStore, datasets

##############################################################################
# Load plot
Expand All @@ -20,10 +20,10 @@
pivot = datasets.load_pivot()

##############################################################################
# Init earthdatastore with env params
# -------------------------------------------
# Init earthdatastore with environment variables or default credentials
# ----------------------------------------------------------------------------

eds = earthdatastore.Auth()
eds = EarthDataStore()

##############################################################################
# Search for collection items
Expand All @@ -39,7 +39,6 @@ def get_cube(rescale=True):
rescale=rescale)
return pivot_cube


##############################################################################
# Get cube with rescale (*0.0001)
# ----------------------------------------------------
Expand All @@ -65,7 +64,6 @@ def get_cube(rescale=True):
# Plots cube with SCL with at least 50% of clear data
# ----------------------------------------------------


pivot_cube.ed.plot_rgb(col_wrap=3)

plt.show()
13 changes: 7 additions & 6 deletions examples/earthdaily_simulated_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,26 @@
# Import librairies
# -------------------------------------------

import earthdaily

import datetime
import earthdaily
from dask.diagnostics import ProgressBar
from matplotlib import pyplot as plt
from earthdaily import datasets, EarthDataStore

ProgressBar().register() # to have chunks progress bar


##############################################################################
# Loading pivot
# -------------------------------------------

pivot = earthdaily.datasets.load_pivot_corumba()
pivot = datasets.load_pivot_corumba()

##############################################################################
# Auth to earthdatastore
# -------------------------------------------
# Init earthdatastore with environment variables or default credentials
# ----------------------------------------------------------------------------

eds = earthdaily.earthdatastore.Auth()
eds = EarthDataStore()

##############################################################################
# Define timerange
Expand Down
9 changes: 5 additions & 4 deletions examples/field_evolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
# Import librairies
# -------------------------------------------

from earthdaily import earthdatastore, datasets

import geopandas as gpd
from matplotlib import pyplot as plt
from earthdaily import datasets, EarthDataStore

##############################################################################
# Load plot
Expand All @@ -20,10 +21,10 @@
pivot = datasets.load_pivot()

##############################################################################
# Init earthdatastore with env params
# -------------------------------------------
# Init earthdatastore with environment variables or default credentials
# ----------------------------------------------------------------------------

eds = earthdatastore.Auth()
eds = EarthDataStore()

##############################################################################
# Search for collection items in august 2022 (1st to 9th)
Expand Down
17 changes: 10 additions & 7 deletions examples/first_steps_create_datacube.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,22 @@
# Import librairies
# -------------------------------------------

from earthdaily import earthdatastore, datasets

import geopandas as gpd
import earthdaily
from matplotlib import pyplot as plt
from earthdaily import datasets, EarthDataStore

##########################
# Loading geometry

geometry = datasets.load_pivot()

##########################
# Init earthdaily and check available assets
##############################################################################
# Init earthdatastore with environment variables or default credentials
# ----------------------------------------------------------------------------

eds = earthdatastore.Auth() # using config from ENV
eds = EarthDataStore()

###########################################################
# Create datacube (in one step)
Expand Down Expand Up @@ -63,7 +66,7 @@
# Creata datacube (independent from being log into earthdatastore)
# We request the "scl" assets which is the native cloudmask

s2_datacube = earthdatastore.datacube(
s2_datacube = earthdaily.earthdatastore.datacube(
items, assets=["blue", "green", "red", "nir", "scl"], intersects=geometry
)

Expand All @@ -72,11 +75,11 @@

# intersects or bbox are asked in order to compute accurate mask statistics

s2_datacube = earthdatastore.mask.Mask(s2_datacube, intersects=geometry).scl(
s2_datacube = earthdaily.earthdatastore.mask.Mask(s2_datacube, intersects=geometry).scl(
mask_statistics=True
)

s2_datacube = earthdatastore.mask.filter_clear_cover(
s2_datacube = earthdaily.earthdatastore.mask.filter_clear_cover(
s2_datacube, 50
) # at least 50% of clear pixels
#
Expand Down
11 changes: 7 additions & 4 deletions examples/multisensors_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@

import geopandas as gpd
from matplotlib import pyplot as plt

from earthdaily import earthdatastore, datasets
from earthdaily import datasets, EarthDataStore

##############################################################################
# Set parameters
# -------------------------------------------

eds = earthdatastore.Auth()
##############################################################################
# Init earthdatastore with environment variables or default credentials
# ----------------------------------------------------------------------------

eds = EarthDataStore()

collections = ["sentinel-2-l2a", "landsat-c2l2-sr"]
datetime = ["2022-07-01", "2022-09-01"]
intersects = datasets.load_pivot_corumba()
Expand Down Expand Up @@ -55,7 +59,6 @@
datacube.ed.plot_rgb(col_wrap=3)
plt.show()


##############################################################################
# See the NDVI evolution
# -------------------------------------------
Expand Down
14 changes: 4 additions & 10 deletions examples/summary_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,17 @@
# Import librairies
# -------------------------------------------

from earthdaily import earthdatastore
from rich.table import Table
from rich.console import Console

from dotenv import load_dotenv

load_dotenv() # take environment variables from .env.
from earthdaily import EarthDataStore

console = Console()


##############################################################################
# Init earthdaily with earthdatastore
# -------------------------------------------------
# Init earthdatastore with environment variables or default credentials
# ----------------------------------------------------------------------------

eds = earthdatastore.Auth()
eds = EarthDataStore()

##############################################################################
# Explore available collections
Expand All @@ -33,7 +28,6 @@
table.add_row(t)
console.print(table)


##############################################################################
# Explore a specific collection
# -------------------------------------------
Expand Down
76 changes: 0 additions & 76 deletions examples/venus_cube_mask.py

This file was deleted.

0 comments on commit cbdd6ac

Please sign in to comment.