Skip to content

Commit b34a547

Browse files
committed
add example data to repository instead of downloading it from external ever
The external solver will be offline due to technical problems so it might be better not be reliant on external servers.
1 parent 9c1bdd7 commit b34a547

File tree

2 files changed

+8762
-26
lines changed

2 files changed

+8762
-26
lines changed

example/basic_example.py

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
import pandas as pd
55
import logging
6-
import os
7-
import requests
86

97
try:
108
from matplotlib import pyplot as plt
@@ -40,37 +38,14 @@
4038
'wind_conv_type': 'VESTAS V 90 3000'}
4139

4240

43-
def download_file(filename, url):
44-
if not os.path.isfile(filename):
45-
logging.info('Copying weather data from {0} to {1}'.format(
46-
url, filename))
47-
req = requests.get(url)
48-
with open(filename, 'wb') as fout:
49-
fout.write(req.content)
50-
51-
def fetch_example_files():
52-
basic_path = os.path.join(os.path.expanduser("~"), '.oemof')
53-
filename_1 = os.path.join(basic_path, 'weather.csv')
54-
url1 = 'http://vernetzen.uni-flensburg.de/~git/weather.csv'
55-
filename_2 = os.path.join(basic_path, 'weather_wittenberg.csv')
56-
url2 = 'http://vernetzen.uni-flensburg.de/~git/weather_wittenberg.csv'
57-
if not os.path.exists(basic_path):
58-
os.makedirs(basic_path)
59-
download_file(filename_1, url1)
60-
download_file(filename_2, url2)
61-
return filename_1, filename_2
62-
63-
6441
def ready_example_data(filename, datetime_column='Unnamed: 0'):
6542
df = pd.read_csv(filename)
6643
return df.set_index(pd.to_datetime(df[datetime_column])).tz_localize(
6744
'UTC').tz_convert('Europe/Berlin').drop(datetime_column, 1)
6845

6946

70-
filename1, filename2 = fetch_example_files()
71-
7247
# Loading weather data
73-
weather_df = ready_example_data(filename1)
48+
weather_df = ready_example_data('weather.csv')
7449

7550
e126 = basicmodel.SimpleWindTurbine(**enerconE126)
7651
v90 = basicmodel.SimpleWindTurbine(**vestasV90)

0 commit comments

Comments
 (0)