|
14 | 14 | stationfile_or_stations, |
15 | 15 | ) |
16 | 16 | from dms_datastore import dstore_config |
17 | | -from .logging_config import logger |
| 17 | +from dms_datastore.logging_config import logger |
18 | 18 |
|
19 | 19 | __all__ = ["noaa_download"] |
20 | 20 |
|
@@ -83,6 +83,12 @@ def faulty_output(text): |
83 | 83 | return "Please make sure" in text or len(text) < 300 |
84 | 84 |
|
85 | 85 |
|
| 86 | +def subprogram(df): |
| 87 | + return df.agency_id.apply( |
| 88 | + lambda x: "tidecurrent" if isinstance(x, str) and len(x) == 7 and x.isdigit() else "buoy" |
| 89 | + ) |
| 90 | + |
| 91 | + |
86 | 92 | def download_station_data( |
87 | 93 | row, dest_dir, start, end, param, overwrite, endfile, skips, verbose |
88 | 94 | ): |
@@ -265,8 +271,15 @@ def noaa_download(stations, dest_dir, start, end=None, param=None, overwrite=Fal |
265 | 271 | os.mkdir(dest_dir) |
266 | 272 | skips = [] |
267 | 273 |
|
| 274 | + # This is an attempt to short-circuit the download of water levels for non-tidal stations |
| 275 | + # The correctness of this remains to be checked. |
| 276 | + if param in ("elev","water_level", "hourly_height", "predictions"): |
| 277 | + stations = stations.loc[subprogram(stations)=="tidecurrent"] |
| 278 | + elif param in ("temp","temperature","conductivity","ec"): |
| 279 | + stations = stations.loc[subprogram(stations)=="buoy"] |
| 280 | + |
268 | 281 | # Use ThreadPoolExecutor |
269 | | - with concurrent.futures.ThreadPoolExecutor(max_workers=6) as executor: |
| 282 | + with concurrent.futures.ThreadPoolExecutor(max_workers=1) as executor: |
270 | 283 | # Schedule the download tasks and handle them asynchronously |
271 | 284 | futures = [] |
272 | 285 | for ndx, row in stations.iterrows(): |
|
0 commit comments