Potential Bug (or My Own Mistake) in Building of Data Query Using "synopitic.services.stations_timeseries" #11
-
Hello to Brian and SynopticPy Users, My name is Marian and I am a graduate student in Geography who recently came across this great SynopticPy repository that Brian created (Thank you, Brian). I followed the directions for creating/installing the synoptic environment from the "environment.yml" provided in the documentation and am just now testing things out to download some data from a single station. I have generated a token and input that into the config file. Following an example in this repository I used the following code to try and download some data: #Import packages/functions
from datetime import datetime
from synoptic.services import stations_timeseries
#Download some data!
data = stations_timeseries(
stdid=['KSBA'],
vars=['air_temp'],
start=datetime(2022,5,11),
end=datetime(2022,5,12)
) Upon running this code, I was greeted with the following error message:
Interestingly, and if my code is correct as is, there seems to be a potential issue somewhere with the start and/or end times when creating the request using python/SynopticPy. I went ahead and tried to build an identical request manually on the Synoptic website and ended up with a working request that looked like:
I was wondering if anyone had any idea what may be the issue here? I was thinking it could be the order in which the python function, "stations_timeseries", is putting the various request variables, but this doesn't seem to have a clear affect on making the request valid or invalid. Also, from all the available working examples on this repository, I find it more likely that I am doing something wrong and not the code. If it is helpful, I can provide additional details about my specific computer/conda/python setup. Thank you for your time spent reading this, and for any assistance you may be able to provide. Best, Marian UPDATE: I tried running a metadata request for this station (KSBA) to ensure that I could could get some output. My code was the following, and it indeed produced output of the metadata for KSBA: from synoptic.services import stations_metadata
stations_metadata(stid='KSBA') I also ran two identical cells for requesting the timeseries data and one of them worked, while the other still produced the error mentioned above. I am attaching a commented Jupyter Notebook file to help with debugging: Final Update: Fixed! I found out that there was a typo in the "stid" parameter for the "stations_timeseries" function. Originally (see above) I wrote this parameter as "stdid" and not "stid". Fixing this typo has now resulted both identical (or so I thought) Jupyter cells to run and fetch the data correctly. My apologies for this long discussion. Hopefully this may help someone down the line if they encounter this type of issue. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @mariandob, I'm glad you like using SynopticPy. Sounds like you got it working by fixing the typo I should have it print a warning when an unknown parameter is used. That might help someone identify this issue easier. Keep sharing in the discussions! Happy research 😎 |
Beta Was this translation helpful? Give feedback.
Hi @mariandob, I'm glad you like using SynopticPy. Sounds like you got it working by fixing the typo
stdid
tostid
.I should have it print a warning when an unknown parameter is used. That might help someone identify this issue easier.
Keep sharing in the discussions! Happy research 😎