Контурный график и Cartopy — вид с геостационарного спутника [графики и код]Python

Программы на Python
Anonymous
Контурный график и Cartopy — вид с геостационарного спутника [графики и код]

Сообщение Anonymous »


I have data which is in X,Y co-ordinates that is transformed from spherical co-ordinates and I am trying to plot a contour of this data on top of a globe which I have taken from Cartopy. But its not working and I have been trying for a few hours googling and attempts at this! Any suggestions would be greatly appreciated.

Code is here and numpy file of the data is here.

Numpy file for plotting

There are sample plots in below links too

import numpy as np import matplotlib.pyplot as plt # import cartopy.feature as cf import cartopy.crs as ccrs import cartopy.feature as cf plt.close('all') #%% Co-ordindate System resolution = 201 theta = np.linspace(-90, 90, num=resolution) * np.pi/180 phi = np.linspace(0, 360, num=resolution) * np.pi/180 theta_grid, phi_grid = np.meshgrid(theta,phi) u_grid = np.sin(theta_grid) * np.cos(phi_grid) v_grid = np.sin(theta_grid) * np.sin(phi_grid) #%% Load Numpy array of data AF = np.load('Plotted_data.npy') c = np.arange(np.min(AF),np.max(AF),0.25) #%% Plots fig = plt.figure('UV') ax = fig.add_subplot(111) plt.contourf(u_grid,v_grid,AF,c,extend="both", cmap = 'Spectral_r') #plasma #gnuplot2 plt.colorbar(label ='Directivity (dBi)') ax.set_xlabel('u = sin(theta)cos(phi)') ax.set_ylabel('v = sin(theta)sin(phi)') ax.legend(loc=1) projection=ccrs.Geostationary(central_longitude=0.0, satellite_height=35785831) fig = plt.figure('No Overlay') ax = plt.axes(projection=projection) ax.add_feature(cf.COASTLINE) plt.show() fig = plt.figure('Attempt to Overlay') ax = plt.axes(projection=projection) plt.contourf(u_grid,v_grid,AF,c,extend="both", cmap = 'Spectral_r', alpha = 0.2) #plasma #gnuplot2 ax.add_feature(cf.COASTLINE) plt.show() Example plots of the data and the failing to overlay countour onto globe

Data Contour Plot in XY transform of spherical coordinates:


Изображение


The Globe I want to plot a contour on top of:


Изображение


I have tried many times googling the problem, Cartopy website, posts on stackexchange but I have not got this working yet... any suggestions greatly appreciated.


Источник: https://stackoverflow.com/questions/781 ... s-and-code

Вернуться в «Python»