Calculate a value at specific latitude and longitude via interpolation

172 views
Skip to first unread message

Mariano Crimaldi

unread,
Sep 14, 2022, 10:18:19 AM9/14/22
to SciTools (iris, cartopy, cf_units, etc.) - https://github.com/scitools
I am quite new to using iris so I apologize for the newbie question.
I'm trying to interpolate GRIB temperature data at a certain point with known latitude and longitude.

For example, I've downloaded a GRIB file for air temperature over 2 days, hourly, converted in celsius degrees:

```
air_temperature / (celsius)         (time: 48; latitude: 21; longitude: 31)
    Dimension coordinates:
        time                             x             -              -
        latitude                         -             x              -
        longitude                        -             -              x
    Auxiliary coordinates:
        forecast_period                  x             -              -
    Scalar coordinates:
        height                      2 m
        originating_centre          European Centre for Medium Range Weather Forecasts
```
Now, I made a daily mean of temperature, so the new cube has 2 values of temperature:

```
iris.coord_categorisation.add_day_of_year(temperature, "time")
daily_Tmean = temperature.aggregated_by(["day_of_year"], iris.analysis.MEAN)
```

The new temperature values are calculated over the entire area (latitude and longitude) of original GRIB file:

```
temperature_iter = daily_Tmean.slices(("latitude", "longitude"))
ani = animate.animate(temperature_iter, qplt.contourf)
plt.show()
```

download.png

Now, I'm trying to calculate a new temperature value at given latitude and longitude interpolating the temperatures already calculated as daily mean. What I am trying to achieve is something like "resizing" the pixel resolution.
I did this before in MatLab and R applying Delanauy triangulation (https://it.mathworks.com/help/matlab/ref/delaunay.html)

With iris I tried this:
```
ws_coords = [("latitude", 40.94), ("longitude", 14.02)]
t_atCoords = daily_Tmean.interpolate(ws_coords, iris.analysis.Nearest())
```
But when I print the calculated temperature values I have this (no Delanauy triangulation so far):

```
print(t_atCoords.data)
[-- --]
```

I am quite sure there is something I did not understand or doing wrong, Any help or suggestions would be very much appreciated. Many thanks.

Laura Dreyer

unread,
Sep 14, 2022, 10:49:33 AM9/14/22
to SciTools (iris, cartopy, cf_units, etc.) - https://github.com/scitools
It looks like t_atCoords.data is returning a masked array (see https://numpy.org/doc/stable/reference/maskedarray.html for more information on these). This would suggest the daily_Tmean also contains masked data as daily_Tmean.interpolate is using the value from the nearest source point so the issue may lie with original data you load in from GRIB.

As it so happens, we are just about to close this google group as we are retiring it in favour of using the Q&A section of the Github Discussions (https://github.com/SciTools/iris/discussions/categories/q-a).
Do you mind raising this question there instead, and hopefully we can help you solve the issue there?
Reply all
Reply to author
Forward
0 new messages