|
3 | 3 |
|
4 | 4 | import pandas as pd |
5 | 5 | import logging |
6 | | -import os |
7 | | -import requests |
8 | 6 |
|
9 | 7 | try: |
10 | 8 | from matplotlib import pyplot as plt |
|
40 | 38 | 'wind_conv_type': 'VESTAS V 90 3000'} |
41 | 39 |
|
42 | 40 |
|
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 | | - |
64 | 41 | def ready_example_data(filename, datetime_column='Unnamed: 0'): |
65 | 42 | df = pd.read_csv(filename) |
66 | 43 | return df.set_index(pd.to_datetime(df[datetime_column])).tz_localize( |
67 | 44 | 'UTC').tz_convert('Europe/Berlin').drop(datetime_column, 1) |
68 | 45 |
|
69 | 46 |
|
70 | | -filename1, filename2 = fetch_example_files() |
71 | | - |
72 | 47 | # Loading weather data |
73 | | -weather_df = ready_example_data(filename1) |
| 48 | +weather_df = ready_example_data('weather.csv') |
74 | 49 |
|
75 | 50 | e126 = basicmodel.SimpleWindTurbine(**enerconE126) |
76 | 51 | v90 = basicmodel.SimpleWindTurbine(**vestasV90) |
|
0 commit comments