Skip to content
Snippets Groups Projects
Commit 3f81b281 authored by Mads M. Pedersen's avatar Mads M. Pedersen
Browse files

update timeseries section in RunWindFarmSimulation.ipynb + add time interpolation support in XRSite

parent 9c859b8c
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
......@@ -96,7 +96,7 @@ class XRSite(Site):
ix = tuple([(slice(None), indices)[dim == i] for dim in range(data.ndim)])
return data[ix]
ip_dims = [n for n in ['i', 'x', 'y', 'h', 'wd', 'ws'] if n in var.dims] # interpolation dimensions
ip_dims = [n for n in ['i', 'x', 'y', 'h', 'time', 'wd', 'ws'] if n in var.dims] # interpolation dimensions
data = var.data
data_dims = var.dims
......@@ -121,7 +121,10 @@ class XRSite(Site):
# pre select, i.e. reduce input data size in case only one ws or wd is needed
data, k_indices = pre_sel(data, 'ws')
data, l_indices = pre_sel(data, 'wd')
if 'time' in coords:
data, l_indices = pre_sel(data, 'time')
else:
data, l_indices = pre_sel(data, 'wd')
if 'i' in ip_dims:
if 'i' in coords and len(var.i) != len(coords['i']):
......@@ -165,8 +168,12 @@ class XRSite(Site):
# if 'i' in var.dims:
# ip_data_dims.insert(0, 'i')
if l_indices is not None:
ip_data_dims.append('wd')
ip_data = sel(ip_data, ip_data_dims, l_indices, 'wd')
if 'time' in coords:
ip_data_dims.append('time')
ip_data = sel(ip_data, ip_data_dims, l_indices, 'time')
else:
ip_data_dims.append('wd')
ip_data = sel(ip_data, ip_data_dims, l_indices, 'wd')
if k_indices is not None:
ip_data_dims.append('ws')
ip_data = sel(ip_data, ip_data_dims, k_indices, 'ws')
......
No preview for this file type
......@@ -377,13 +377,17 @@ def test_time_series_values():
def test_time_series_dates():
import pandas as pd
import xarray as xr
d = np.load(tfp + "time.npz")
wd, ws = [d[k][:6 * 24] for k in ['wd', 'ws']]
wd, ws, ws_std = [d[k][:6 * 24] for k in ['wd', 'ws', 'ws_std']]
ti = np.minimum(ws_std / ws, .5)
t = pd.date_range("2000-01-01", freq="10T", periods=24 * 6)
wt = V80()
site = Hornsrev1Site()
site.ds['TI'] = xr.DataArray(ti, [('time', t)])
x, y = site.initial_position.T
wfm = NOJ(site, wt)
t = pd.date_range("2000-01-01", freq="10T", periods=24 * 6)
sim_res = wfm(x, y, ws=ws, wd=wd, time=t, verbose=False)
npt.assert_array_equal(sim_res.WS, ws)
npt.assert_array_equal(sim_res.WD, wd)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment