Skip to content
Snippets Groups Projects
Commit 5556a4c1 authored by tomrink's avatar tomrink
Browse files

snapshot...

parent fc7b0c59
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,7 @@ from netCDF4 import Dataset
import datetime
from datetime import timezone
from util.util import LatLonTuple
import re
# -- AMV intercompare stuff ------------------------------------------
# --------------------------------------------------------------------
......@@ -41,6 +42,70 @@ amv_qif_idx = amv_hdr_list.index('qif')
amv_centers_list = ['EUM', 'BRZ', 'JMA', 'KMA', 'NOA', 'NWC']
NO_ICE = '\s*NEG\s*|\s*NONE\s*|\s*NEGATIVE\s*|\s*NO\s*'
ICE_LVL = '\d+-\d+|FL\d+-FL\d+'
def pireps(filename):
reports = []
lats = []
lons = []
alts = []
no_ice_reports = []
ice_reports = []
with open(filename) as file:
all = 0
cnt = 0
for idx, line in enumerate(file):
all += 1
toks = line.split(',')
report = toks[3]
# Flight level
f_i = report.find('/FL')
if f_i >= 0:
fl = report[f_i+3:]
ti = fl.find('/TP')
fl = fl[:ti]
fl = fl.rstrip()
fl = fl.lstrip()
if fl.isnumeric():
fl = float(fl) * 100 * 0.3048 # conv flight level to meters
else:
continue
# Icing
ii = report.find('/IC')
if ii >= 0:
s = report[ii+3:]
ri = s.find('/RM')
lat = float(toks[4])
lon = float(toks[5])
if ri >= 0:
s = s[:ri]
else:
ri = s.find(',')
if ri >= 0:
s = s[:ri]
s = s.lstrip()
if s.find('N/A') >= 0:
continue
if len(re.findall(NO_ICE, s)) != 0:
no_ice_reports.append(idx)
else:
ice_reports.append(idx)
reports.append(s)
lats.append(lat)
lons.append(lon)
alts.append(fl)
cnt += 1
lats = np.array(lats)
lons = np.array(lons)
print(len(ice_reports), len(no_ice_reports))
def get_amv_nd(filename):
header = None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment