Esempio n. 1
0
#%%
#   Opens and reads in the acoustic and TAC data from the h5 files
with h5py.File(os.path.join(dir, 'acs_data.h5'), 'r') as dat_file:
    acs_data = (dat_file['Acoustic Data'][:].transpose() / (dat_file['Sensitivities'][:] * 1e-3))
    ttl = dat_file['Motor1 RPM'][()]
    fs_acs = dat_file['Sampling Rate'][()]
    fs_ttl = round((np.mean(np.diff(dat_file['Time (s)'])))**-1)

#%%
# generates time vectors for the tac and acoustic data
t = np.arange(len(ttl)) / fs_ttl
t_acs = np.arange(len(acs_data)) / fs_acs

#%%

LE_ind1, lim_ind1, rpm_nom1, u_rpm1 = fun.rpm_eval(ttl,fs_ttl,start_t,end_t)

ind = list(map(lambda x: bisect(t_acs,x),t[LE_ind1[lim_ind1[0]:lim_ind1[1]]]))
f,fs1,spl,u_low, u_high, Xn_avg,Xm_avg,Xn_avg_filt,Xn_bb = fun.harm_extract(acs_data, ind, fs_acs, 0, harm_filt,filt_shaft_harm=True,Nb = 2)

f_bb,Xm_bb,Sxx_bb,Gxx_bb,Gxx_avg_bb = fun.msPSD(Xn_bb, fs = fs1, df = df, save_fig = False, plot = False)

# construct time vector for the averaged rpm waveform
t_rev = (np.arange(len(Xn_avg))*(rpm_nom1/60)**-1/len(Xn_avg))

#%%

#   Initializes figure with the number of subplots equal to the number of mics specified in the "mics" list
fig,ax = plt.subplots(len(mics),1,figsize = (8,6))
#   Adds a space in between the subplots and at the bottom for the subplot titles and legend, respectfully.
plt.subplots_adjust(hspace = 0.35,bottom = 0.15)
#%% Spherical spreading correction

micR = np.array([
    65.19, 62.97, 61.34, 60.34, 60.00, 60.34, 61.34, 62.97, 65.19, 67.93,
    71.14, 74.75
])
exp = exp * micR / micR[4]

#%% Sync average experimental measurements

Nb = 2
t = np.arange(len(ttl)) / fs_ttl
t_acs = np.arange(len(exp)) / fs_exp

LE_ind, lim_ind, rpm_nom, u_rpm = fun.rpm_eval(ttl, fs_ttl, start_t, end_t)
ind = list(map(lambda x: bisect(t_acs, x), t[LE_ind[lim_ind[0]:lim_ind[1]]]))

#%%

f_exp, fs1, spl, u_low, u_high, Xn_avg, Xm_avg, Xn_avg_filt, Xn_bb = fun.harm_extract(
    exp,
    tac_ind=ind,
    fs=fs_exp,
    rev_skip=0,
    harm_filt=harm_filt,
    filt_shaft_harm=True,
    Nb=Nb)

xn_inph = ifft((Xm_avg[:, mics[0] - 1] + Xm_avg[:, mics[-1] - 1]) / 2) * fs1
Esempio n. 3
0
#%%
#   Opens and reads in the acoustic and TAC data from the h5 files

with h5py.File(os.path.join(dir, 'acs_data.h5'), 'r') as dat_file:
    ttl_1 = dat_file['Motor1 RPM'][()]
    ttl_2 = dat_file['Motor2 RPM'][()]
    fs_acs = dat_file['Sampling Rate'][()]
    fs_ttl = round((np.mean(np.diff(dat_file['Time (s)'])))**-1)

#%%
# generates time vectors for the tac and acoustic data
t = np.arange(len(ttl_1))/fs_ttl

# evaluates the leading edge of the tac pulses, start/end time rpm indices, nominal rpm, and rpm confidence limit for
# each rotor.
LE_ind1, lim_ind1, rpm_nom1, u_rpm1 = fun.rpm_eval(ttl_1,fs_ttl,start_t,end_t)
LE_ind2, lim_ind2, rpm_nom2, u_rpm2 = fun.rpm_eval(ttl_2,fs_ttl,start_t,end_t)

if abs(rpm_nom1-rpm_nom2)/rpm_nom2 > 0.01:
    print('Caution: The difference between the rotational rates of the upper and lower rotors are significant. This '
          'technique may not yield accurate results.')

# averages the nominal rpm between the upper and lower rotor for the separated case
rpm_avg = np.mean((rpm_nom1,rpm_nom2))

# number of total revs considered
Nrev = int(np.floor((end_t-start_t)*rpm_avg/60))

# computes the azimuthal offset between the upper and lower rotor for the separated cases (lower-upper)
dphi = (LE_ind1[lim_ind1[0]:lim_ind1[0]+Nrev]-LE_ind2[lim_ind2[0]:lim_ind2[0]+Nrev])/fs_ttl*rpm_avg/60*360
# uses the indices of the upper rotor to generate the resulting time vector