Comments (5)
thanks for the suggestion. We'll try to see if there is a neat option for the user to provide the filtration function directly, to also solve any similar issues in the future.
from eo-learn.
Good idea! Something along these lines?
In eolearn.io.sentinelhub_process.py
- introduce
filter_timestamps
parameter toget_available_timestamps
- introduce
filter_timestamps
parameter to__init__()
- save as "private" method
- pass filtering method in
_get_timestamp()
from sentinelhub import filter_times as sentinelhub_filter_times
class SentinelHubInputTask(SentinelHubInputBaseTask):
def __init__(
self,
....
filter_timestamps=False,
...
):
"""
:param ...
:param filter_timestamps: A Callable that filters the timestamps returned by get_available_timestamps, returning them in a list.
: param ...
"""
...
self._filter_timestamps = filter_timestamps or sentinelhub_filter_times
...
def _get_timestamp(self, time_interval, bbox):
"""Get the timestamp array needed as a parameter for downloading the images"""
if self.single_scene:
return [time_interval[0]]
return get_available_timestamps(
bbox=bbox,
time_interval=time_interval,
data_collection=self.data_collection,
maxcc=self.maxcc,
time_difference=self.time_difference,
filter_timestamps=self._filter_timestamps,
config=self.config,
)
# copy of get_available_timestamps, where only filtering in the last line is replaced with
# the newly passed function filter_timestamps
def get_available_timestamps(
bbox: BBox,
data_collection: DataCollection,
*,
time_interval: Optional[Tuple[dt.datetime, dt.datetime]] = None,
time_difference: dt.timedelta = dt.timedelta(seconds=-1),
filter_timestamps: Optional[Callable] = None,
maxcc: Optional[float] = None,
config: Optional[SHConfig] = None,
) -> List[dt.datetime]:
...
filter_timestamps = filter_timestamps or sentinelhub_filter_times
....
return filter_timestamps(all_timestamps, time_difference)
Define own filtering function somewhere, e.g. in timestamp_filters.py
# an adapted version of filter_times, allowing for reverse filtering
def my_filter_times_reverse(timestamps: Iterable[TimeType],
time_difference: dt.timedelta) -> List[TimeType]:
"""Filters out timestamps within time_difference, preserving only the most recent timestamp.
:param timestamps: A list of timestamps.
:param time_difference: A time difference threshold.
:return: An ordered list of timestamps `d_1 <= d_2 <= ... <= d_n` such that `d_(i+1)-d_i > time_difference`.
"""
timestamps = sorted(set(timestamps))[::-1]
filtered_timestamps: List[TimeType] = []
for current_timestamp in timestamps:
if not filtered_timestamps or filtered_timestamps[-1] - current_timestamp > time_difference:
filtered_timestamps.append(current_timestamp)
return filtered_timestamps[::-1]
Usage
from timestamp_filters import my_filter_times_reverse
input_task = SentinelHubInputTask(
...
filter_timestamps=my_filter_times,
...
)
Not sure if other tasks would need to be updated, too 🤷
Best,
Colin
from eo-learn.
Something along these lines yes, anything else feels like we'd have to re-do it in a few months for another use-case.
We are planning a minor release this month (if all goes well), and this will likely be included. If you wish we can include you in the pull-request process once we get around to it.
from eo-learn.
We are planning a minor release this month (if all goes well), and this will likely be included. If you wish we can include you in the pull-request process once we get around to it.
That would be great!
from eo-learn.
was released in 1.3.1
from eo-learn.
Related Issues (20)
- [BUG] ImportError: cannot import name 'PointSamplingTask' from 'eolearn.geometry' HOT 5
- SI_LULC_pipeline notebook HOT 9
- readthedocs links not working HOT 1
- [BUG] SentinelHubInputTask downloads incorrect timestamps HOT 6
- [BUG] Issue with the SpatialResizeTask in ImportTiffPipeline when using the resolution approach HOT 5
- [BUG] eo-learn installation issue due to open-cv latest update on Dec 30, 2022. HOT 2
- Registration HOT 4
- [BUG] Failing tests on MacOS related to lock-related EOExecutor tests HOT 1
- [BUG] Reading EOPatches saved with eo-learn 0.10.1 with eolearn 1.4 HOT 2
- [HELP] Where has eopatch_to_dataset gone? HOT 6
- [FEAT] TDigestTask handle nans HOT 1
- [HELP] Error when I'm trying to run land-cover-map HOT 5
- [HELP] Perform sen2cor atmospheric correction on L1C EOPatch HOT 2
- [HELP] Using eo-learn for the classification of land surface types of Ukraine HOT 23
- Why I have problems with these imports? HOT 3
- ExecutableNotFound: failed to execute WindowsPath('dot'), make sure the Graphviz executables are on your systems' PATH HOT 3
- how do i fix this HOT 2
- CRSError in rasterio when using ExportToTiffTask HOT 6
- `eo-learn` 1.5.0 migration guide
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eo-learn.