0

I have 3 vectors (1d): lat,lon and Temp (scalars) with the same length and Temp(lat,lon). ej.:

lat=[-90,-45,0,45,90]

lon=[ 0, 90, 180,270,360]

Temp=[274,290,280,300,310]

I want to plot it with matplotlib using contour, but Temp need to be in 2D dimension.

I found this topic 2D plot using 1D arrays without griddata() which is close of what I'm searching but i don't know how to create a function of Temp in 2D.

Could somebody help me?

Thanks

Paul

Community
  • 1
  • 1
Paul Vbl
  • 147
  • 2
  • 8
  • How is Temp calculated? do you have a function that will calculate Temp for a given lat and lon? – Julien Spronck Jul 12 '15 at 11:16
  • Thanks for your answer. No, It's an output from a atmospheric model. I have the lat lon coordinates and the value of the temperature for each point. But If I want to plot it using plt.contour I need a 2d array and I don't know how to convert the 1d Temp vector to 2d array – Paul Vbl Jul 12 '15 at 12:42
  • 1
    if lat and lon are similar to your example, you can't convert it to a 2d array. say you have lat = [-45, 45] and lon = [90, 270]. Here, you only have 2 points. To make it a 2d array, you need four points. For example lat = [-45, -45, 45, 45] and lon = [90, 270, 90, 270]. These four points represent a 2d mesh, while the original 2 points are just a line. Same thing for 3, 4, ... n points. So without the possibility to resample lat and lon, you might not have the data you need to plot it in 2D. In your example, the 5 points that you have are all on one line (and therefore can't be plotted in 2d) – Julien Spronck Jul 12 '15 at 13:08
  • Thanks for your help Julien. Finally I solved interpolating the data using scipy.interpolate.griddata and it worked. Thanks your help. – Paul Vbl Jul 12 '15 at 15:27

0 Answers0