<gh_stars>0
import tropomi_tools as tt
import letkf_utils as lu
from datetime import datetime

timeperiod = [datetime.strptime('2019-01-01 00:00', '%Y-%m-%d %H:%M'), datetime.strptime('2019-01-02 23:59', '%Y-%m-%d %H:%M')]

histens = lu.HIST_Ens('20190102_0000',True)
histens.getLocObsMeanPertDiff(0,0)

trans = tt.TROPOMI_Translator()

hist_trans = lu.HIST_Translator('/n/holyscratch01/jacob_lab/dpendergrass/GC-LETKF/test_4x5/',timeperiod)
gc = hist_trans.combineHist('CH4',True)

trop_dat = trans.getSatellite('CH4',timeperiod)

gc_cols,trop_cols = trans.gcCompare('CH4',timeperiod,trop_dat,gc)

import letkf_utils as lu
assimilator = lu.Assimilator('20190110_0000',4,4)

latval = assimilator.latinds[0]
lonval = assimilator.loninds[0]
assimilator.prepareMeansAndPerts(latval,lonval)
assimilator.makeR(latval,lonval)
assimilator.makeC()
assimilator.makePtildeAnalysis()
assimilator.makeWAnalysis()
assimilator.makeWbarAnalysis()
assimilator.adjWAnalysis()
assimilator.makeAnalysisCombinedEnsemble()
assimilator.saveColumn(latval,lonval)

assimilator.analysisEnsemble = np.zeros(np.shape(assimilator.Xpert_background))
for i in assimilator.ensemble_numbers:
	assimilator.analysisEnsemble[:,i] = assimilator.Xpert_background[:,i]+assimilator.xbar_background	

# sourcedir = trans.spc_config['TROPOMI_dirs']['CH4']
# obs_list = glob(f'{sourcedir}/S5P_*.nc')
# obs_list.sort()

# with open(f"{trans.scratch}/tropomi_dates.pickle", 'rb') as handle:
# 	TROPOMI_date_dict = pickle.load(handle)

# obs_dates = TROPOMI_date_dict['CH4']

import tropomi_tools as tt
import letkf_utils as lu
from datetime import datetime

timeperiod = [datetime.strptime('2019-01-01 00:00', '%Y-%m-%d %H:%M'), datetime.strptime('2019-01-02 23:59', '%Y-%m-%d %H:%M')]

histens = lu.HIST_Ens('20190102_0000',True)
histens.getLocObsMeanPertDiff(0,0)

trans = tt.TROPOMI_Translator()

hist_trans = lu.HIST_Translator('/n/holyscratch01/jacob_lab/dpendergrass/GC-LETKF/test_4x5/',timeperiod)
gc = hist_trans.combineHist('CH4',True)

trop_dat = trans.getSatellite('CH4',timeperiod)

gc_cols,trop_cols = trans.gcCompare('CH4',timeperiod,trop_dat,gc)

import letkf_utils as lu
assimilator = lu.Assimilator('20190110_0000',4,4)

latval = assimilator.latinds[0]
lonval = assimilator.loninds[0]
assimilator.prepareMeansAndPerts(latval,lonval)
assimilator.makeR(latval,lonval)
assimilator.makeC()
assimilator.makePtildeAnalysis()
assimilator.makeWAnalysis()
assimilator.makeWbarAnalysis()
assimilator.adjWAnalysis()
assimilator.makeAnalysisCombinedEnsemble()
assimilator.saveColumn(latval,lonval)

assimilator.analysisEnsemble = np.zeros(np.shape(assimilator.Xpert_background))
for i in assimilator.ensemble_numbers:
	assimilator.analysisEnsemble[:,i] = assimilator.Xpert_background[:,i]+assimilator.xbar_background	

# sourcedir = trans.spc_config['TROPOMI_dirs']['CH4']
# obs_list = glob(f'{sourcedir}/S5P_*.nc')
# obs_list.sort()

# with open(f"{trans.scratch}/tropomi_dates.pickle", 'rb') as handle:
# 	TROPOMI_date_dict = pickle.load(handle)

# obs_dates = TROPOMI_date_dict['CH4']
# sourcedir = trans.spc_config['TROPOMI_dirs']['CH4'] # obs_list = glob(f'{sourcedir}/S5P_*.nc') # obs_list.sort() # with open(f"{trans.scratch}/tropomi_dates.pickle", 'rb') as handle: # 	TROPOMI_date_dict = pickle.load(handle) # obs_dates = TROPOMI_date_dict['CH4']