I'm starting in python programming and I would like to make a small script which displays the data of "Local temperature diagnosed at 2m height above the relief", "Zonal component of the west-east horizontal wind diagnosed at 10 m height" and the "Meridian component of the horizontal wind diagnosed at 10 m height" as a function of longitude and latitude.
For this, I download a file from the open data site of Meteofrance OPEN DATA by selecting:
Domain: "France - 0.01 °", Sub Package: "SP1 - Current surface parameters", Deadline group "0h" and Run date "2020-02-10 00 UTC"
So I have a file in grib2 format that I am trying to process with the pygrib library
To start simple, I'm just trying to get the temperature for a given point (longitude = 0.25, latitude = 49.21)
I created an index to read the file (It seems that it is the fastest)
indx = pygrib.index('./AROME_0.01_SP1_00H_2020021000.grib2', 'typeOfLevel', 'level', 'name')
I select the records which correspond to the temperature and I recover the values:
msg = indx.select(level=2, typeOfLevel="heightAboveGround", name="2 metre temperature")
temp2m = msg[0].values
The problem is that from there, I fumble and I don't find how to retrieve from this variable (numpy.ma.core.MaskedArray) the value that corresponds to my longitude = 0.25 and latitude = 49.21
If someone has an idea, I'm interested
import pygrib
indx = pygrib.index('./AROME_0.01_SP1_00H_2020021000.grib2', 'typeOfLevel', 'level', 'name')
msg = indx.select(level=2, typeOfLevel="heightAboveGround", name="2 metre temperature")
temp2m = msg[0].values