<commit_before>from __future__ import division
import logging
import numpy as np
import pandas as pd
import sqlite3

from sqlalchemy import Column, Table,Integer, Float, String, create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker, scoped_session
from sqlalchemy import *
metadata = MetaData()
from base.uber_model import UberModel, ModelSharedInputs


class AgdriftInputs(ModelSharedInputs):
    """
    Input class for Agdrift.
    """

    def __init__(self):
        """Class representing the inputs for TerrPlant"""
        super(AgdriftInputs, self).__init__()
        self.application_rate = pd.Series([], dtype="float")
        self.application_method = pd.Series([], dtype="object")
        self.drop_size = pd.Series([], dtype="object")
        self.ecosystem_type = pd.Series([], dtype="object")
        self.boom_height = pd.Series([], dtype="object")
        self.orchard_type = pd.Series([], dtype="object")
        self.aquatic_type = pd.Series([], dtype="object")
        self.calculation_input = pd.Series([], dtype="object")
        self.distance = pd.Series([], dtype="float")


class AgdriftOutputs(object):
    """
    Output class for Agdrift.
    """

    def __init__(self):
        """Class representing the outputs for Agdrift"""
        super(AgdriftOutputs, self).__init__()
        self.out_init_avg_dep_foa = pd.Series(name="out_init_avg_dep_foa").astype("float")
        self.out_avg_depo_lbac = pd.Series(name="out_avg_depo_lbac").astype("float")
        self.out_avg_depo_gha = pd.Series(name="out_avg_depo_gha").astype("float")
        self.out_deposition_ngl = pd.Series(name="out_deposition_ngl").astype("float")
        self.out_deposition_mgcm = pd.Series(name="out_deposition_mgcm").astype("float")
        self.out_nasae = pd.Series(name="out_nasae").astype("int")
        self.out_y = pd.Series(name="out_y").astype("object")
        self.out_x = pd.Series(name="out_x").astype("object")
        self.out_express_y = pd.Series(name="out_express_y").astype("object")


class Agdrift(UberModel, AgdriftInputs, AgdriftOutputs):
    """
    Agdrift class to implement tier 1 air drift screening models.
    """

    def __init__(self, pd_obj, pd_obj_exp):
        """Class representing the Agdrift model and containing all its methods"""
        super(Agdrift, self).__init__()
        self.pd_obj = pd_obj
        self.pd_obj_exp = pd_obj_exp
        self.pd_obj_out = None

    def execute_model(self):
        """
        Callable to execute the running of the model:
            1) Populate input parameters
            2) Create output DataFrame to hold the model outputs
            3) Run the model's methods to generate outputs
            4) Fill the output DataFrame with the generated model outputs
        """
        self.populate_inputs(self.pd_obj)
        self.pd_obj_out = self.populate_outputs()
        self.run_methods()
        self.fill_output_dataframe()
        logging.info(self.pd_obj_out)
        logging.info('executed agdrift')

    def run_methods(self):
        """
        Controller method that runs all subroutines in sequence.
        :return:
        """
        try:
            self.load_data()
            #loop over all possible cases
            for i in range(self.application_method):
                if self.application_method[i] == 'Tier I Aerial':
                    self.tier_I_aerial(i)
                elif self.application_method[i] == 'Tier I Ground':
                    self.tier_I_ground(i)
                elif self.application_method[i] == 'Tier I Orchard':
                    self.tier_I_airblast(i)
                else:
                    print('no application method match')

            if self.calculation_input[0] == 'Distance':
                self.tier_I_aerial()
                self.tier_I_ground()
                self.tier_I_airblast()
                self.express_extrapolate_f()
                self.deposition_foa_to_gha_f()
                self.deposition_ghac_to_lbac_f()
                self.deposition_gha_to_ngl_f()
                self.deposition_gha_to_mgcm_f()
        except TypeError:
            print "Type Error: Your variables are not set correctly."

    def load_data(self):
        """
        Grabbing interpolated output from agdrift model.
        :return:
        """
        self.pond_ground_high_vf2f = self.get_pond_ground_high_vf2f()
        self.pond_ground_high_f2m = self.get_pond_ground_high_f2m()
        self.pond_ground_low_vf2f = self.get_pond_ground_low_vf2f()
        self.pond_ground_low_f2m = self.get_pond_ground_low_f2m()

        self.pond_aerial_vf2f = self.get_pond_aerial_vf2f()
        self.pond_aerial_f2m = self.get_pond_aerial_f2m()
        self.pond_aerial_m2c = self.get_pond_aerial_m2c()
        self.pond_aerial_c2vc = self.get_pond_aerial_c2vc()

        self.pond_airblast_orchard = self.get_pond_airblast_orchard()
        self.pond_airblast_vineyard = self.get_pond_airblast_vineyard()

        self.out_x = self.get_distance()

    def tier_I_aerial(self, i):
        logging.info('------------- Agdrift results' + self.ecosystem_type[0] + self.application_method[0] + self.drop_size[0])

        # TIER I AERIAL
        if self.ecosystem_type[i] == 'EPA Pond' and self.application_method[i] == 'Aerial' and self.drop_size[i] == 'Fine':
            self.out_y[i] = [self.pond_aerial_vf2f]
            # self.out_x[0] = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            self.out_nasae[0] = [0]
            self.out_express_y[i] = [self.pond_aerial_vf2f]
            self.out_x[i] = self.out_x
        # TIER I AERIAL
        elif (self.ecosystem_type[i] == 'EPA Pond' and self.application_method[i] == 'Aerial' and self.drop_size[i] == 'Medium'):
            self.out_y[i] = [self.pond_aerial_f2m]
            # self.out_x[0] = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            self.out_nasae[i] = [1]
            self.out_express_y[i] = [self.pond_aerial_f2m]
            self.out_x[i] = self.out_x
        # TIER I AERIAL
        elif (self.ecosystem_type[i] == 'EPA Pond' and self.application_method[i] == 'Aerial' and self.drop_size[i] == 'Coarse'):
            self.out_y[i] = [self.pond_aerial_m2c]
            self.out_nasae[i] = [2]
            self.out_express_y[i] = [self.pond_aerial_m2c]
            self.out_x[i] = self.out_x
        # TIER I AERIAL
        elif (self.ecosystem_type[i] == 'EPA Pond' and self.application_method[i] == 'Aerial' and self.drop_size[i] == 'Very Coarse'):
            self.out_y[i] = self.pond_aerial_c2vc
            #python 3 = list(map(str,self.pond_aerial_c2vc))
            # self.out_x[0] = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            self.out_nasae[i] = [3]
            self.out_express_y[i] =self.pond_aerial_c2vc
            self.out_x[i] = self.out_x
        else:
            self.out_y[i] = [3]

    def tier_I_ground(self, i):
        logging.info('------------- Agdrift results' + self.ecosystem_type[0] + self.application_method[0] + self.drop_size[0] + self.boom_height[0])

        # TIER I GROUND
        if (self.ecosystem_type[i] == 'EPA Pond' and self.application_method[i] == 'Ground' and self.drop_size[i] == 'Fine' and self.boom_height[i] == 'low'):
            self.out_y[i] = [self.pond_ground_low_vf2f]
            # self.out_x[0] = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            self.out_nasae[i] = [4]
            self.out_express_y[i] =[self.pond_ground_low_vf2f]
            self.out_x[i] = self.out_x
        # TIER I GROUND
        elif (self.ecosystem_type[i] == 'EPA Pond' and self.application_method[i] == 'Ground' and self.drop_size[i] == 'Medium' and self.boom_height[i] == 'low'):
            self.out_y[i] = [self.pond_ground_low_f2m]
            # self.out_x[0] = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            self.out_nasae[i] = [6]
            self.out_express_y[i] =[self.pond_ground_low_f2m]
            self.out_x[i] = self.out_x
        # TIER I GROUND
        elif (self.ecosystem_type[i] == 'EPA Pond' and self.application_method[i] == 'Ground' and
                      self.drop_size[i] == 'Fine' and self.boom_height[i] == 'High'):
            self.out_y[i] = [self.pond_ground_high_vf2f] #??
            # self.out_x[0] = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            self.out_nasae[i] = [5]
            self.out_express_y[i] =[self.pond_ground_high_vf2f]
            self.out_x[i] = self.out_x
        # TIER I GROUND
        elif (self.ecosystem_type[i] == 'EPA Pond' and self.application_method[i] == 'Ground' and self.drop_size[i] == 'Medium' and self.boom_height[i] == 'High'):
            self.out_y[i] = [self.pond_ground_high_f2m]
            # self.out_x[0] = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            self.out_nasae[i] = [7]
            self.out_express_y[i] =[self.pond_ground_high_f2m]
            self.out_x[i] = self.out_x

    # TIER I ORCHARD/AIRBLAST
    def tier_I_airblast(self, i):
        logging.info('------------- Agdrift results' + self.ecosystem_type[0] + self.application_method[0] + self.orchard_type[0])

        if (self.ecosystem_type[i] == 'EPA Pond' and self.application_method[i] == 'Orchard/Airblast' and self.orchard_type[i] == 'Orchard'):
            self.out_y[i] = [self.pond_airblast_orchard]
            # self.out_x[0] = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            self.out_nasae[i] = [9]
            self.out_express_y[i] =[self.pond_airblast_orchard]
            self.out_x[i] = self.out_x

        # TIER I ORCHARD/AIRBLAST
        elif (self.ecosystem_type[i] == 'EPA Pond' and self.application_method[i] == 'Orchard/Airblast' and self.orchard_type[i] == 'Vineyard'):
            self.out_y[i] = [self.pond_airblast_vineyard]
            self.out_express_y[i] =[self.pond_airblast_vineyard]
            self.out_x[i] = self.out_x
            self.out_nasae[i] = [8]
        else:
            self.out_y[i] = [3]

    def express_extrapolate_f(self):
        """
        Extrapolate results from express implementation.
        :param out_y:
        :param out_nasae:
        :param distance:
        :return:
        """
        # XV = np.array([X0, X1, X2, X3, X4, X5, X6, X7, X8, X9])

        # NASAE1=int(self.out_nasae[0])-1
        # N=max(0,min(9,(self.out_nasae[0]-1)))
        # I=max(0,min(99,int(0.5*int(self.distance[0]))+1))
        i_f = max(1, min(100, int(0.5 * int(self.distance)) + 1))
        ym = 2.0 * (i_f - 1)
        yp = 2.0 * i_f
        i = i_f - 1  # to account for python being zero based

        self.out_init_avg_dep_foa = [(0.5 * (self.out_y[i] * (yp - int(self.distance)) + self.out_y[i + 1] *
                                     (int(self.distance) - ym))) / 100]
        return self.out_init_avg_dep_foa

    # def extrapolate_from_fig(self, bisect_left, out_x):
    #     """
    #     Extrapolating from nearest figure points.
    #     :param ecosystem_type:
    #     :param distance:
    #     :param bisect_left:
    #     :param out_x:
    #     :param out_y:
    #     :return:
    #     """
    #     #self.distance = int(self.distance)
    #     if self.distance[0] in self.out_x:
    #         y_index = out_x.index(self.distance[0])
    #         self.out_init_avg_dep_foa = [self.out_y[y_index]]
    #     else:
    #         i = bisect_left(self.out_x, self.distance[0])  # find largest distance closest to value
    #         low1 = self.out_x[0][i - 1]  # assign nearest lowest out_x value for interpolation
    #         high1 = self.out_x[0][i]  # assign nearest highest out_x value for interpolation
    #         low_i = i - 1  # assign index values to use to find nearest out_y values for interpolation
    #         high_i = i  # assign index values to use to find nearest out_y values for interpolation
    #         self.out_init_avg_dep_foa = [((self.distance[0] - low1) * (self.out_y[0][high_i] - self.out_y[0][low_i]) / (high1 - low1)) + \
    #                                 self.out_y[0][low_i]]
    #     return self.out_init_avg_dep_foa

    # def extrapolate_from_fig2(self, out_y):
    #     """
    #     Extrapolating from nearest figure points, alternative figure.
    #     :param ecosystem_type:
    #     :param out_init_avg_dep_foa:
    #     :param bisect_left:
    #     :param out_x:
    #     :param out_y:
    #     :return:
    #     """
    #     #self.out_init_avg_dep_foa = float(self.out_init_avg_dep_foa)
    #     if self.out_init_avg_dep_foa in self.out_y:
    #         x_index = out_y.index(self.out_init_avg_dep_foa[0])
    #         self.distance[0] = self.out_x[x_index]
    #     else:
    #         i = min(enumerate(self.out_y), key=lambda out_x: abs(
    #                 out_x[1] - self.out_init_avg_dep_foa))  # finds smallest closest value closest to input value
    #         i2 = i[0]
    #         low1 = self.out_y[i2]  # assign nearest lowest out_x value for interpolation
    #         high1 = self.out_y[i2 - 1]  # assign nearest highest out_x value for interpolation
    #         low_i = i2  # assign index values to use to find nearest out_y values for interpolation
    #         high_i = i2 - 1  # assign index values to use to find nearest out_y values for interpolation
    #         self.distance[0] = ((self.out_init_avg_dep_foa[0] - low1) * (self.out_x[high_i] - self.out_x[low_i]) / (high1 - low1)) + \
    #                         self.out_x[low_i]
    #     return self.distance

    def deposition_foa_to_gha_f(self):
        """
        Deposition calculation.
        :param out_init_avg_dep_foa:
        :param application_rate:
        :return:
        """
        self.out_avg_depo_gha = [self.out_init_avg_dep_foa * 100.0 * self.application_rate * 10.0]
        return self.out_avg_depo_gha

    def deposition_foa_to_lbac_f(self):
        """
        Deposition calculation.
        :param out_init_avg_dep_foa:
        :param application_rate:
        :return:
        """
        #self.application_rate = float(self.application_rate)
        # print self.application_rate
        # print self.out_init_avg_dep_foa
        self.out_avg_depo_lbac = [self.out_init_avg_dep_foa * self.application_rate]
        # print self.out_avg_depo_lbac
        return self.out_avg_depo_lbac

    def deposition_lbac_to_gha_f(self):
        """
        Deposition calculation.
        :param out_init_avg_dep_foa:
        :param application_rate:
        :return:
        """
        #self.out_avg_depo_lbac = float(self.out_avg_depo_lbac)
        self.out_avg_depo_gha = [(self.out_avg_depo_lbac[0] * 453.592) / 0.404686]
        # print self.out_avg_depo_gha
        return self.out_avg_depo_gha

    def deposition_gha_to_ngl_f(self):
        """
        Deposition calculation.
        :param out_init_avg_dep_foa:
        :param application_rate:
        :return:
        """
        if (self.aquatic_type == '1'):
            self.out_deposition_gha_ngl_f = [self.out_avg_depo_gha * 0.05 * 1000.0]
        else:
            self.out_deposition_ngl_f = [self.out_avg_depo_gha * 0.05 * 1000.0 * (6.56 / 0.4921)]
        return self.out_deposition_gha_ngl_f

    def deposition_gha_to_mgcm_f(self):
        """
        Deposition calculation.
        :param out_init_avg_dep_foa:
        :param application_rate:
        :return:
        """
        self.out_deposition_mgcm = [self.out_avg_depo_gha * 0.00001]
        return self.out_deposition_mgcm

    def deposition_ngl_2_gha_f(self):
        """
        Deposition calculation.
        :param out_init_avg_dep_foa:
        :param application_rate:
        :return:
        """
        #self.out_deposition_ngl = float(self.out_deposition_ngl)
        if (self.aquatic_type == '1'):
            self.deposition_ngl_2_gha_f = [self.out_deposition_ngl[0] / (0.05 * 1000)]
        else:
            self.deposition_ngl_2_gha_f = [((self.out_deposition_ngl[0]/6.56) * 0.4921) / (0.05 * 1000)]
        return self.deposition_ngl_2_gha_f

    def deposition_ghac_to_lbac_f(self):
        """
        Deposition calculation.
        :param out_init_avg_dep_foa:
        :param application_rate:
        :return:
        """
        #self.out_avg_depo_gha = float(self.out_avg_depo_gha)
        self.out_avg_depo_lbac = [(self.out_avg_depo_gha[0] * 0.00220462 / 2.47105)]
        return self.out_avg_depo_lbac

    def deposition_lbac_to_foa_f(self):
        """
        Deposition calculation.
        :param out_init_avg_dep_foa:
        :param application_rate:
        :return:
        """
        #self.application_rate = float(self.application_rate)
        self.out_init_avg_dep_foa = [self.out_avg_depo_lbac[0] / self.application_rate[0]]
        return self.out_init_avg_dep_foa

    def deposition_mgcm_to_gha_f(self):
        """
        Deposition calculation.
        :param out_init_avg_dep_foa:
        :param application_rate:
        :return:
        """
        #self.out_deposition_mgcm = float(self.out_deposition_mgcm)
        self.out_avg_depo_gha = [self.out_deposition_mgcm[0] / 0.00001]
        return self.out_avg_depo_gha


                # elif (self.calculation_input == 'Fraction'):
                #     self.extrapolate_from_fig2(self.out_y)
                #     self.deposition_foa_to_lbac_f()
                #     self.deposition_lbac_to_gha_f()
                #     self.deposition_gha_to_ngl_f()
                #     self.deposition_gha_to_mgcm_f()

                # elif (self.calculation_input == 'Initial Average Deposition (g/ha)'):
                #     self.deposition_ghac_to_lbac_f()
                #     self.deposition_lbac_to_foa_f()
                #     self.extrapolate_from_fig2(self.out_y)
                #     self.deposition_gha_to_ngl_f()
                #     self.deposition_gha_to_mgcm_f()

                # elif (self.calculation_input == 'Initial Average Deposition (lb/ac)'):
                #     print self.out_avg_depo_lbac
                #     self.deposition_lbac_to_gha_f()
                #     self.deposition_gha_to_ngl_f()
                #     self.deposition_gha_to_mgcm_f()
                #     self.deposition_lbac_to_foa_f()
                #     self.extrapolate_from_fig2(self.out_y)

                # elif (self.calculation_input == 'Initial Average Concentration (ng/l)'):
                #     self.deposition_ngl_2_gha_f()
                #     self.deposition_ghac_to_lbac_f()
                #     self.deposition_lbac_to_foa_f()
                #     self.extrapolate_from_fig2(self.out_y)
                #     self.deposition_gha_to_mgcm_f()

                # else:
                #     self.deposition_mgcm_to_gha_f()
                #     self.deposition_ghac_to_lbac_f()
                #     self.deposition_lbac_to_foa_f()
                #     self.extrapolate_from_fig2(self.out_y)
                #     self.deposition_gha_to_ngl_f()

        # def results(self):
        #     self.pond_ground_high_vf2f = [0.0616,0.0572,0.0455,0.0376,0.0267,0.0194,0.013,0.0098,0.0078,0.0064,0.0053,0.0046,0.0039,0.0035,0.003,0.0027,0.0024,0.0022,0.002,0.0018,0.0017,0.0015,0.0014,0.0013,0.0012]
        #     self.pond_ground_high_f2m = [0.0165,0.0137,0.0104,0.009,0.0071,0.0056,0.0042,0.0034,0.0028,0.0024,0.0021,0.0019,0.0017,0.0015,0.0014,0.0013,0.0012,0.0011,0.001,0.00095,0.0009,0.0008,0.0008,0.0007,0.0007]
        #     self.pond_ground_low_vf2f = [0.0268,0.0231,0.0167,0.0136,0.01,0.0076,0.0054,0.0043,0.0036,0.0031,0.0027,0.0024,0.0021,0.0019,0.0017,0.0016,0.0015,0.0013,0.0012,0.0012,0.0011,0.001,0.001,0.0009,0.0009]
        #     self.pond_ground_low_f2m = [0.0109,0.0086,0.0065,0.0056,0.0045,0.0036,0.0028,0.0023,0.0019,0.0017,0.0015,0.0013,0.0012,0.0011,0.001,0.0009,0.0009,0.0008,0.0008,0.0007,0.0007,0.0006,0.0006,0.0006,0.0006]

        # #####one less value (begin)
        #     self.pond_aerial_vf2f = [0.2425,0.2409,0.2344,0.2271,0.2083,0.1829,0.1455,0.1204,0.103,0.0904,0.0809,0.0734,0.0674,0.0625,0.0584,0.055,0.0521,0.0497,0.0476,0.0458,0.0442,0.0428,0.0416,0.0405,0.0396]
        #     self.pond_aerial_f2m = [0.1266,0.1247,0.1172,0.1094,0.0926,0.0743,0.0511,0.0392,0.0321,0.0272,0.0238,0.0212,0.0193,0.0177,0.0165,0.0155,0.0146,0.0139,0.0133,0.0128,0.0124,0.012,0.0117,0.0114,0.0111]
        #     self.pond_aerial_m2c = [0.0892,0.0900,0.0800,0.0700,0.0600,0.0400,0.0300,0.0200,0.0200,0.0130,0.0112,0.0099,0.0090,0.0083,0.0077,0.0073,0.0069,0.0066,0.0063,0.0060,0.0058,0.0056,0.0055,0.0053,0.0052]
        #     self.pond_aerial_c2vc = [0.0892,0.0900,0.0800,0.0700,0.0600,0.0400,0.0300,0.0200,0.0200,0.0130,0.0112,0.0099,0.0090,0.0083,0.0077,0.0073,0.0069,0.0066,0.0063,0.0060,0.0058,0.0056,0.0055,0.0053,0.0052]
        #     self.terr_aerial_vf2f = [0.5000,0.4913,0.4564,0.4220,0.3588,0.3039,0.2247,0.1741,0.1403,0.1171,0.1010,0.0893,0.0799,0.0729,0.0671,0.0626,0.0585,0.0550,0.0519,0.0494,0.0475,0.0458,0.0442,0.0428,0.0416]
        #     self.terr_aerial_f2m = [0.4999,0.4808,0.4046,0.3365,0.2231,0.1712,0.0979,0.0638,0.0469,0.0374,0.0312,0.0266,0.0234,0.021,0.0192,0.0177,0.0164,0.0154,0.0146,0.0139,0.0133,0.0128,0.0124,0.012,0.0117]
        #     self.terr_aerial_m2c =[0.5,0.4776,0.3882,0.3034,0.1711,0.1114,0.0561,0.0346,0.0249,0.0188,0.015,0.0126,0.011,0.0098,0.0089,0.0082,0.0077,0.0072,0.0069,0.0065,0.0063,0.006,0.0058,0.0056,0.0055]
        #     self.terr_aerial_c2vc =[0.5,0.4776,0.3882,0.3034,0.1711,0.1114,0.0561,0.0346,0.0249,0.0188,0.015,0.0126,0.011,0.0098,0.0089,0.0082,0.0077,0.0072,0.0069,0.0065,0.0063,0.006,0.0058,0.0056,0.0055]
        #     self.terr_ground_vf2f = [1.06,0.8564,0.4475,0.2595,0.104,0.05,0.0248,0.0164,0.012,0.0093,0.0075,0.0062,0.0053,0.0045,0.0039,0.0034,0.003,0.0027,0.0024,0.0022,0.002,0.0018,0.0017,0.0015,0.0014]
        # #####one less value (end)

        #     self.terr_ground_f2m = [1.01,0.3731,0.0889,0.0459,0.0208,0.0119,0.007,0.0051,0.004,0.0033,0.0028,0.0024,0.0021,0.0019,0.0017,0.0015,0.0014,0.0013,0.0012,0.0011,0.001,0.0009,0.0009,0.0008,0.0008]
        #     self.pond_airblast_normal = [0.0011,0.0011,0.001,0.0009,0.0007,0.0005,0.0003,0.0002,0.0002,0.0002,0.0001,0.0001,0.0000978,0.0000863,0.0000769,0.0000629,0.0000626,0.0000571,0.0000523,0.0000482,0.0000446,0.0000414,0.0000386,0.0000361,0.0000339]
        #     self.pond_airblast_dense = [0.0145,0.014,0.0122,0.0106,0.0074,0.005,0.003,0.0022,0.0017,0.0014,0.0012,0.0011,0.001,0.0009,0.0008,0.0007,0.0007,0.0006,0.0006,0.0005,0.0005,0.0005,0.0005,0.0004,0.0004]
        #     self.pond_airblast_sparse = [0.0416,0.0395,0.0323,0.0258,0.015,0.0077,0.0031,0.0017,0.001,0.0007,0.0005,0.0004,0.0003,0.0002,0.0002,0.0002,0.0001,0.0001,0.0000898,0.0000771,0.0000668,0.0000583,0.0000513,0.0000453,0.0000405]
        #     self.pond_airblast_vineyard = [0.0024,0.0023,0.0018,0.0014,0.0009,0.0006,0.0003,0.0002,0.0002,0.0001,0.0001,0.0001,0.0000881,0.0000765,0.0000672,0.0000596,0.0000533,0.000048,0.0000435,0.0000397,0.0000363,0.0000334,0.0000309,0.0000286,0.0000267]
        #     self.pond_airblast_orchard = [0.0218,0.0208,0.0175,0.0145,0.0093,0.0056,0.0031,0.0021,0.0016,0.0013,0.0011,0.0009,0.0008,0.0007,0.0007,0.0006,0.0005,0.0005,0.0005,0.0004,0.0004,0.0004,0.0004,0.0003,0.0003]
        #     self.terr_airblast_normal = [0.0089,0.0081,0.0058,0.0042,0.0023,0.0012,0.0006,0.0004,0.0003,0.0002,0.0002,0.0002,0.0001,0.0001,0.0000965,0.0000765,0.0000625,0.0000523,0.0000446,0.0000387]
        #     self.terr_airblast_dense = [0.1155,0.1078,0.0834,0.0631,0.033,0.0157,0.0065,0.0038,0.0026,0.002,0.0016,0.0014,0.0012,0.0011,0.0009,0.0008,0.0007,0.0006,0.0005,0.0005]
        #     self.terr_airblast_sparse = [0.4763,0.4385,0.3218,0.2285,0.1007,0.0373,0.0103,0.0044,0.0023,0.0014,0.0009,0.0006,0.0005,0.0004,0.0003,0.0002,0.0001,0.0000889,0.0000665,0.0000514]
        #     self.terr_airblast_vineyard = [0.0376,0.0324,0.0195,0.012,0.0047,0.0019,0.0008,0.0004,0.0003,0.0002,0.0002,0.0001,0.0001,0.0001,0.000087,0.0000667,0.0000531,0.0000434,0.0000363,0.000031]
        #     self.terr_airblast_orchard = [0.2223,0.2046,0.1506,0.108,0.0503,0.021,0.0074,0.004,0.0026,0.0019,0.0015,0.0012,0.0011,0.0009,0.0008,0.0006,0.0005,0.0005,0.0004,0.0004]

        #     if (self.ecosystem_type == 'EPA Pond' and self.application_method == 'Aerial' and self.drop_size == 'Fine'):
        #         self.out_y = self.pond_aerial_vf2f
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'EPA Pond' and self.application_method == 'Aerial' and self.drop_size == 'Medium'):
        #         self.out_y = self.pond_aerial_f2m
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'EPA Pond' and self.application_method == 'Aerial' and self.drop_size == 'Coarse'):
        #         self.out_y = self.pond_aerial_m2c
        #     elif (self.ecosystem_type == 'EPA Pond' and self.application_method == 'Aerial' and self.drop_size == 'Very Coarse'):
        #         self.out_y = self.pond_aerial_c2vc
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'EPA Pond' and self.application_method == 'Ground' and self.drop_size == 'Fine' and self.boom_height == 'low'):
        #         self.out_y = self.pond_ground_low_vf2f
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'EPA Pond' and self.application_method == 'Ground' and self.drop_size == 'Medium' and self.boom_height == 'low'):
        #         self.out_y = self.pond_ground_low_f2m
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'EPA Pond' and self.application_method == 'Ground' and self.drop_size == 'Fine' and self.boom_height == 'High'):
        #         self.out_y = self.pond_ground_high_vf2f
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'EPA Pond' and self.application_method == 'Ground' and self.drop_size == 'Medium' and self.boom_height == 'High'):
        #         self.out_y = self.pond_ground_high_f2m
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Aerial' and self.drop_size == 'Fine'):
        #         self.out_y = self.terr_aerial_vf2f
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Aerial' and self.drop_size == 'Medium'):
        #         self.out_y = self.terr_aerial_f2m
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Aerial' and self.drop_size == 'Coarse'):
        #         self.out_y = self.terr_aerial_m2c
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Aerial' and self.drop_size == 'Very Coarse'):
        #         self.out_y = self.terr_aerial_c2vc
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Ground' and self.drop_size == 'Fine'):
        #         self.out_y = self.terr_ground_vf2f
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Ground' and self.drop_size == 'Medium'):
        #         self.out_y = self.terr_ground_f2m
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'EPA Pond' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Normal'):
        #         self.out_y = self.pond_airblast_normal
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'EPA Pond' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Dense'):
        #         self.out_y = self.pond_airblast_dense
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'EPA Pond' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Sparse'):
        #         self.out_y = self.pond_airblast_sparse
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'EPA Pond' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Vineyard'):
        #         self.out_y = self.pond_airblast_vineyard
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'EPA Pond' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Orchard'):
        #         self.out_y = pond_airblast_orchard
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Normal'):
        #         self.out_y = self.terr_airblast_normal
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,600,700,800,900,997]
        #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Dense'):
        #         self.out_y = self.terr_airblast_dense
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,600,700,800,900,997]
        #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Sparse'):
        #         self.out_y = self.terr_airblast_sparse
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,600,700,800,900,997]
        #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Vineyard'):
        #         self.out_y = self.terr_airblast_vineyard
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,600,700,800,900,997]
        #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Orchard'):
        #         self.out_y = self.terr_airblast_orchard
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,600,700,800,900,997]
        #         self.z = 4
        #     else:
        #         #print 2
        #         self.out_y = 3
        #     return self.out_x, self.out_y

        #     self.terr_aerial_vf2f = [0.5000,0.4913,0.4564,0.4220,0.3588,0.3039,0.2247,0.1741,0.1403,0.1171,0.1010,0.0893,0.0799,0.0729,0.0671,0.0626,0.0585,0.0550,0.0519,0.0494,0.0475,0.0458,0.0442,0.0428,0.0416]
        #     self.terr_aerial_f2m = [0.4999,0.4808,0.4046,0.3365,0.2231,0.1712,0.0979,0.0638,0.0469,0.0374,0.0312,0.0266,0.0234,0.021,0.0192,0.0177,0.0164,0.0154,0.0146,0.0139,0.0133,0.0128,0.0124,0.012,0.0117]
        #     self.terr_aerial_m2c =[0.5,0.4776,0.3882,0.3034,0.1711,0.1114,0.0561,0.0346,0.0249,0.0188,0.015,0.0126,0.011,0.0098,0.0089,0.0082,0.0077,0.0072,0.0069,0.0065,0.0063,0.006,0.0058,0.0056,0.0055]
        #     self.terr_aerial_c2vc =[0.5,0.4776,0.3882,0.3034,0.1711,0.1114,0.0561,0.0346,0.0249,0.0188,0.015,0.0126,0.011,0.0098,0.0089,0.0082,0.0077,0.0072,0.0069,0.0065,0.0063,0.006,0.0058,0.0056,0.0055]
        #     self.terr_ground_vf2f = [1.06,0.8564,0.4475,0.2595,0.104,0.05,0.0248,0.0164,0.012,0.0093,0.0075,0.0062,0.0053,0.0045,0.0039,0.0034,0.003,0.0027,0.0024,0.0022,0.002,0.0018,0.0017,0.0015,0.0014]
        # #####one less value (end)

        #     self.terr_ground_f2m = [1.01,0.3731,0.0889,0.0459,0.0208,0.0119,0.007,0.0051,0.004,0.0033,0.0028,0.0024,0.0021,0.0019,0.0017,0.0015,0.0014,0.0013,0.0012,0.0011,0.001,0.0009,0.0009,0.0008,0.0008]
        #     self.pond_airblast_normal = [0.0011,0.0011,0.001,0.0009,0.0007,0.0005,0.0003,0.0002,0.0002,0.0002,0.0001,0.0001,0.0000978,0.0000863,0.0000769,0.0000629,0.0000626,0.0000571,0.0000523,0.0000482,0.0000446,0.0000414,0.0000386,0.0000361,0.0000339]
        #     self.pond_airblast_dense = [0.0145,0.014,0.0122,0.0106,0.0074,0.005,0.003,0.0022,0.0017,0.0014,0.0012,0.0011,0.001,0.0009,0.0008,0.0007,0.0007,0.0006,0.0006,0.0005,0.0005,0.0005,0.0005,0.0004,0.0004]

        #     self.pond_airblast_orchard = [0.0218,0.0208,0.0175,0.0145,0.0093,0.0056,0.0031,0.0021,0.0016,0.0013,0.0011,0.0009,0.0008,0.0007,0.0007,0.0006,0.0005,0.0005,0.0005,0.0004,0.0004,0.0004,0.0004,0.0003,0.0003]
        #     self.terr_airblast_normal = [0.0089,0.0081,0.0058,0.0042,0.0023,0.0012,0.0006,0.0004,0.0003,0.0002,0.0002,0.0002,0.0001,0.0001,0.0000965,0.0000765,0.0000625,0.0000523,0.0000446,0.0000387]
        #     self.terr_airblast_dense = [0.1155,0.1078,0.0834,0.0631,0.033,0.0157,0.0065,0.0038,0.0026,0.002,0.0016,0.0014,0.0012,0.0011,0.0009,0.0008,0.0007,0.0006,0.0005,0.0005]
        #     self.terr_airblast_sparse = [0.4763,0.4385,0.3218,0.2285,0.1007,0.0373,0.0103,0.0044,0.0023,0.0014,0.0009,0.0006,0.0005,0.0004,0.0003,0.0002,0.0001,0.0000889,0.0000665,0.0000514]
        #     self.terr_airblast_vineyard = [0.0376,0.0324,0.0195,0.012,0.0047,0.0019,0.0008,0.0004,0.0003,0.0002,0.0002,0.0001,0.0001,0.0001,0.000087,0.0000667,0.0000531,0.0000434,0.0000363,0.000031]
        #     self.terr_airblast_orchard = [0.2223,0.2046,0.1506,0.108,0.0503,0.021,0.0074,0.004,0.0026,0.0019,0.0015,0.0012,0.0011,0.0009,0.0008,0.0006,0.0005,0.0005,0.0004,0.0004]

            #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Aerial' and self.drop_size == 'Fine'):
            #         self.out_y = self.terr_aerial_vf2f
            #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Aerial' and self.drop_size == 'Medium'):
            #         self.out_y = self.terr_aerial_f2m
            #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Aerial' and self.drop_size == 'Coarse'):
            #         self.out_y = self.terr_aerial_m2c
            #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Aerial' and self.drop_size == 'Very Coarse'):
            #         self.out_y = self.terr_aerial_c2vc
            #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Ground' and self.drop_size == 'Fine'):
            #         self.out_y = self.terr_ground_vf2f
            #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Ground' and self.drop_size == 'Medium'):
            #         self.out_y = self.terr_ground_f2m
            #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            #     elif (self.ecosystem_type == 'EPA Pond' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Normal'):
            #         self.out_y = self.pond_airblast_normal
            #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            #     elif (self.ecosystem_type == 'EPA Pond' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Dense'):
            #         self.out_y = self.pond_airblast_dense
            #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            #     elif (self.ecosystem_type == 'EPA Pond' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Orchard'):
            #         self.out_y = pond_airblast_orchard
            #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Normal'):
            #         self.out_y = self.terr_airblast_normal
            #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,600,700,800,900,997]
            #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Dense'):
            #         self.out_y = self.terr_airblast_dense
            #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,600,700,800,900,997]
            #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Sparse'):
            #         self.out_y = self.terr_airblast_sparse
            #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,600,700,800,900,997]
            #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Vineyard'):
            #         self.out_y = self.terr_airblast_vineyard
            #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,600,700,800,900,997]
            #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Orchard'):
            #         self.out_y = self.terr_airblast_orchard
            #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,600,700,800,900,997]
            #         self.z = 4

    # def load_pond_ground_high_vf2f(self):
    #     conn = sqlite3.connect('agdrift.db')
    #     cur = conn.cursor()
    #     cur.execute("SELECT pond_ground_high_vf2f  from output")
    #     pond_ground_high_vf2fs = cur.fetchall()
    #     pond_ground_high_vf2fs = np.array(pond_ground_high_vf2fs).astype('float').flatten()
    #     cur.close()
    #     conn.close()
    #     return pond_ground_high_vf2fs
    def get_distance(self):
        engine = create_engine('sqlite:///sqlite_agdrift.db')
        conn = engine.connect()
        result = conn.execute("SELECT distance from output")
        data = np.zeros(300)
        for i, row in enumerate(result):
            temp = float(row[0])
            data[i] = temp.real
        conn.close()
        return data

    def get_pond_ground_high_vf2f(self):
        engine = create_engine('sqlite:///sqlite_agdrift.db')
        conn = engine.connect()
        result = conn.execute("SELECT pond_ground_high_vf2f from output")
        data = np.zeros(300)
        for i, row in enumerate(result):
            temp = float(row[0])
            data[i] = temp.real
        conn.close()
        return data

    def get_pond_ground_high_f2m(self):
        engine = create_engine('sqlite:///sqlite_agdrift.db')
        conn = engine.connect()
        result = conn.execute("SELECT pond_ground_high_f2m from output")
        data = np.zeros(300)
        for i, row in enumerate(result):
            temp = float(row[0])
            data[i] = temp.real
        conn.close()
        return data

    def get_pond_ground_low_f2m(self):
        engine = create_engine('sqlite:///sqlite_agdrift.db')
        conn = engine.connect()
        result = conn.execute("SELECT pond_ground_low_f2m from output")
        data = np.zeros(300)
        for i, row in enumerate(result):
            temp = float(row[0])
            data[i] = temp.real
        conn.close()
        return data

    def get_pond_ground_low_vf2f(self):
        engine = create_engine('sqlite:///sqlite_agdrift.db')
        conn = engine.connect()
        result = conn.execute("SELECT pond_ground_low_vf2f from output")
        data = np.zeros(300)
        for i, row in enumerate(result):
            temp = float(row[0])
            data[i] = temp.real
        conn.close()
        return data

    def get_pond_aerial_vf2f(self):
        engine = create_engine('sqlite:///sqlite_agdrift.db')
        conn = engine.connect()
        result = conn.execute("SELECT pond_aerial_vf2f from output")
        data = np.zeros(300)
        for i, row in enumerate(result):
            temp = float(row[0])
            data[i] = temp.real
        conn.close()
        return data

    def get_pond_aerial_f2m(self):
        engine = create_engine('sqlite:///sqlite_agdrift.db')
        conn = engine.connect()
        result = conn.execute("SELECT pond_aerial_f2m from output")
        data = np.zeros(300)
        for i, row in enumerate(result):
            temp = float(row[0])
            data[i] = temp.real
        conn.close()
        return data

    def get_pond_aerial_m2c(self):
        engine = create_engine('sqlite:///sqlite_agdrift.db')
        conn = engine.connect()
        result = conn.execute("SELECT pond_aerial_m2c from output")
        data = np.zeros(300)
        for i, row in enumerate(result):
            temp = float(row[0])
            data[i] = temp.real
        conn.close()
        return data

    def get_pond_aerial_c2vc(self):
        engine = create_engine('sqlite:///sqlite_agdrift.db')
        conn = engine.connect()
        result = conn.execute("SELECT pond_aerial_c2vc from output")
        data = np.zeros(300)
        for i, row in enumerate(result):
            temp = float(row[0])
            data[i] = temp.real
        conn.close()
        return data

    def get_pond_airblast_orchard(self):
        engine = create_engine('sqlite:///sqlite_agdrift.db')
        conn = engine.connect()
        result = conn.execute("SELECT pond_airblast_orchard from output")
        data = np.zeros(300)
        for i, row in enumerate(result):
            temp = float(row[0])
            data[i] = temp.real
        conn.close()
        return data

    def get_pond_airblast_vineyard(self):
        engine = create_engine('sqlite:///sqlite_agdrift.db')
        conn = engine.connect()
        result = conn.execute("SELECT pond_airblast_vineyard from output")
        data = np.zeros(300)
        for i, row in enumerate(result):
            temp = float(row[0])
            data[i] = temp.real
        conn.close()
        return data<commit_msg>small exe change for agdrift<commit_after>from __future__ import division
import logging
import numpy as np
import pandas as pd
import sqlite3

from sqlalchemy import Column, Table,Integer, Float, String, create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker, scoped_session
from sqlalchemy import *
metadata = MetaData()
from base.uber_model import UberModel, ModelSharedInputs


class AgdriftInputs(ModelSharedInputs):
    """
    Input class for Agdrift.
    """

    def __init__(self):
        """Class representing the inputs for TerrPlant"""
        super(AgdriftInputs, self).__init__()
        self.application_rate = pd.Series([], dtype="float")
        self.application_method = pd.Series([], dtype="object")
        self.drop_size = pd.Series([], dtype="object")
        self.ecosystem_type = pd.Series([], dtype="object")
        self.boom_height = pd.Series([], dtype="object")
        self.orchard_type = pd.Series([], dtype="object")
        self.aquatic_type = pd.Series([], dtype="object")
        self.calculation_input = pd.Series([], dtype="object")
        self.distance = pd.Series([], dtype="float")


class AgdriftOutputs(object):
    """
    Output class for Agdrift.
    """

    def __init__(self):
        """Class representing the outputs for Agdrift"""
        super(AgdriftOutputs, self).__init__()
        self.out_init_avg_dep_foa = pd.Series(name="out_init_avg_dep_foa").astype("float")
        self.out_avg_depo_lbac = pd.Series(name="out_avg_depo_lbac").astype("float")
        self.out_avg_depo_gha = pd.Series(name="out_avg_depo_gha").astype("float")
        self.out_deposition_ngl = pd.Series(name="out_deposition_ngl").astype("float")
        self.out_deposition_mgcm = pd.Series(name="out_deposition_mgcm").astype("float")
        self.out_nasae = pd.Series(name="out_nasae").astype("int")
        self.out_y = pd.Series(name="out_y").astype("object")
        self.out_x = pd.Series(name="out_x").astype("object")
        self.out_express_y = pd.Series(name="out_express_y").astype("object")


class Agdrift(UberModel, AgdriftInputs, AgdriftOutputs):
    """
    Agdrift class to implement tier 1 air drift screening models.
    """

    def __init__(self, pd_obj, pd_obj_exp):
        """Class representing the Agdrift model and containing all its methods"""
        super(Agdrift, self).__init__()
        self.pd_obj = pd_obj
        self.pd_obj_exp = pd_obj_exp
        self.pd_obj_out = None

    def execute_model(self):
        """
        Callable to execute the running of the model:
            1) Populate input parameters
            2) Create output DataFrame to hold the model outputs
            3) Run the model's methods to generate outputs
            4) Fill the output DataFrame with the generated model outputs
        """
        self.populate_inputs(self.pd_obj)
        self.pd_obj_out = self.populate_outputs()
        self.run_methods()
        self.fill_output_dataframe()
        logging.info(self.pd_obj_out)
        logging.info('executed agdrift')

    def run_methods(self):
        """
        Controller method that runs all subroutines in sequence.
        :return:
        """
        try:
            self.load_data()
            #loop over all possible cases
            for i in range(self.application_method):
                if self.application_method[i] == 'Tier I Aerial':
                    self.tier_I_aerial(i)
                elif self.application_method[i] == 'Tier I Ground':
                    self.tier_I_ground(i)
                elif self.application_method[i] == 'Tier I Orchard':
                    self.tier_I_airblast(i)
                else:
                    print('no application method match')

            if self.calculation_input[i] == 'Distance':
                self.tier_I_aerial()
                self.tier_I_ground()
                self.tier_I_airblast()
                self.express_extrapolate_f()
                self.deposition_foa_to_gha_f()
                self.deposition_ghac_to_lbac_f()
                self.deposition_gha_to_ngl_f()
                self.deposition_gha_to_mgcm_f()
        except TypeError:
            print "Type Error: Your variables are not set correctly."

    def load_data(self):
        """
        Grabbing interpolated output from agdrift model.
        :return:
        """
        self.pond_ground_high_vf2f = self.get_pond_ground_high_vf2f()
        self.pond_ground_high_f2m = self.get_pond_ground_high_f2m()
        self.pond_ground_low_vf2f = self.get_pond_ground_low_vf2f()
        self.pond_ground_low_f2m = self.get_pond_ground_low_f2m()

        self.pond_aerial_vf2f = self.get_pond_aerial_vf2f()
        self.pond_aerial_f2m = self.get_pond_aerial_f2m()
        self.pond_aerial_m2c = self.get_pond_aerial_m2c()
        self.pond_aerial_c2vc = self.get_pond_aerial_c2vc()

        self.pond_airblast_orchard = self.get_pond_airblast_orchard()
        self.pond_airblast_vineyard = self.get_pond_airblast_vineyard()

        self.out_x = self.get_distance()

    def tier_I_aerial(self, i):
        logging.info('------------- Agdrift results' + self.ecosystem_type[0] + self.application_method[0] + self.drop_size[0])

        # TIER I AERIAL
        if self.ecosystem_type[i] == 'EPA Pond' and self.application_method[i] == 'Aerial' and self.drop_size[i] == 'Fine':
            self.out_y[i] = [self.pond_aerial_vf2f]
            # self.out_x[0] = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            self.out_nasae[0] = [0]
            self.out_express_y[i] = [self.pond_aerial_vf2f]
            self.out_x[i] = self.out_x
        # TIER I AERIAL
        elif (self.ecosystem_type[i] == 'EPA Pond' and self.application_method[i] == 'Aerial' and self.drop_size[i] == 'Medium'):
            self.out_y[i] = [self.pond_aerial_f2m]
            # self.out_x[0] = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            self.out_nasae[i] = [1]
            self.out_express_y[i] = [self.pond_aerial_f2m]
            self.out_x[i] = self.out_x
        # TIER I AERIAL
        elif (self.ecosystem_type[i] == 'EPA Pond' and self.application_method[i] == 'Aerial' and self.drop_size[i] == 'Coarse'):
            self.out_y[i] = [self.pond_aerial_m2c]
            self.out_nasae[i] = [2]
            self.out_express_y[i] = [self.pond_aerial_m2c]
            self.out_x[i] = self.out_x
        # TIER I AERIAL
        elif (self.ecosystem_type[i] == 'EPA Pond' and self.application_method[i] == 'Aerial' and self.drop_size[i] == 'Very Coarse'):
            self.out_y[i] = self.pond_aerial_c2vc
            #python 3 = list(map(str,self.pond_aerial_c2vc))
            # self.out_x[0] = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            self.out_nasae[i] = [3]
            self.out_express_y[i] =self.pond_aerial_c2vc
            self.out_x[i] = self.out_x
        else:
            self.out_y[i] = [3]

    def tier_I_ground(self, i):
        logging.info('------------- Agdrift results' + self.ecosystem_type[0] + self.application_method[0] + self.drop_size[0] + self.boom_height[0])

        # TIER I GROUND
        if (self.ecosystem_type[i] == 'EPA Pond' and self.application_method[i] == 'Ground' and self.drop_size[i] == 'Fine' and self.boom_height[i] == 'low'):
            self.out_y[i] = [self.pond_ground_low_vf2f]
            # self.out_x[0] = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            self.out_nasae[i] = [4]
            self.out_express_y[i] =[self.pond_ground_low_vf2f]
            self.out_x[i] = self.out_x
        # TIER I GROUND
        elif (self.ecosystem_type[i] == 'EPA Pond' and self.application_method[i] == 'Ground' and self.drop_size[i] == 'Medium' and self.boom_height[i] == 'low'):
            self.out_y[i] = [self.pond_ground_low_f2m]
            # self.out_x[0] = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            self.out_nasae[i] = [6]
            self.out_express_y[i] =[self.pond_ground_low_f2m]
            self.out_x[i] = self.out_x
        # TIER I GROUND
        elif (self.ecosystem_type[i] == 'EPA Pond' and self.application_method[i] == 'Ground' and
                      self.drop_size[i] == 'Fine' and self.boom_height[i] == 'High'):
            self.out_y[i] = [self.pond_ground_high_vf2f] #??
            # self.out_x[0] = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            self.out_nasae[i] = [5]
            self.out_express_y[i] =[self.pond_ground_high_vf2f]
            self.out_x[i] = self.out_x
        # TIER I GROUND
        elif (self.ecosystem_type[i] == 'EPA Pond' and self.application_method[i] == 'Ground' and self.drop_size[i] == 'Medium' and self.boom_height[i] == 'High'):
            self.out_y[i] = [self.pond_ground_high_f2m]
            # self.out_x[0] = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            self.out_nasae[i] = [7]
            self.out_express_y[i] =[self.pond_ground_high_f2m]
            self.out_x[i] = self.out_x

    # TIER I ORCHARD/AIRBLAST
    def tier_I_airblast(self, i):
        logging.info('------------- Agdrift results' + self.ecosystem_type[0] + self.application_method[0] + self.orchard_type[0])

        if (self.ecosystem_type[i] == 'EPA Pond' and self.application_method[i] == 'Orchard/Airblast' and self.orchard_type[i] == 'Orchard'):
            self.out_y[i] = [self.pond_airblast_orchard]
            # self.out_x[0] = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            self.out_nasae[i] = [9]
            self.out_express_y[i] =[self.pond_airblast_orchard]
            self.out_x[i] = self.out_x

        # TIER I ORCHARD/AIRBLAST
        elif (self.ecosystem_type[i] == 'EPA Pond' and self.application_method[i] == 'Orchard/Airblast' and self.orchard_type[i] == 'Vineyard'):
            self.out_y[i] = [self.pond_airblast_vineyard]
            self.out_express_y[i] =[self.pond_airblast_vineyard]
            self.out_x[i] = self.out_x
            self.out_nasae[i] = [8]
        else:
            self.out_y[i] = [3]

    def express_extrapolate_f(self):
        """
        Extrapolate results from express implementation.
        :param out_y:
        :param out_nasae:
        :param distance:
        :return:
        """
        # XV = np.array([X0, X1, X2, X3, X4, X5, X6, X7, X8, X9])

        # NASAE1=int(self.out_nasae[0])-1
        # N=max(0,min(9,(self.out_nasae[0]-1)))
        # I=max(0,min(99,int(0.5*int(self.distance[0]))+1))
        i_f = max(1, min(100, int(0.5 * int(self.distance)) + 1))
        ym = 2.0 * (i_f - 1)
        yp = 2.0 * i_f
        i = i_f - 1  # to account for python being zero based

        self.out_init_avg_dep_foa = [(0.5 * (self.out_y[i] * (yp - int(self.distance)) + self.out_y[i + 1] *
                                     (int(self.distance) - ym))) / 100]
        return self.out_init_avg_dep_foa

    # def extrapolate_from_fig(self, bisect_left, out_x):
    #     """
    #     Extrapolating from nearest figure points.
    #     :param ecosystem_type:
    #     :param distance:
    #     :param bisect_left:
    #     :param out_x:
    #     :param out_y:
    #     :return:
    #     """
    #     #self.distance = int(self.distance)
    #     if self.distance[0] in self.out_x:
    #         y_index = out_x.index(self.distance[0])
    #         self.out_init_avg_dep_foa = [self.out_y[y_index]]
    #     else:
    #         i = bisect_left(self.out_x, self.distance[0])  # find largest distance closest to value
    #         low1 = self.out_x[0][i - 1]  # assign nearest lowest out_x value for interpolation
    #         high1 = self.out_x[0][i]  # assign nearest highest out_x value for interpolation
    #         low_i = i - 1  # assign index values to use to find nearest out_y values for interpolation
    #         high_i = i  # assign index values to use to find nearest out_y values for interpolation
    #         self.out_init_avg_dep_foa = [((self.distance[0] - low1) * (self.out_y[0][high_i] - self.out_y[0][low_i]) / (high1 - low1)) + \
    #                                 self.out_y[0][low_i]]
    #     return self.out_init_avg_dep_foa

    # def extrapolate_from_fig2(self, out_y):
    #     """
    #     Extrapolating from nearest figure points, alternative figure.
    #     :param ecosystem_type:
    #     :param out_init_avg_dep_foa:
    #     :param bisect_left:
    #     :param out_x:
    #     :param out_y:
    #     :return:
    #     """
    #     #self.out_init_avg_dep_foa = float(self.out_init_avg_dep_foa)
    #     if self.out_init_avg_dep_foa in self.out_y:
    #         x_index = out_y.index(self.out_init_avg_dep_foa[0])
    #         self.distance[0] = self.out_x[x_index]
    #     else:
    #         i = min(enumerate(self.out_y), key=lambda out_x: abs(
    #                 out_x[1] - self.out_init_avg_dep_foa))  # finds smallest closest value closest to input value
    #         i2 = i[0]
    #         low1 = self.out_y[i2]  # assign nearest lowest out_x value for interpolation
    #         high1 = self.out_y[i2 - 1]  # assign nearest highest out_x value for interpolation
    #         low_i = i2  # assign index values to use to find nearest out_y values for interpolation
    #         high_i = i2 - 1  # assign index values to use to find nearest out_y values for interpolation
    #         self.distance[0] = ((self.out_init_avg_dep_foa[0] - low1) * (self.out_x[high_i] - self.out_x[low_i]) / (high1 - low1)) + \
    #                         self.out_x[low_i]
    #     return self.distance

    def deposition_foa_to_gha_f(self):
        """
        Deposition calculation.
        :param out_init_avg_dep_foa:
        :param application_rate:
        :return:
        """
        self.out_avg_depo_gha = [self.out_init_avg_dep_foa * 100.0 * self.application_rate * 10.0]
        return self.out_avg_depo_gha

    def deposition_foa_to_lbac_f(self):
        """
        Deposition calculation.
        :param out_init_avg_dep_foa:
        :param application_rate:
        :return:
        """
        #self.application_rate = float(self.application_rate)
        # print self.application_rate
        # print self.out_init_avg_dep_foa
        self.out_avg_depo_lbac = [self.out_init_avg_dep_foa * self.application_rate]
        # print self.out_avg_depo_lbac
        return self.out_avg_depo_lbac

    def deposition_lbac_to_gha_f(self):
        """
        Deposition calculation.
        :param out_init_avg_dep_foa:
        :param application_rate:
        :return:
        """
        #self.out_avg_depo_lbac = float(self.out_avg_depo_lbac)
        self.out_avg_depo_gha = [(self.out_avg_depo_lbac[0] * 453.592) / 0.404686]
        # print self.out_avg_depo_gha
        return self.out_avg_depo_gha

    def deposition_gha_to_ngl_f(self):
        """
        Deposition calculation.
        :param out_init_avg_dep_foa:
        :param application_rate:
        :return:
        """
        if (self.aquatic_type == '1'):
            self.out_deposition_gha_ngl_f = [self.out_avg_depo_gha * 0.05 * 1000.0]
        else:
            self.out_deposition_ngl_f = [self.out_avg_depo_gha * 0.05 * 1000.0 * (6.56 / 0.4921)]
        return self.out_deposition_gha_ngl_f

    def deposition_gha_to_mgcm_f(self):
        """
        Deposition calculation.
        :param out_init_avg_dep_foa:
        :param application_rate:
        :return:
        """
        self.out_deposition_mgcm = [self.out_avg_depo_gha * 0.00001]
        return self.out_deposition_mgcm

    def deposition_ngl_2_gha_f(self):
        """
        Deposition calculation.
        :param out_init_avg_dep_foa:
        :param application_rate:
        :return:
        """
        #self.out_deposition_ngl = float(self.out_deposition_ngl)
        if (self.aquatic_type == '1'):
            self.deposition_ngl_2_gha_f = [self.out_deposition_ngl[0] / (0.05 * 1000)]
        else:
            self.deposition_ngl_2_gha_f = [((self.out_deposition_ngl[0]/6.56) * 0.4921) / (0.05 * 1000)]
        return self.deposition_ngl_2_gha_f

    def deposition_ghac_to_lbac_f(self):
        """
        Deposition calculation.
        :param out_init_avg_dep_foa:
        :param application_rate:
        :return:
        """
        #self.out_avg_depo_gha = float(self.out_avg_depo_gha)
        self.out_avg_depo_lbac = [(self.out_avg_depo_gha[0] * 0.00220462 / 2.47105)]
        return self.out_avg_depo_lbac

    def deposition_lbac_to_foa_f(self):
        """
        Deposition calculation.
        :param out_init_avg_dep_foa:
        :param application_rate:
        :return:
        """
        #self.application_rate = float(self.application_rate)
        self.out_init_avg_dep_foa = [self.out_avg_depo_lbac[0] / self.application_rate[0]]
        return self.out_init_avg_dep_foa

    def deposition_mgcm_to_gha_f(self):
        """
        Deposition calculation.
        :param out_init_avg_dep_foa:
        :param application_rate:
        :return:
        """
        #self.out_deposition_mgcm = float(self.out_deposition_mgcm)
        self.out_avg_depo_gha = [self.out_deposition_mgcm[0] / 0.00001]
        return self.out_avg_depo_gha


                # elif (self.calculation_input == 'Fraction'):
                #     self.extrapolate_from_fig2(self.out_y)
                #     self.deposition_foa_to_lbac_f()
                #     self.deposition_lbac_to_gha_f()
                #     self.deposition_gha_to_ngl_f()
                #     self.deposition_gha_to_mgcm_f()

                # elif (self.calculation_input == 'Initial Average Deposition (g/ha)'):
                #     self.deposition_ghac_to_lbac_f()
                #     self.deposition_lbac_to_foa_f()
                #     self.extrapolate_from_fig2(self.out_y)
                #     self.deposition_gha_to_ngl_f()
                #     self.deposition_gha_to_mgcm_f()

                # elif (self.calculation_input == 'Initial Average Deposition (lb/ac)'):
                #     print self.out_avg_depo_lbac
                #     self.deposition_lbac_to_gha_f()
                #     self.deposition_gha_to_ngl_f()
                #     self.deposition_gha_to_mgcm_f()
                #     self.deposition_lbac_to_foa_f()
                #     self.extrapolate_from_fig2(self.out_y)

                # elif (self.calculation_input == 'Initial Average Concentration (ng/l)'):
                #     self.deposition_ngl_2_gha_f()
                #     self.deposition_ghac_to_lbac_f()
                #     self.deposition_lbac_to_foa_f()
                #     self.extrapolate_from_fig2(self.out_y)
                #     self.deposition_gha_to_mgcm_f()

                # else:
                #     self.deposition_mgcm_to_gha_f()
                #     self.deposition_ghac_to_lbac_f()
                #     self.deposition_lbac_to_foa_f()
                #     self.extrapolate_from_fig2(self.out_y)
                #     self.deposition_gha_to_ngl_f()

        # def results(self):
        #     self.pond_ground_high_vf2f = [0.0616,0.0572,0.0455,0.0376,0.0267,0.0194,0.013,0.0098,0.0078,0.0064,0.0053,0.0046,0.0039,0.0035,0.003,0.0027,0.0024,0.0022,0.002,0.0018,0.0017,0.0015,0.0014,0.0013,0.0012]
        #     self.pond_ground_high_f2m = [0.0165,0.0137,0.0104,0.009,0.0071,0.0056,0.0042,0.0034,0.0028,0.0024,0.0021,0.0019,0.0017,0.0015,0.0014,0.0013,0.0012,0.0011,0.001,0.00095,0.0009,0.0008,0.0008,0.0007,0.0007]
        #     self.pond_ground_low_vf2f = [0.0268,0.0231,0.0167,0.0136,0.01,0.0076,0.0054,0.0043,0.0036,0.0031,0.0027,0.0024,0.0021,0.0019,0.0017,0.0016,0.0015,0.0013,0.0012,0.0012,0.0011,0.001,0.001,0.0009,0.0009]
        #     self.pond_ground_low_f2m = [0.0109,0.0086,0.0065,0.0056,0.0045,0.0036,0.0028,0.0023,0.0019,0.0017,0.0015,0.0013,0.0012,0.0011,0.001,0.0009,0.0009,0.0008,0.0008,0.0007,0.0007,0.0006,0.0006,0.0006,0.0006]

        # #####one less value (begin)
        #     self.pond_aerial_vf2f = [0.2425,0.2409,0.2344,0.2271,0.2083,0.1829,0.1455,0.1204,0.103,0.0904,0.0809,0.0734,0.0674,0.0625,0.0584,0.055,0.0521,0.0497,0.0476,0.0458,0.0442,0.0428,0.0416,0.0405,0.0396]
        #     self.pond_aerial_f2m = [0.1266,0.1247,0.1172,0.1094,0.0926,0.0743,0.0511,0.0392,0.0321,0.0272,0.0238,0.0212,0.0193,0.0177,0.0165,0.0155,0.0146,0.0139,0.0133,0.0128,0.0124,0.012,0.0117,0.0114,0.0111]
        #     self.pond_aerial_m2c = [0.0892,0.0900,0.0800,0.0700,0.0600,0.0400,0.0300,0.0200,0.0200,0.0130,0.0112,0.0099,0.0090,0.0083,0.0077,0.0073,0.0069,0.0066,0.0063,0.0060,0.0058,0.0056,0.0055,0.0053,0.0052]
        #     self.pond_aerial_c2vc = [0.0892,0.0900,0.0800,0.0700,0.0600,0.0400,0.0300,0.0200,0.0200,0.0130,0.0112,0.0099,0.0090,0.0083,0.0077,0.0073,0.0069,0.0066,0.0063,0.0060,0.0058,0.0056,0.0055,0.0053,0.0052]
        #     self.terr_aerial_vf2f = [0.5000,0.4913,0.4564,0.4220,0.3588,0.3039,0.2247,0.1741,0.1403,0.1171,0.1010,0.0893,0.0799,0.0729,0.0671,0.0626,0.0585,0.0550,0.0519,0.0494,0.0475,0.0458,0.0442,0.0428,0.0416]
        #     self.terr_aerial_f2m = [0.4999,0.4808,0.4046,0.3365,0.2231,0.1712,0.0979,0.0638,0.0469,0.0374,0.0312,0.0266,0.0234,0.021,0.0192,0.0177,0.0164,0.0154,0.0146,0.0139,0.0133,0.0128,0.0124,0.012,0.0117]
        #     self.terr_aerial_m2c =[0.5,0.4776,0.3882,0.3034,0.1711,0.1114,0.0561,0.0346,0.0249,0.0188,0.015,0.0126,0.011,0.0098,0.0089,0.0082,0.0077,0.0072,0.0069,0.0065,0.0063,0.006,0.0058,0.0056,0.0055]
        #     self.terr_aerial_c2vc =[0.5,0.4776,0.3882,0.3034,0.1711,0.1114,0.0561,0.0346,0.0249,0.0188,0.015,0.0126,0.011,0.0098,0.0089,0.0082,0.0077,0.0072,0.0069,0.0065,0.0063,0.006,0.0058,0.0056,0.0055]
        #     self.terr_ground_vf2f = [1.06,0.8564,0.4475,0.2595,0.104,0.05,0.0248,0.0164,0.012,0.0093,0.0075,0.0062,0.0053,0.0045,0.0039,0.0034,0.003,0.0027,0.0024,0.0022,0.002,0.0018,0.0017,0.0015,0.0014]
        # #####one less value (end)

        #     self.terr_ground_f2m = [1.01,0.3731,0.0889,0.0459,0.0208,0.0119,0.007,0.0051,0.004,0.0033,0.0028,0.0024,0.0021,0.0019,0.0017,0.0015,0.0014,0.0013,0.0012,0.0011,0.001,0.0009,0.0009,0.0008,0.0008]
        #     self.pond_airblast_normal = [0.0011,0.0011,0.001,0.0009,0.0007,0.0005,0.0003,0.0002,0.0002,0.0002,0.0001,0.0001,0.0000978,0.0000863,0.0000769,0.0000629,0.0000626,0.0000571,0.0000523,0.0000482,0.0000446,0.0000414,0.0000386,0.0000361,0.0000339]
        #     self.pond_airblast_dense = [0.0145,0.014,0.0122,0.0106,0.0074,0.005,0.003,0.0022,0.0017,0.0014,0.0012,0.0011,0.001,0.0009,0.0008,0.0007,0.0007,0.0006,0.0006,0.0005,0.0005,0.0005,0.0005,0.0004,0.0004]
        #     self.pond_airblast_sparse = [0.0416,0.0395,0.0323,0.0258,0.015,0.0077,0.0031,0.0017,0.001,0.0007,0.0005,0.0004,0.0003,0.0002,0.0002,0.0002,0.0001,0.0001,0.0000898,0.0000771,0.0000668,0.0000583,0.0000513,0.0000453,0.0000405]
        #     self.pond_airblast_vineyard = [0.0024,0.0023,0.0018,0.0014,0.0009,0.0006,0.0003,0.0002,0.0002,0.0001,0.0001,0.0001,0.0000881,0.0000765,0.0000672,0.0000596,0.0000533,0.000048,0.0000435,0.0000397,0.0000363,0.0000334,0.0000309,0.0000286,0.0000267]
        #     self.pond_airblast_orchard = [0.0218,0.0208,0.0175,0.0145,0.0093,0.0056,0.0031,0.0021,0.0016,0.0013,0.0011,0.0009,0.0008,0.0007,0.0007,0.0006,0.0005,0.0005,0.0005,0.0004,0.0004,0.0004,0.0004,0.0003,0.0003]
        #     self.terr_airblast_normal = [0.0089,0.0081,0.0058,0.0042,0.0023,0.0012,0.0006,0.0004,0.0003,0.0002,0.0002,0.0002,0.0001,0.0001,0.0000965,0.0000765,0.0000625,0.0000523,0.0000446,0.0000387]
        #     self.terr_airblast_dense = [0.1155,0.1078,0.0834,0.0631,0.033,0.0157,0.0065,0.0038,0.0026,0.002,0.0016,0.0014,0.0012,0.0011,0.0009,0.0008,0.0007,0.0006,0.0005,0.0005]
        #     self.terr_airblast_sparse = [0.4763,0.4385,0.3218,0.2285,0.1007,0.0373,0.0103,0.0044,0.0023,0.0014,0.0009,0.0006,0.0005,0.0004,0.0003,0.0002,0.0001,0.0000889,0.0000665,0.0000514]
        #     self.terr_airblast_vineyard = [0.0376,0.0324,0.0195,0.012,0.0047,0.0019,0.0008,0.0004,0.0003,0.0002,0.0002,0.0001,0.0001,0.0001,0.000087,0.0000667,0.0000531,0.0000434,0.0000363,0.000031]
        #     self.terr_airblast_orchard = [0.2223,0.2046,0.1506,0.108,0.0503,0.021,0.0074,0.004,0.0026,0.0019,0.0015,0.0012,0.0011,0.0009,0.0008,0.0006,0.0005,0.0005,0.0004,0.0004]

        #     if (self.ecosystem_type == 'EPA Pond' and self.application_method == 'Aerial' and self.drop_size == 'Fine'):
        #         self.out_y = self.pond_aerial_vf2f
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'EPA Pond' and self.application_method == 'Aerial' and self.drop_size == 'Medium'):
        #         self.out_y = self.pond_aerial_f2m
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'EPA Pond' and self.application_method == 'Aerial' and self.drop_size == 'Coarse'):
        #         self.out_y = self.pond_aerial_m2c
        #     elif (self.ecosystem_type == 'EPA Pond' and self.application_method == 'Aerial' and self.drop_size == 'Very Coarse'):
        #         self.out_y = self.pond_aerial_c2vc
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'EPA Pond' and self.application_method == 'Ground' and self.drop_size == 'Fine' and self.boom_height == 'low'):
        #         self.out_y = self.pond_ground_low_vf2f
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'EPA Pond' and self.application_method == 'Ground' and self.drop_size == 'Medium' and self.boom_height == 'low'):
        #         self.out_y = self.pond_ground_low_f2m
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'EPA Pond' and self.application_method == 'Ground' and self.drop_size == 'Fine' and self.boom_height == 'High'):
        #         self.out_y = self.pond_ground_high_vf2f
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'EPA Pond' and self.application_method == 'Ground' and self.drop_size == 'Medium' and self.boom_height == 'High'):
        #         self.out_y = self.pond_ground_high_f2m
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Aerial' and self.drop_size == 'Fine'):
        #         self.out_y = self.terr_aerial_vf2f
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Aerial' and self.drop_size == 'Medium'):
        #         self.out_y = self.terr_aerial_f2m
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Aerial' and self.drop_size == 'Coarse'):
        #         self.out_y = self.terr_aerial_m2c
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Aerial' and self.drop_size == 'Very Coarse'):
        #         self.out_y = self.terr_aerial_c2vc
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Ground' and self.drop_size == 'Fine'):
        #         self.out_y = self.terr_ground_vf2f
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Ground' and self.drop_size == 'Medium'):
        #         self.out_y = self.terr_ground_f2m
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'EPA Pond' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Normal'):
        #         self.out_y = self.pond_airblast_normal
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'EPA Pond' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Dense'):
        #         self.out_y = self.pond_airblast_dense
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'EPA Pond' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Sparse'):
        #         self.out_y = self.pond_airblast_sparse
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'EPA Pond' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Vineyard'):
        #         self.out_y = self.pond_airblast_vineyard
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'EPA Pond' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Orchard'):
        #         self.out_y = pond_airblast_orchard
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
        #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Normal'):
        #         self.out_y = self.terr_airblast_normal
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,600,700,800,900,997]
        #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Dense'):
        #         self.out_y = self.terr_airblast_dense
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,600,700,800,900,997]
        #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Sparse'):
        #         self.out_y = self.terr_airblast_sparse
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,600,700,800,900,997]
        #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Vineyard'):
        #         self.out_y = self.terr_airblast_vineyard
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,600,700,800,900,997]
        #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Orchard'):
        #         self.out_y = self.terr_airblast_orchard
        #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,600,700,800,900,997]
        #         self.z = 4
        #     else:
        #         #print 2
        #         self.out_y = 3
        #     return self.out_x, self.out_y

        #     self.terr_aerial_vf2f = [0.5000,0.4913,0.4564,0.4220,0.3588,0.3039,0.2247,0.1741,0.1403,0.1171,0.1010,0.0893,0.0799,0.0729,0.0671,0.0626,0.0585,0.0550,0.0519,0.0494,0.0475,0.0458,0.0442,0.0428,0.0416]
        #     self.terr_aerial_f2m = [0.4999,0.4808,0.4046,0.3365,0.2231,0.1712,0.0979,0.0638,0.0469,0.0374,0.0312,0.0266,0.0234,0.021,0.0192,0.0177,0.0164,0.0154,0.0146,0.0139,0.0133,0.0128,0.0124,0.012,0.0117]
        #     self.terr_aerial_m2c =[0.5,0.4776,0.3882,0.3034,0.1711,0.1114,0.0561,0.0346,0.0249,0.0188,0.015,0.0126,0.011,0.0098,0.0089,0.0082,0.0077,0.0072,0.0069,0.0065,0.0063,0.006,0.0058,0.0056,0.0055]
        #     self.terr_aerial_c2vc =[0.5,0.4776,0.3882,0.3034,0.1711,0.1114,0.0561,0.0346,0.0249,0.0188,0.015,0.0126,0.011,0.0098,0.0089,0.0082,0.0077,0.0072,0.0069,0.0065,0.0063,0.006,0.0058,0.0056,0.0055]
        #     self.terr_ground_vf2f = [1.06,0.8564,0.4475,0.2595,0.104,0.05,0.0248,0.0164,0.012,0.0093,0.0075,0.0062,0.0053,0.0045,0.0039,0.0034,0.003,0.0027,0.0024,0.0022,0.002,0.0018,0.0017,0.0015,0.0014]
        # #####one less value (end)

        #     self.terr_ground_f2m = [1.01,0.3731,0.0889,0.0459,0.0208,0.0119,0.007,0.0051,0.004,0.0033,0.0028,0.0024,0.0021,0.0019,0.0017,0.0015,0.0014,0.0013,0.0012,0.0011,0.001,0.0009,0.0009,0.0008,0.0008]
        #     self.pond_airblast_normal = [0.0011,0.0011,0.001,0.0009,0.0007,0.0005,0.0003,0.0002,0.0002,0.0002,0.0001,0.0001,0.0000978,0.0000863,0.0000769,0.0000629,0.0000626,0.0000571,0.0000523,0.0000482,0.0000446,0.0000414,0.0000386,0.0000361,0.0000339]
        #     self.pond_airblast_dense = [0.0145,0.014,0.0122,0.0106,0.0074,0.005,0.003,0.0022,0.0017,0.0014,0.0012,0.0011,0.001,0.0009,0.0008,0.0007,0.0007,0.0006,0.0006,0.0005,0.0005,0.0005,0.0005,0.0004,0.0004]

        #     self.pond_airblast_orchard = [0.0218,0.0208,0.0175,0.0145,0.0093,0.0056,0.0031,0.0021,0.0016,0.0013,0.0011,0.0009,0.0008,0.0007,0.0007,0.0006,0.0005,0.0005,0.0005,0.0004,0.0004,0.0004,0.0004,0.0003,0.0003]
        #     self.terr_airblast_normal = [0.0089,0.0081,0.0058,0.0042,0.0023,0.0012,0.0006,0.0004,0.0003,0.0002,0.0002,0.0002,0.0001,0.0001,0.0000965,0.0000765,0.0000625,0.0000523,0.0000446,0.0000387]
        #     self.terr_airblast_dense = [0.1155,0.1078,0.0834,0.0631,0.033,0.0157,0.0065,0.0038,0.0026,0.002,0.0016,0.0014,0.0012,0.0011,0.0009,0.0008,0.0007,0.0006,0.0005,0.0005]
        #     self.terr_airblast_sparse = [0.4763,0.4385,0.3218,0.2285,0.1007,0.0373,0.0103,0.0044,0.0023,0.0014,0.0009,0.0006,0.0005,0.0004,0.0003,0.0002,0.0001,0.0000889,0.0000665,0.0000514]
        #     self.terr_airblast_vineyard = [0.0376,0.0324,0.0195,0.012,0.0047,0.0019,0.0008,0.0004,0.0003,0.0002,0.0002,0.0001,0.0001,0.0001,0.000087,0.0000667,0.0000531,0.0000434,0.0000363,0.000031]
        #     self.terr_airblast_orchard = [0.2223,0.2046,0.1506,0.108,0.0503,0.021,0.0074,0.004,0.0026,0.0019,0.0015,0.0012,0.0011,0.0009,0.0008,0.0006,0.0005,0.0005,0.0004,0.0004]

            #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Aerial' and self.drop_size == 'Fine'):
            #         self.out_y = self.terr_aerial_vf2f
            #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Aerial' and self.drop_size == 'Medium'):
            #         self.out_y = self.terr_aerial_f2m
            #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Aerial' and self.drop_size == 'Coarse'):
            #         self.out_y = self.terr_aerial_m2c
            #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Aerial' and self.drop_size == 'Very Coarse'):
            #         self.out_y = self.terr_aerial_c2vc
            #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Ground' and self.drop_size == 'Fine'):
            #         self.out_y = self.terr_ground_vf2f
            #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Ground' and self.drop_size == 'Medium'):
            #         self.out_y = self.terr_ground_f2m
            #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            #     elif (self.ecosystem_type == 'EPA Pond' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Normal'):
            #         self.out_y = self.pond_airblast_normal
            #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            #     elif (self.ecosystem_type == 'EPA Pond' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Dense'):
            #         self.out_y = self.pond_airblast_dense
            #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            #     elif (self.ecosystem_type == 'EPA Pond' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Orchard'):
            #         self.out_y = pond_airblast_orchard
            #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,997]
            #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Normal'):
            #         self.out_y = self.terr_airblast_normal
            #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,600,700,800,900,997]
            #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Dense'):
            #         self.out_y = self.terr_airblast_dense
            #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,600,700,800,900,997]
            #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Sparse'):
            #         self.out_y = self.terr_airblast_sparse
            #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,600,700,800,900,997]
            #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Vineyard'):
            #         self.out_y = self.terr_airblast_vineyard
            #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,600,700,800,900,997]
            #     elif (self.ecosystem_type == 'Terrestrial' and self.application_method == 'Orchard/Airblast' and self.orchard_type == 'Orchard'):
            #         self.out_y = self.terr_airblast_orchard
            #         self.out_x = [0,1,5,10,25,50,100,150,200,250,300,350,400,450,500,600,700,800,900,997]
            #         self.z = 4

    # def load_pond_ground_high_vf2f(self):
    #     conn = sqlite3.connect('agdrift.db')
    #     cur = conn.cursor()
    #     cur.execute("SELECT pond_ground_high_vf2f  from output")
    #     pond_ground_high_vf2fs = cur.fetchall()
    #     pond_ground_high_vf2fs = np.array(pond_ground_high_vf2fs).astype('float').flatten()
    #     cur.close()
    #     conn.close()
    #     return pond_ground_high_vf2fs
    def get_distance(self):
        engine = create_engine('sqlite:///sqlite_agdrift.db')
        conn = engine.connect()
        result = conn.execute("SELECT distance from output")
        data = np.zeros(300)
        for i, row in enumerate(result):
            temp = float(row[0])
            data[i] = temp.real
        conn.close()
        return data

    def get_pond_ground_high_vf2f(self):
        engine = create_engine('sqlite:///sqlite_agdrift.db')
        conn = engine.connect()
        result = conn.execute("SELECT pond_ground_high_vf2f from output")
        data = np.zeros(300)
        for i, row in enumerate(result):
            temp = float(row[0])
            data[i] = temp.real
        conn.close()
        return data

    def get_pond_ground_high_f2m(self):
        engine = create_engine('sqlite:///sqlite_agdrift.db')
        conn = engine.connect()
        result = conn.execute("SELECT pond_ground_high_f2m from output")
        data = np.zeros(300)
        for i, row in enumerate(result):
            temp = float(row[0])
            data[i] = temp.real
        conn.close()
        return data

    def get_pond_ground_low_f2m(self):
        engine = create_engine('sqlite:///sqlite_agdrift.db')
        conn = engine.connect()
        result = conn.execute("SELECT pond_ground_low_f2m from output")
        data = np.zeros(300)
        for i, row in enumerate(result):
            temp = float(row[0])
            data[i] = temp.real
        conn.close()
        return data

    def get_pond_ground_low_vf2f(self):
        engine = create_engine('sqlite:///sqlite_agdrift.db')
        conn = engine.connect()
        result = conn.execute("SELECT pond_ground_low_vf2f from output")
        data = np.zeros(300)
        for i, row in enumerate(result):
            temp = float(row[0])
            data[i] = temp.real
        conn.close()
        return data

    def get_pond_aerial_vf2f(self):
        engine = create_engine('sqlite:///sqlite_agdrift.db')
        conn = engine.connect()
        result = conn.execute("SELECT pond_aerial_vf2f from output")
        data = np.zeros(300)
        for i, row in enumerate(result):
            temp = float(row[0])
            data[i] = temp.real
        conn.close()
        return data

    def get_pond_aerial_f2m(self):
        engine = create_engine('sqlite:///sqlite_agdrift.db')
        conn = engine.connect()
        result = conn.execute("SELECT pond_aerial_f2m from output")
        data = np.zeros(300)
        for i, row in enumerate(result):
            temp = float(row[0])
            data[i] = temp.real
        conn.close()
        return data

    def get_pond_aerial_m2c(self):
        engine = create_engine('sqlite:///sqlite_agdrift.db')
        conn = engine.connect()
        result = conn.execute("SELECT pond_aerial_m2c from output")
        data = np.zeros(300)
        for i, row in enumerate(result):
            temp = float(row[0])
            data[i] = temp.real
        conn.close()
        return data

    def get_pond_aerial_c2vc(self):
        engine = create_engine('sqlite:///sqlite_agdrift.db')
        conn = engine.connect()
        result = conn.execute("SELECT pond_aerial_c2vc from output")
        data = np.zeros(300)
        for i, row in enumerate(result):
            temp = float(row[0])
            data[i] = temp.real
        conn.close()
        return data

    def get_pond_airblast_orchard(self):
        engine = create_engine('sqlite:///sqlite_agdrift.db')
        conn = engine.connect()
        result = conn.execute("SELECT pond_airblast_orchard from output")
        data = np.zeros(300)
        for i, row in enumerate(result):
            temp = float(row[0])
            data[i] = temp.real
        conn.close()
        return data

    def get_pond_airblast_vineyard(self):
        engine = create_engine('sqlite:///sqlite_agdrift.db')
        conn = engine.connect()
        result = conn.execute("SELECT pond_airblast_vineyard from output")
        data = np.zeros(300)
        for i, row in enumerate(result):
            temp = float(row[0])
            data[i] = temp.real
        conn.close()
        return data
{'fraction_non_alphanumeric': 0.15389322665820518, 'fraction_numerical': 0.17736251034076359, 'mean_word_length': 2.718198289301816, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5979142', 'n_tokens_mistral': 43710, 'n_tokens_neox': 35485, 'n_words': 3973}