Skip to content

Commit

Permalink
bug fixes; add testing
Browse files Browse the repository at this point in the history
  • Loading branch information
mammatus95 committed May 18, 2024
1 parent 3429788 commit 92c36e0
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 39 deletions.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Describe your changes


## Related Issues
- [x] #739
- [ ]
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@
*/*/*.pyc

src/modeldata
src/run.yml
56 changes: 29 additions & 27 deletions run_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,31 @@ fi
FP=${1}
R=0 # select run 0 or 12z
D=$(date +"%Y%m%d") # date in format YYYYMMDD
#######################################################################

echo
echo
echo "Hodograph Maps Run Script"
echo "Script configurations:"
echo "Version: 0.1"
echo
echo "Configurations:"
echo "Model run: ${R}z"
echo "Leadtime: ${FP}z"
echo "Config Date: " ${D}
echo "Today Date: " $(date)
echo "--------------------------------"
echo "Today Date: " $(date +"%d.%m.%Y")
echo
echo

#######################################################################
# load bash profile
source /etc/profile
# load bash profile and add Pythonpath
#source /etc/profile
export PYTHONPATH=$(pwd):$PYTHONPATH

#######################################################################
cd src
store_path=$(pwd)/modeldata

# rm log
rm ./log.txt
rm ./log.txt > /dev/null 2>&1

# create nwp directory and if not there a output images directory
mkdir -p ${store_path}
Expand Down Expand Up @@ -63,34 +68,34 @@ echo "Start downloading leadtime ${T}h"
# single level
for N in CAPE_ML CAPE_CON PS
do
typeset -l nvar
nvar=${N}
wget -q ${icon_model_pfad}/${nvar}/${icon_single}${T}_${N}.grib2.bz2 -P ${store_path} 2>&1 log.txt
bzip2 -dfq ${store_path}/${icon_single}${T}_${N}.grib2.bz2 >> log.txt 2>&1
typeset -l nvar
nvar=${N}
wget -q ${icon_model_pfad}/${nvar}/${icon_single}${T}_${N}.grib2.bz2 -P ${store_path} 2>&1 log.txt
bzip2 -dfq ${store_path}/${icon_single}${T}_${N}.grib2.bz2 >> log.txt 2>&1
done

for H in 1000 950 925 900 875 850 825 800 775 700 600 500 400 300
do
for N in U V
do
typeset -l nvar
nvar=${N}
wget -q ${icon_model_pfad}/${nvar}/${icon_pressure}${T}_${H}_${N}.grib2.bz2 -P ${store_path} >> log.txt 2>&1
bzip2 -dfq ${store_path}/${icon_pressure}${T}_${H}_${N}.grib2.bz2 >> log.txt 2>&1
done
for N in U V
do
typeset -l nvar
nvar=${N}
wget -q ${icon_model_pfad}/${nvar}/${icon_pressure}${T}_${H}_${N}.grib2.bz2 -P ${store_path} >> log.txt 2>&1
bzip2 -dfq ${store_path}/${icon_pressure}${T}_${H}_${N}.grib2.bz2 >> log.txt 2>&1
done
done

# ifs
ifs_file=${ifs_model_pfad}/${D}/$(printf "%02d" "$R")z/ifs/0p25/oper/${D}$(printf "%02d" "$R")0000-${FP}h-oper-fc.grib2
ifs_index=${ifs_model_pfad}/${D}/$(printf "%02d" "$R")z/ifs/0p25/oper/${D}$(printf "%02d" "$R")0000-${FP}h-oper-fc.index
wget ${ifs_file} -P ${store_path}/ >> log.txt 2>&1
wget ${ifs_index} -P ${store_path}/ >> log.txt 2>&1
wget -q ${ifs_file} -P ${store_path}/ >> log.txt 2>&1
wget -q ${ifs_index} -P ${store_path}/ >> log.txt 2>&1
mv ${store_path}/${D}$(printf "%02d" "$R")0000-${FP}h-oper-fc.grib2 ${store_path}/ifs_$(printf "%02d" "$R")z_${D}_f${T}.grib2
mv ${store_path}/${D}$(printf "%02d" "$R")0000-${FP}h-oper-fc.index ${store_path}/ifs_$(printf "%02d" "$R")z_${D}_f${T}.index

# gfs
gfs_file=${gfs_model_pfad}/gfs.${D}/$(printf "%02d" "$R")/atmos/gfs.t$(printf "%02d" "$R")z.pgrb2.0p25.f${T}
wget ${gfs_file} -P ${store_path}/ >> log.txt 2>&1
wget -q ${gfs_file} -P ${store_path}/ >> log.txt 2>&1
mv ${store_path}/gfs.t$(printf "%02d" "$R")z.pgrb2.0p25.f${T} ${store_path}/gfs_$(printf "%02d" "$R")z_${D}_f${T}.grib2

# Plot Hodograph
Expand All @@ -101,16 +106,13 @@ echo default_date: \"$(date +%Y-%m-%d)\" >> run.yml

echo "Plot Hodograph Maps"
# run python script

#which python3
python3 main.py IFS >> log.txt 2>&1
python3 main.py GFS >> log.txt 2>&1
python3 main.py ICON >> log.txt 2>&1

echo "done with leadtime ${T}h on $(date)"
ls -al ./images/*${FP}.png



ls -lh ./images/*${FP}.png

# remove nwp files
rm -rf ${store_path}
rm -r ${store_path}
2 changes: 1 addition & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def main():
raise ValueError(f"Unknown input field!\n Only CAPE ML works in the moment. Argument: {args.field}")

if args.Model is None:
model_obj = model.MODELIFNO("ICON EU", 1377, 657, 0.0625, "pres")
model_obj = model.MODELINFO("ICON EU", 1377, 657, 0.0625, "pres")
elif "ICON" in args.Model:
model_obj = model.icon_nest
elif args.Model == "IFS":
Expand Down
12 changes: 6 additions & 6 deletions src/modelinfolib.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from datetime import datetime, date
import pygrib
import numpy as np
import src.utilitylib as ut
import utilitylib as ut

"""
# ICON Nest
Expand Down Expand Up @@ -104,7 +104,7 @@
# ---------------------------------------------------------------------------------------------------------------------


class MODELIFNO:
class MODELINFO:

def __init__(self, modelname, nlon, nlat, d_grad, levtyp):
config = ut.load_yaml('config.yml')
Expand Down Expand Up @@ -196,7 +196,7 @@ def getnlev(self):
return len(self.levels)

def getlevtyp(self):
return self.d_grad
return self.levtyp

def getd_grad(self):
return self.d_grad
Expand Down Expand Up @@ -298,6 +298,6 @@ def open_icon_gribfile_single(self, fieldname, fp, path="./modeldata/"):


# Example usage:
icon_nest = MODELIFNO("ICON Nest", 1377, 657, 0.0625, "pres")
ifs = MODELIFNO("IFS", 1440, 721, 0.25, "pres")
gfs = MODELIFNO("GFS", 1440, 721, 0.25, "pres")
icon_nest = MODELINFO("ICON Nest", 1377, 657, 0.0625, "pres")
ifs = MODELINFO("IFS", 1440, 721, 0.25, "pres")
gfs = MODELINFO("GFS", 1440, 721, 0.25, "pres")
3 changes: 0 additions & 3 deletions src/run.yml

This file was deleted.

4 changes: 2 additions & 2 deletions test/test_modelinfo.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python3
import unittest
from datetime import datetime
# project moduls
# project modul
from src.modelinfolib import MODELINFO


Expand Down Expand Up @@ -42,7 +42,7 @@ def test_getnlev(self):
self.assertEqual(self.icon_nest.getnlev(), 14)

def test_getlevtyp(self):
self.assertEqual(self.icon_nest.getlevtyp(), 0.0625)
self.assertEqual(self.icon_nest.getlevtyp(), "pres")

def test_getd_grad(self):
self.assertEqual(self.icon_nest.getd_grad(), 0.0625)
Expand Down

0 comments on commit 92c36e0

Please sign in to comment.