MetOffice / aws-earth-examples

Example code of how to freely use Met Office's weather datasets through Earth on AWS.
https://metoffice.gov.uk
Other
43 stars 15 forks source link

Add examples for working with Lambert Azimuthal projection (UKV, MOGREPS-UK) #20

Open AlexHilson opened 4 years ago

AlexHilson commented 4 years ago

Code along the lines of the following can be used to turn the lambert azimuthal x / y co-ordinates into lat/lon. It'd be good to get a full example up to show one way of working with regional UK model data.

import pyproj
p = pyproj.Proj("+proj=laea +lon_0=-2.5 +lat_0=54.9 +x_0=0.0 +y_0=0.0 +ellps=GRS80")
# lon, lat = p(x, y, inverse=True)
lon, lat = p(-36000, -158000, inverse=True)
print (lat, lon)

53.47926025120268 -3.0422171310489534

Originally posted by @boristyukin in https://github.com/MetOffice/aws-earth-examples/issues/19#issuecomment-643481826

AlexHilson commented 4 years ago

Iris regridding docs are at https://scitools.org.uk/iris/docs/latest/userguide/interpolation_and_regridding.html. If the Global data works for you but the UKV data doesn't, this would be one easy method of translating the UKV grid into the Global grid.

The following is written from memory and untested:

import iris

# load data
global_cube = iris.load_cube('global_data.nc')
uk_cube = iris.load_cube('uk_data.nc')

# subset global cube so that it only contains data in the UK area of interest
global_subset = global_cube.intersection(longitude=(-2, 5), latitude=(-50, 60))

result = uk_cube.regrid(global_subset, iris.analysis.Linear)