-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add example or function to make it easier to use your own weather data #9
Comments
Assuming that data_height = {
'pressure': 0,
'temperature': 2,
'wind_speed': 10,
'roughness_length': 0}
new_columns = [(key, data_height[key]) for key in weather.columns]
weather.columns = pd.MultiIndex.from_tuples(new_columns) |
I moved this issue to the v0.1.1 milestone as the feedinlib is not ready, yet.
This is already done. |
I wrote an example to change the structure of a typical DataFrame into our weather format. I put it here to keep it in mind. import pandas as pd
import numpy as np
# This is random data but you could read a csv or excel sheet
# my_weather = pd.read_csv('my_path/my_file.csv')
my_wind_data_at_10m = np.random.rand(10)
my_temperature_data_at_2m = np.random.rand(10)
my_pressure_data_at_0m = np.random.rand(10)
column_names = ['windspeed', 'temp', 'pres']
my_weather = pd.DataFrame(np.array([
my_wind_data_at_10m,
my_temperature_data_at_2m,
my_pressure_data_at_0m]).transpose(),
columns=column_names)
# Rename your columns to the names used in the windpowerlib
translate = {
'windspeed': 'wind_speed',
'temp': 'temperature',
'pres': 'pressure'}
my_weather.rename(translate, inplace=True, axis=1)
# Add the heights of the data as a second column level
heights = [10, 2, 0]
my_weather.columns = pd.MultiIndex.from_arrays([my_weather.columns, heights])
print(my_weather) |
oemof dev:
|
Now addressed in #86. |
I would keep it open as a reminder, therefore I changed the title. I would like to do something similar to the cp-values examples/docs. |
Weather data in the ModelChain currently needs to be a MultiIndex DataFrame. This has on the one hand the drawback that the data height can only be a scalar and on the other hand that it is not easy to use for people who have not worked with pandas alot.
Concerning the first issue I will wait for the feedinlib weather data class and maybe use ideas from it for the windpowerlib, so either also add a class or use xarray directly.
Concerning the second issue we should provide an example how to create a MultiIndex DataFrame.
The text was updated successfully, but these errors were encountered: