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

  • Context: MATLAB 
  • Thread starter Thread starter Arjani
  • Start date Start date
  • Tags Tags
    Graph Matlab
Click For Summary
SUMMARY

The discussion focuses on adjusting Matlab code for plotting climate data, specifically targeting a ±40-degree band around the equator. The original code reshapes longitude and latitude data but resulted in incorrect plots. Adjustments to the code were made, including changing the reshaping indices, which improved the plot's appearance. However, the user questions the accuracy of the data representation and whether the adjustments reflect reality or merely create a visually appealing output.

PREREQUISITES
  • Proficiency in Matlab programming
  • Understanding of climate data representation
  • Familiarity with data reshaping techniques
  • Knowledge of plotting functions in Matlab, such as pcolor
NEXT STEPS
  • Research Matlab's pcolor function and its parameters for better plotting control
  • Explore data validation techniques to ensure accurate representation of climate data
  • Learn about handling geographical data in Matlab, including mapping libraries
  • Investigate the implications of data cropping and scaling in visualizations
USEFUL FOR

Data scientists, climate researchers, and Matlab users interested in accurately plotting geographical data and ensuring the integrity of visual representations.

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.