Skip to content

Commit

Permalink
Add LPI #8
Browse files Browse the repository at this point in the history
  • Loading branch information
mammatus95 committed Jun 20, 2024
1 parent 362eb0b commit 135a506
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/greetings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ jobs:
- uses: actions/first-interaction@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
issue-message: "Message that will be displayed on users' first issue"
pr-message: "Message that will be displayed on users' first pull request"
issue-message: "Thanks for you suggestions to improve the project further."
pr-message: "Thanks for interest in the project. We will review the pull request as quickly as possible."
15 changes: 5 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,13 @@

**log.txt

*/*.png
*/*/*.png
**.png
**.svg
**.gif

*/*.svg
*/*/*.svg
**.log
**.pyc

*.log
*/*.log

*.pyc
*/*.pyc
*/*/*.pyc

src/modeldata
src/run.yml
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ You need to addg Conda initialization to your etc/profile, as well.

![Map of Hodographs IFS](images/hodographmap_IFS.png)

![Map of Hodographs GFS](images/hodographmap_GFS.png)
![Map of Hodographs GFS](images/GFS.gif)


## How to run
Expand Down
Binary file added images/GFS.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/ICON.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 9 additions & 6 deletions run_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fi


FP=${1}
R=0 # select run 0 or 12z
R=00 # select run 0 or 12z
D=$(date +"%Y%m%d") # date in format YYYYMMDD
#######################################################################

Expand Down Expand Up @@ -66,7 +66,7 @@ echo "Start downloading leadtime ${T}h"

# ICON
# single level
for N in CAPE_ML CAPE_CON PS
for N in CAPE_ML CAPE_CON PS LPI_CON_MAX
do
typeset -l nvar
nvar=${N}
Expand Down Expand Up @@ -107,13 +107,16 @@ echo default_date: \"$(date +%Y-%m-%d)\" >> run.yml
echo "Plot Hodograph Maps"
# run python script
#which python3
python3 main.py ICON >> log.txt 2>&1
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 -lh ./images/*${FP}.png

rm run.yml
# remove nwp files
rm -r ${store_path}

echo "done with leadtime ${T}h on $(date)"
cd ..
mkdir -p ./results_img
mv ./src/images/*${FP}.png ./results_img
ls -lh ./results_img/*${FP}.png
2 changes: 2 additions & 0 deletions src/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ hodomap : True

threshold: 0

lpi: True

fontsize: 14
titlesize: 18

Expand Down
2 changes: 1 addition & 1 deletion src/down_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ do
echo "Start downloading leadtime ${T}h"
# ICON
# single level
for N in CAPE_ML CAPE_CON PS
for N in CAPE_ML CAPE_CON PS LPI_CON_MAX
do
typeset -l nvar
nvar=${N}
Expand Down
9 changes: 8 additions & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,14 @@ def run_plots(model_obj, fp):
print(f"u_mean by lvl: {np.nanmean(u_fld, axis=(1, 2))}")
plotlib.basic_plot(model_obj, cape_fld, u_fld, v_fld, lats, lons, fp,
threshold=config["threshold"])
plotlib.basic_plot_custarea(model_obj, cape_fld, u_fld, v_fld, lats, lons, fp,

# Create a 2D array filled with NaNs
lpi_fld = np.full(cape_fld.shape, np.nan)
if config["lpi"] is True:
lpi_fld, _, _ = model_obj.open_icon_gribfile_single("LPI_CON_MAX", fp, path="./modeldata/")


plotlib.basic_plot_custarea(model_obj, cape_fld, lpi_fld, u_fld, v_fld, lats, lons, fp,
threshold=config["threshold"])
else:
print("Wrong command line argument")
Expand Down
13 changes: 10 additions & 3 deletions src/plotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def basic_plot(model_obj, cape_fld, u, v, lats, lons, hour, threshold=10., imfmt
plt.close()


def basic_plot_custarea(model_obj, cape_fld, u, v, lats, lons, hour, threshold=10., imfmt="png"):
def basic_plot_custarea(model_obj, cape_fld, lpi_fld, u, v, lats, lons, hour, threshold=10., imfmt="png"):
pres_levels = model_obj.getlevels()
model_name = model_obj.getname()
start = model_obj.getrun()
Expand All @@ -275,6 +275,12 @@ def basic_plot_custarea(model_obj, cape_fld, u, v, lats, lons, hour, threshold=1
wx = ax.contourf(lons, lats, cape_fld[:, :], levels=clevs, transform=crs.PlateCarree(),
cmap=cmap, extend='max', alpha=0.4, antialiased=True)

# LPI contours
lpi_levs = np.array([50, 500])
cs = plt.contour(lons, lats, lpi_fld[:,:], levels=lpi_levs, transform=crs.PlateCarree(), colors='darkred', linewidths=1.4)
fmt = '%.f'
plt.clabel(cs, fontsize=9, inline=1, fmt=fmt)

for i in range(340, 400, 5):
for j in range(555, 665, 5):
if np.mean(cape_fld[i-1:i+1, j-1:j+1]) > threshold:
Expand All @@ -285,8 +291,9 @@ def basic_plot_custarea(model_obj, cape_fld, u, v, lats, lons, hour, threshold=1
cax = fig.add_axes([0.44, 0.03, 0.35, 0.05])
fig.colorbar(wx, cax=cax, orientation='horizontal')

ax.annotate("CAPE ML(contour plot)", xy=(0.8, -0.07), xycoords='axes fraction', fontsize=14)
ax.annotate(r'in $J/kg$', xy=(0.8, -0.1), xycoords='axes fraction', fontsize=14)
ax.annotate("CAPE ML(contour plot)", xy=(0.8, -0.03), xycoords='axes fraction', fontsize=14)
ax.annotate(r'in $J/kg$', xy=(0.8, -0.06), xycoords='axes fraction', fontsize=14)
ax.annotate("LPI (darkred contours)", xy=(0.8, -0.1), xycoords='axes fraction', fontsize=14)

ax.annotate('1000-850 hPa in magenta', xy=(0.02, -0.025), xycoords='axes fraction', fontsize=13)
ax.annotate(' 850-600 hPa in blue', xy=(0.02, -0.05), xycoords='axes fraction', fontsize=13)
Expand Down

0 comments on commit 135a506

Please sign in to comment.