from asist.pitot import read_pitot_from_netcdf
from datetime import datetime, timedelta
import numpy as np
import os
from netCDF4 import Dataset

np.warnings.filterwarnings('ignore')  # ignore numpy warnings

L2_DATA_PATH = os.environ['L2_DATA_PATH']

exp_name = 'asist-windonly-salt'
exp = experiments[exp_name]

hotfilm_filename = 'hotfilm_' + exp_name + '.nc'

origin, hotfilm_seconds, fan, ch1, ch2 = read_hotfilm_from_netcdf(
    hotfilm_filename)
origin, pitot_seconds, fan, u_pitot = read_pitot_from_netcdf(L2_DATA_PATH +
                                                             '/pitot_' +
                                                             exp_name + '.nc')

ch1, ch2 = clean_hotfilm_exp3(exp, ch1, ch2, hotfilm_seconds)

# start and end time of fitting period
t0 = exp.runs[1].start_time + timedelta(seconds=60)
t1 = exp.runs[-2].end_time

# start and end seconds of fitting period
t0_seconds = (t0 - origin).total_seconds()
t1_seconds = (t1 - origin).total_seconds()

# start index of pitot and hotfilm time series
from asist.hotfilm import hotfilm_velocity, read_hotfilm_from_netcdf
from asist.pitot import read_pitot_from_netcdf
from datetime import datetime, timedelta
import numpy as np
import os
import matplotlib.pyplot as plt

plt.rcParams.update({'font.size': 16}) # global font size setting
np.warnings.filterwarnings('ignore') # ignore numpy warnings

L2_DATA_PATH = os.environ['L2_DATA_PATH']

exp_name = 'asist-windonly-salt'
exp = experiments[exp_name]

origin, hotfilm_seconds, fan, ch1, ch2 = read_hotfilm_from_netcdf(L2_DATA_PATH + '/hotfilm_' + exp_name + '.nc')
origin, pitot_seconds, fan, u = read_pitot_from_netcdf(L2_DATA_PATH + '/pitot_' + exp_name + '.nc')

ch1, ch2 = clean_hotfilm_exp3(exp, ch1, ch2, hotfilm_seconds)

# start and end time of fitting period
t0 = exp.runs[1].start_time + timedelta(seconds=60)
t1 = exp.runs[-2].end_time

# start and end seconds of fitting period
t0_seconds = (t0 - origin).total_seconds()
t1_seconds = (t1 - origin).total_seconds()

# start index of pitot and hotfilm time series
n0 = np.argmin((pitot_seconds - t0_seconds)**2)
n1 = np.argmin((pitot_seconds - t1_seconds)**2)