Skip to content

Commit

Permalink
style(ruff) : automatic lint/format
Browse files Browse the repository at this point in the history
  • Loading branch information
nkarasiak authored and github-actions[bot] committed Feb 10, 2025
1 parent 434e886 commit 5157b1d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion earthdaily/accessor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def zonal_stats(
self,
geometry,
reducers: list = ["mean"],
preserve_columns: bool= True,
preserve_columns: bool = True,
lazy_load=True,
**kwargs,
):
Expand Down
22 changes: 13 additions & 9 deletions earthdaily/earthdatastore/cube_utils/_zonal.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,18 +238,22 @@ def _loop_time_chunks(dataset, method, smart_load, time_chunks):
**kwargs,
)
zs = zs.drop("geometry")
zs = zs.assign_coords(geometry=('feature',geoms.geometry.to_wkt(rounding_precision=-1).values))
zs = zs.assign_coords(index=('feature',geoms.index))
zs = zs.set_index(feature=["geometry","index"])
zs = zs.transpose('time', 'feature', 'zonal_statistics')

zs = zs.assign_coords(
geometry=("feature", geoms.geometry.to_wkt(rounding_precision=-1).values)
)
zs = zs.assign_coords(index=("feature", geoms.index))
zs = zs.set_index(feature=["geometry", "index"])
zs = zs.transpose("time", "feature", "zonal_statistics")

# store columns
if preserve_columns:
coords = [col for col in geoms.columns if col not in geoms._geometry_column_name]
coords = [
col for col in geoms.columns if col not in geoms._geometry_column_name
]
values = geoms.loc[zs.index.values][coords].values.T
for coord, value in zip(coords,values):
zs = zs.assign_coords({coord:("feature",value)})
feature_index_names = list(zs['feature'].to_index().names)
for coord, value in zip(coords, values):
zs = zs.assign_coords({coord: ("feature", value)})
feature_index_names = list(zs["feature"].to_index().names)
feature_index_names.extend(coords)
zs = zs.set_index(feature=feature_index_names)

Expand Down
2 changes: 1 addition & 1 deletion earthdaily/earthdatastore/parallel_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def datetime_split(
# Calculate or convert frequency
if freq == "auto":
# Calculate automatic frequency, 1 process per month
freq = Timedelta(days=np.ceil(date_diff.days/30)*31)
freq = Timedelta(days=np.ceil(date_diff.days / 30) * 31)
elif isinstance(freq, (int, str)):
freq = Timedelta(days=int(freq))
elif not isinstance(freq, Timedelta):
Expand Down

0 comments on commit 5157b1d

Please sign in to comment.