function astFormatContourLines(contourMatrix,contourGrpHandle,labelLine)
% astFormatContourLines: Helper function to format major contour lines' color
% and width to match published WMM2010 reports/plots (see
% http://www.ngdc.noaa.gov/geomag/WMM/ )

% Copyright 2009-2011 The MathWorks, Inc.

%*********************
% Label Contour Lines
%*********************
hclabel = clabelm(contourMatrix,contourGrpHandle,labelLine);
set(hclabel,'BackgroundColor','none','FontSize',8,'FontWeight','bold');

%*********************
% Find Contour Values
%*********************
% Get handles to all Contour lines
hcontourLines = findall(contourGrpHandle,'Type','Line');

% Use the line contour Tag to extract contour value.
contourValueTag = get(hcontourLines,'Tag');
contourValues = regexprep(contourValueTag,'contour line: ','');
contourValues = str2double(contourValues);

%****************************
% Format Contour Line Colors
%****************************
% Contour default contour line width
lineWidth = 0.5;

% If Positive ... (red)
set(hcontourLines(contourValues>0),'LineWidth',lineWidth,'Color','r')

% If Zero ... (green)
set(hcontourLines(contourValues==0),'LineWidth',lineWidth,'Color','g')

% If Negative ... (blue)
set(hcontourLines(contourValues<0),'LineWidth',lineWidth,'Color',[.1176 .5647 1])

%***********************************
% Format Labeled Contour Line Width
%***********************************
% Get Unique text string values for all labeled contour lines
labeledValues = get(hclabel,'String');
if ~iscell(labeledValues)
    labeledValues = {labeledValues};
end
labeledContours = str2double(unique(labeledValues));

lineWidth = 1.6;
set(hcontourLines(ismember(contourValues,labeledContours)),'LineWidth',lineWidth)

end