0

I have two data arrays that have temperature data and precip data and I want to plot them over one map of the U.S. as contours. I have the cooresponding lat and lon locations for each data point. I also have cooresponding "ilat" and "ilon" values for each location as well.

When I try to simply use the contour function I found out it won't work because my data arrays are only 1-D.

How can I plot this data? I've searched everywhere but the closest I could find was a solution to re-grid the data entirely.

Note: I turned ilat and ilon into floats because it was yelling at me about integers when I tried to use griddata, can easily be made back to integers.

Here is some sample data:

Tmax = [  86.,   88.,   86.,   88.,   86.,   87.,   82.,   83.,  102.,
         81.,   83.,   88.,   96.,   90.,   76.,   85.,   87.,   87.]

Precip = [5827, 5432, 5687, 5088, 5266, 6059, 5551, 2153,  390, 2415, 1726,
       2101, 1528, 1795, 2212, 4694, 5012, 4738, 5274, 5480, 4241, 6091]

lat = [ 32.8203,  32.7019,  31.8814,  32.4111,  33.4164,  31.9169,
        34.5667,  34.7522,  34.1547,  34.5706,  34.5081,  31.7119]

lon = [ -86.6522,  -87.5817,  -86.2503,  -87.0144,  -86.135 ,  -87.7347,
        -85.6128, -112.1114, -114.2897, -112.4322, -110.0839, -110.0686]

ilat = [  8.,   8.,   7.,   8.,   9.,   7.,  10.,  10.,  10.,  10.,  10.,
         7.,   8.,   8.,  11.,  10.,   9.,  11.,  12.,  12.,  11.,  10.]

ilon = [ 26.,  27.,  26.,  27.,  26.,  27.,  25.,  52.,  54.,  52.,  50.,
        50.,  50.,  49.,  52.,  31.,  32.,  32.,  34.,  34.,  30.,  34.]

Please be as explicit as you can in explanations, I'm pretty new to python!! Thank you!

Manish Jesani
  • 1,339
  • 5
  • 20
  • 36
  • It's not completely clear what you are trying to do - for instance, are you calling [matplotlib's `contour()`](http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.contour) or some other contour function? How do you expect all six lists to be shown on the plot? That said, making a 2d contour plot from three lists is covered here: http://stackoverflow.com/questions/9008370/python-2d-contour-plot-from-3-lists-x-y-and-rho – Lack Jan 11 '15 at 21:12
  • By the way, you can programatically convert a list from ints to floats: `[float(i) for i in lst]` (http://stackoverflow.com/a/1614247/431033) – Lack Jan 11 '15 at 21:16

0 Answers0