# Path: pymeteo/dynamics.py
# def avg_wind(_u, _v, _z, zmin, zmax):
# def storm_motion_rasmussen(_u,_v,_z):
# def storm_motion_bunkers(_u,_v,_z):
# def circulation(u, v, w, x, y, z):
# def integral_Bdz(th, thp, z):
# def integral_dt(i, t):
# def uv_to_deg(u,v):
# def wind_deg_to_uv(direction, speed):
# def shear(_u, _v, _z, zbot, ztop):
# def srh(_u,_v,_z, zbot, ztop, cx, cy):
# def mean_wind(_u,_v,_z, zbot, ztop):
# def brn(_u,_v,_z,cape):
#   C = 0.0
#   C = np.sum(-uavg*dx - vavg*dy - wavg*dz) 
#   C = C * km2m  # C now in units m2/s
# 
# Path: pymeteo/thermo.py
# def T(theta,p):
# def theta(T,p):
# def es(T):
# def esi(T):
# def w_vs(T,pd):
# def theta_v(th, qv):
# def Td(p, qv):
# def Lv(T):
# def p_from_pressure_altitude(pz, T):
# def th_e(p, t, td, qv):
# def q_vl(p, t):
# def q_vi(p, t):
# def dTdz_moist(T,p):
# def dTdp_moist(T,p):
# def Twb(z,p,th,qv,z0):
# def CAPE(z, p, t, q, parcel):


import re
import netCDF4
import gzip
import io
import tempfile
import os
import numpy as np
    import urllib2 as request
from PyQt5 import QtWidgets, QtGui, QtCore
from PyQt5.QtCore import pyqtSignal, pyqtSlot
from datetime import datetime
from pymeteo import dynamics, thermo
    from urllib import request
            for _, line in enumerate(f):
                fields = line.strip().split()
                airport_ids[int(fields[0])] = fields[1]
    return airport_ids[airport_id]

def processDataSet(data):
    print("[+] Writing data into temporary file")
    tdata = tempfile.NamedTemporaryFile()
    tdata.write(data.read())
    print("[-] Data written to {0}".format(tdata.name))
    print("[+] Opening data as NetCDF")
    d = data.read()
    with netCDF4.Dataset(tdata.name, mode='r') as nc:
        print("[-] Dataset open with")

        _z = nc["altitude"][:]
        _T = nc["temperature"][:]
        _qv = nc["waterVaporMR"][:]
        windSpeed = nc["windSpeed"][:]
        windDir = nc["windDir"][:]
        _lon = nc["longitude"][:]
        _lat = nc["latitude"][:]
        flag = nc["sounding_flag"][:]
        _airport = nc["sounding_airport_id"][:]
        time = nc["soundingSecs"][:]

        print ("[-] {0} Records".format(len(_z)))
        #conversions
        _p = thermo.p_from_pressure_altitude(_z, _T)
        _u, _v = dynamics.wind_deg_to_uv(windDir, windSpeed)

# Path: pymeteo/dynamics.py
# def avg_wind(_u, _v, _z, zmin, zmax):
# def storm_motion_rasmussen(_u,_v,_z):
# def storm_motion_bunkers(_u,_v,_z):
# def circulation(u, v, w, x, y, z):
# def integral_Bdz(th, thp, z):
# def integral_dt(i, t):
# def uv_to_deg(u,v):
# def wind_deg_to_uv(direction, speed):
# def shear(_u, _v, _z, zbot, ztop):
# def srh(_u,_v,_z, zbot, ztop, cx, cy):
# def mean_wind(_u,_v,_z, zbot, ztop):
# def brn(_u,_v,_z,cape):
#   C = 0.0
#   C = np.sum(-uavg*dx - vavg*dy - wavg*dz) 
#   C = C * km2m  # C now in units m2/s
# 
# Path: pymeteo/thermo.py
# def T(theta,p):
# def theta(T,p):
# def es(T):
# def esi(T):
# def w_vs(T,pd):
# def theta_v(th, qv):
# def Td(p, qv):
# def Lv(T):
# def p_from_pressure_altitude(pz, T):
# def th_e(p, t, td, qv):
# def q_vl(p, t):
# def q_vi(p, t):
# def dTdz_moist(T,p):
# def dTdp_moist(T,p):
# def Twb(z,p,th,qv,z0):
# def CAPE(z, p, t, q, parcel):


# Path: pymeteo/data/acars.py
import re
import netCDF4
import gzip
import io
import tempfile
import os
import numpy as np
    import urllib2 as request
from PyQt5 import QtWidgets, QtGui, QtCore
from PyQt5.QtCore import pyqtSignal, pyqtSlot
from datetime import datetime
from pymeteo import dynamics, thermo
    from urllib import request

            for _, line in enumerate(f):
                fields = line.strip().split()
                airport_ids[int(fields[0])] = fields[1]
    return airport_ids[airport_id]

def processDataSet(data):
    print("[+] Writing data into temporary file")
    tdata = tempfile.NamedTemporaryFile()
    tdata.write(data.read())
    print("[-] Data written to {0}".format(tdata.name))
    print("[+] Opening data as NetCDF")
    d = data.read()
    with netCDF4.Dataset(tdata.name, mode='r') as nc:
        print("[-] Dataset open with")

        _z = nc["altitude"][:]
        _T = nc["temperature"][:]
        _qv = nc["waterVaporMR"][:]
        windSpeed = nc["windSpeed"][:]
        windDir = nc["windDir"][:]
        _lon = nc["longitude"][:]
        _lat = nc["latitude"][:]
        flag = nc["sounding_flag"][:]
        _airport = nc["sounding_airport_id"][:]
        time = nc["soundingSecs"][:]

        print ("[-] {0} Records".format(len(_z)))
        #conversions
        _p = thermo.p_from_pressure_altitude(_z, _T)
        _u, _v = dynamics.wind_deg_to_uv(windDir, windSpeed)

        _th = thermo.theta(_T, _p)