# DataFrame of EWS df_ews = ews_dic['EWS metrics'] # DataFrame of Power spectra df_pspec = ews_dic['Power spectrum'] print('Do bootstrapping') #------------------------------------- # Compute EWS using bootstrapping #–---------------------------------- df_samples = ewstools.roll_bootstrap(series, span=span, roll_window=rw, roll_offset=roll_offset, upto=tcrit, n_samples=n_samples, bs_type=bs_type, block_size=block_size) # Execute ews_compute for each bootstrapped time-series # List to store EWS DataFrames list_df_ews = [] # List to store power spectra DataFrames list_pspec = [] # Realtime values tVals = np.array(df_samples.index.levels[0]) # Sample values sampleVals = np.array(df_samples.index.levels[1])
#---------------------- ## Compute EWS of each realisation *with bootstrapping* #--------------------- print('\nBegin bootstrapped EWS computation\n') # Make list of samples from each realisation samples_list = [] for i in range(numSims): # Compute samples for particular realisation df_samples_temp = ewstools.roll_bootstrap(df_traj.loc[i + 1]['x'], span=span, roll_window=rw, roll_offset=roll_offset, upto=tcrit, n_samples=n_samples, bs_type=bs_type, block_size=block_size) # Add realisation number df_samples_temp['Realisation number'] = i + 1 # Add dataframe to list samples_list.append(df_samples_temp) # Concatenate into a full DataFrame of sample time-series df_samples = pd.concat(samples_list).reset_index().set_index( ['Realisation number', 'Time', 'Sample', 'Wintime']) # Execute ews_compute for each bootstrapped time-series