Blog

Tips on creating movies in Matlab

To those of you who are interested in enhancing the way you present data using Matlab, possible avenues include changing the viewpoint specification (i.e.  the elevation and azimuth) of the figure or creating a movie (or both).  The following is a simple example to demonstrate how to accomplish both changing the view of the figure while simultaneously creating a video of the process.

In my current research I am investigating atmospheric temperature disturbances and the data set I am using involves 37 (2D) layers of the atmosphere.  When discussing my work with colleagues it is important to properly explain what is happening at each atmospheric layer. A good way to do this is to create a movie that starts with the lowest atmospheric layer (surface level) and build an atmospheric profile by adding more layers one at a time.  Here is some pseuo Matlab code to help perform this task:

(Note that each number from 1-19 represents the equivalent line number of code)

  1. j=0;     %This is the atmospheric layer number, which could also represent height
  2. for i = 1:37    %This will iterate through each of the 37 layers
  3. h= plot(data(i));    %Plot the data associated with the i-th layer
  4. z = get(h,’ZData’,) + j;    %This will specify the placement of the 2D plot on a z-axis
  5. set(h,’ZData’,z);    %Set the data at the current iteration to the specified height
  6. j=j+1;
  7. view(0,50);     %This will change the view of the data, where the first number represents the azimuth and the second is the elevation
  8. drawnow       %Display the current iteration’s plot
  9. videoframe(j) = getframe(gcf);    %This will store the current frame to the j-th element of the filename ‘videoframe’
  10. end
  11. for i = 1:360    %Next let’s rotate the atmospheric column 360 degrees
  12. view=(i,50)   %At each iteration we change the azimuth while keeping height the same
  13. drawnow
  14. j=37+i;           %Be careful not to overwrite any of the past frames
  15. videoframe(j) = getframe(gcf);
  16. end
  17. my_video = VideoWriter(‘video_name.avi’);  %Call the video writer function and specify the name of the video and format
  18. open(my_video);
  19. writeVideo(my_video,videoframe);   %Write your video frames stored in ‘videoframe’ to ‘video_name.avi’

After running this code with your own data you should have an AVI movie that builds a 37 layer atmospheric profile and then rotates the image around 360 degrees.  If you find the video runs too quickly try adding more video frames at each iteration.

If you have any further questions please don’t hesitate to ask.

Happy plotting!

CSA proposal funded

Our proposal to study atmospheric water vapor is funded by the Canadian Space Agency. In this project we will use satellite data to study the water budget in the climatically very important UTLS region. A new postdoc is WANTED for this research (see the ad below); prospective graduate students interested in the topic are equally welcome to join this research!


Postdoctoral Fellow Position in Satellite Data Analysis and Atmospheric Modeling

We seek a postdoctoral fellow to analyze satellite data and conduct numerical simulations for understanding atmospheric water vapor distribution and variation in the upper-troposphere and lower-stratosphere region.

Required qualifications include:

PhD in Atmospheric Sciences or a relevant physical science discipline (e.g., Meteorology, Physics, Computational Fluid Dynamics, etc.); and

Experience of scientific computing and capability of running high-resolution atmospheric dynamics models such as WRF and transport model such as HYSPLIT.

Desirable qualifications:

Experience of satellite data analysis; and

Knowledge of radiative transfer and cloud physics.

The initial appointment will be for one year, renewable contingent on satisfactory performance and funding availability. Interested candidates should contact Professor Yi Huang (yi.huang@mcgill.ca) by email, enclosing a curriculum vitae, transcripts of academic records, and names and contacts of at least two references.

GRL paper on atmospheric supersaturation

Tan et al. studied an interesting phenomenon – supersaturation, i.e., water vapor pressure exceeding saturation value – in the atmosphere by assembling data from multiple aircraft measurement campaigns. We find the climatic impact, as measured by radiative forcing, of supersaturation is significant and, interestingly, very sensitive to co-existing clouds. Particularly, we note an interesting change of the sign of the radiative effect of cirrus cloud at optical depth ~ 1.8 (see Manuscript Fig. 3j and Supplementary Information Fig. S4). Read more about it in this article “An assessment of the radiative effect of supersaturation based on in-situ observations“.