Wrong lon/lat of interpolate_corners for L2 product
I tested the interpolate_corners
function for L2_obj and the result is wrong.
result of the show_map function
L2_obj.data.show_map(band=[0], res_factor=1, xlim=(500, 650), ylim=(850, 1000), out_epsg=4326)
test interpolate_corners
def interpolate_corners(ul: float, ur: float, ll: float, lr: float, nx: int, ny: int):
"""Compute interpolated field from corner values of a scalar field given at: ul, ur, ll, lr.
:param ul: tbd
:param ur: tbd
:param ll: tbd
:param lr: tbd
:param nx: final shape (x-axis direction)
:param ny: final shape (y-axis direction)
"""
# FIXME this method must later be replaced by the geolayer provided by the ground segment
# => a linear interpolation between the EnMAP corner coordinates is NOT sufficient for modelling the
# geometry of VNIR and SWIR
# - especially at off-nadir acquisitions and with some terrain present, a linear interpolation leads
# to large deviations (> 180 m y-coordinate offset for the EnPT test dataset)
# TODO ensure that lons/lats represent UL coordinates not pixel coordinate centers (as given by Karl / DLR(?))
corner_coords = np.array([[ul, ur],
[ll, lr]])
rowpos, colpos = [0, 1], [0, 1]
from scipy.interpolate import RegularGridInterpolator
rgi = RegularGridInterpolator([rowpos, colpos], corner_coords, method='linear')
out_rows_grid, out_cols_grid = np.meshgrid(np.linspace(0, 1, ny),
np.linspace(0, 1, nx),
indexing='ij')
coords = rgi(np.dstack([out_rows_grid, out_cols_grid]))
return coords
lons_l2 = interpolate_corners(*L2_obj.meta.lon_UL_UR_LL_LR, L2_obj.meta.ncols, L2_obj.meta.nrows)
lats_l2 = interpolate_corners(*L2_obj.meta.lat_UL_UR_LL_LR, L2_obj.meta.ncols, L2_obj.meta.nrows)
fig, ax = plt.subplots(subplot_kw={'projection': ccrs.PlateCarree()},
figsize=(6, 6),
constrained_layout=True)
ax.pcolormesh(lons_l2[850:1000, 500:650], lats_l2[850:1000, 500:650], L2_obj.data[850:1000, 500:650, 0])
gl = ax.gridlines(draw_labels=True, dms=False, color = 'gray', linewidth=1, alpha=0.5, linestyle='--')
gl.top_labels = False
gl.right_labels = False
The location of the cloud is wrong using the lon/lat calculated by interpolate_corners.