~1 min read

Categories

Sometimes I need to shift a map 180 degree back and forth when I’m processing TMPA 3B42RT and 3B42(RP) data. It’s relatively easy of doing this when the map is in 2D matrix format but a bit complicated in 1D array format. Here’s how I did it in Matlab. Note that the index numbering is different between Matlab and Perl (The first element of an array in Matlab is “Array(1)” but is “Array(0)” in Perl).

The first element of the array is the upper left cell in the map,  second element is the second cell in the first row of the map.

1

2

for i = 1:nrow; %shift 180 degree, nrow is row number and ncol is column number
 map_new(((i-1)*ncol+(ncol/2)+1):(i*ncol)) = map (((i-1)*ncol+1):((i-0.5)*ncol));
 map_new(((i-1)*ncol+1):((i-0.5)*ncol)) = map (((i-1)*ncol+(ncol/2)+1):(i*ncol)); 
end