meteostat

FREEMIUM
By Meteostat | Updated 22日前 | Weather
Popularity

9.9 / 10

Latency

364ms

Service Level

100%

Health Check

N/A

Back to All Discussions

NULL or missing values

Rapid account: A 2 K
a2k
1年前

I am using the JavaScript jQuery API for daily station data.

Lets say I want to retrieve station data for station D2968 for the 2013-06-09:

Object { date: “2013-06-09”, tavg: 16.6, tmin: 13.1, tmax: 20.2, prcp: 4.8, snow: null, wdir: null, wspd: null, wpgt: null, pres: null, tsun: null }

As u can see, I get many NULL values. But when doing the same with the Meteostat Python Library I get the following list:

date: 2013-06-09, tavg: 16.6, tmin: 13.1, tmax: 20.2, prcp: 4.8, snow: 0.0, wdir: 342.0, wspd: 12.6, wpgt: 29.2, pres: 1009.5, tsun: 174.0.

So the values actually exist, but are not returned using the JS jQ API. This happens consistently throughout the queries I make.

Whats wrong/What am I doing wrong?

Thanks ahead!!

  • as of now, I am not subscribed to paid plan. Might that be the reason?
Rapid account: A 2 K
a2k Commented 1年前

Hey, thanks for the clarification. My bad! Everything works for me now using the interpolated point data with the RapidAPI interface.

Rapid account: Meteostat
meteostat Commented 1年前

The discrepancy occurs because you’re using a Point instead of a station ID in your Python script. In order to get data for the station D2968 you’d have to do this:


dataTen = Daily(‘D2968’, startTen, endTen)

Otherwise, you’ll get interpolated data from multiple stations.

Rapid account: A 2 K
a2k Commented 1年前

Hey, thx for the reply.

Yes, I mean the GET daily station data jQuery code provided by RapidAPI.

Sure. In order to get the station data via Meteostat Python Library I use the following:


from meteostat import Point, Daily, Stations
import datetime as dt
from dateutil.relativedelta import relativedelta

latitude = 50.9507252
longitude = 6.9665561

##Get nearby weather stations according to latitude and longitude
stations = Stations()
stations = stations.nearby(latitude, longitude)
station = stations.fetch(1)

stationlat = list(station.values[0])[5]
stationlon = list(station.values[0])[6]
location = Point(stationlat, stationlon)

#today - 10y
dateTen = dt.date.today() - relativedelta(years=10)
yearTen = dateTen.year
monthTen = dateTen.month
dayTen = dateTen.day
startTen = dt.datetime(yearTen, monthTen, dayTen)
endTen = dt.datetime(yearTen, monthTen, dayTen)
dataTen = Daily(location, startTen, endTen)
dataTen = dataTen.fetch()

print(dataTen)


Which returns this:
tavg tmin tmax prcp snow wdir wspd wpgt pres tsun
time
2013-06-09 16.6 13.1 20.2 4.8 0.0 342.0 12.6 29.2 1009.5 174.0

Rapid account: Meteostat
meteostat Commented 1年前

Hi,

By “JavaScript jQuery API” you mean the RapidAPI interface? I can confirm the data above is consistent with the data provided on the website: https://meteostat.net/en/station/D2968?t=2013-06-01/2013-06-30

Also, I’m getting the same data using the Python lib.

Script:

from meteostat import Daily
from datetime import datetime

print(Daily(‘D2968’, datetime(2013, 6, 9), datetime(2013, 6, 9)).fetch())

Result:

        tavg  tmin  tmax  prcp  snow  wdir  wspd  wpgt  pres  tsun

time
2013-06-09 16.6 13.1 20.2 4.8 NaN NaN NaN NaN NaN NaN

Can you share your Python code?

Join in the discussion - add comment below:

Login / Signup to post new comments