Skip to content

Commit e8e2584

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.
1 parent 589d1bb commit e8e2584

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

GA_Detect.py

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

910

1011
def main(start_n, fidder, do_write):
@@ -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: 3 additions & 3 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)
@@ -381,8 +381,7 @@ def proc_fl(flight, check_rwys, odirs, colormap, do_save, verbose):
381381
bpos=None)
382382
if (ga_flag):
383383
ga_time = pd.Timestamp(fd['strt'] +
384-
pd.Timedelta(seconds=fd['time'][gapt]),
385-
tz='UTC')
384+
pd.Timedelta(seconds=fd['time'][gapt]))
386385
else:
387386
gapt = 0
388387
ga_time = fd['strt']
@@ -679,6 +678,7 @@ def do_labels(fd):
679678
try:
680679
labels = flph.fuzzylabels(fd['time'], fd['alts'],
681680
fd['spds'], fd['rocs'], twindow=15)
681+
labels = np.array(labels)
682682
except Exception as e:
683683
print("Error creating spline", e, fd['call'])
684684
quit()

0 commit comments

Comments
 (0)