[Python] open ICON model with python

Discussão em 'Python' iniciado por Stack, Abril 8, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to open the precipitation data from the ICON model, but I'm running into some difficulties. Could someone help me?

    The data is located here: https://opendata.dwd.de/weather/nwp/icon/grib/00/tot_prec/ Here is the part related to latitude and longitude: https://opendata.dwd.de/weather/nwp/icon/grib/00/ Latitude: https://opendata.dwd.de/weather/nwp/icon/grib/00/elat/ Longitude: https://opendata.dwd.de/weather/nwp/icon/grib/00/elon/

    my script:

    import pygrib
    import matplotlib.pyplot as plt

    data = pygrib.open('/content/icon_global_icosahedral_single-level_2025040700_114_TOT_PREC.grib2')
    lon = pygrib.open('/content/icon_global_icosahedral_time-invariant_2025040700_ELON.grib2')
    lat = pygrib.open('/content/icon_global_icosahedral_time-invariant_2025040700_ELAT.grib2')

    data = data.select(name='Total Precipitation')[0]
    lon = lon.select(name='Longitude on V grid')[0]
    lat = lat.select(name='Latitude on V grid')[0]

    lon_cut = lon.values[:2949120]
    lat_cut = lat.values[:2949120]
    data_cut = data.values # assuming this has shape (2949120,)

    plt.figure(figsize=(10, 8))
    sc = plt.scatter(lon_cut, lat_cut, c=data_cut, cmap='viridis', s=1)
    plt.colorbar(sc, label='Variable')
    plt.xlabel('Longitude')
    plt.ylabel('Latitude')
    plt.title('ICON Model Data (Scatter)')
    plt.show()


    [​IMG]

    Continue reading...

Compartilhe esta Página