How do I get the 1D profile from an Array given geographic coordinates instead of pixel coordinates.
I have radiance data in Geo-coordinates (NASA GOLD Mission).
The data for each hemisphere is stored in a separate file. I want to take a 1D profile of the spliced hemispheres along a curve (10 degNorth dip latitude) which is in Geo coords,
I tried to adapt the answer here using map_coordinates but I realised it is in pixel coordinates that is why I believe the profile does not correspond to the map;
To get the 1D profile I plotted the output from mapcoords against the input curve (X) values so as to get the variation against longitude.
The other profile in yellow also does not correspond to the data in the map;
When I plot the data using imshow it does not look the same as on the map;
The data and Python Code is here Data+Code;
from netCDF4 import Dataset
import glob, matplotlib,os;matplotlib.pyplot as plt
import cartopy.crs as ccrs
import numpy.ma as ma
Mag = pd.read_csv(r"\mag_cords.csv")
X_dip10s,Y_dip10s = Mag.LON10S.to_numpy(),Mag.LAT10S.to_numpy()
g = Dataset('GOLD_L1C_CH*23*.nc','r');
wavelength = g.variables['WAVELENGTH'][:]
radiance = g.variables['RADIANCE'][:]
lat = g.variables['REFERENCE_POINT_LAT'][:]
lon = g.variables['REFERENCE_POINT_LON'][:]
g.close()
O5s_ids = np.argwhere((134.3 <= wavelength[50,25,:]) & (wavelength[50,25,:] <= 137.7))
O5s = np.array(np.nansum(radiance[:,:,O5s_ids],axis = 2))*.04 # integrate under the peak!
O5s = np.transpose(O5s[:,:,0])
x=lon[9:-8,9:-8];y=lat[9:-8,9:-8];z=O5s[9:-8,9:-8].T;z=abs(z)#To remove Nans
z2=np.ma.masked_array(z, (z > 30))
Zs=scipy.ndimage.map_coordinates(np.transpose(z),
np.vstack((X_dip10s,Y_dip10s)),
mode="nearest")
Xs=scipy.ndimage.map_coordinates(np.transpose(x),
np.vstack((X_dip10s,Y_dip10s)),mode="nearest")
fig=plt.figure(figsize=(10,10))
axarr = fig.add_subplot(211,projection=ccrs.PlateCarree())
ax2 = fig.add_subplot(212)
grid_lines =axarr.gridlines(draw_labels=True'); axarr.coastlines()
cs1 = axarr.contourf(x,y, z2, transform=ccrs.PlateCarree(),cmap='jet',levels=50)
ax2.plot(X_dip10s,Zs, 'k-', Xs ,Zs, 'k-')
[1]: https://i.stack.imgur.com/66C4P.png