def dB(day, peak_datetimes, instrument, current_dif, windows, probe_list, plot = False, lowpass = False, rand_noise=True): #for only one instrument if day == 1: if windows: path_fol_A = r'C:\Users\jonas\MSci-Data\day_one\A' path_fol_B = r'C:\Users\jonas\MSci-Data\day_one\B' else: path_fol_A = os.path.expanduser("~/Documents/MSciProject/Data/day_one/A") path_fol_B = os.path.expanduser("~/Documents/MSciProject/Data/day_one/B") elif day == 2: if windows: path_fol_A = r'C:\Users\jonas\MSci-Data\day_two\A' path_fol_B = r'C:\Users\jonas\MSci-Data\day_two\B' else: path_fol_A = os.path.expanduser("~/Documents/MSciProject/Data/day_two/A") path_fol_B = os.path.expanduser("~/Documents/MSciProject/Data/day_two/B") #set start and end time to first and last current jump time with a 3 minute buffer either side start_dt = peak_datetimes[0] - pd.Timedelta(minutes = 3) end_dt = peak_datetimes[-1] + pd.Timedelta(minutes = 3) sampling_freq = 1 #do we want to remove the high freq noise? start_csv_A, end_csv_A = processing.which_csvs(True, day ,start_dt, end_dt, tz_MAG = True) start_csv_B, end_csv_B = processing.which_csvs(False, day ,start_dt, end_dt, tz_MAG = True) print(start_csv_A, end_csv_A) all_files_A = [0]*(end_csv_A + 1 - start_csv_A) #finding all the csv files that we need from the start and end time if day == 1: for index, j in enumerate(range(start_csv_A, end_csv_A + 1)): #this will loop through and add the csv files that contain the start and end time set above if windows: all_files_A[index] = path_fol_A + f'\SoloA_2019-06-21--08-10-10_{j}.csv' else: all_files_A[index] = path_fol_A + os.path.expanduser(f'/SoloA_2019-06-21--08-10-10_{j}.csv') #need to change path_fol_A to the path where your A folder is all_files_B = [0]*(end_csv_B + 1 - start_csv_B) for index, j in enumerate(range(start_csv_B, end_csv_B + 1)): if windows: all_files_B[index] = path_fol_B + f'\SoloB_2019-06-21--08-09-10_{j}.csv' else: all_files_B[index] = path_fol_B + os.path.expanduser(f'/SoloB_2019-06-21--08-09-10_{j}.csv') #need to change path_f if day == 2: for index, j in enumerate(range(start_csv_A, end_csv_A + 1)): #this will loop through and add the csv files that contain the start and end time set above if windows: all_files_A[index] = path_fol_A + f'\SoloA_2019-06-24--08-14-46_{j}.csv' else: all_files_A[index] = path_fol_A + os.path.expanduser(f'/SoloA_2019-06-24--08-14-46_{j}.csv') #need to change path_fol_A to the path where your A folder is all_files_B = [0]*(end_csv_B + 1 - start_csv_B) for index, j in enumerate(range(start_csv_B, end_csv_B + 1)): if windows: all_files_B[index] = path_fol_B + f'\SoloB_2019-06-24--08-14-24_{j}.csv' else: all_files_B[index] = path_fol_B + os.path.expanduser(f'/SoloB_2019-06-24--08-14-24_{j}.csv') #need to change path_f vect_dict = {} for i in probe_list: #looping through each sensor if i < 8: soloA_bool = True all_files = all_files_A else: soloA_bool = False all_files = all_files_B if i < 9: num_str = f'0{i+1}' else: num_str = i+1 collist = ['time', f'Probe{num_str}_X', f'Probe{num_str}_Y', f'Probe{num_str}_Z'] #reads csv files and rotates to spacecraft frame if soloA_bool: df = processing.read_files(all_files, soloA_bool, sampling_freq, collist, day=day, start_dt = start_dt, end_dt = end_dt) if day == 1: rotate_mat = processing.rotate_21(soloA_bool)[i] else: rotate_mat = processing.rotate_24(soloA_bool)[i] else: df = processing.read_files(all_files, soloA_bool, sampling_freq, collist, day=day, start_dt = start_dt, end_dt = end_dt) if day == 1: rotate_mat = processing.rotate_21(soloA_bool)[i-8] else: rotate_mat = processing.rotate_24(soloA_bool)[i-8] df.iloc[:,0:3] = np.matmul(rotate_mat, df.iloc[:,0:3].values.T).T df = processing.shifttime(df, soloA_bool, day) # must shift MFSA data to MAG/spacecraft time df = df.between_time(start_dt.time(), end_dt.time()) #lowpass filter to remove high frequency signals if lowpass: def butter_lowpass(cutoff, fs, order=10): nyq = 0.5 * fs normal_cutoff = cutoff / nyq b, a = butter(order, normal_cutoff, btype='low', analog=False) return b, a def butter_lowpass_filter(data, cutoff, fs, order=10): b, a = butter_lowpass(cutoff, fs, order=order) y = lfilter(b, a, data) return y cutoff = 15 fs = sampling_freq for axis in ['X','Y','Z']: df[f'Probe{num_str}_{axis}'] = butter_lowpass_filter(df[f'Probe{num_str}_{axis}'], cutoff, fs) step_dict = processing.calculate_dB(df, peak_datetimes) #get data for dI xdata = list(current_dif[:len(peak_datetimes)]) print(xdata) #get data for dB probe_x_tmp = step_dict.get(f'Probe{num_str}_X') probe_y_tmp = step_dict.get(f'Probe{num_str}_Y') probe_z_tmp = step_dict.get(f'Probe{num_str}_Z') probe_x_tmp_err = step_dict.get(f'Probe{num_str}_X err') probe_y_tmp_err = step_dict.get(f'Probe{num_str}_Y err') probe_z_tmp_err = step_dict.get(f'Probe{num_str}_Z err') #force zero forces the fir through the origin by adding this as a point - should theoretically go through the origin force_zero = False if force_zero: xdata.append(0.0) probe_x_tmp.append(0.0) probe_y_tmp.append(0.0) probe_z_tmp.append(0.0) probe_x_tmp_err.append(0.0) #error on bonus point should be zero, but curve_fit requires finite error - and this forces the line through the origin anyway probe_y_tmp_err.append(0.0) probe_z_tmp_err.append(0.0) if rand_noise: #takes random noise and adds it in quadrature with the standard error of averaging if day == 1: err_path = f'..\\Results\\day1_mfsa_probe_vars.csv' elif day == 2: err_path = f'..\\Results\\day2_mfsa_probe_vars.csv' df_err_correction = pd.read_csv(err_path) df_err = df_err_correction.iloc[i] #print(df_err, i, num_str) probe_x_tmp_err = [df_err['Bx_var'] for k in range(len(xdata))]#[np.sqrt(k**2 + df_err['Bx_var']**2) for k in probe_x_tmp_err] probe_y_tmp_err = [df_err['By_var'] for k in range(len(xdata))]#[np.sqrt(k**2 + df_err['By_var']**2) for k in probe_y_tmp_err] probe_z_tmp_err = [df_err['Bz_var'] for k in range(len(xdata))]#[np.sqrt(k**2 + df_err['Bz_var']**2) for k in probe_z_tmp_err] def line(x,a,b): return a*x + b params_x,cov_x = spo.curve_fit(line, xdata, probe_x_tmp[:], sigma = probe_x_tmp_err[:], absolute_sigma = True) params_y,cov_y = spo.curve_fit(line, xdata, probe_y_tmp[:], sigma = probe_y_tmp_err[:], absolute_sigma = True) params_z,cov_z = spo.curve_fit(line, xdata, probe_z_tmp[:], sigma = probe_z_tmp_err[:], absolute_sigma = True) perr_x = np.sqrt(np.diag(cov_x)) perr_y = np.sqrt(np.diag(cov_y)) perr_z = np.sqrt(np.diag(cov_z)) print('spo.curve_fit') print('Slope = ', params_x[0], '+/-', perr_x[0], 'Intercept = ', params_x[1], '+/-', perr_x[1]) print('Slope = ', params_y[0], '+/-', perr_y[0], 'Intercept = ', params_y[1], '+/-', perr_y[1]) print('Slope = ', params_z[0], '+/-', perr_z[0], 'Intercept = ', params_z[1], '+/-', perr_z[1]) else: X = spstats.linregress(xdata, probe_x_tmp) #adding bonus point has little effect on grad - only changes intercept Y = spstats.linregress(xdata, probe_y_tmp) Z = spstats.linregress(xdata, probe_z_tmp) print('sps.linregress') print('Slope = ', X.slope, '+/-', X.stderr, ' Intercept = ', X.intercept) print('Slope = ', Y.slope, '+/-', Y.stderr, ' Intercept = ', Y.intercept) print('Slope = ', Z.slope, '+/-', Z.stderr, ' Intercept = ', Z.intercept) if plot: plt.figure() if rand_noise: plt.plot(xdata, params_x[0]*np.array(xdata) + params_x[1], 'b:', label = f'curve_fit - X grad: {round(params_x[0],2)} ± {round(perr_x[0],2)} int: {round(params_x[1],2)} ± {round(perr_x[1],2)}') plt.plot(xdata, params_y[0]*np.array(xdata) + params_y[1], 'r:', label = f'curve_fit - Y grad: {round(params_y[0],2)} ± {round(perr_y[0],2)} int: {round(params_y[1],2)} ± {round(perr_y[1],2)}') plt.plot(xdata, params_z[0]*np.array(xdata) + params_z[1], 'g:', label = f'curve_fit - Z grad: {round(params_z[0],2)} ± {round(perr_z[0],2)} int: {round(params_z[1],2)} ± {round(perr_z[1],2)}') elif rand_noise == False: plt.plot(xdata, X.intercept + X.slope*np.array(xdata), 'b-', label = f'X grad: {round(X.slope,2)} ± {round(X.stderr,2)} int: {round(X.intercept, 2)}') plt.plot(xdata, Y.intercept + Y.slope*np.array(xdata), 'r-', label = f'Y grad: {round(Y.slope,2)} ± {round(Y.stderr,2)} int: {round(Y.intercept, 2)}') plt.plot(xdata, Z.intercept + Z.slope*np.array(xdata), 'g-', label = f'Z grad: {round(Z.slope,2)} ± {round(Z.stderr,2)} int: {round(Z.intercept, 2)}') plt.errorbar(xdata, probe_x_tmp, yerr = probe_x_tmp_err, fmt = 'bs', markeredgewidth = 2) plt.errorbar(xdata, probe_y_tmp, yerr = probe_y_tmp_err, fmt = 'rs', markeredgewidth = 2) plt.errorbar(xdata, probe_z_tmp, yerr = probe_z_tmp_err, fmt = 'gs', markeredgewidth = 2) plt.legend(loc="best") plt.title(f'{instrument} - Probe {num_str} - MFSA - Day {day_number}') plt.xlabel('dI [A]') plt.ylabel('dB [nT]') plt.show() save_all = False if save_all: dBdI = {} for dI in range(len(xdata)): dBdI[f'{dI+1}'] = [xdata[dI],probe_x_tmp[dI],probe_x_tmp_err[dI],probe_y_tmp[dI],probe_y_tmp_err[dI],probe_z_tmp[dI],probe_z_tmp_err[dI]] w = csv.writer(open(f"..\\Results\\dBdI_data\\Day{day_number}\\1Hz_with_err\\{instrument}\\{instrument}_probe{i+1}_vect_dict_1Hz_day{day_number}.csv", "w")) w.writerow(["key","dI","dB_X","dB_X_err","dB_Y","dB_Y_err","dB_Z","dB_Z_err"]) for key, val in dBdI.items(): w.writerow([key,val[0],val[1],val[2],val[3],val[4],val[5],val[6]])#,val[9],val[10],val[11]]) if rand_noise: vect_dict[f'{i+1}'] = [params_x[0], params_y[0], params_z[0], perr_x[0], perr_y[0], perr_z[0], params_x[1], params_y[1], params_z[1], perr_x[1], perr_y[1], perr_z[1]] else: vect_dict[f'{i+1}'] = [X.slope, Y.slope, Z.slope,X.stderr,Y.stderr,Z.stderr, X.intercept ,Y.intercept, Z.intercept] ##,params_x[0],params_y[0],params_z[0],perr_x[0],perr_y[0],perr_z[0]] #atm linear regression gradient - or should it be curve_fit? return vect_dict
def day_two(windows, probe_num_list, start_dt, end_dt, *, alt=False, sampling_freq=None, plot=True, spectrogram=False, powerspec=False, inst_name=None): """day_two(windows, probe_num_list, start_dt, end_dt, *, alt = False, sampling_freq = None, plot = True, spectrogram = False, powerspec = False, inst_name=None) --> used to analyse day 2 MFSA data Parameters: windows: first arg. Determines if using Windows or Mac path probe_num_list: second arg. List of probe numbers as integers that are desired start_dt: third arg. Start datetime for timespan interested in end_dt: fourth arg. End datetime for timespan interested in Keyword Args: alt: fifth arg. If True uses brute force fft method rather than inbuilt scipy periodogram to compute power spectra sampling_freq: sixth arg. Determines the desired sampling freqeuncy. If None defaults to 1kHz native. plot: seventh arg. If true plots timeseries of the desired data spectrogram: eigth arg. If true plots spectrogram of the desired data powerspec: ninth arg. If true plots powerspectrum, x,y,z and trace of desired data inst_name: tenth arg. Provides the name of the instrument to go in powerspec suptitle """ if windows: path_fol_A = r'C:\Users\jonas\MSci-Data\day_two\A' path_fol_B = r'C:\Users\jonas\MSci-Data\day_two\B' else: path_fol_A = os.path.expanduser( "~/Documents/MsciProject/Data/day_two/A") path_fol_B = os.path.expanduser( "~/Documents/MsciProject/Data/day_two/B") #here select which probe is desired, only one at a time #num = 12 b_noise = [] for num in probe_num_list: print('num = ', num) if num < 9: soloA_bool = True else: soloA_bool = False if num < 10: num_str = f'0{num}' else: num_str = num collist = [ 'time', f'Probe{num_str}_X', f'Probe{num_str}_Y', f'Probe{num_str}_Z' ] #finding the correct MFSA data files start_csv, end_csv = processing.which_csvs( soloA_bool, 2, start_dt, end_dt, tz_MAG=False ) #this function (in processing.py) finds the number at the end of the csv files we want print(start_csv, end_csv) all_files = [0] * (end_csv + 1 - start_csv) for index, i in enumerate( range(start_csv, end_csv + 1) ): #this will loop through and add the csv files that contain the start and end time set above if soloA_bool: if windows: all_files[ index] = path_fol_A + f'\SoloA_2019-06-24--08-14-46_{i}.csv' else: all_files[index] = path_fol_A + os.path.expanduser( f'/SoloA_2019-06-24--08-14-46_{i}.csv' ) #need to change path_fol_A to the path where your A folder is else: if windows: all_files[ index] = path_fol_B + f'\SoloB_2019-06-24--08-14-24_{i}.csv' else: all_files[index] = path_fol_B + os.path.expanduser( f'/SoloB_2019-06-24--08-14-24_{i}.csv' ) #need to change path_fol_B to the path where your B folder is #set this to the directory where the data is kept on your local computer if soloA_bool: df = processing.read_files(all_files, soloA_bool, sampling_freq, collist, day=2, start_dt=start_dt, end_dt=end_dt) rotate_mat = processing.rotate_24(soloA_bool)[num - 1] else: df = processing.read_files(all_files, soloA_bool, sampling_freq, collist, day=2, start_dt=start_dt, end_dt=end_dt) rotate_mat = processing.rotate_24(soloA_bool)[num - 9] df.iloc[:, 0:3] = np.matmul(rotate_mat, df.iloc[:, 0:3].values.T).T #find the df of the exact time span desired df2 = df.between_time(start_dt.time(), end_dt.time()) dflen = len(df2) #df3 = df2.resample('1s').mean() #shitfing time so the axes are in spacecraft time to compare with current data df2 = processing.shifttime(df2, soloA_bool, 2) if plot: #plotting the raw probes results #plt.figure() df3 = df2.resample('1s').mean() tmp = [] for col in collist[1:]: df2[col] = df2[col] - df2[col].mean() plt.plot(df2.index.time, df2[col], label=str(col)) var_1hz = np.std(df3[col]) var_1khz = np.std(df2[col]) print('std - 1Hz', col, var_1hz) print('std - 1kHz', col, var_1khz) tmp.append(var_1hz) tmp.append(var_1khz) #print(df2[col].abs().idxmax()) plt.xlabel('Time (s)') plt.ylabel('dB (nT)') plt.title(f'Probe {num} @ {sampling_freq}Hz, {start_dt.date()}') plt.legend(loc="best") plt.show() return tmp if spectrogram: x = np.sqrt(df2[collist[1]]**2 + df2[collist[2]]**2 + df2[collist[3]]**2) fs = sampling_freq div = dflen / 1000 #f, Pxx = sps.periodogram(x,fs) #div = 500 nff = dflen // div wind = sps.hamming(int(dflen // div)) f, t, Sxx = sps.spectrogram(x, fs, window=wind, noverlap=int(dflen // (2 * div)), nfft=nff) #,nperseg=700) ax = plt.figure() plt.pcolormesh(t, f, Sxx, vmin=0., vmax=0.03) plt.semilogy() plt.ylabel('Frequency [Hz]') plt.xlabel('Time [sec]') plt.title( f'Spectrogram: Probe {num} @ {sampling_freq}Hz, {start_dt.date()}' ) plt.ylim((10**0, sampling_freq / 2)) plt.clim() fig = plt.gcf() cbar = plt.colorbar() #cbar.ax.set_yticklabels(fontsize=8) cbar.set_label('Normalised Power/Frequency') #, rotation=270) #fig, ax2 = plt.subplots() #Pxx, freqs, bins, im = ax2.specgram(x, Fs=sampling_freq)#, noverlap=900) #ax2.set_yscale('log') #ax2.set_ylim((10**0,sampling_freq/2)) plt.show() if powerspec: if inst_name == None: processing.powerspecplot(df2, sampling_freq, collist, alt, save=False) else: processing.powerspecplot(df2, sampling_freq, collist, alt, inst=inst_name, save=True)
def day_one(windows, probe_num_list, start_dt, end_dt, alt, sampling_freq=None, plot=False, spectrogram=False, powerspec=False): """ all_files - set this to the directory where the data is kept on your local computer collist - list of columns desired soloA_bool - set to True if desire sensors in SoloA channel, else False num - set to the number of the probe desired start_dt - start datetime desired end_dt - end datetime desired alt - boolean - set to True if desire the 'brute force' method for power spectrum rather than periodogram method sampling_freq - set to desired sampling frequency - default = None """ if windows: path_fol_A = r'C:\Users\jonas\MSci-Data\day_one\A' path_fol_B = r'C:\Users\jonas\MSci-Data\day_one\B' else: path_fol_A = os.path.expanduser( "~/Documents/MSciProject/Data/day_one/A") path_fol_B = os.path.expanduser( "~/Documents/MSciProject/Data/day_one/B") #alt - set to true if you want to see power spec using the stnadard method - not the inbuilt funciton #num = 5 #b_noise = [] for num in probe_num_list: print('num = ', num) if num < 9: soloA_bool = True else: soloA_bool = False if num < 10: num_str = f'0{num}' else: num_str = num collist = [ 'time', f'Probe{num_str}_X', f'Probe{num_str}_Y', f'Probe{num_str}_Z' ] day = 1 start_csv, end_csv = processing.which_csvs( soloA_bool, day, start_dt, end_dt, tz_MAG=True ) #this function (in processing.py) finds the number at the end of the csv files we want print(start_csv, end_csv) all_files = [0] * (end_csv + 1 - start_csv) for index, i in enumerate( range(start_csv, end_csv + 1) ): #this will loop through and add the csv files that contain the start and end time set above if soloA_bool: if windows: all_files[ index] = path_fol_A + f'\SoloA_2019-06-21--08-10-10_{i}.csv' else: all_files[index] = path_fol_A + os.path.expanduser( f'/SoloA_2019-06-21--08-10-10_{i}.csv' ) #need to change path_fol_A to the path where your A folder is else: if windows: all_files[ index] = path_fol_B + f'\SoloB_2019-06-21--08-09-10_{i}.csv' else: all_files[index] = path_fol_B + os.path.expanduser( f'/SoloB_2019-06-21--08-09-10_{i}.csv' ) #need to change path_fol_B to the path where your B folder is if soloA_bool: df = processing.read_files(all_files, soloA_bool, sampling_freq, collist, day=1, start_dt=start_dt, end_dt=end_dt) rotate_mat = processing.rotate_21(soloA_bool)[num - 1] else: df = processing.read_files(all_files, soloA_bool, sampling_freq, collist, day=1, start_dt=start_dt, end_dt=end_dt) rotate_mat = processing.rotate_21(soloA_bool)[num - 9] df.iloc[:, 0:3] = np.matmul(rotate_mat, df.iloc[:, 0:3].values.T).T print(len(df)) df2 = df.between_time(start_dt.time(), end_dt.time()) dflen = len(df2) if plot: #plotting the raw probes results plt.figure() tmp = [] df3 = df2.resample('1s').mean() for col in collist[1:]: #plt.plot(df2.index.time, df2[col], label=str(col)) #print(df2[col].abs().idxmax()) var_1hz = np.std(df3[col]) var_1khz = np.std(df2[col]) print('std - 1Hz', col, var_1hz) print('std - 1kHz', col, var_1khz) tmp.append(var_1hz) tmp.append(var_1khz) plt.xlabel('Time (s)') plt.ylabel('B (nT)') plt.title(f'Probe {num} @ {sampling_freq}Hz, {start_dt.date()}') plt.legend(loc="best") plt.show() return tmp if spectrogram: x = np.sqrt(df2[collist[1]]**2 + df2[collist[2]]**2 + df2[collist[3]]**2) fs = sampling_freq div = dflen / 1000 #f, Pxx = sps.periodogram(x,fs) #div = 500 nff = dflen // div wind = sps.hamming(int(dflen // div)) f, t, Sxx = sps.spectrogram(x, fs, window=wind, noverlap=int(dflen // (2 * div)), nfft=nff) #,nperseg=700) ax = plt.figure() plt.pcolormesh(t, f, Sxx, vmin=0., vmax=0.01) plt.semilogy() plt.ylabel('Frequency [Hz]') plt.xlabel('Time [sec]') plt.title( f'Spectrogram: Probe {num} @ {sampling_freq}Hz, {start_dt.date()}' ) plt.ylim((10**0, sampling_freq / 2)) plt.clim() fig = plt.gcf() cbar = plt.colorbar() #cbar.ax.set_yticklabels(fontsize=8) cbar.set_label('Normalised Power/Frequency') #, rotation=270) # fig, ax2 = plt.subplots() # Pxx, freqs, bins, im = ax2.specgram(x, Fs=sampling_freq)#, noverlap=900) # ax2.set_yscale('log') # ax2.set_ylim((10**0,sampling_freq/2)) plt.show() if powerspec: processing.powerspecplot(df2, sampling_freq, collist, alt, save=False)
def get_data(self, windows=True): start = time.time() if windows: os.environ['MFSA_raw'] = 'C:\\Users\\jonas\\MSci-Data' else: os.environ['MFSA_raw'] = os.path.expanduser( '~/Documents/MsciProject/Data') mfsa_init_path = os.environ.get('MFSA_raw') #print(mfsa_init_path) if self.day == 1: mfsa_init_path = os.path.join(mfsa_init_path, 'day_one') elif self.day == 2: mfsa_init_path = os.path.join(mfsa_init_path, 'day_two') #print(mfsa_init_path) mfsa_fol_A = os.path.join(mfsa_init_path, 'A') mfsa_fol_B = os.path.join(mfsa_init_path, 'B') #print(mfsa_fol_A) if self.probe < 9: soloA_bool = True else: soloA_bool = False if self.probe < 10: num_str = f'0{self.probe}' else: num_str = self.probe self.collist = [ 'time', f'Probe{num_str}_X', f'Probe{num_str}_Y', f'Probe{num_str}_Z' ] #finding the correct MFSA data files start_csv, end_csv = processing.which_csvs( soloA_bool, day, self.start, self.end, tz_MAG=False ) #this function (in processing.py) finds the number at the end of the csv files we want print(start_csv, end_csv) all_files = [0] * (end_csv + 1 - start_csv) if self.day == 2: for index, i in enumerate( range(start_csv, end_csv + 1) ): #this will loop through and add the csv files that contain the start and end time set above if soloA_bool: all_files[index] = os.path.join( mfsa_fol_A, f'SoloA_2019-06-24--08-14-46_{i}.csv') else: all_files[index] = os.path.join( mfsa_fol_B, f'SoloB_2019-06-24--08-14-24_{i}.csv') elif self.day == 1: for index, i in enumerate( range(start_csv, end_csv + 1) ): #this will loop through and add the csv files that contain the start and end time set above if soloA_bool: all_files[index] = os.path.join( mfsa_fol_A, f'SoloA_2019-06-21--08-10-10_{i}.csv') else: all_files[index] = os.path.join( mfsa_fol_B, f'SoloB_2019-06-21--08-09-10_{i}.csv') if soloA_bool: self.df = processing.read_files(all_files, soloA_bool, self.fs, self.collist, self.day, start_dt=self.start, end_dt=self.end) if self.day == 2: rotate_mat = processing.rotate_24(soloA_bool)[self.probe - 1] elif self.day == 1: rotate_mat = processing.rotate_21(soloA_bool)[self.probe - 1] else: self.df = processing.read_files(all_files, soloA_bool, self.fs, self.collist, self.day, start_dt=self.start, end_dt=self.end) if self.day == 2: rotate_mat = processing.rotate_24(soloA_bool)[self.probe - 9] elif self.day == 1: rotate_mat = processing.rotate_21(soloA_bool)[self.probe - 9] self.df.iloc[:, 0:3] = np.matmul(rotate_mat, self.df.iloc[:, 0:3].values.T).T #find the df of the exact time span desired self.df = self.df.between_time(self.start.time(), self.end.time()) self.df = processing.shifttime(self.df, soloA_bool, self.day) self.dflen = len(self.df) print(self.df.head()) print(self.df.tail()) print('Data Loaded - Execution Time: ', round(time.time() - start, 2), 'seconds')