Skip to content

Commit

Permalink
Issue #16 cleanup trailing spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
soxofaan committed Jan 30, 2024
1 parent 69414ca commit 2b1a8a7
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/openeo_gfmap/fetching/s1.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def get_s1_grd_default_processor(
def s1_grd_default_processor(cube: openeo.DataCube, **params):
"""Default collection preprocessing method.
This method performs:
* Compute the backscatter of all the S1 products. By default, the
"sigma0-ellipsoid" method is used with "COPERNICUS_30" DEM, but those
can be changed by specifying "coefficient" and "elevation_model" in
Expand All @@ -115,7 +115,7 @@ def s1_grd_default_processor(cube: openeo.DataCube, **params):
cube = resample_reproject(
cube,
params.get("target_resolution", 10.0),
params.get("target_crs", None)
params.get("target_crs", None)
)

cube = rename_bands(cube, BASE_SENTINEL1_GRD_MAPPING)
Expand Down
2 changes: 1 addition & 1 deletion src/openeo_gfmap/preprocessing/cloudmasking.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def get_bap_score(cube: openeo.DataCube, **params: dict) -> openeo.DataCube:
* Coverage Score: Per date, the percentage of all pixels that are classified
as a cloud over the entire spatial extent is calculated. The Coverage
Score is then equal to 1 - the cloud percentage.
* Date Score: In order to favor pixels that are observed in the middle of a
* Date Score: In order to favor pixels that are observed in the middle of a
month, a date score is calculated, which follows a Gaussian shape. I.e.
the largest scores are given for days in the middle of the month, the
lowest scores are given for days at the beginning and end of the month.
Expand Down
2 changes: 1 addition & 1 deletion src/openeo_gfmap/preprocessing/udf_rank.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def select_maximum(score: xr.DataArray):
elif isinstance(intervals, list):
# Convert YYYY-mm-dd to datetime64 objects
time_bins = [np.datetime64(interval[0]) for interval in intervals]

rank_mask = bap_score.groupby_bins('t', bins=time_bins).map(
select_maximum
)
Expand Down
4 changes: 2 additions & 2 deletions src/openeo_gfmap/utils/catalogue.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def _check_cdse_catalogue(
# The date format should be YYYY-MM-DD
start_date = f'{temporal_extent.start_date}T00:00:00Z'
end_date = f'{temporal_extent.end_date}T00:00:00Z'

url = (
f"https://catalogue.dataspace.copernicus.eu/resto/api/collections/"
f"{collection}/search.json?box={minx},{miny},{maxx},{maxy}"
Expand All @@ -69,4 +69,4 @@ def _check_cdse_catalogue(
filter(lambda feature: feature["properties"]["productType"].contains("GRD"), body["features"])
)

return len(grd_tiles) > 0
return len(grd_tiles) > 0
4 changes: 2 additions & 2 deletions src/openeo_gfmap/utils/intervals.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Utilitary function for intervals, useful for temporal aggregation
"""Utilitary function for intervals, useful for temporal aggregation
methods.
"""

Expand Down Expand Up @@ -27,7 +27,7 @@ def quintad_intervals(temporal_extent: TemporalContext) -> list:
offset = (start_date - timedelta(days=1)).day % 5
current_date = current_date - timedelta(days=offset)
else:
offset = 0
offset = 0

while current_date <= end_date:
# Get the last day of the current month
Expand Down
4 changes: 2 additions & 2 deletions src/openeo_gfmap/utils/tile_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def normalize_array(
minimum = inarr.min(dim=["x", "y", "t"])

inarr = (inarr - minimum) / (quantile_value - minimum)

# Perform clipping on values that are higher than the computed quantile
return inarr.where(inarr < 1.0, 1.0)

Expand Down Expand Up @@ -60,7 +60,7 @@ def arrays_cosine_similarity(
) -> float:
"""Returns a similarity score based on normalized cosine distance. The
input arrays must have similar ranges to obtain a valid score.
1.0 represents the best score (same tiles), while 0.0 is the worst score.
1.0 represents the best score (same tiles), while 0.0 is the worst score.
"""
dot_product = np.sum(first_array * second_array)
first_norm = np.linalg.norm(first_array)
Expand Down
8 changes: 4 additions & 4 deletions tests/test_openeo_gfmap/test_cloud_masking.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def test_bap_score(backend: Backend):
# Compute the BAP score
bap_score = get_bap_score(cube, **preprocessing_parameters)
ndvi = cube.ndvi(nir="S2-B08", red="S2-B04")

cube = bap_score.merge_cubes(ndvi).rename_labels(
'bands', ['S2-BAPSCORE', 'S2-NDVI']
)
Expand All @@ -70,7 +70,7 @@ def test_bap_score(backend: Backend):
)

job.start_and_wait()

for asset in job.get_results().get_assets():
if asset.metadata["type"].startswith("application/x-netcdf"):
asset.download(
Expand Down Expand Up @@ -101,7 +101,7 @@ def test_bap_masking(backend: Backend):

cube = cube.linear_scale_range(0, 65535, 0, 65535)

# Perform masking with BAP, masking optical bands
# Perform masking with BAP, masking optical bands
cube = bap_masking(cube, period="dekad")

# Perform compositing, the cube should be only composed of optical bands
Expand Down Expand Up @@ -137,7 +137,7 @@ def test_bap_quintad(backend: Backend):
"fetching_resolution": 10.0
}
preprocessing_parameters = {
"apply_scl_dilation": True
"apply_scl_dilation": True
}

# Fetch the datacube
Expand Down
2 changes: 1 addition & 1 deletion tests/test_openeo_gfmap/test_intervals.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test_quintad_four_months():
end_date = "2023-04-30"

temporal_extent = TemporalContext(start_date, end_date)

expected = [
("2023-01-01", "2023-01-05"),
("2023-01-06", "2023-01-10"),
Expand Down
4 changes: 2 additions & 2 deletions tests/test_openeo_gfmap/test_s1_fetchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def compare_sentinel1_tiles():
dtype = array.dtype
else:
assert dtype == array.dtype

bounds = None
for tile in loaded_tiles:
tile_bounds = array_bounds(tile)
Expand Down Expand Up @@ -202,7 +202,7 @@ def sentinel1_grd_point_based(
if band in col:
exists = True
assert exists, f"Couldn't find a single column for band {band}"

assert len(df.columns) % len(bands) == 0, (
f"The number of columns ({len(df.columns)}) should be a multiple"
f"of the number of bands ({len(bands)})"
Expand Down

0 comments on commit 2b1a8a7

Please sign in to comment.