diff --git a/GA_Detect.py b/GA_Detect.py index 0fe66d0..c52b0c4 100644 --- a/GA_Detect.py +++ b/GA_Detect.py @@ -4,6 +4,7 @@ import multiprocessing as mp from OS_Airports import VABB import OS_Funcs as OSF +import os import glob @@ -39,6 +40,8 @@ def main(start_n, fidder, do_write): odir_da_ga = top_dir + 'OUT_DATA/PSGA/' odirs = [odir_pl_nm, odir_pl_ga, odir_da_nm, odir_da_ga] + for odir in odirs: + os.makedirs(odir, exist_ok=True) # Output filenames for saving data about go-arounds out_file_ga = 'GA_MET_NEW.csv' @@ -60,12 +63,12 @@ def main(start_n, fidder, do_write): Temp, Dewp, Wind_Spd, Wind_Gust, Wind_Dir,Cld_Base,\ CB, Vis, Pressure\n') files = [] - files = glob.glob(indir+'**.pkl') + files = glob.glob(indir+'*.pkl') + glob.glob(indir+'*/*.pkl') files.sort() fli_len = len(files) - colormap = {'GND': 'black', 'CL': 'green', 'CR': 'blue', + colormap = {'GND': 'black', 'GN': 'black', 'CL': 'green', 'CR': 'blue', 'DE': 'orange', 'LVL': 'purple', 'NA': 'red'} # Number of files to open in one go diff --git a/OS_Funcs.py b/OS_Funcs.py index 956fa4f..3bfe67d 100644 --- a/OS_Funcs.py +++ b/OS_Funcs.py @@ -351,7 +351,7 @@ def proc_fl(flight, check_rwys, odirs, colormap, do_save, verbose): # Correct barometric altitudes t_alt = fd['alts'] l_time = fd['strt'] + (fd['dura'] / 2) - l_time = pd.Timestamp(l_time, tz='UTC') + l_time = pd.Timestamp(l_time) bmet, tdiff = find_closest_metar(l_time, metars) if (bmet is not None): t_alt = correct_baro(t_alt, bmet.temp, bmet.pres) @@ -363,16 +363,17 @@ def proc_fl(flight, check_rwys, odirs, colormap, do_save, verbose): # Now the actual go-around check ga_flag, gapt = check_ga(fd, True) + if (ga_flag): + odir_pl = odirs[1] + odir_np = odirs[3] + else: + odir_pl = odirs[0] + odir_np = odirs[2] + # Make some plots if required, this needs a spline to smooth output if do_save: spldict = create_spline(fd, bpos=None) # Choose output directory based upon go-around flag - if (ga_flag): - odir_pl = odirs[1] - odir_np = odirs[3] - else: - odir_pl = odirs[0] - odir_np = odirs[2] OSO.do_plots(fd, spldict, colormap, @@ -381,8 +382,7 @@ def proc_fl(flight, check_rwys, odirs, colormap, do_save, verbose): bpos=None) if (ga_flag): ga_time = pd.Timestamp(fd['strt'] + - pd.Timedelta(seconds=fd['time'][gapt]), - tz='UTC') + pd.Timedelta(seconds=fd['time'][gapt])) else: gapt = 0 ga_time = fd['strt'] @@ -679,6 +679,7 @@ def do_labels(fd): try: labels = flph.fuzzylabels(fd['time'], fd['alts'], fd['spds'], fd['rocs'], twindow=15) + labels = np.array(labels) except Exception as e: print("Error creating spline", e, fd['call']) quit()