function a = GraphPLineData(b)

	% This function plots the requested data in a BinOutput file.
	% The input data may be from a BinOutput file or from a
	% Matlab file that was saved from a previous execution of
	% this script.  Some parameters will be requested of the 
	% user including the angle set (1-6), plot set (1-4), 
	% and maybe parameter (1-6) if the plot set = 4.
	% The user will need to set the date, set and rep within
	% this file to get the appropriate data.
	
	% Initialize some local variables.
	
rad = pi/180;

fromMatFileFlag = 1;
adjustChiAngleFlag = 1;
firstTime = 1;

	% Specify date to process.
	
date = '725';

	% Specify the set to be plotted.
	
set = 2;

	% Specify the rep to be plotted.
	
rep = 1;

angleSet = 2;

	% Plot set to be displayed
	% 1 = Green, Red, Blue; 
	% 2 = I, Q, U; 
	% 3 = PP, X, Rp
	% 4 = Display of MMR Channels 7's
	
plotSet = 3;

band = 3;

	% Parameter to be plotted.
	% I = 1, 
	% Q = 2, 
	% U = 3, 
	% Percent Polarization = 4, 
	% Chi angle of plane of polarization = 5, 
	% Reflectance percent = 6;

parameter = 5;

continueCode = 'y';
while continueCode == 'y';

if firstTime ~= 1

		% Get new user parameters

		% Plot set
	
	valueString = num2str( plotSet );
	promptString = ['Plot Set? [', valueString, ']: '];
	x = input(promptString);
	if isempty (x) == 0
		plotSet = x;
		end;

		% Angle set
	
	valueString = num2str( angleSet );
	promptString = ['Angle Set? [', valueString, ']: '];
	x = input(promptString);
	if isempty (x) == 0
		angleSet = x;
		end;
		
	if plotSet ~= 4
			% Band
		
		valueString = num2str( band );
		promptString = ['Band? [', valueString, ']: '];
		x = input(promptString);
		if isempty (x) == 0
			band = x;
			end;

		end;	% if plotSet ~= 4

	if plotSet == 1
			% Parameter
		
		valueString = num2str( parameter );
		promptString = ['Parameter? [', valueString, ']: '];
		x = input(promptString);
		if isempty (x) == 0
			parameter = x;
			end;

		end;	% if plotSet == 1

	end;	% if firstTime ~= 1

if parameter == 1
	numberLines = 3;
	numberPlots = 3;
	
else
	numberLines = 2;
	numberPlots = 3;
	
end;

if plotSet == 1
	if parameter == 1
		yString = 'RI (percent)';
		
	elseif parameter == 2
		yString = 'RQ (percent)';
		
	elseif parameter == 3
		yString = 'RU (percent)';
		
	elseif parameter == 4
		yString = 'Percent Polarized)';
		
	elseif parameter == 5
		yString = 'Pol. Angle (degrees)';
		
	else	% parameter == 6
		yString = 'Rp (percent)';

	end;		% if parameter == 1, elseif...
	
	end;	% if plotSet == 1
	
setString = num2str( set );
repString = num2str( rep );

	% Get part of title string
	
dateString = [date, ' S', setString, '-', repString, ' '];
dateString

	% Get file name.
%fileName = [date, 'S', setString, 'R', repString, 'b'];
fileName = [date, 'S', setString, 'R', repString];
fileName

if fromMatFileFlag == 1

		% Load the data set in if needed.
	
	if firstTime == 1
		firstTime
		load (fileName);
		end;

else	% fromMatFileFlag != 1

	inputFileName = ['m0', date, '.BinOutput'];
	
	rfid = fopen(inputFileName);
	if rfid == -1,
		rfid
		return,
		end;
	
		% Skip header lines.
	
	for i=1:3
		dataline = fgets(rfid);
		fileError = ferror(rfid);
		if fileError ~= [],
			return,
			end;
			
		end;	% for i=1:3
		
		% Get the request set and replication
	
	notFound = 1;
	while notFound == 1
			% Get header for set and decode some parameters.
			
		dataline = fgets(rfid);
		fileError = ferror(rfid);
		if fileError ~= [],
			return,
			end;
		
		[A count] = sscanf(dataline,...
			'Set %d\tRep %d\tCode %d\tScene: %s\tRelative Azimuth: %d to %d\tSolar Zenith: %d to %d\tSolar Azimuth: %d to %d');
		if (A(1) == set) & (A(2) == rep)
			notFound = 0;
			
		else		% A(1) ~= set) | A(2) ~= rep
				% Determine number of lines in this group of data
				
			numberLines = 39;
			if A(3) > 80
				numberLines = 44;
				end;
				
				% Skip to next group of data
				
			for i=1:numberLines
				dataline = fgets(rfid);
				fileError = ferror(rfid);
				if fileError ~= [],
					return,
					end;
				end;
				
			end;	% if (A(1) == set) & (A(2) == rep), else...
		
		end;	% while notFound == 1
		
		% The requested set and replication has been found.
		% Now get the number of angles in the set.
		
	numberAngles = 77;
	numberGroups = 12;
	numberGroupAngles = 39;
	sunflowerCode = 1;
	if A(3) > 80
		numberAngles = 87;
		numberGroups = 4;
		numberGroupAngles = 44;
		sunflowerCode = 0;
		end;

	B1 = zeros(numberAngles,numberGroups*3);
	B2 = zeros(numberAngles,numberGroups*3);
	B3 = zeros(numberAngles,numberGroups*3);
	B4 = zeros(numberAngles,numberGroups*3);
	B5 = zeros(numberAngles,numberGroups*3);
	B6 = zeros(numberAngles,numberGroups*3);
	
	B7NP = zeros(numberAngles,numberGroups*3/2);
	
	C1 = zeros(numberAngles,numberGroups*3);
	C2 = zeros(numberAngles,numberGroups*3);
	C3 = zeros(numberAngles,numberGroups*3);
	
	CNP = zeros(numberAngles,numberGroups*3/2);
	
	Angles2DBin = zeros(numberAngles,numberGroups/2);
	Angles12DBin = zeros(numberAngles,numberGroups/2);

	CimelAngles = zeros(numberAngles,1);
	
	for i=1:numberAngles
		for j=1:numberGroups/2
			Angles2DBin(i,j) = nan;
			Angles12DBin(i,j) = nan;
			end;
		end;
	
	tempAz = zeros(6,2);
	
	RelAz = [0; 90; 0; 0; 0; 0];
	
		% Get the index into the array for the view group.
		% The 0 degree view set will always be the first.
		% The 90 degree view set will be second.
		% The rest will be in increasing order of azimuth direction from
		% 0 to 180 degrees.
	
	if sunflowerCode == 1	
		if rep == 1
			setOrderVector = [2 -2 -1 1 3 -3 4 -4 5 -5 6 -6]';
		
		else	% rep == 2
			setOrderVector = [3 -3 4 -4 5 -5 6 -6 -2 2 1 -1]';
			
		end;	% if rep == 1, else...
		
	else	% sunflowerCode == 0
		if A(3) == 81
			setOrderVector = [-2 2 -1 1 3 -3 4 -4 5 -5 6 -6]';
			
		else	% A(3) == 82
			setOrderVector = [-1 1 -2 2 3 -3 4 -4 5 -5 6 -6]';
			
		end;	% if A(3) == 81, else...
		
	end;	% if sunflowerCode == 1, else...
		
		% Indicate that the header for the first group of data has been read.
		
	headerRead = 1;
	
	numberGroups
	setOrderVector
		
	for group = 1:numberGroups
	
		indexSet = abs( setOrderVector(group) );
	
		if headerRead == 0
				% Get header for set and decode some parameters.
				
			dataline = fgets(rfid);
			fileError = ferror(rfid);
				
			if fileError ~= [],
				break,
				end;
			
			[A count] = sscanf(dataline,...
				'Set %d\tRep %d\tCode %d\tScene: %s\tRelative Azimuth: %d to %d\tSolar Zenith: %d to %d\tSolar Azimuth: %d to %d');
			
			end;
			
		if set ~= A(1) |  rep ~= A(2)
			break;
			end;
		
		code = A(3);
		
		if sunflowerCode == 1
			scene = A(4:13);
			relAzM = A(14);
			relAzP = A(15);
			solZenM = A(16);
			solZenP = A(17);
			solAzM = A(18);
			solAzP = A(19);
			
		else	% sunflowerCode == 0
			scene = A(4:6);
			relAzM = A(7);
			relAzP = A(8);
			solZenM = A(9);
			solZenP = A(10);
			solAzM = A(11);
			solAzP = A(12);
			
		end;	% if sunflowerCode == 1, else...
		
		if group == 1 & sunflowerCode == 1
				% Determine the order to store the data base on
				% the relative view-sun azimuth differenct
			
			if rep == 1	
				tempAz(1,1) = 0;
				tempAz(2,1) = 90;
				tempAz(3,1) = rem(180-solAzP+360, 360);
				tempAz(4,1) = rem(225-solAzP+360, 360);
				tempAz(5,1) = rem(270-solAzP+360, 360);
				tempAz(6,1) = rem(315-solAzP+360, 360);
				
				tempAz(1,2) = 1;
				tempAz(2,2) = -1;
				
			else
				tempAz(1,1) = 0;
				tempAz(2,1) = 90;
				tempAz(3,1) = rem(0-solAzP+360, 360);
				tempAz(4,1) = rem(45-solAzP+360, 360);
				tempAz(5,1) = rem(90-solAzP+360, 360);
				tempAz(6,1) = rem(135-solAzP+360, 360);
				
				tempAz(1,2) = -1;
				tempAz(2,2) = 1;
			
			end;	% if rep == 1, else...
			
			for i=3:6
				if tempAz(i,1) >= 180
					tempAz(i,1) = tempAz(i,1) - 180;
					tempAz(i,2) = -1;
					
					end; 	% if tempAz(i,1) >= 180
					
				end;	% for i=3:6
			
				% Find the minimum azimuth angle for rows 3 to 6 in the
				% first column of the tempAz matrix.
				
			tempIndex = 3;
			for i=3:6
				if tempAz(i,1) < tempAz(tempIndex,1)
					tempIndex = i;
					end;
				end;
			
			sIndex = 3;
			for i=5:2:12
				setOrderIndex = tempIndex*2 - 1;
				if rep == 2
					setOrderIndex = setOrderIndex - 4;
					end;
					
				setOrderVector(setOrderIndex) = sIndex;
				setOrderVector(setOrderIndex+1) = ...
										-setOrderVector(setOrderIndex);
				
				if tempAz(tempIndex,2) < 0
					setOrderVector(setOrderIndex+1) = setOrderVector(setOrderIndex);
					setOrderVector(setOrderIndex) = -setOrderVector(setOrderIndex);
					
					end;	% if tempAz(sIndex,2) < 0
				
				RelAz(tempIndex) = tempAz(tempIndex,1);
				
				tempIndex = rem(tempIndex-2, 4) + 3;
				
				sIndex = sIndex + 1;
				
				end;	% for i=5:2:12
				
			setOrderVector
			RelAz
	
				% Get the index set again in case it was changed.
				
			indexSet = abs( setOrderVector(group) );
			
			end;	% if group == 1 && ...

		if sunflowerCode == 0
			if (group == 1 | group == 3) & relAzP < 180
				setOrderVector(group) = indexSet;
				setOrderVector(group+1) = -indexSet;
				end;	% if (group == 1 | group == 3) & relAzP < 180

			if relAzP == 359
				relAzP = 0
				end;
				
			end;	% if sunflowerCode == 0
		
			% Save the relative azimuth for the half of the set that
			% is positive.
			
		if setOrderVector(group) > 0
			RelAz(indexSet) = relAzP;
			end;
			
		aIndex = numberGroupAngles;
		dir = 1;
		if setOrderVector(group) < 0
			dir = -1;
			end;
			
		ks = 1 + (indexSet - 1) * 6;
		ke = ks + 5;
			
		ksnp = 1 + (indexSet - 1) * 3;
		kenp = ksnp + 2;
			
		for angles = 1:numberGroupAngles
			dataline = fgets(rfid);
			fileError = ferror(rfid);
			
			if fileError ~= [],
				break,
				end;
			
				% Get data for observation.
					
			obs = sscanf(dataline, '%f', 65);
			
			if obs == []
				aIndex
				indexSet
				numberGroups
				group
				numberGroupAngles
				setOrderVector
				break;
				end;
			
			Angles12DBin(aIndex, indexSet) = dir * obs(4);
			Angles2DBin(aIndex, indexSet) =  dir * obs(5);
			
			B1(aIndex, ks:ke) = obs(6:11)';
			B2(aIndex, ks:ke) = obs(12:17)';
			B3(aIndex, ks:ke) = obs(18:23)';
			B4(aIndex, ks:ke) = obs(24:29 )';
			B5(aIndex, ks:ke) = obs(30:35)';
			B6(aIndex, ks:ke) = obs(36:41)';
			
			C1(aIndex, ks:ke) = obs(42:47)';
			C2(aIndex, ks:ke) = obs(48:53)';
			C3(aIndex, ks:ke) = obs(54:59)';
			
			B7NP(aIndex, ksnp:kenp) = obs(60:62)';
			
			CNP(aIndex, ksnp:kenp) = obs(63:65)';
			
			aIndex = aIndex + dir;
			
			end;	% for angles = 1:numberGroupAngles
			
		if fileError ~= [],
			break,
			end;
		
		headerRead = 0;
			
		group
	
		end;	% for group = 1:numberGroups
		
	fclose(rfid);
	
		% Now force the angle chi of the plane of polarization to not jump
		% back and forth between 90 and -90 degrees.
	
	if adjustChiAngleFlag == 1
		B1 = AdjustChiAngle(B1, numberAngles, numberGroups/2);
		B2 = AdjustChiAngle(B2, numberAngles, numberGroups/2);
		B3 = AdjustChiAngle(B3, numberAngles, numberGroups/2);
		B4 = AdjustChiAngle(B4, numberAngles, numberGroups/2);
		B5 = AdjustChiAngle(B5, numberAngles, numberGroups/2);
		B6 = AdjustChiAngle(B6, numberAngles, numberGroups/2);
		C1 = AdjustChiAngle(C1, numberAngles, numberGroups/2);
		C2 = AdjustChiAngle(C2, numberAngles, numberGroups/2);
		C3 = AdjustChiAngle(C3, numberAngles, numberGroups/2);
		
		end;	% if adjustChiAngleFlag == 1
	
	if fromMatFileFlag == 0
		variables = ' B1 B2 B3 B4 B5 B6 C1 C2 C3 CNP B7NP RelAz Angles12DBin Angles2DBin numberAngles';
		eval (['save ' fileName variables]);
		end;

end;	% if fromMatFileFlag == 1, else

	% Make certain that we have a proper code for sky or sunflowers

sunflowerCode = 1;
if numberAngles == 87
	sunflowerCode = 0;
	end;

	% Make certain that angle set makes sense

if numberAngles == 87 & angleSet > 2
	angleSet = 2;
	end;

if numberAngles == 87 & plotSet == 4 & angleSet > 1
	angleSet = 1;
	end;
	
angleSetIndex = (angleSet-1) * 6;
angleSetNPIndex = (angleSet-1) * 3;

	% Get the Angle to use for the Cimel data based on the date the data were collected.
	% Dates before 7/25 were collected as a 1 deg. FOV; 7/25 and after were 12 deg. FOV.

if date == '711' | date == '712' | date == '715' | date == '716'
	CimelAngles = Angles12DBin(:,angleSet);

else
	CimelAngles = Angles2DBin(:,angleSet);

end;	% if date == ...

	% Set the figure to draw into.
	
figure(1);

	% Set some graph parameters.
	
SetFigureSize;
azString = num2str( RelAz(angleSet) );

if numberPlots == 3
	if plotSet == 1
		subplot1(1,3,1);
		graphTitle = [dateString, azString, ' Green'];
		pIndex = parameter + angleSetIndex;
		Draw3LineGraph(Angles12DBin(:,angleSet), B2(:,pIndex),...
							CimelAngles, C1(:,pIndex),...
							Angles2DBin(:,angleSet), CNP(:,1+angleSetNPIndex),...
							yString, graphTitle, 1, numberLines);
		
		subplot1(1,3,2);
		graphTitle = [dateString, azString, ' Red'];
		pIndex = parameter + angleSetIndex;
		Draw3LineGraph(Angles12DBin(:,angleSet), B3(:,pIndex),...
							CimelAngles, C2(:,pIndex),...
							Angles2DBin(:,angleSet), CNP(:,2+angleSetNPIndex),...
							yString, graphTitle, 0, numberLines);
		
		subplot1(1,3,3);
		graphTitle = [dateString, azString, ' IR'];
		pIndex = parameter + angleSetIndex;
		Draw3LineGraph(Angles12DBin(:,angleSet), B4(:,pIndex),...
							CimelAngles, C3(:,pIndex),...
							Angles2DBin(:,angleSet), CNP(:,3+angleSetNPIndex),...
							yString, graphTitle, 0, numberLines);
		
	elseif	plotSet == 2
		pIndex = angleSetIndex + 1;
		
		if band == 1
			yString = 'MMR1 Reflectance (%)';
			Graph_IQU(	Angles12DBin(:,angleSet), B1,...
							[], [],...
							[], [],...
 							dateString, azString, yString, pIndex);
 			
 		elseif band == 2
			yString = 'Green Reflectance (%)';
			Graph_IQU(	Angles12DBin(:,angleSet), B2,...
							CimelAngles, C1,...
							Angles2DBin(:,angleSet), CNP(:,1+angleSetNPIndex),...
 							dateString, azString, yString, pIndex);
 			
 		elseif band == 3
			yString = 'Red Reflectance (%)';
			Graph_IQU(	Angles12DBin(:,angleSet), B3,...
							CimelAngles, C2,...
							Angles2DBin(:,angleSet), CNP(:,1+angleSetNPIndex),...
 							dateString, azString, yString, pIndex);
 			
 		elseif band == 4
			yString = 'IR Reflectance (%)';
			Graph_IQU(	Angles12DBin(:,angleSet), B4,...
							CimelAngles, C3,...
							Angles2DBin(:,angleSet), CNP(:,3+angleSetNPIndex),...
 							dateString, azString, yString, pIndex);
							
		elseif band == 5
			yString = 'MMR5 Reflectance (%)';
			Graph_IQU(	Angles12DBin(:,angleSet), B5,...
							[], [],...
							[], [],...
 							dateString, azString, yString, pIndex);
							
		elseif band == 6
			yString = 'MMR6 Reflectance (%)';
			Graph_IQU(	Angles12DBin(:,angleSet), B6,...
							[], [],...
							[], [],...
 							dateString, azString, yString, pIndex);
 							
 		end;	% if band == 1, elsif...
		
	elseif	plotSet == 3
		pIndex = angleSetIndex + 4;
		
		if band == 1
			yString = 'Blue Band';
			Graph_PXR(	Angles12DBin(:,angleSet), B1,...
							[], [],...
 							dateString, azString, yString, pIndex);
 			
 		elseif band == 2
			yString = 'Green Band';
			Graph_PXR(	Angles12DBin(:,angleSet), B2,...
							CimelAngles, C1,...
 							dateString, azString, yString, pIndex);
 			
 		elseif band == 3
			yString = 'Red Band';
			Graph_PXR(	Angles12DBin(:,angleSet), B3,...
							CimelAngles, C2,...
 							dateString, azString, yString, pIndex);
 			
 		elseif band == 4
			yString = 'IR Band';
			Graph_PXR(	Angles12DBin(:,angleSet), B4,...
							CimelAngles, C3,...
 							dateString, azString, yString, pIndex);
							
		elseif band == 5
			yString = 'MMR5 Band';
			Graph_PXR(	Angles12DBin(:,angleSet), B5,...
							[], [],...
 							dateString, azString, yString, pIndex);
							
		elseif band == 6
			yString = 'MMR6 Band';
			Graph_PXR(	Angles12DBin(:,angleSet), B6,...
							[], [],...
 							dateString, azString, yString, pIndex);
 							
 		end;	% if band == 1, elsif...
		
	else	% plotSet == 4
		subplot1(1,3,1);
		yString = 'MMR7 Reflectance (%)';
		graphTitle = [dateString, azString];
		Draw3LineGraph(Angles12DBin(:,angleSet), B7NP(:,1+angleSetNPIndex),...
					Angles12DBin(:,angleSet), B7NP(:,2+angleSetNPIndex),...
					Angles12DBin(:,angleSet), B7NP(:,3+angleSetNPIndex),...
					yString, graphTitle, 1, 3);
					
		subplot1(1,3,2);
		angleSetNPIndex = angleSetNPIndex + 3;
		azString = num2str( RelAz(angleSet+1) );
		graphTitle = [dateString, azString];
		Draw3LineGraph(Angles12DBin(:,angleSet+1), B7NP(:,1+angleSetNPIndex),...
					Angles12DBin(:,angleSet+1), B7NP(:,2+angleSetNPIndex),...
					Angles12DBin(:,angleSet+1), B7NP(:,3+angleSetNPIndex),...
					yString, graphTitle, 0, 3);
		
		subplot1(1,3,3);
		if sunflowerCode == 1
			angleSetNPIndex = angleSetNPIndex + 3;
			azString = num2str( RelAz(angleSet+2) );
			graphTitle = [dateString, azString];
			Draw3LineGraph(Angles12DBin(:,angleSet+2), B7NP(:,1+angleSetNPIndex),...
						Angles12DBin(:,angleSet+2), B7NP(:,2+angleSetNPIndex),...
						Angles12DBin(:,angleSet+2), B7NP(:,3+angleSetNPIndex),...
						yString, graphTitle, 0, 3);
			end;
					
	end;	% if plotSet == 1, elseif...

	end;	% if numberPlots == 3

	continueCode = input('Continue? y/n [y]: ', 's');
	if isempty (continueCode)
		continueCode = 'y';
		
	else if continueCode ~= 'n'
		continueCode = 'y';
		end;
		
	end;

	firstTime = 0;
	fromMatFileFlag = 1;

	end;	% while continueCode = 'y'
