Thursday, May 26, 2016

Set Lat Lon Limits at the edge of the map

It looks nicer when you have the numbers at the edge.
setm(gca,'fontsize', 12,'PLabelLocation',[ylim(1)+0.001, mean(ylim), ylim(2)],'PLineLocation',[ylim(1)+0.001, mean(ylim), ylim(2)],...
    'PLabelRound',-3,'MLabelLocation',[xlim(1), mean(xlim), xlim(2)],'MLineLocation',[xlim(1), mean(xlim), xlim(2)], 'MLabelRound',-3, ...
     'Grid','on')

Thursday, May 5, 2016

Colormap Stark #matlab colorbar

I wanted to have a colormap which had a great degree of contrast, and was not really a rainbow scheme.

I have tried to solve this issue by poking at different colormaps
http://usefulcodes.blogspot.com/2015/06/colormap-hotjet.html
(very close, but keeps the rainbow defect flat intensity for the large part in the middle.)
http://usefulcodes.blogspot.com/2015/06/colormap-goofy-matlab.html
(looks green and goofy! Did not like it.)
http://usefulcodes.blogspot.com/2015/06/matlab-colormap-rose.html
(has nice monotonic intensity gradient, but not that beautiful on maps.)
See the examples: http://usefulcodes.blogspot.com/search/label/colormap
I present you a new one! Colormap "stark".
This does have the defect of not linearly increasing the intensity, but does not stay flat in the middle. It has two saddles, allowing the left/right contrast. I like it so far.
Well, it is inspired from the LST image from MODIS
http://neo.sci.gsfc.nasa.gov/view.php?datasetId=MOD11C1_M_LSTDA


175 256 255
100 249 255
50 223 253
10 191 252
9 144 252
12 106 255
11 79 254
26 56 254
34 38 255
50 34 255
79 33 255
85 33 255
101 34 255
132 35 255
150 36 255
177 39 255
217 36 255
243 35 255
255 35 213
255 34 175
255 30 143
255 36 110
255 34 88
255 33 65
255 44 35
255 72 35
254 95 39
255 116 45
254 138 41
254 160 46
255 183 45
255 199 46
255 210 47
253 225 47
254 230 75
256 256 110
R G B





newN = 1:64;

isn = floor(linspace(1,64,36));
%RGB = [R G B];
R1 = RGB(:,1);
G1 = RGB(:,2);
B1 = RGB(:,3);

Rn = runmean(interp1(isn, R1, newN),2);
Gn = runmean(interp1(isn, G1, newN),2);
Bn = runmean(interp1(isn, B1, newN),2);

newC=  [Rn', Gn', Bn']./256;


close all
figure ;
plot(newN, Rn, 'r-')
hold on
plot(newN, Gn, 'G-')
plot(newN, Bn, 'b-')
colormap(newC);
colorbar('southoutside')
ylim([0 260])
xlim([1 64])
legend('R', 'G', 'B','Location','southoutside','Orientation','horizontal')
xlabel('C-index')
ylabel('R,G,B')
export_fig([ 'RGB-colormap'   ],'-jpeg','-r250')

figure;
plot(newN, sum(newC,2)./3, 'r-')
ylabel('Intensity')
xlabel('C-index')
xlim([1 64])
export_fig([ 'RGB-intensity' ],'-jpeg','-r250')

Here is an alternate
175 256 255
100 249 255
50 223 253
10 191 252
9 144 252
12 106 255
11 79 254
26 56 254
34 38 255
50 25 255
79 15 255
85 15 255
101 30 255
132 50 255
150 70 255
177 80 255
217 100 255
243 100 255
255 80 213
255 70 175
255 50 143
255 30 110
255 15 88
255 25 65
255 44 35
255 72 35
254 95 39
255 116 45
254 138 41
254 160 46
255 183 45
255 199 46
255 225 47
253 240 47
254 250 75
256 256 129
R G B

It adds whiteness in the middle, creating W shaped swing to the green pallets.





Thursday, April 21, 2016

M_Map Examples for matlab mapping

There are so many projections to choose from:
%      Stereographic
%      Orthographic
%      Azimuthal Equal-area
%      Azimuthal Equidistant
%      Gnomonic
%      Satellite
%      Albers Equal-Area Conic
%      Lambert Conformal Conic
%      Mercator
%      Miller Cylindrical
%      Equidistant Cylindrical
%      Oblique Mercator
%      Transverse Mercator
%      Sinusoidal
%      Gall-Peters
%      Hammer-Aitoff
%      Mollweide
%      Robinson
%      UTM
Which one to choose?
Let me quote: "Well, it depends really on how large an area you are mapping. Usually, maps of the whole world are Mercator, although often the Miller Cylindrical projection looks better because it doesn't emphasize the polar areas as much. Another choice is the Hammer-Aitoff or Mollweide (which has meridians curving together near the poles). Both are equal-area. It's probably not a good idea to use these projections for maps that don't have the equator somewhere near the middle. The Robinson projection is not equal-area or conformal, but was the choice of National Geographic (for a while, anyway), and also appears in the IPCC reports.If you are plotting something with a large north/south extent, but not very wide (say, North and South America, or the North and South Atlantic), then the Sinusoidal or Mollweide projections will look pretty good. Another choice is the Transverse Mercator, although that is usually used only for very large-scale maps.
For smaller areas within one hemisphere or other (say, Australia, the United States, the Mediterranean, the North Atlantic) you might pick a conic projection. The differences between the two available conic projections are subtle, and if you don't know much about projections it probably won't make much difference which one you use.
If you get smaller than that, it doesn't matter a whole lot which projection you use. One projection I find useful in many cases is the Oblique Mercator, since you can align it along a long (but narrow) coastal area. If map limits along lines of longitude/latitude are OK, use a Transverse Mercator or Conic Projection. The UTM projection is also useful.
Polar areas are traditionally mapped using a Stereographic projection, since for some reason it looks nice to have a "bullseye" pattern of latitude lines."
https://www.eoas.ubc.ca/~rich/private/mapug.html#p2.5

Here are some of my favs:

latlim=[ (min(min(Lat11))), (max(max(Lat11)))];
lonlim=[ (min(min(Lon11))), (max(max(Lon11)))];figure(1)
% m_proj('UTM','long',lonlim,'lat',latlim);
% m_proj('Miller Cylindrical','long',lonlim,'lat',latlim);
% m_proj('Albers Equal-Area Conic','long',lonlim,'lat',latlim);
m_proj('Robinson','long',lonlim,'lat',latlim);
% m_proj('Sinusoidal','long',lonlim,'lat',latlim);

m_pcolor(Lon11,Lat11,LST11);
set(gca,'Fontsize',24)
shading interp
m_gshhs_i('color','k');
m_grid('linestyle','-.','box','fancy','tickdir','in' );
caxis([310 335])
colorbar
set(gcf,'Color','White')
title('Robinson')
set(gca,'Fontsize',24)

Some examples of the projected MODIS LST data



Native: examples
https://www.eoas.ubc.ca/~rich/map.html

Wednesday, April 20, 2016

Matlab Plot Latitude and Longitude with degree symbol on the axis label

Not the complete code, but it does the job.
close all
load coast
cfigure( 40, 20);
plot(long, lat, 'k')
grid on
% s = sprintf('45%c', char(176));

set(gca,'XLim',[-180 180])
set(gca,'YLim',[-180/2 180/2])
set(gca,'XTick',[-180:40: 180])
set(gca,'YTick',[-90:30: 90])

xt=get(gca,'xtick');
for k=1:numel(xt);
xt1{k}=sprintf('%d°',xt(k));
end
set(gca,'xticklabel',xt1);

xt=get(gca,'ytick');
for k=1:numel(xt);
xt1{k}=sprintf('%d°',xt(k));
end
set(gca,'yticklabel',xt1);

set(gca,'Fontsize',26)

annotation('textbox', [.15  .232 0.16  0.1 ],'EdgeColor',[ 0 0 0] )

% xlim([-180 180])
% ylim([-90 90])
hold on
plot(longitude(dayyes==0), latitude(dayyes==0), 'o', 'MarkerEdgeColor','b','MarkerSize',5);
plot(longitude(dayyes==1),latitude(dayyes==1), '*', 'MarkerEdgeColor','r','MarkerSize',6);
text(-167,-50,  sprintf('* Day Profile  ' ), 'color', 'r', 'FontSize', 26)
text(-167,-60,  sprintf('o Night Profile' ), 'color', 'b', 'FontSize', 26)
%    annotation('textbox', [-175  -55 20  15 ],'EdgeColor',[0 0 0] )
ylabel('Latitude ', 'FontSize', 26)
xlabel('Longitude ', 'FontSize', 26)
set(gcf,'Color','white')

Monday, April 4, 2016

Readability Statistics in owrd

readability features in the word count are interesting one to pass at.

In Word 2013/2010, File>Option>Proofing
In word 2007, search for proofing option

Then under spelling and grammar section of the display menu, check the "Show readability statistics".
This will enable readability statistics.

A usual rule of thumb is that  the Flesch-Kincaid Grade (FKG) Level  should be around 10-12, and the Flesch Reading Ease should be between 60-70.
The FKG level is between 1-12, and represents how many years of US school is needed to understand the document.
There is also passive sentence score. While technical documents may be written with some passive statements, business documents are written with active sentences.


Find the abbreviations in word

To Find the abbreviations in the document,
Go to find, advanced, more and then set search options to "Use wildcards".
Find the following:
<[A-Z]{2,}>
Do find a reading highlight, and then highlight all.

Minus sign is another issue
SymbolUnicode
hyphen
minus sign
N-dash
M-dash
–
−
–
—
f-f
f−f
f–f
f—f
002D or 2010
2212
2013
2014