Vertical cross files - tnipen/NWPdocs GitHub Wiki
This is an example recipe for the VC-files provided at thredds.
import xarray as xr
import matplotlib.pyplot as plt
DS = xr.open_dataset("https://thredds.met.no/thredds/dodsC/meps25epsarchive/2020/09/29/meps_lagged_6_h_vc_2_5km_20200929T00Z.nc")
# Decode from Latin1 due to æ,ø,å chars and print all vcross
for name in DS.vcross_name.str.decode("latin1"):
#print(name.values)
pass
# Iterate through the names to search for stations we want
for nvcross, name in enumerate(DS.vcross_name.str.decode("latin1")):
# Convert from 0-sized array to scalar string to make searchable
scalar = str(name.values)
# Search with uppercase to prevent case sensitivity
if "Vadsø".upper() in scalar.upper():
print(nvcross,scalar)
if "ENZV".upper() in scalar.upper():
print(nvcross,scalar)
122 ENJS-ENZV
126 SOLA/STAVANGER - 01415/ENZV
145 VADSØ - ENVD
It is important to note here that there are two types of vertical cross sections in the file: Route forecasts and vertical soundings: 145 VADSØ - ENVD (note here that ENVD is the ICAO-code of Vadsø airport, so this is not a route forecast) is a vertical "sounding", whilst 122 ENJS-ENZV is a route forecast (Johan Sverdrup to Sola). The difference is seen in the vcross_bnds variable:
# 122 ENJS-ENZV
nvcross = 122
xvals = DS.vcross_bnds.isel(nvcross=nvcross).values
# If not route-forecast, reduce list to scalar
if xvals[0] == xvals[1]:
xvals = xvals[0]
print(xvals)
[27781 27851]
DS.air_temperature_ml.isel(x=xvals,ensemble_member=0,time=0).plot(y="hybrid")
plt.title("Route ENJS - ENZV")
plt.gca().invert_yaxis()

# 145 VADSØ - ENVD
nvcross = 145
xvals = DS.vcross_bnds.isel(nvcross=nvcross).values
# If not route-forecast, reduce list to scalar
if xvals[0] == xvals[1]:
xvals = xvals[0]
print(xvals)
27874
DS.air_temperature_ml.isel(x=xvals,ensemble_member=0,time=0).plot(y="hybrid")
plt.title("Vertical profile - Vadsø airport - ENVD")
plt.gca().invert_yaxis()
