MATLAB Is there a problem with adjusting the code for plotting climate data in Matlab?

  • Thread starter Thread starter Arjani
  • Start date Start date
  • Tags Tags
    Graph Matlab
AI Thread Summary
The discussion centers around plotting climate data in Matlab, specifically focusing on adjusting the code to visualize a band of ±40 degrees around the equator. The user initially reshapes longitude and latitude data to create a grid, but encounters issues with the plot when modifying the data to focus on the equatorial region. After several code adjustments, the user achieves a more acceptable graph but questions the accuracy of the representation. Key points include the need to verify whether the data covers the entire surface or is limited to the equatorial band, and the suggestion that plotting techniques, such as adjusting alpha values, could help manage the visualization depending on the intended focus area. The conversation emphasizes the importance of ensuring that the plotted data accurately reflects reality, rather than just appearing correct due to code modifications.
Arjani
Messages
20
Reaction score
1
I have climate data that I am plotting in Matlab with a script. The relevant code for this problem, I think, is this:

Code:
lon = reshape(grid_txt_lon,144,73);
lon(lon>180) = lon(lon>180) - 360;
lon = [lon(74:144,:);lon(1:73,:)];
lat = reshape(grid_txt_lat,144,73);
deg = reshape(degree,144,73);
deg = [deg(74:144,:);deg(1:73,:)];

The map is divided in a grid of 2.5 degrees each, so the 144 longitude comes out to 360 degrees and the 73 latitude comes out to 182.5 degrees. I guess the latitude has one degree overlap. Using these values, I get a plot such as this:

http://img36.imageshack.us/img36/479/ex1pr.jpg

But this isn't what I need, what I need is to plot a band of ±40 degrees (using different data) around the equator. So, I adjust the code to these values:

Code:
lon = reshape(grid_txt_lon,144,[B][U]33[/U][/B]);
lon(lon>180) = lon(lon>180) - 360;
lon = [lon([B][U]34[/U][/B]:144,:);lon(1:[B][U]33[/U][/B],:)];
lat = reshape(grid_txt_lat,144,[B][U]33[/U][/B]);
deg = reshape(degree,144,[B][U]33[/U][/B]);
deg = [deg([B][U]34[/U][/B]:144,:);deg(1:[B][U]33[/U][/B],:)];

Changes emphasized. It works somewhat, but the graph becomes screwed up:

http://img803.imageshack.us/img803/6199/ex2u.jpg

Exactly at 2*40, or 80 degrees, it starts doing weird things. Is there a problem in the way I adjusted the code perhaps?
 
Last edited by a moderator:
Physics news on Phys.org
I played around with it some more and adjusted the adjusted code in the following way, changes emphasized again:

Code:
lon = reshape(grid_txt_lon,144,33);
lon(lon>180) = lon(lon>180) - 360;
lon = [lon([B][U]74[/U][/B]:144,:);lon(1:[B][U]73[/U][/B],:)];
lat = reshape(grid_txt_lat,144,33);
deg = reshape(degree,144,33);
deg = [deg(34:144,:);deg(1:33,:)];

This results in the following graph, which looks more like what you'd expect:

http://img687.imageshack.us/img687/3705/ex3w.jpg

But how can I be sure this still reflecs reality and doesn't just look correct due to my tweaks to the code??
 
Last edited by a moderator:
I have one thing I'm not sure of,

Is the data covering the entire surface, and do you want it to be cropped for the purposes of an image, or does the data only cover your equatorial band of interest, and are you trying to make sure it is overlaid onto the world map with the correct scaling?

If it's the former then I think this can be solved at the plotting level, depending on what code you're using, eg. by adjusting the pcolor face alpha values depending on the region you want to be omitted from the image. But the specifics will depend on the plotting code.
 
Back
Top