pro param_SSRT,Indate,Intime,Inrec,Date=Date,Time=Time, $
	Receiver=Receiver, silent=silent,SUN=SUN, $
		parameters=parameters,group_leader=group_leader, $
		nofile=nofile

;	Displays the SSRT parameters in a time moment given.

if n_elements(group_leader) le 0 then group_leader=0L

if n_params() ge 2 then begin
Date=Indate	&	Time=Intime
endif
if n_params() eq 3 then Receiver=Inrec


if n_elements(Date) le 0 then Date=''
if strlen(Date) lt 2 then read,'Date (e.g. 24 08 93) - ', Date
if n_elements(Time) le 0 then Time=''
if strlen(Time) lt 2 then read,'Time (e.g. 07 04 33.457) - ', Time
	if n_elements(Receiver) le 0 then begin
Receiver=0   &	read,'Receiver (0-MFB, 1-AOR) - ', Receiver
	endif

suneph,Date,Time,SUN

WIDGET_CONTROL,/hourglass

Radio=1.175D
D=4.9D  &  C=2.997925D8  &  Fi=51.7575D*!DPi/180  &  Nant=128
Sum_chan=[180,192]

Bound_Frequencies=chanfreq([1,Sum_chan(Receiver)],Receiver)

Fmin=Bound_Frequencies(0)
Fmax=Bound_Frequencies(1)

F0=(Fmax+Fmin)/2
Df=(Fmax-Fmin)/(Sum_chan(Receiver)-1)
Rads=!DPi/180/3600


; *************   Interferometer E-W   ********************

INT_ORD,0,Receiver,SUN,P,NnEW,NordEW,ChanEW

NmaxEW=fix(Fmax*D*cos(SUN.Decl)/C)
ExpFactorEW=[1.,Coeffr(NordEW(0),band=2), $
	Coeffr(NordEW(0),band=4,rec=Receiver)]
RoEW=0.886*C/(Nant*F0*D*abs(sin(P(1))))*ExpFactorEW

SpacingEW=abs(tan(!Dpi/2-p(1))*Df/F0)

A_EW=atan(tan(SUN.H)*sin(SUN.Decl))
G_EW=A_EW+SUN.Dp

;Tmod=Df/F0*tan(abs(SUN.H))/SUN.W0

TmodEW0=abs(asin(NordEW(0)*C/(Fmin*D*cos(SUN.Decl)) < 1 > (-1))- $
  asin(NordEW(0)*C/((Fmin+Df)*D*cos(SUN.Decl)) < 1 > (-1)))/SUN.W0

TmodEW1=abs(asin(NordEW(0)*C/(Fmax*D*cos(SUN.Decl)) < 1 > (-1))- $
  asin(NordEW(0)*C/((Fmax+Df)*D*cos(SUN.Decl)) < 1 > (-1)))/SUN.W0

TneighEW=abs(asin(NordEW(0)*C/(F0*D*cos(SUN.Decl)))- $
  asin((NordEW(0)+1)*C/(F0*D*cos(SUN.Decl)) < 1 > (-1)))/SUN.W0


TPassBeamEW=0.886*C/abs((Nant*F0*D*cos(SUN.H)*cos(SUN.Decl))* $
	ExpFactorEW(1))/SUN.W0

; *************   Interferometer S-N   ********************

INT_ORD,1,Receiver,SUN,Q,NnSN,NordSN,ChanSN

NmaxSN=fix(Fmax*D*sin(Fi-SUN.Decl)/C)


ExpFactorSN=[1.,Coeffr(NordSN(0),band=2), $
	Coeffr(NordSN(0),band=4,rec=Receiver)]

RoSN=0.886*C/(Nant*F0*D*abs(sin(Q(1))))*ExpFactorSN

SpacingSN=abs(tan(!Dpi/2-q(1))*Df/F0)

	IF SUN.H Ne 0 THEN A_SN= $
-atan(cos(SUN.Decl)/sin(SUN.H)/tan(Fi)+sin(SUN.Decl)/Tan(SUN.H)) $
 	ELSE A_SN=!DPi/2

G_SN=A_SN+SUN.Dp

CDSF=cos(SUN.Decl)*sin(Fi)
SDCF=sin(SUN.Decl)*cos(Fi)

TmodSN0=abs(acos((NordSN(0)*C/(Fmin*D)+SDCF)/CDSF < 1 > (-1))- $
  acos((NordSN(0)*C/((Fmin+Df)*D) +SDCF)/CDSF < 1 > (-1)))/SUN.W0

TmodSN1=abs(acos((NordSN(0)*C/(Fmax*D)+SDCF)/CDSF < 1 > (-1))- $
  acos((NordSN(0)*C/((Fmax+Df)*D)+SDCF)/CDSF < 1 > (-1)))/SUN.W0

TneighSN=abs(acos((NordSN(0)*C/(F0*D)+SDCF)/CDSF < 1 > (-1))- $
  acos(((NordSN(0)+1)*C/(F0*D)+SDCF)/CDSF < 1 > (-1)))/SUN.W0

TPassBeamSN=0.886*C/abs((Nant*F0*D*sin(SUN.H)*cos(SUN.Decl)* $
	sin(Fi))*ExpFactorSN(1))/SUN.W0

;   **************** PRINT DATA ******************

if keyword_set(nofile) then goto,exit
name_for_file=strmid(date, 6, 2)+strmid(date, 3, 2)+strmid(date, 0, 2)

Filename=newfilename(model=name_for_file,filt='*.par',	$
	path=getenv('results'))


	CASE !version.OS OF

'windows':	Delim='\'

'Win32':	Delim='\'

ELSE:		Delim='/'

	ENDCASE

Filename=getenv('results')+Delim+Filename

	openw,lun,Filename,/get_lun

printf,lun,Date_string(Date),Time, $
	format="(5X,'DATE: ',A11,',     TIME: ',A12,' UT',/)"
printf,lun,smh(SUN.Tcul*3600,/str,ms=2), $
	format="(T10,'Culmination: ',A11,/)"
printf,lun,SUN.H,SUN.H/!Dpi*180,SUN.H/SUN.W0/3600,format=$
"('Hour angle = ',F8.5,' rad = ',F8.4,' degree = ',F8.5,' hours',/)"

IF SUN.Decl lt 0 THEN Dsign='-' ELSE IF SUN.Decl gt 0 THEN Dsign='+' $
	ELSE Dsign=' '
printf,lun, Dsign,smh(abs(SUN.Decl)/!DPi*180*3600, /str,ms=1), SUN.Decl, $
	SUN.Decl/!DPi*180, format= $
"('Declination = ',A1,A10,' = ',F8.5,' rad = ',F8.4,' degree',/,/)"

printf,lun,format="(T15,'INTERFEROMETER E-W')"
printf,lun,format="(60('-'),/)"

	Com_for= $
 ["('Bandwidth, kHz',T25,'Beam FWHM',T40,'Spreading factor')", $
 "('(CCD elements ',T20,'Arcsec',T30,'Channels')", $
 "('    integrated)')", $
 "(60('-'))"]

	First_words= $
  ["(T12,'0 (0 CCD)'","(T8,'292 (2 CCD)'","(T8,'583 (4 CCD)'"]

	for j=0,3 do printf,lun,format=Com_for(j)

	for j=0,2 do $
  printf,lun,RoEW(j)/Rads,RoEW(j)/SpacingEW,ExpFactorEW(j), $
	format=First_words(j)+",T30,F4.1,T45,F6.2,T55,F4.2)"

printf,lun,format="(60('-'),/)"

printf,lun,SpacingEW/!Pi*180*3600,format= $
"('Spacing between frequency lobes (peak to peak) = ',F5.1,' arcsec',/)"
printf,lun,NmaxEW,format="(5X,'Maximum order number = ',I2,/)"

printf,lun,A_EW/!DPi*180,format= $
"(5X,'Angle measured from the Earth meridium',/,T15,'to the knife-edge beam E-W = ',F7.2,' degree',/)"

printf,lun,G_EW/!DPi*180,format= $
"(5X,'Angle measured from the polar axis of the Sun',/,T15,'to the knife-edge beam E-W = ',F7.2,' degree',/)"

printf,lun,format="(60('-'))"
printf,lun,format="(T4,'Order',T20,'Channels',T41,'Visible')"
printf,lun,format="(T15,29('-'),T53,'Centre')"

	printf,lun,format= $
   "(T9,' Left edge*',' Centre ',' Right edge*')"
printf,lun,format="(60('-'))"
	for j=0,NnEW-1 do printf,lun,NordEW(j),ChanEW(*,j), $
 (ChanEW(0,j)+ChanEW(2,j))/2, format="(T4,I3,3X,4(F7.1,3X))"
printf,lun,format="(60('-'))"
printf,lun,p,format="(T4,'P',T11,3(F7.4,3X))"
printf,lun,cos(p),format="(T2,'Cos(P)',T10,3(F7.4,3X))"
printf,lun,format="(60('-'))"
printf,lun,ChanEW(2)-ChanEW(0),2*SUN.R*!Radeg*60,format= $
"(T10,'* Radio diameter (',F6.1,' channels) to optical one',/,'(',F5.2,' arc min) ratio assumed 1.175',/)"
printf,lun,TmodEW0,TmodEW1,1/TmodEW0,1/TmodEW1,format= $
"('Period of the beam-induced modulation = ',F6.2,' (fmin) ...',/,F6.2,' (fmax) sec',' (frequency = ',F6.2,' ... ',F6.2,' Hz)',/)"
printf,lun,TneighEW,format=$
"('Interval between passages of neighbouring orders = ',F6.1,' sec',/)"
printf,lun,TPassBeamEW,format= $
"('Duration of passing beam E-W = ',F4.1,' sec',/,/)"


printf,lun,format="(T15,'INTERFEROMETER S-N')"
printf,lun,format="(60('-'),/)"

	for j=0,3 do printf,lun,format=Com_for(j)

	for j=0,2 do $
  printf,lun,RoSN(j)/Rads,RoSN(j)/SpacingSN,ExpFactorSN(j), $
	format=First_words(j)+",T30,F4.1,T45,F6.2,T55,F4.2)"

printf,lun,format="(60('-'),/)"

printf,lun,SpacingSN/!Pi*180*3600,format= $
"('Spacing between frequency lobes (peak to peak) = ',F5.1,' arcsec',/)"
printf,lun,NmaxSN,format="(5X,'Maximum order number = ',I2,/)"

printf,lun,A_SN/!DPi*180,format= $
"(5X,'Angle measured from the Earth meridium',/,T15,'to the knife-edge beam S-N = ',F7.2,' degree',/)"

printf,lun,G_SN/!DPi*180,format= $
"(5X,'Angle measured from the polar axis of the Sun',/,T15,'to the knife-edge beam S-N = ',F7.2,' degree',/)"

printf,lun,format="(60('-'))"
printf,lun,format="(T4,'Order',T20,'Channels',T41,'Visible')"
printf,lun,format="(T15,29('-'),T53,'Centre')"
	printf,lun,format= $
   "(T9,' Left edge*',' Centre ',' Right edge*')"
printf,lun,format="(60('-'))"
	for j=0,NnSN-1 do printf,lun,NordSN(j),ChanSN(*,j), $
 (ChanSN(0,j)+ChanSN(2,j))/2, format="(T4,I3,3X,4(F7.1,3X))"
printf,lun,format="(60('-'))"
printf,lun,Q,format="(T4,'Q',T11,3(F7.4,3X))"
printf,lun,cos(Q),format="(T2,'Cos(Q)',T10,3(F7.4,3X))"
printf,lun,format="(60('-'))"
printf,lun,ChanSN(2)-ChanSN(0),2*SUN.R*!Radeg*60,format= $
"(T10,'* Radio diameter (',F6.1,' channels) to optical one',/,'(',F5.2,' arc min) ratio assumed 1.175',/)"
printf,lun,TmodSN0,TmodSN1,1/TmodSN0,1/TmodSN1,format= $
"('Period of the beam-induced modulation = ',F6.2,' (fmin) ... ',/,F6.2,' (fmax) sec',' (frequency = ',F6.2,' ... ',F6.2,' Hz)',/)"
printf,lun,TneighSN,format=$
"('Interval between passages of neighbouring orders = ',F6.1,' sec',/)"
printf,lun,TPassBeamSN,format= $
"('Duration of passing beam S-N = ',F4.1,' sec',/,/)"


free_lun,lun

flush,lun

if not keyword_set(silent) then xtext,file=Filename,group=group_leader

exit:
parameters={Date:Date, Time:Time, Rec:Receiver, $
A_EW:A_EW, G_EW:G_EW, A_SN:A_SN, G_SN:G_SN, $
BeamEW:RoEW, BeamEWchan:RoEW/SpacingEW, $
SpacingEW:SpacingEW, TmodEW:[TmodEW0,TmodEW1], $
BeamSN:RoSN, BeamSNchan:RoSN/SpacingSN, $
SpacingSN:SpacingSN, TmodSN:[TmodSN0,TmodSN1]}
end