from Thermal_Models import read_database, clean_paired_data, gmean, normalise, weighted_std, weighted_amean import numpy as np import pandas as pd print('\n\tCalculating EG values...\n') agg_data = read_database('../Data/summaries/non_aggregate_data_fix.csv') gb_cols = [['ConKingdom'], ['RespiratoryPathway'], ['TempPref', 'ConKingdom'], ['RespiratoryPathway', 'TempPref']] #calculate ES as the weighted geometric mean def ES(g): pair_data = agg_data.ix[g.index]['E_std'] return weighted_amean(g, pair_data, normalise_weights=True) #calculate ES certainty as the weighted standard deviation def ES_min(g): pair_data = np.array(agg_data.ix[g.index]['E_std']) g = np.array(g) length = len(g) bootvals = [] for i in range(1000): indices = np.random.choice(length, length) g_boot = g[indices] pair_boot = pair_data[indices] bootvals.append(
estimate_uncertainty, \ bootstrap_model import numpy as np import pandas as pd from datetime import datetime import warnings warnings.simplefilter( action="ignore", category=FutureWarning ) #Probably ought to deal with this, but for the moment I'll sweep it under the rug. warnings.simplefilter(action="ignore", category=RuntimeWarning) starttime = datetime.now() data_path = '../Data/database.csv' data = read_database(data_path) Datasets = split_datasets( data) #return a dictionary of growth curves split by ID #names of the models I want to fit as strings model_names = ['schoolfield_two_factor_tpk'] all_models = [] #place to put fitted models #Column names of parameters I want to use as explanatory variables when I analyse the data aux_parameters = [ 'FinalID', 'OriginalID', 'Citation', 'Latitude', 'Longitude', 'ConKingdom', 'ConPhylum', 'ConClass', 'ConOrder', 'ConFamily', 'ConGenus', 'ConSpecies', 'OptimalConditions', 'ConLabGrowthTemp' ] for i in Datasets.keys(): #Iterate through the dictionary by key
import pandas as pd import numpy as np from Thermal_Models import read_database, clean_paired_data, gmean, normalise, weighted_std, weighted_amean print('\n\tAggregating Summary...\n') def mesophile_thermophile(entry): if entry > 323.15: return 'Thermophile' else: return 'Mesophile' agg_data = read_database('../Data/summaries/summary.csv') agg_data = agg_data[(agg_data.Citation != "Mackey et al. (2013)")] # I really don't trust this data having looked at it (it came from BioTraits, not us) - TS colnames = list(agg_data.columns.values) #columns to keep keep = ['Species', 'Trait', 'ConKingdom', 'ConPhylum', 'ConClass', 'ConOrder', 'ConFamily', 'ConGenus', 'RespiratoryPathway', 'Max_response', 'Est_Tpk', 'Rank', 'Points_Before_Peak', 'Tpk_std', 'Response_std', 'E_std', 'E'] #Drop any column not in the keep list for colname in colnames: if colname not in keep: agg_data.drop(colname, 1, inplace=True) #select best fits for growth rates only groups = agg_data[(agg_data.Rank == 1) & (agg_data.Trait == 'Specific Growth Rate') & (agg_data.Points_Before_Peak > 2)] #Rename appropriately groups.rename(columns={'Est_Tpk': 'Est_Tpk', 'Tpk_std': 'Est_Tpk_std', 'Max_response': 'Est_Response',
bootstrap_model, \ split_datasets, \ rank_and_flatten, \ compile_models, \ find_linear_arrhenius, \ estimate_uncertainty import numpy as np import pandas as pd from datetime import datetime import matplotlib.pyplot as plt starttime = datetime.now() summary_path = '../Data/summaries/group_means_non_aggregated.csv' #We will merge results into this data_path = '../Data/summaries/non_aggregate_data_fix.csv' data = read_database(data_path) summary = read_database(summary_path) data = data[(np.isfinite(data.Est_Tpk)) & (np.isfinite(data.Est_Response))] aux_parameters = [] #no supplementary information needed analysis_levels = ['ConKingdom'] #levels at which models should be fitted model_names = ['boltzmann_arrhenius_one_weight_non_linear'] #models to fit for level in analysis_levels: if level == '': hist_axes = True else: hist_axes = False #see readme for more details on this dictionary param_est_flags = {
from Thermal_Models import read_database, clean_paired_data, gmean, normalise, weighted_std, weighted_amean import numpy as np import pandas as pd print('\n\tCalculating EG values...\n') agg_data = read_database( '../Data/summaries/non_aggregate_data_fluxes_best.csv') gb_cols = ['ConKingdom'] #calculate ES as the weighted geometric mean def ES(g): pair_data = agg_data.ix[g.index]['E_std'] return weighted_amean(g, pair_data, normalise_weights=True) #calculate ES certainty as the weighted standard deviation def ES_min(g): pair_data = np.array(agg_data.ix[g.index]['E_std']) g = np.array(g) length = len(g) bootvals = [] for i in range(1000): indices = np.random.choice(length, length) g_boot = g[indices] pair_boot = pair_data[indices] bootvals.append(
schoolfield_original, \ LM, \ read_database, \ fit_models, \ bootstrap_model, \ split_datasets, \ rank_and_flatten, \ compile_models import numpy as np import pandas as pd from datetime import datetime starttime = datetime.now() data_path = '../Data/summaries/aggregate_data.csv' data = read_database(data_path) aux_parameters = [] #no supplementary information needed analysis_levels = ['ConKingdom', 'ConPhylum', 'ConClass', 'ConOrder', 'ConFamily', 'ConGenus'] #levels at which models should be fitted model_names = ['Boltzmann_Arrhenius', 'LM'] #models to fit for level in analysis_levels: #set the axis type of the plot based on analysis level. if level == 'ConKingdom': hist_axes = True else: hist_axes = False #see readme for more details on this dictionary param_est_flags = {'Trait_Col_Name': 'Trait', 'X_vals_col_name': 'Est.Tpk',