Skip to content

Commit 1ece4a4

Browse files
committed
Several smaller bugfixes
- pd.Timedelta does not like to be initialized with `tz` argument, failing with "Cannot pass a datetime or Timestamp with tzinfo with the tz parameter. Use tz_convert instead." My understanding is that since all timezones are UTC throughout, it should be safe to drop this everywhere. - flph.fuzzylabels returns a list for me, and so I explicitly convert it to an np.array before applying fancy indexing with `labels[pts] = 'GND'`. Before, this would error with "list indices must be integers or slices, not tuple". - The existing glob pattern did not seem to work for the new way of saving pickles into subdirectories of `outdir`. Instead I'm now applying to separate glob patterns that will pick up pkl files from the `INDATA/` directory and its subdirectories. - I'm creating the output directories for plots and data if they do not exist already. - The plotting functions mysteriously saw a `GN` label. I'm really not sure if this is the right thing to do here, but I simply assumed that this was the same as `GND` and added another entry to the colormap accordingly. This may be really a symptom of a bug that should be fixed in another place. - In proc_fl, set `odir_np` also when do_save==False, because it's used later on.
1 parent 3810b9b commit 1ece4a4

2 files changed

Lines changed: 15 additions & 11 deletions

File tree

GA_Detect.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import multiprocessing as mp
55
from OS_Airports import VABB
66
import OS_Funcs as OSF
7+
import os
78
import glob
89

910

@@ -39,6 +40,8 @@ def main(start_n, fidder, do_write):
3940
odir_da_ga = top_dir + 'OUT_DATA/PSGA/'
4041

4142
odirs = [odir_pl_nm, odir_pl_ga, odir_da_nm, odir_da_ga]
43+
for odir in odirs:
44+
os.makedirs(odir, exist_ok=True)
4245

4346
# Output filenames for saving data about go-arounds
4447
out_file_ga = 'GA_MET_NEW.csv'
@@ -60,12 +63,12 @@ def main(start_n, fidder, do_write):
6063
Temp, Dewp, Wind_Spd, Wind_Gust, Wind_Dir,Cld_Base,\
6164
CB, Vis, Pressure\n')
6265
files = []
63-
files = glob.glob(indir+'**.pkl')
66+
files = glob.glob(indir+'*.pkl') + glob.glob(indir+'*/*.pkl')
6467
files.sort()
6568

6669
fli_len = len(files)
6770

68-
colormap = {'GND': 'black', 'CL': 'green', 'CR': 'blue',
71+
colormap = {'GND': 'black', 'GN': 'black', 'CL': 'green', 'CR': 'blue',
6972
'DE': 'orange', 'LVL': 'purple', 'NA': 'red'}
7073

7174
# Number of files to open in one go

OS_Funcs.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ def proc_fl(flight, check_rwys, odirs, colormap, do_save, verbose):
351351
# Correct barometric altitudes
352352
t_alt = fd['alts']
353353
l_time = fd['strt'] + (fd['dura'] / 2)
354-
l_time = pd.Timestamp(l_time, tz='UTC')
354+
l_time = pd.Timestamp(l_time)
355355
bmet, tdiff = find_closest_metar(l_time, metars)
356356
if (bmet is not None):
357357
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):
363363
# Now the actual go-around check
364364
ga_flag, gapt = check_ga(fd, True)
365365

366+
if (ga_flag):
367+
odir_pl = odirs[1]
368+
odir_np = odirs[3]
369+
else:
370+
odir_pl = odirs[0]
371+
odir_np = odirs[2]
372+
366373
# Make some plots if required, this needs a spline to smooth output
367374
if do_save:
368375
spldict = create_spline(fd, bpos=None)
369376
# Choose output directory based upon go-around flag
370-
if (ga_flag):
371-
odir_pl = odirs[1]
372-
odir_np = odirs[3]
373-
else:
374-
odir_pl = odirs[0]
375-
odir_np = odirs[2]
376377
OSO.do_plots(fd,
377378
spldict,
378379
colormap,
@@ -381,8 +382,7 @@ def proc_fl(flight, check_rwys, odirs, colormap, do_save, verbose):
381382
bpos=None)
382383
if (ga_flag):
383384
ga_time = pd.Timestamp(fd['strt'] +
384-
pd.Timedelta(seconds=fd['time'][gapt]),
385-
tz='UTC')
385+
pd.Timedelta(seconds=fd['time'][gapt]))
386386
else:
387387
gapt = 0
388388
ga_time = fd['strt']
@@ -679,6 +679,7 @@ def do_labels(fd):
679679
try:
680680
labels = flph.fuzzylabels(fd['time'], fd['alts'],
681681
fd['spds'], fd['rocs'], twindow=15)
682+
labels = np.array(labels)
682683
except Exception as e:
683684
print("Error creating spline", e, fd['call'])
684685
quit()

0 commit comments

Comments
 (0)