# How to get value of uvIndex for a particular latitude and longitude from a grib2 file?

I'm trying to find out the uvIndex of a particular set of lat,lng. I'm getting the data file from this link. I'm using pygrib to read the file.

import pygrib
grbs = pygrib.open('uv.t12z.grbf01.grib2')
grb = grbs.select(name='UV index')[0]
print grb.data(23.5,55.5)


This prints 3 numpy arrays. But I'm not able to figure out how to extract data from it.

Based in PyGrib Documentation from Arulalan, you can see that:

>>>import pygrib
>>>grbs = pygrib.open('/home/zeito/Desktop/uv.t12z.grbf01.grib2') #path in my system
>>>grb = grbs.select(name='UV index')[0]
>>>print grb.data(23.5,55.5)
... a long array of data
>>>print grbs.messages
>>>g = grbs[1]
>>>print g
1:UV index:Numeric (instant):regular_ll:surface:level 0:fcst time 1 hrs:from 201606021200
>>>my_values = g['values']
>>>print my_values[69][46]
0.106689453125
>>>my_lats = g['distinctLatitudes']
>>>print my_lats[69]
55.5
>>>my_longs = g['distinctLongitudes']
>>>print my_longs[46]
23.0


Afterward, I opened this kind of file in QGIS (supported by GDAL) and, with the help of 'Value Tool' plugin, I corroborated that results at the Python Console of QGIS were as expected (see next image).