Converting GRIB era5 data for micro_era5

58 views
Skip to first unread message

Blair Bentley

unread,
Jan 30, 2026, 8:41:47 AMJan 30
to NicheMapR
Hi Mike,

I'm running a model to cover a relatively large geographic area and wrote a python script to pull era5 data in GRIB format in an array to optimize active tolling times. I had to pull using GRIB due to the size of the data request, which is too large to pull in Netcdf format. I have successfully downloaded the data I wanted, which are in monthly GRIB files, but I'm having some issues formatting them to be compatible with the micro_era5 function. I was wondering if there's any existing functions to convert these internally that I can leverage to get these formatted properly? I have pasted the python script below and can send a format summary of the downloaded file if it's helpful. Any help is greatly appreciated!

Thanks,
Blair

---

python3 <<EOF

import cdsapi


dataset = "reanalysis-era5-single-levels"

request = {

    "product_type": ["reanalysis"],

    "variable": [

        "2m_temperature",

        "2m_dewpoint_temperature",

        "surface_pressure",

        "10m_u_component_of_wind",

        "10m_v_component_of_wind",

        "total_precipitation",

        "total_cloud_cover",

        "mean_surface_net_long_wave_radiation_flux",

        "mean_surface_downward_long_wave_radiation_flux",

        "total_sky_direct_solar_radiation_at_surface",

        "surface_solar_radiation_downwards",

        "land_sea_mask"

    ],

    "year": ["${YEAR}"],

    "month": ["${MONTH}"],

    "day": [

        "01", "02", "03",

        "04", "05", "06",

        "07", "08", "09",

        "10", "11", "12",

        "13", "14", "15",

        "16", "17", "18",

        "19", "20", "21",

        "22", "23", "24",

        "25", "26", "27",

        "28", "29", "30",

        "31"

    ],

    "time": [

        "00:00", "01:00", "02:00",

        "03:00", "04:00", "05:00",

        "06:00", "07:00", "08:00",

        "09:00", "10:00", "11:00",

        "12:00", "13:00", "14:00",

        "15:00", "16:00", "17:00",

        "18:00", "19:00", "20:00",

        "21:00", "22:00", "23:00"

    ],

    "data_format": "grib",

    "download_format": "zip",

    "area": [-12, 112, -28, 130]

}


client = cdsapi.Client()

client.retrieve(dataset, request, "${OUTFILE}").download()

EOF

NicheMapR

unread,
Jan 30, 2026, 9:17:45 PMJan 30
to NicheMapR
Hi Blair,
Sorry there's nothing in NicheMapR - you could delve into the mcera5 code to find a solution. We need to develop some easier ways to work with ERA5. Dave Klinges may have some insights ...
All the best,
Mike

David Klinges

unread,
Jan 31, 2026, 9:51:08 AMJan 31
to NicheMapR
Hi Blair,

Yes this would be on the mcera5 side of the equation— I’ve messed around a bit with this with some uncommitted code, but the conversion of GRIB to netcdf is best handled in Python or NCO rather than R and mcera5 is an R package. As a result, it the approach that works best with R code is iterating through smaller queries that stay as netCDF, or conversion to GRIB on-the-fly (which I haven’t written yet). Feel free to follow up with me with more details.

Best,
Dave

David Klinges, PhD
Assistant Professor, Rutgers University (incoming)


--
You received this message because you are subscribed to the Google Groups "NicheMapR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nichemapr+...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/nichemapr/fd52a84c-1d21-4c6b-bbdd-e73d4e928a7dn%40googlegroups.com.

Blair Bentley

unread,
Feb 2, 2026, 10:31:32 AMFeb 2
to NicheMapR
Thanks Mike and Dave. I've tried converting with NCO but didn't have any luck, I'll email you off here for details.

Best,
Blair

Reply all
Reply to author
Forward
0 new messages