1919from meteora .clients .mixins import StationsEndpointMixin , VariablesHardcodedMixin
2020from meteora .utils import DateTimeType , KwargsType , VariablesType
2121
22- # to show a progress bar in pandas/geopandas apply
23- tqdm .pandas ()
24-
2522# API endpoints
2623BASE_URL = "https://api.netatmo.com"
2724OAUTH2_TOKEN_ENDPOINT = f"{ BASE_URL } /oauth2/token"
@@ -491,6 +488,21 @@ def _station_records_from_window(window):
491488 )
492489 return None
493490
491+ response_jsons = (
492+ self ._get_content_from_url (
493+ self ._stations_endpoint ,
494+ params = dict (
495+ lon_sw = window .bounds [0 ],
496+ lat_sw = window .bounds [1 ],
497+ lon_ne = window .bounds [2 ],
498+ lat_ne = window .bounds [3 ],
499+ ),
500+ )
501+ for window in tqdm (
502+ self .region_window_gser ,
503+ total = len (self .region_window_gser ),
504+ )
505+ )
494506 _stations_df = pd .concat (
495507 [
496508 pd .DataFrame (
@@ -499,29 +511,7 @@ def _station_records_from_window(window):
499511 for station_record in response_json ["body" ]
500512 ],
501513 )
502- for response_json in self .region_window_gser .progress_apply (
503- # for response_json, _ in self.region_window_gser.apply(
504- # lambda window: self._perform_request(
505- # STATIONS_ENDPOINT,
506- # data=dict(
507- # lon_sw=window.bounds[0],
508- # lat_sw=window.bounds[1],
509- # lon_ne=window.bounds[2],
510- # lat_ne=window.bounds[3],
511- # ),
512- # )
513- # we can use the cache to get the stations (note that the same
514- # endpoint is used to get the latest observations)
515- lambda window : self ._get_content_from_url (
516- self ._stations_endpoint ,
517- params = dict (
518- lon_sw = window .bounds [0 ],
519- lat_sw = window .bounds [1 ],
520- lon_ne = window .bounds [2 ],
521- lat_ne = window .bounds [3 ],
522- ),
523- )
524- )
514+ for response_json in response_jsons
525515 ],
526516 axis = "rows" ,
527517 ignore_index = True ,
0 commit comments