# Data Columns in Each Dataset
Calibrated_Data_Columns = {
    "B1dw"         : "Spectrometer data Bands 1 downwelling (W/m^2/band)",
    "B1uw"         : "Spectrometer data Bands 1 upwelling (W/m^2/band)",
    "B2dw"         : "Spectrometer data Bands 2 downwelling (W/m^2/band)",
    "B2uw"         : "Spectrometer data Bands 2 upwelling (W/m^2/band)",
    "B3dw"         : "Spectrometer data Bands 3 downwelling (W/m^2/band)",
    "B3uw"         : "Spectrometer data Bands 3 upwelling (W/m^2/band)",
    "B4dw"         : "Spectrometer data Bands 4 downwelling (W/m^2/band)",
    "B4uw"         : "Spectrometer data Bands 4 upwelling (W/m^2/band)",
    "B5dw"         : "Spectrometer data Bands 5 downwelling (W/m^2/band)",
    "B5uw"         : "Spectrometer data Bands 5 upwelling (W/m^2/band)",
    "B6dw"         : "Spectrometer data Bands 6 downwelling (W/m^2/band)",
    "B6uw"         : "Spectrometer data Bands 6 upwelling (W/m^2/band)",
    "B7dw"         : "Spectrometer data Bands 7 downwelling (W/m^2/band)",
    "B7uw"         : "Spectrometer data Bands 7 upwelling (W/m^2/band)",
    "LWdw"         : "Long wave downwelling, hourly mean (W/m^2)",
    "LWuw"         : "Long wave upwelling, hourly mean (W/m^2)",
    "P"            : "Pressure (kPa)",
    "PARdw"        : "Photosynthetically Active Radiation downwelling (uE/m^2/s)",
    "PARuw"        : "Photosynthetically Active Radiation upwelling (uE/m^2/s)",
    "RH"           : "Relative humidity [0-1]",
    "SWdw"         : "Short wave downwelling, hourly mean (W/m^2)",
    "SWuw"         : "Short wave upwelling, hourly mean (W/m^2)",
    "Tabove"       : "Sky temperature (C)",
    "Tair"         : "Air temperature (C)",
    "Tbelow"       : "Leaf/Ground temperature (C)",
    "tair_version" : "UNKNOWN"
}

Hourly_Data_Columns = {
    "B1dw"         : "Spectrometer data Bands 1 downwelling (W/m^2/band)",
    "B1uw"         : "Spectrometer data Bands 1 upwelling (W/m^2/band)",
    "B2dw"         : "Spectrometer data Bands 2 downwelling (W/m^2/band)",
    "B2uw"         : "Spectrometer data Bands 2 upwelling (W/m^2/band)",
    "B3dw"         : "Spectrometer data Bands 3 downwelling (W/m^2/band)",
    "B3uw"         : "Spectrometer data Bands 3 upwelling (W/m^2/band)",
    "B4dw"         : "Spectrometer data Bands 4 downwelling (W/m^2/band)",
    "B4uw"         : "Spectrometer data Bands 4 upwelling (W/m^2/band)",
    "B5dw"         : "Spectrometer data Bands 5 downwelling (W/m^2/band)",
    "B5uw"         : "Spectrometer data Bands 5 upwelling (W/m^2/band)",
    "B6dw"         : "Spectrometer data Bands 6 downwelling (W/m^2/band)",
    "B6uw"         : "Spectrometer data Bands 6 upwelling (W/m^2/band)",
    "B7dw"         : "Spectrometer data Bands 7 downwelling (W/m^2/band)",
    "B7uw"         : "Spectrometer data Bands 7 upwelling (W/m^2/band)",
    "LWdw"         : "Long wave downwelling, hourly mean (W/m^2)",
    "LWuw"         : "Long wave upwelling, hourly mean (W/m^2)",
    "LfW"          : "Leaf wetness [-, 1]",
    "P"            : "Pressure (kPA)",
    "SLP"          : "Sea Level Pressure (kPA)",
    "PARdw"        : "Photosynthetically Active Radiation downwelling (uE/m^2/s)",
    "PARuw"        : "Photosynthetically Active Radiation upwelling (uE/m^2/s)",
    "RH"           : "Relative humidity [0-1]",
    "SWdw"         : "Short wave downwelling, hourly mean (W/m^2)",
    "SWuw"         : "Short wave upwelling, hourly mean (W/m^2)",
    "Tabove"       : "Sky temperature (C)",
    "Tair"         : "Air temperature (C)",
    "Tbelow"       : "Leaf/Ground temperature (C)",
    "Tdew"         : "Dew temperature (C)",
    "prate"        : "Precipitation rate (mm/hr)",
    "precip"       : "Precipitation total (mm)"
}

Daily_Data_Columns = {
    "CGDD"              : "Cumulative Growing Degree Days, accumulated from time of install (C-days)",
    "Cl"                : "Chlorophyll Index",
    "ET"                : "Evapotranspiration (ET_o, mm)",
    "GDD"               : "Growing Degree Days for the day (C-days)",
    "LfAirDelta"        : "Leaf to Air temperature difference (C)",
    "NDVI"              : "Normalized Difference Vegetation Index [-1,1]",
    "SWdw"              : "Short wave downwelling, hourly mean (Megajoules/m^2)",
    "maxT"              : "Daily Maximum Temperature (C)",
    "meanT"             : "Daily Mean Temperature (C)",
    "minT"              : "Daily Minimum Temperature (C)",
    "prate"             : "Precipitation rate (mm/hr)",
    "precip"            : "Precipitation total (mm)",
    "SLP"               : "Sea Level Pressure (kPA)",
    "Kc"                : "Crop coefficient (K_c)",
    "ETc"               : "Crop Evapotranspiration (mm)",
    "mean_tbelow"       : "Daily Mean Leaf/Ground temperature (C)",
    "lfw"               : "Leaf wetness [-, 1]",
    "crop_water_demand" : "Crop Water Demand",
    "sunshine_duration" : "Sunshine Duration"
}

Soil_Data_Columns = {
    "device"          :"Device ID",
    "time"            :"Time stamp",
    "sdi12_value_0"   :"5TE raw VWC (dielectric permittivity)",
    "sdi12_value_1"   :"5TE Bulk EC (dS/m)",
    "sdi12_value_2"   :"5TE Temp (C)",
    "analog"          :"EC-5 Sensor VWC (%)"
}

# Units for Data Columns in Each Dataset

Calibrated_Data_Columns_Units = {
    "B1dw"         : "",
    "B1uw"         : "W/m^2/band",
    "B2dw"         : "W/m^2/band",
    "B2uw"         : "W/m^2/band",
    "B3dw"         : "W/m^2/band",
    "B3uw"         : "W/m^2/band",
    "B4dw"         : "W/m^2/band",
    "B4uw"         : "W/m^2/band",
    "B5dw"         : "W/m^2/band",
    "B5uw"         : "W/m^2/band",
    "B6dw"         : "W/m^2/band",
    "B6uw"         : "W/m^2/band",
    "B7dw"         : "W/m^2/band",
    "B7uw"         : "W/m^2/band",
    "LWdw"         : "(W/m^2)",
    "LWuw"         : "W/m^2",
    "P"            : "kPA",
    "PARdw"        : "uE/m^2/s",
    "PARuw"        : "uE/m^2/s",
    "RH"           : "between 0 and 1",
    "SWdw"         : "W/m^2",
    "SWuw"         : "W/m^2",
    "Tabove"       : "C",
    "Tair"         : "C",
    "Tbelow"       : "C",
    "tair_version" : "UNKNOWN"
}

Hourly_Data_Columns_Units = {
    "B1dw"         : "W/m^2/band",
    "B1uw"         : "W/m^2/band",
    "B2dw"         : "W/m^2/band",
    "B2uw"         : "W/m^2/band",
    "B3dw"         : "W/m^2/band",
    "B3uw"         : "W/m^2/band",
    "B4dw"         : "W/m^2/band",
    "B4uw"         : "W/m^2/band",
    "B5dw"         : "W/m^2/band",
    "B5uw"         : "W/m^2/band",
    "B6dw"         : "W/m^2/band",
    "B6uw"         : "W/m^2/band",
    "B7dw"         : "W/m^2/band",
    "B7uw"         : "W/m^2/band",
    "LWdw"         : "W/m^2",
    "LWuw"         : "W/m^2",
    "LfW"          : "[-, 1]",
    "P"            : "kPA",
    "SLP"          : "kPA",
    "PARdw"        : "(uE/m^2/s)",
    "PARuw"        : "uE/m^2/s",
    "RH"           : "between 0 and 1",
    "SWdw"         : "W/m^2",
    "SWuw"         : "W/m^2",
    "Tabove"       : "C",
    "Tair"         : "C",
    "Tbelow"       : "C",
    "Tdew"         : "C",
    "prate"        : "mm/hr",
    "precip"       : "mm"
}

Daily_Data_Columns_Units = {
    "CGDD"              : "C-days",
    "Cl"                : "Unitless index",
    "ET"                : "mm",
    "GDD"               : "C-days",
    "LfAirDelta"        : "C",
    "NDVI"              : "Unitless index between -1 and 1",
    "SWdw"              : "Megajoules/m^2",
    "maxT"              : "C",
    "meanT"             : "C",
    "minT"              : "C",
    "prate"             : "mm/day",
    "precip"            : "mm",
    "SLP"               : "kPa",
    "Kc"                : "Unitless",
    "ETc"               : "mm",
    "mean_tbelow"       : "C",
    "lfw"               : "[-, 1]",
    "crop_water_demand" : "UNKNOWN",
    "sunshine_duration" : "UNKNOWN"
}

import arable
from   arable.client   import ArableClient as a
a = a()
def arable_query(a, b, c, d, e, f, g):
    df = a.query(select = str(a),
               format = str(b),
               devices = c,
               measure = str(d),
               order = str(e),
               end = f,
               start = g,
               limit = 100000000)
    return df