Skip to content
Snippets Groups Projects
Commit aa92f77b authored by lukas leufen's avatar lukas leufen
Browse files

removed join_settings for local token setting

parent 97e428df
No related branches found
No related tags found
2 merge requests!37include new development,!36include using of hourly data
......@@ -53,8 +53,8 @@ def download_join(station_name: Union[str, List[str]], stat_var: dict, station_t
logging.info('load: {}'.format(var))
# create data link
opts = {'base': join_url_base, 'service': 'stats', 'id': vars_dict[var], 'statistics': stat_var[var],
'sampling': sampling, 'capture': 0, 'min_data_length': 1460}
opts = {'base': join_url_base, 'service': 'stats', 'id': vars_dict[var], #'statistics': stat_var[var],
'sampling': sampling, 'capture': 0, 'min_data_length': 1460, 'format': 'json'}
# load data
data = get_data(opts, headers)
......@@ -116,7 +116,11 @@ def _save_to_pandas(df: Union[pd.DataFrame, None], data: dict, stat: str, var: s
:param var: variable the data is from (e.g. 'o3')
:return: new created or concatenated data frame
"""
index = map(lambda s: dt.datetime.strptime(s, "%Y-%m-%d %H:%M"), data['datetime'])
if len(data[0][0]) == 19:
str_format = "%Y-%m-%d %H:%M:%s"
else:
str_format = "%Y-%m-%d %H:%M"
index = map(lambda s: dt.datetime.strptime(s, str_format), data['datetime'])
if df is None:
df = pd.DataFrame(data[stat], index=index, columns=[var])
else:
......@@ -164,4 +168,5 @@ if __name__ == "__main__":
'v': 'average_values', 'no': 'dma8eu', 'no2': 'dma8eu', 'cloudcover': 'average_values',
'pblheight': 'maximum'}
station = 'DEBW107'
download_join(station, var_all_dic)
# download_join(station, var_all_dic, sampling="daily")
download_join(station, var_all_dic, sampling="hourly")
def join_settings(sampling="daily"):
if sampling == "daily":
TOAR_SERVICE_URL = 'https://join.fz-juelich.de/services/rest/surfacedata/'
headers = {}
elif sampling == "hourly":
TOAR_SERVICE_URL = 'https://join.fz-juelich.de/services/rest/surfacedata/'
headers = {"Authorization": "Token 12345"}
else:
raise NameError(f"Given sampling {sampling} is not supported, choose from either daily or hourly sampling.")
return TOAR_SERVICE_URL, headers
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment