This page demonstrates Python tips and tricks that I use in my everyday programming as an atmospheric science graduate student.
-Brian Blaylock
Wednesday, May 7, 2014
Plotting Ceilometer data with imshow()
I have plotted a month of ceilometer data with matplotlib using imshow(). This figure shows backscatter at the mountain meteorology lab for January 2014.
I am just learning python and starting with plotting some ceilometer data. I was just wondering if you would mind sharing your program? Thanks in anticipation. Emily
Hi Emily! Thanks for visiting this blog. Yes, plotting ceilometer data is easy if you can get the data into a numpy 2D array. I have found pcolormesh is much quicker at creating plots than contourf or imshow. Here's a simple example:
>>import numpy as np >>import matplotlib.pyplot as plt
>>data = np.array([[1,2,3,4,5],[6,5,4,3,2],[9,8,70,6,5]]) #this is your ceilometer data in a numpy array
>>plt.pcolormesh(data, cmap=plt.cm.jet, vmin=0,vmax=10) #makes plot, defines color scale, and sets color range >>plt.colorbar() #adds a colorbar >>plt.show() #displays your image
you can find more documentation on using pcolormesh here: http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.pcolormesh
This comment has been removed by the author.
ReplyDeleteHello Brain,
ReplyDeleteI am just learning python and starting with plotting some ceilometer data. I was just wondering if you would mind sharing your program? Thanks in anticipation. Emily
Hi Emily! Thanks for visiting this blog. Yes, plotting ceilometer data is easy if you can get the data into a numpy 2D array. I have found pcolormesh is much quicker at creating plots than contourf or imshow. Here's a simple example:
ReplyDelete>>import numpy as np
>>import matplotlib.pyplot as plt
>>data = np.array([[1,2,3,4,5],[6,5,4,3,2],[9,8,70,6,5]]) #this is your ceilometer data in a numpy array
>>plt.pcolormesh(data, cmap=plt.cm.jet, vmin=0,vmax=10) #makes plot, defines color scale, and sets color range
>>plt.colorbar() #adds a colorbar
>>plt.show() #displays your image
you can find more documentation on using pcolormesh here: http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.pcolormesh
Hope this helps!