meteoserver.sundata module¶
Functions to obtain, read and write four-day sun-forecast (“Zon Actueel”) data from Meteoserver.nl.
-
meteoserver.sundata.
extract_Sun_dataframes_from_dict
(dataDict, numeric)[source]¶ Extract the location name, current-data and forecast Pandas dataframes from a data dictionary.
Parameters: - dataDict (dict) – The name of the data dictionary to convert.
- numeric (bool) – Convert dataframe content from strings to numeric/datetime format (default=True). Set this to False if you intend to write a JSON file that is (nearly) identical to the original format.
Returns: Tuple containing (location, current, forecast):
- current (df): Pandas dataframe containing current-weather data from a nearby station.
- forecast (df): Pandas dataframe containing forecast data for the specified location (or region?).
- forecast (df): Pandas dataframe containing forecast data for the specified location (or region?).
Return type: tuple (str, df, df)
-
meteoserver.sundata.
read_json_file_sunData
(fileJSON, loc=False, numeric=True)[source]¶ Read a Meteoserver Sun-data JSON file from disc and return the current-data and forecast dataframes, and optionally the location name.
This uses the “Zon Actueel” Meteoserver data.
Parameters: - fileJSNO (string) – The name of the JSON file to read.
- loc (bool) – Return the location name as a third return value (default=False).
- numeric (bool) – Convert dataframe content from strings to numeric/datetime format (default=True). Set this to False if you intend to write a JSON file that is (nearly) identical to the original format.
Returns: Tuple containing (current, forecast (, location)):
- current (df): Pandas dataframe containing current-weather data from a nearby station.
- forecast (df): Pandas dataframe containing forecast data for the specified location (or region?).
- location (str): The location the data are for.
Return type: tuple (df, df (,str))
-
meteoserver.sundata.
read_json_url_sunData
(key, location, loc=False, numeric=True)[source]¶ Get the Sun data from the Meteoserver server and return the current-data and forecast dataframes and optionally the location name.
This uses the “Zon Actueel” Meteoserver API/data.
Parameters: - key (string) – The Meteoserver API key.
- location (string) – The name of the location (in the Netherlands) to obtain data for (e.g. ‘De Bilt’).
- loc (bool) – Return the location name as a third return value (default=False).
- numeric (bool) – Convert dataframe content from strings to numeric/datetime format (default=True). Set this to False if you intend to write a JSON file that is (nearly) identical to the original format.
Returns: Tuple containing (current, forecast (, location)):
- current (df): Pandas dataframe containing current-weather data from a nearby station.
- forecast (df): Pandas dataframe containing forecast data for the specified location (or region?).
- retLoc (str): The name of the location the data are for (only returned if loc=True).
Return type: tuple (df, df (,str))
-
meteoserver.sundata.
write_json_file_sunData
(fileName, location, current, forecast)[source]¶ Write a Meteoserver sun-forecast-data JSON file to disc.
The resulting file has the same format as a downloaded file (barring some spacing).
Parameters: - fileName (string) – The name of the JSON file to write.
- location (string) – The location the data are for.
- current (df) – Pandas dataframe containing current/recent measurements for the specified location (or region).
- forecast (df) – Pandas dataframe containing sun forecast data for the specified location (or region).