Beispiel #1
0
def test_timecon_get_T():
    """verify we get correct time frame"""
    # given
    con_tc = TimeConstraint(np.atleast_2d([0, 0, 0, 119, 0, 1]).T,
                            index=['k', 'x', 'y', 'z', 0, 1],
                            columns=['u_p0'])
    theo_T = 2  # pulls out last two rows
    # when
    T = con_tc.get_T()
    # then
    np.testing.assert_array_equal(theo_T, T)
Beispiel #2
0
    savename = Input.savename[i]
    print('running file ' + savename)
    # import pdb; pdb.set_trace()
    con_tc = TimeConstraint(con_df)  # Constraining in time
    con_tc.index = con_tc.index.map(lambda x: float(x)
                                    if (x not in 'kxyz') else x)

    # Inputs to constrained Turbulence:
    spat_df = gen_spat_grid(GridY.iloc[0, :], GridZ.iloc[
        0, :])  # create our spatial pandas dataframe with our grid data.
    kwargs = {
        'u_ref': Variables.iloc[0, 2],
        'z_ref': Variables.iloc[0, 4],
        'z_hub':
        Variables.iloc[0, 4],  # necessary keyword arguments for IEC turbulence
        'T': con_tc.get_T(),
        'dt': con_tc.get_time().index[1],
        'turb_class': Variables.iloc[0, -1],
        'alpha': Variables.iloc[0, -2],
        'seed': Variables.iloc[0, 9]
    }  # simulation length (s) and time step (s)

    wsp_funcin = Variables.iloc[0, 6]
    sig_funcin = Variables.iloc[0, 7]
    spec_funcin = Variables.iloc[0, 8]
    interp_data2 = Variables.iloc[0, 10]
    nf_chunkin = Variables.iloc[0, 3]
    coh_model_in = Variables.iloc[0, 5]

    if interp_data2 == "Take_list":
        # here we have to define all the cases in wsp_func, spec_func and sig_func that we want to use as inputs for "gen_turb":
Beispiel #3
0
print('>>> Case:   {}'.format(Case))
print('>>> Suffix: {}'.format(Suffix))
print('>>> Write:  {} {}'.format(write_freq_data,combine_freq_data))
print('>>> y:      {} {} {}'.format(ymin,ymax,ny))
print('>>> z:      {} {} {}'.format(zmin,zmax,nz))
h_hub=57;
pkl_file = '{}{}.pkl'.format(Case,Suffix)
pkl_space = '{}{}_space.pkl'.format(Case,Suffix)
con_file = '35Hz_data/{}_pyConTurb_tc.csv'.format(Case)

# --- Constraint time series
con_tc = TimeConstraint(pd.read_csv(con_file, index_col=0))  # load data from csv directly into tc
con_tc.index = con_tc.index.map(lambda x: float(x) if (x not in 'kxyz') else x)  # index cleaning
time_df = con_tc.get_time()
dt      = con_tc.get_time().index[1]
T       = con_tc.get_T()-dt          # TODO
print('>>> Pkl : {}Mb'.format(0.07*ny*nz))
print('>>> T, dt:',T,dt)

# --- Fitting power law and sigma
# alpha,u_ref, my_wsp_func,veer_func = get_wsp_func(con_tc, h_hub, plot   = False)
# my_sig_func                        = get_sigma_func(con_tc, plot = False)
if Case=='A1':
    def my_sig_func(k, y, z, **kwargs):
        sig = np.zeros(y.shape)
        sig[k==0] =  0.46577620264919134*np.exp(-0.009459702869284256*z[k==0])+0.5242096170226613
        sig[k==1] =  0.32501065767141885*np.exp(-0.009059732365499604*z[k==1])+0.4664357892808409
        sig[k==2] =  0.25265083664918636*np.exp(-0.00816719396912162 *z[k==2])+0.27864558900332614
        return sig
    alpha=0.09501
    u_ref=8.86407