pythonpython-3.xopenweathermapweathermeteostat

daily sunshine hours/ minutes from weather API


I am currently using meteostat weather API and extracting data, but I see that sunshine minutes is NaN for mostly all the countries. Am I doing something wrong? Should I look for a Paid weather API? my major focus is Sunshine minutes or hours per day for last 3 years.

I m using the below code snippet

!pip install meteostat

# Import Meteostat library and dependencies
from datetime import datetime
import matplotlib.pyplot as plt
from meteostat import Stations, Daily

# Set time period
start = datetime(2016, 1, 1)
end = datetime(2022, 12, 31)

# Get daily data
data = Daily('06660', start, end)
data = data.fetch()

data

where 06660 is the weather station WMO code for Switzerland. Thank you in advance.


Solution

  • I did some digging in the meteostat documentation and issues on github. If you change the weather station from the one you're using to the one given in the documentation example, values of tsun aren't NaN. You are able to see proper data. So it's probably not an issue with your code but simple the tsun data for your weather station isn't available. In this issue on their Githib repo, the Founder of meteostat has commented saying

    Unfortunately, there isn't much we can do about it. tsun is one of the parameters which isn't well covered by most weather stations. We can only try to incorporate more data sources moving forward. But it might be the data simply isn't available for the weather stations in this area.