Hi @Rogier,
Wow! It worked and BWC dataset was generated.
However now I get another error (pasted below) when I use this BWC dataset to get weibull fit using "windkit.weibull.weibull_fit(bwc, include_met_fields=None, keep_attrs=True)".
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
File <timed exec>:1
File ~\AppData\Roaming\Python\Python39\site-packages\windkit\weibull.py:61, in weibull_fit(bwc, include_met_fields, keep_attrs)
57 # TODO: Add include met_fields here
59 wb = update_var_attrs(wb, _WEIB_ATTRS)
---> 61 return update_history(wb)
File ~\AppData\Roaming\Python\Python39\site-packages\windkit\metadata.py:460, in update_history(ds)
458 current_utc = datetime.utcnow().replace(microsecond=0).isoformat()
459 package = __name__.split(".")[0]
--> 460 function_call = inspect.stack()[2].code_context[0][:-1]
462 if "=" in function_call:
463 function_call = function_call[function_call.index("=") + 1 :]
TypeError: 'NoneType' object is not subscriptable
MRE as follows.
import windkit
import pandas as pd
import random
import xarray as xr
# Function to make dummy dataframe
def dummy_df(size):
df = pd.DataFrame(zip([random.uniform(0, 25) for i in range(size)], [random.uniform(0, 360) for i in range(size)]),
index=pd.date_range("01-01-2023 00:00:00", periods=size, freq="10T"), columns=['wind_speed', 'wind_direction'])
df.index.name = 'time'
df = np.round(df, 2)
return df
# Dummy pandas dataframe
DF = dummy_df(144)
# Dataframe to xarray dataset
DS = xr.Dataset.from_dataframe(DF)
# Assigning coords to dataset
DS = DS.assign_coords({"west_east":0,"south_north":0,"height":90.0})
# Adding CRS to dataset
windkit.add_crs(DS, 4326)
# Windkit binned wind climate from timeseries
bwc = windkit.binned_wind_climate.bwc_from_timeseries(DS, ws_bin_width=1, nwsbin=35,
nsec=12, normalize=True, crs=None)
# Fitting windkit weibull
weibull = windkit.weibull.weibull_fit(bwc, include_met_fields=None, keep_attrs=False)
What possibly could be wrong here? 😅
BR
Omer