'subroutine to read x12 spectrum data file and plot the spectrum
'version 4
'last checked and revised 9/20/2000 h
'
'fname = string containing path/file name of data
'gname = name for graph to plot spectrum
'freq = seasonal frequency (4 for quarterly and 12 for monthly)

subroutine sub_readX12Spectrum(string %fname, string %gname, scalar freq)

'read spectrum of original series from {%fname}
matrix(61,2) x_sp0
x_sp0.read(d=t,mult,rect,skiprow=2,skipcol=1) "{%fname}"

'plot spectrum
freeze({%gname}) x_sp0.line
{%gname}.type xy

'show seasonal frequencies
if (freq=12) then
	for !i=1 to 5
		!dbl = !i/12
		{%gname}.draw(dashline,bottom) !dbl
	next
else			'freq=4
	{%gname}.draw(dashline,bottom) 0.25
endif

'show trading day freqs
if (freq=12) then
	{%gname}.draw(dashline,bottom,rgb(255,0,0)) 0.348199993371964
	{%gname}.draw(dashline,bottom,rgb(255,0,0)) 0.432000011205673
else			'freq=4
	{%gname}.draw(dashline,bottom,rgb(255,0,0)) 0.0445999987423420
	{%gname}.draw(dashline,bottom,rgb(255,0,0)) 0.0892999991774559
endif


{%gname}.scale(bottom) range(minmax)
{%gname}.elem(1) legend("frequency")
{%gname}.elem(2) legend("-10*log(spectrum)")

'show {%gname}

endsub

