%*******************************************************************
% 4-level model					       22 Sept. 1997
%*******************************************************************

function [Vlamp,Ilamp,Rlamp,Temp,Lamptype]=pldata(lamp,temp,pwr)
%lampdata
%[Vlamp,Ilamp,Rlamp,Temp,Lamptype]=pldata(lamp,temp,pwr)
if lamp==1
	%lamp=1 : Pl24 lamp function of ambienttemperature
	%         temp = 1: -5C, 2: 0C, 3: 5C, 4: 15C, 5: 25C, 6: 45C
	Tl=[-5 1e5 36 181 6.94
	0 1e5 36 195 7.28
	5 8e4 40 165 8.53
	15 7e4 42 144 13.61
	25 1e5 26 137 27.35
	45 4e4 0 126 36.41];
	Lamptype='Pl24';
end
%
if lamp==2
	%lamp=2 : Pl36 lamp function of ambienttemperature
	%         temp = 1: 0C, 2: 5C, 3: 15C, 4: 25C, 5: 45C
	Tl=[0 65e3 56 314 7.9
	5 55e3 59 272 9.7
	15 12e4 65 203 16.3
	25 12e4 65 198 23
	45 8e4 0 165 43.9];
	Lamptype='Pl36';
end
%
if lamp==3
	%lamp=3 : Pl40/58 lamp function of ambienttemperature
	%         temp = 1: 0C, 2: 5C, 3: 15C, 4: 25C, 5: 45C
	Tl=[0 5e5 65 257 14.9
	5 18e4 78 272 15.7
	15 9e4 99 243 21.4
	25 10e4 68 232 41.3
	45 3e4 60 223 29.1];
	Lamptype='Pl40/58';
end
%
if lamp==4
	%lamp=4 TLD 32W HF
	%	temp= 1: -15C, 2: -5C, 3:  5C,  4: 15C,  5: 20C, 6: 25C,
	%	      7:  30C, 8: 35C, 9: 45C, 10: 55C, 11: 65C
	Tl=[-15 99999999 69 304 10.7
	-5 99999999 90 242 12.3
	5 600000 113 216 12.5
	15 120000 66 191 50
	20 89000 -12500 177 8839.3
	25 40000 -1249995 179 744186
	30 37000 -1250 170 841.8
	35 18000 0 180 65.9
	45 19000 63 175 26.2
	55 38000 69 165 17.8
	65 58000 73 163 12];
	Lamptype='TLD 32W HF';
end
%
if lamp==5
	%lamp=5 TLD 50W HF
	%	temp= 1: -15C, 2: -5C, 3:  5C,  4: 15C,  5: 20C, 6: 25C,
	%	      7:  30C, 8: 35C, 9: 45C, 10: 55C, 11: 65C
	Tl=[-15 12e4 107 435 10
	-5 8e4 130 393 8.2
	5 25e4 138 243 16.4
	15 99999999 -1370 211 1320.8
	20 75000 -137000 220 92488.4
	25 47000 -1370 218 973.1
	30 30000 -247 217 253.2
	35 19000 55 237 46.6
	45 21000 75 224 29.5
	55 38000 82 201 24.3
	65 75000 88 197 15.3];
	Lamptype='TLD 50W HF';
end
%
if lamp==6
	%lamp=6 TLD 36W (Krypton)
	%	temp= 1: -15C, 2: -5C, 3:  5C,  4: 15C,  5: 20C, 6: 25C,
	%	      7:  30C, 8: 35C, 9: 45C, 10: 55C, 11: 65C
	Tl=[-15 350000 45 288 4.73
	-5 110000 53 315 4.42
	5 60000 66 256 5.32
	15 60000 84 190 9.29
	20 55000 75 165 20.13
	25 46000 19 155 55.32
	30 28000 -48 156 82.94
	35 28000 0 152 56.26
	45 25000 48 151 25.12
	55 65000 62 143 14.27
	65 170000 67 142 9.13];
	Lamptype='TLD 36W (Krypton)';
end
%
if lamp==7
	%lamp=7 TLD 58W (Krypton)
	%	temp= 1: -15C, 2: -5C, 3:  5C,  4: 15C,  5: 20C, 6: 25C,
	%	      7:  30C, 8: 35C, 9: 45C, 10: 55C, 11: 65C
	Tl=[-15 200000 53 301 8.9
	-5 300000 53 308 6.98
	5 900000 68 239 10.33
	15 250000 99 220 12.9
	20 200000 84 197 28.77
	25 80000 21 195 68.6
	30 45000 31 199 57.64
	35 35000 47 199 44.25
	45 40000 63 188 29.95
	55 80000 73 180 18.7
	65 500000 77 171 14.27];
	Lamptype='TLD 58W (Krypton)';
end
%
Rlim=Tl(temp,2);
Ulamin=Tl(temp,3);
Ula0=Tl(temp,4);
pk=Tl(temp,5);
%
ula=Ulamin+(Ula0-Ulamin).*exp(-pwr./pk);
rla=ula.^2 ./pwr;
Rlamp=1 ./(1 ./rla+1 ./Rlim);
Vlamp=sqrt(pwr.*Rlamp);
Ilamp=pwr./Vlamp;
Temp=Tl(temp,1);
