"""
Ingest files provided by NLAE containing flux information
"""
import os
from io import StringIO
import datetime

import pytz
import pandas as pd
from pyiem.observation import Observation
from pyiem.util import get_dbconn, logger, utc, convert_value, c2f

LOG = logger()
BASEDIR = "/mesonet/home/mesonet/ot/ot0005/incoming/Fluxdata"
FILENAMES = {
    "NSTL10": ["Flux10_AF_15.dat", "Anc10_AF_15.dat"],
    "NSTL11": ["Flux11_AF_15.dat", "Anc11_AF_15.dat"],
    "NSTL30FT": ["30ft_15.dat"],
    "NSTLNSPR": ["NSP_Flux_15.dat"],
}

DBCOLS = [
    "station",
    "valid",
    "fc_wpl",
    "le_wpl",
    "hs",
    "tau",
    "u_star",
    "cov_uz_uz",
    "cov_uz_ux",
    "cov_uz_uy",
    "cov_uz_co2",
    "cov_uz_h2o",
    "cov_uz_ts",
    "cov_ux_ux",
    "cov_ux_uy",
    "cov_ux_co2",
    "cov_ux_h2o",
    "cov_ux_ts",
    "cov_uy_uy",
    "cov_uy_co2",
    "cov_uy_h2o",
    "cov_uy_ts",
    "cov_co2_co2",
    "cov_h2o_h2o",
    "cov_ts_ts",
    "ux_avg",
    "uy_avg",
    "uz_avg",
    "co2_avg",
    "h2o_avg",
    "ts_avg",
    "rho_a_avg",
    "press_avg",
    "panel_temp_avg",
    "wnd_dir_compass",
    "wnd_dir_csat3",
    "wnd_spd",
    "rslt_wnd_spd",
    "batt_volt_avg",
    "std_wnd_dir",
    "fc_irga",
    "le_irga",
    "co2_wpl_le",
    "co2_wpl_h",
    "h2o_wpl_le",