Jump to content

Omer Khan

Members
  • Posts

    3
  • Joined

  • Last visited

Omer Khan's Achievements

  1. Hi @Neil Davis, Appreciate your prompt reply. I was using jupyter lab, it didn't work there but yes it worked in Spyder (Ipython). Thanks to you and your team for publishing this amazing library. Highly appreciate support on this forum and the efforts for this library. 🙂 BR Omer
  2. 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
  3. Hi @Andrea Vignaroli Ørsted & @Neil Davis, @Andrea Vignaroli Ørsted did you manage to make binned_wind_climate from pandas time-series datafrme? I tried making xarray dataset from pandas dataframe and then using the xarray dataset to "windkit.binned_wind_climate.bwc_from_timeseries", however I get some errors. My pandas dataframe (DF) has two columns wind_speed & wind_direction and index as time (see table below). time wind_speed wind_direction 2012-10-30 23:00:00 5.11 209.1 2012-10-30 23:10:00 5.42 244.6 2012-10-30 23:20:00 5.22 220.6 Minimal reproducible example of my code with dummy data is: 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 # Pandas dataframe DF = dummy_df(6*24*365) # dataframe to xarray dataset DS = xr.Dataset.from_dataframe(DF) # 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) The errors that I get are, WindClimateValidationError: validate found 4 errors 1. Missing coordinate: south_north 2. Missing coordinate: west_east 3. Missing coordinate: height 4. Missing coordinate: crs I tried manually adding these missing coordinates (dummy values) to xarray dataset (DS) with following code. # Manually making missing xarray coordinates for DS height = xr.DataArray([90], dims='point', coords={'point': [0]}) DS.coords['height'] = height south_north = xr.DataArray([0], dims='point', coords={'point': [0]}) DS.coords['south_north'] = south_north west_east = xr.DataArray([0], dims='point', coords={'point': [0]}) DS.coords['west_east'] = west_east crs = xr.DataArray([0], dims='point', coords={'point': [0]}) DS.coords['crs'] = crs After this, I get new error that is, KeyError: 'crs_wkt' I also manually added a DataArray "crs_wkt" to the DS dataset but it doesn't work. Any pointers where things are being done wrong? Thank you 🙂
×
×
  • Create New...