Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skip_empty not working #858

Open
TheAnalystx opened this issue Jan 29, 2023 · 3 comments
Open

skip_empty not working #858

TheAnalystx opened this issue Jan 29, 2023 · 3 comments

Comments

@TheAnalystx
Copy link

Describe the bug
I want to find the latest weather data for one or multiple coordinates, I thought skip_empty would be the way to go, but this seem not to actually skip empty stations.

To Reproduce

from wetterdienst.provider.dwd.observation import DwdObservationRequest, DwdObservationDataset, \
    DwdObservationResolution, DwdObservationPeriod
r = DwdObservationRequest(
            parameter=[
                DwdObservationDataset.TEMPERATURE_AIR,
                DwdObservationDataset.WIND,
                DwdObservationDataset.PRECIPITATION
            ],
            resolution=DwdObservationResolution.MINUTE_10,
            period=DwdObservationPeriod.NOW,
        )
# search weather for coordinates:
print('skip_empty: ', r.skip_empty)  # -> True
hannover = {'latitude': 52.39197954397832, 'longitude': 9.80360833506706}
station = r.filter_by_rank(rank=1, latlon=(hannover['latitude'], hannover['longitude']))
assert not station.values.all().df.empty, 'empty dataframe found'  # <- error

Expected behavior
not empty dataframe with values

Desktop (please complete the following information):

  • OS: [Windows]
  • Python-Version [3.9]
@TheAnalystx
Copy link
Author

Is that actually a bug or do I missunderstand the use of skip_empty? Because if that isn't a bug but simply wrong parameter usage I would close the issue and implement something to find the nearest non-empty station for my problem.

@gutzbenj
Copy link
Member

Dear @TheAnalystx ,

this option is currently not working as intended. Atm when using it we just skip the empty station however we don't request another alternative station! For this to work I'll have to put in some more work:

  • probably add some counter to the ScalarRequestCore that is not increased if station is empty
  • add a request mode like FILTER_BY that indicates that we want X closest stations
  • use the counter and the request mode and add some magic to the query method in ScalarValuesCore to actually continue searching for data if a previous station returned empty data
  • add/return DataFrame with list of actually returned stations after figuring which have data

Would you want to work on this kind of topic? I could give you some hints on where to place to code!

@TheAnalystx
Copy link
Author

Dear @gutzbenj ,

could be interesting to solve, maybe I can address this next month, if I can find the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants