Skip to content

Commit

Permalink
Nixon proj
Browse files Browse the repository at this point in the history
  • Loading branch information
mammatus95 committed Feb 28, 2024
1 parent 835666f commit 32e2f50
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 106 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ conda activate HodographMaps
cd src
bash download_script.sh
conda activate HodographMaps
python3 main.py Basic
```

## Cartopy?

https://github.com/mammatus95/cartopy
https://scitools.org.uk/cartopy/docs/latest/#
- https://github.com/mammatus95/cartopy
- https://scitools.org.uk/cartopy/docs/latest/#

## Datasource
ICON Nest: https://opendata.dwd.de/weather/nwp/icon-eu/
IFS: https://www.ecmwf.int/en/forecasts/datasets/open-data
- ICON Nest: https://opendata.dwd.de/weather/nwp/icon-eu/
- IFS: https://www.ecmwf.int/en/forecasts/datasets/open-data
8 changes: 8 additions & 0 deletions src/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@ threshold: 0
fontsize: 12
titlesize: 18

# customize
customize: # east de
lon1: 10.7
lon2: 18
lat1: 49.8
lat2: 54.8

# 10.77, 18.92, 49.80, 55.06
44 changes: 42 additions & 2 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ def main():
cape_fld, lats, lons = ut.open_gribfile_single(fieldname, rundate, run, fp, path="./iconnest/")
assert cape_fld.shape == (model.getnlat, model.getnlon), "Shape inconsistency"
plotlib.test_plot (cape_fld, lats, lons, fp, run, titel='CAPE')
else:

elif args.mode == "Basic":
cape_fld, lats, lons = ut.open_gribfile_single(fieldname, rundate, run, fp, path="./iconnest/")

steps=config["steps"]
Expand All @@ -102,9 +103,48 @@ def main():
break

print(np.nanmean(u_fld, axis=(1,2)))
plotlib.basic_plot (cape_fld, u_fld, v_fld, lats, lons, fp, run, titel='CAPE', threshold=config["threshold"])
plotlib.basic_plot_custarea (cape_fld, u_fld, v_fld, lats, lons, fp, run, titel='CAPE', threshold=config["threshold"])
elif args.mode == "Nixon":
cape_fld, lats, lons = ut.open_gribfile_single(fieldname, rundate, run, fp, path="./iconnest/")

plotlib.basic_plot (cape_fld, u_fld, v_fld, lats, lons, 9, 0, titel='CAPE', threshold=config["threshold"])
steps=config["steps"]
nlvl = int(model.getnlev()/steps)
u_fld = np.empty(nlvl*model.getpoints()).reshape((nlvl, model.getnlat(), model.getnlon()))
u_fld.fill(np.nan)
v_fld = np.empty(nlvl*model.getpoints()).reshape((nlvl, model.getnlat(), model.getnlon()))
v_fld.fill(np.nan)
h_fld = np.empty(nlvl*model.getpoints()).reshape((nlvl, model.getnlat(), model.getnlon()))
h_fld.fill(np.nan)
p_fld = np.empty(nlvl*model.getpoints()).reshape((nlvl, model.getnlat(), model.getnlon()))
p_fld.fill(np.nan)

if config["levels"][0] > config["levels"][1]:
steps *= -1
elif config["levels"][0] == config["levels"][1]:
print("Wrong levels in config.yml!")
exit(0)

lvl_idx = 0
for level in range(config["levels"][0], config["levels"][1], steps):
u_fld[lvl_idx,:,:] = ut.open_gribfile_multi("U", level, rundate, run, fp, path="./iconnest/")
v_fld[lvl_idx,:,:] = ut.open_gribfile_multi("V", level, rundate, run, fp, path="./iconnest/")
h_fld[lvl_idx,:,:] = ut.open_gribfile_multi("H", level, rundate, run, fp, path="./iconnest/")
p_fld[lvl_idx,:,:] = ut.open_gribfile_multi("P", level, rundate, run, fp, path="./iconnest/")

lvl_idx += 1
if lvl_idx >= nlvl:
break

print(np.nanmean(p_fld, axis=(1,2)))

du = np.subtract(u_fld[30,:,:], u_fld[0,:,:])
dv = np.subtract(v_fld[30,:,:], v_fld[0,:,:])
dls_fld = np.sqrt(np.add(np.square(du), np.square(dv)))
plotlib.nixon_proj(cape_fld, dls_fld, u_fld, v_fld, p_fld, h_fld, lats, lons, fp, run, imfmt="png")
else:
print("Wrong command line argument")
exit(-1)


if __name__ == "__main__":
Expand Down
11 changes: 8 additions & 3 deletions src/modelinfolib.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,35 +72,39 @@
d_grad = 0.75
"""


class MODELIFNO:

def __init__(self, nlon, nlat, nlev, d_grad):
self.points = nlon*nlat
self.nlon = nlon
self.nlat = nlat
self.nlev = nlev
self.d_grad = d_grad

"""
def __init__(self, nlon, nlat, nlev, lonmin, lonmax, latmin, latmax, d_grad):
self.points = nlon*nlat
self.nlon = nlon
self.nlat = nlat
self.nlev = nlev
self.d_grad = d_grad
print(lonmin, lonmax, latmin, latmax)
"""

def __str__(self):
return (
f"Model Information:\nPoints: {self.points}\n"
f"Number of Longitudes: {self.nlon}\nNumber of Latitudes: {self.nlat}\n"
f"Number of Levels: {self.nlev}\nGradient: {self.d_grad}"
)

def getpoints(self):
return self.points

def getnlon(self):
return self.nlon

def getnlat(self):
return self.nlat

Expand All @@ -110,7 +114,8 @@ def getnlev(self):
def getd_grad(self):
return self.d_grad


# Example usage:
icon_nest = MODELIFNO(1377, 657, 51, -23.5, 45.0, 29.5, 70.5, 0.0625)
icon_nest = MODELIFNO(1377, 657, 51, 0.0625)
cosmo_d2 = MODELIFNO(651, 716, 65, 0.02)
ifs = MODELIFNO(450, 900, 10, 0.4)
Loading

0 comments on commit 32e2f50

Please sign in to comment.