<jupyter_start><jupyter_text>Station Coordinates Timeseries First you have to import the meteomatics module and the datetime module<jupyter_code>import datetime as dt
import meteomatics.api as api

from __future__ import print_function<jupyter_output><empty_output><jupyter_text>Input here your username and password from your meteomatics profile<jupyter_code>###Credentials:
username = 'python-community'
password = '<PASSWORD>'<jupyter_output><empty_output><jupyter_text>Input here a startdate, an enddate and the time interval, all as datetime-objects. The interval tells you, if you get the data in hourly steps, daily steps or every five minutes in between the startdate and the enddate. Be aware, that the enddate has to be in the past.<jupyter_code>startdate_station_ts = dt.datetime.utcnow().replace(hour=0, minute=0, second=0, microsecond=0)-dt.timedelta(days=2)
enddate_station_ts = startdate_station_ts + dt.timedelta(days=1)
interval_station_ts = dt.timedelta(hours=1)<jupyter_output><empty_output><jupyter_text>Choose the parameters you want to get and put them into a list. Check here which parameters are available: https://www.meteomatics.com/en/api/available-parameters/<jupyter_code>parameters_station_ts = ['t_2m:C', 'wind_speed_10m:ms', 'relative_humidity_2m:p', 'precip_1h:mm']<jupyter_output><empty_output><jupyter_text>Input here 'mix-obs' to get observational data.<jupyter_code>model_station_ts = 'mix-obs'<jupyter_output><empty_output><jupyter_text>Put the coordinates you want to get as tuples (north,east) in a list. If you want to get coordinates in the south or in the west, just write a minus in front of the number.<jupyter_code>coordinates_station_ts = [(47.43, 9.4)]<jupyter_output><empty_output><jupyter_text>In the following, the request will start. If there is an error in the request as for example a wrong parameter or a date that doesn't exist, you get a message. Note, that this model 'mix-obs' is not available for the 'python-community' trial account.<jupyter_code>print("station coordinates timeseries:")
try:
    df_sd_coord = api.query_station_timeseries(startdate_station_ts, enddate_station_ts, interval_station_ts,
                                               parameters_station_ts, username, password, model=model_station_ts,
                                               latlon_tuple_list=coordinates_station_ts, on_invalid='fill_with_invalid',
                                               request_type="POST", temporal_interpolation='none')
    print(df_sd_coord.head())
except Exception as e:
    print("Failed, the exception is {}".format(e))<jupyter_output>station coordinates timeseries:
2021-03-02 14:12:07| INFO |Calling URL: https://api.meteomatics.com/2021-02-28T00:00:00+00:00--2021-03-01T00:00:00+00:00:PT1H (username = python-community)
                                      t_2m:C  wind_speed_10m:ms  \
station_id validdate                                              
47.43,9.4  2021-02-28 00:00:00+00:00     NaN                NaN   
           2021-02-28 01:00:00+00:00     NaN                NaN   
           2021-02-28 02:00:00+00:00     NaN                NaN   
           2021-02-28 03:00:00+00:00     NaN                NaN   
           2021-02-28 04:00:00+00:00     NaN                NaN   

                                      relative_humidity_2m:p  precip_1h:mm  
station_id validdate                                                        
47.43,9.4  2021-02-28 00:00:00+00:00                     NaN           NaN  
           2021-02-28 01:00:00+00:00                     NaN           NaN  
           2021-02-28 02:00:00+00:[...]<jupyter_text>As output you get a pandas dataframe with the coordinates and the date in the index. You get the timeseries of the closest station to your coordinates.![10_station_coordinates_output](api_demo_images/10_station_coordinates_output.png) Now you can work on the data by using pandas commands. Here are some examples how you can access to the different datapoints.<jupyter_code>maximum_temperature = df_sd_coord['t_2m:C'].max()
minimum_windspeed = df_sd_coord['wind_speed_10m:ms'].min()
mean_temperature = df_sd_coord['t_2m:C'].mean()
just_precipitation = df_sd_coord['precip_1h:mm']
first_value_of_precipitation = df_sd_coord.iloc[0]['precip_1h:mm']
just_at_12UTC = df_sd_coord[df_sd_coord.index.get_level_values('validdate').hour == 12]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.0890909090909091, 'fraction_numerical': 0.05522727272727273, 'mean_word_length': 3.2769679300291545, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 2, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '303923', 'license': 'MIT', 'n_tokens_mistral': 1524, 'n_tokens_neox': 1360, 'n_words': 341, 'path': 'examples/notebooks/10_Stations_Coordinates_Timeseries.ipynb', 'repo_name': 'salimfadhleyhtp/python-connector-api', 'size': '4402'}