From a5c1e72cac2eb0f09ac8684e4e6f8241ca3ca0cd Mon Sep 17 00:00:00 2001 From: fly Date: Sun, 3 May 2020 22:46:39 +1000 Subject: [PATCH] Caught up to C++ Signed-off-by: fly --- aloftWxr.py | 19 +++++++++++++ config.py | 16 +++++++++++ dataCycle.py | 28 +++++++++++++++++++ fg.py | 20 +++++++++++++ functions.py | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++ wind.py | 29 +++++++++++++++++++ 6 files changed, 191 insertions(+) diff --git a/aloftWxr.py b/aloftWxr.py index 08f3bde..5b8c673 100755 --- a/aloftWxr.py +++ b/aloftWxr.py @@ -1,8 +1,27 @@ #! /usr/bin/python3 +# Copyright (C) 2020 Merspieler, merspieler _at_ airmail.cc +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import pygrib import sys from config import config +from dataCycle import dataCycle +from fg import connection +from wind import windpoint +from functions import getForecast, getFilename, getMillibars conf = config() diff --git a/config.py b/config.py index 022e63e..6e7f2ca 100644 --- a/config.py +++ b/config.py @@ -1,3 +1,19 @@ +# Copyright (C) 2020 Merspieler, merspieler _at_ airmail.cc +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + import sys import os diff --git a/dataCycle.py b/dataCycle.py index e69de29..3cdf759 100644 --- a/dataCycle.py +++ b/dataCycle.py @@ -0,0 +1,28 @@ +# Copyright (C) 2020 Merspieler, merspieler _at_ airmail.cc +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +from time import time, gmtime + +class dataCycle: + def __init__(self): + timeStamp = gmtime(time() - 18000) + self.hour = timeStamp.tm_hour + self.day = timeStamp.tm_mday + self.month = timeStamp.tm_mon + self.year = timeStamp.tm_year + self.cycle = self.hour - (self.hour % 6) + def getString(self): + return '{:04d}{:02d}{:02d}/{:02d}'.format(self.year, self.month, self.day, self.cycle) diff --git a/fg.py b/fg.py index e69de29..287811f 100644 --- a/fg.py +++ b/fg.py @@ -0,0 +1,20 @@ +# Copyright (C) 2020 Merspieler, merspieler _at_ airmail.cc +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class connection: + def sendData(wp): + # TODO + pass diff --git a/functions.py b/functions.py index e69de29..ba360e4 100644 --- a/functions.py +++ b/functions.py @@ -0,0 +1,79 @@ +# Copyright (C) 2020 Merspieler, merspieler _at_ airmail.cc +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +from time import time, gmtime + +def getForecast(cycle): + ts = gmtime(time() - 18000) + return ts.tm_hour - (ts.tm_hour % 3) + +def getFilename(dc, fc): + return 'gfs.t{:02d}z.pgrb2full.0p50.f0{:02d}'.format(dc.cycle, fc) + +def getMillibars(alt): + if alt < 710 or alt > 54000: # 1000mb and 75mb + return -9999; + if alt >= 710 and alt < 1410: + return 975; + if alt >= 1410 and alt < 2135: + return 950; + if alt >= 2135 and alt < 2875: + return 925; + if alt >= 2875 and alt < 4000: + return 900; + if alt >= 4000 and alt < 5600: + return 850; + if alt >= 5600 and alt < 7235: + return 800; + if alt >= 7235 and alt < 8995: + return 750; + if alt >= 8995 and alt < 10820: + return 700; + if alt >= 10820 and alt < 12775: + return 650; + if alt >= 12775 and alt < 14865: + return 600; + if alt >= 14865 and alt < 17100: + return 550; + if alt >= 17100 and alt < 19530: + return 500; + if alt >= 19530 and alt < 22160: + return 450; + if alt >= 22160 and alt < 25065: + return 400; + if alt >= 25065 and alt < 27450: + return 350; + if alt >= 27450 and alt < 29170: + return 325; + if alt >= 29170 and alt < 31000: + return 300; + if alt >= 31000 and alt < 32965: + return 275; + if alt >= 32965 and alt < 35100: + return 250; + if alt >= 35100 and alt < 37400: + return 225; + if alt >= 37400 and alt < 39950: + return 200; + if alt >= 39950 and alt < 42800: + return 175; + if alt >= 42800 and alt < 46000: + return 150; + if alt >= 46000 and alt < 49750: + return 125; + if alt >= 49750 and alt < 54000: + return 100; + return -9999; diff --git a/wind.py b/wind.py index e69de29..dd9482d 100644 --- a/wind.py +++ b/wind.py @@ -0,0 +1,29 @@ +# Copyright (C) 2020 Merspieler, merspieler _at_ airmail.cc +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class wind: + direction = 0 + speed = 0 + +class windpoint: + def __init__(self): + self.lat = 0 + self.lon = 0 + self.winds = [] + i = 0 + while i < 9: + self.winds.append(wind()) + i += 1