pro spectrum_flag ;read the fits file into an array of IDL structures. You can replace this file name with ;any of the Greenbank sdfits files. arr=mrdfits('1422_200MHz.raw.acs.fits',1,header) ;get the number of rows in this array dims = size(arr, /dimensions) numRows = dims[0] ; number of rows (spectra) ;get the number of channels. channels=size(arr[0].data,/n_elements) ;define an array that will hold all the spectra of one Stokes parameter ;since there are 4 Stokes and each integration has a calon and caloff, we ;must skip 8 rows each time (see loop below). image=fltarr(channels,numRows/8.) ;here we are fitting a 10th order polynomial to the first spectrum, normalizing it, ;then dividing each spectrum by this to flatten it (called bandpass calibration). ;looks like we may need to go hire than 10th order. I'll keep it commented out for now. ;x=findgen(4096) ;a fake channel axis just for doing the fit ;spec=arr[0].data ;getting the first spectra in the array ;fit=polyfit(x,spec,10) ;fitting a 10th order polynomial to the data ;creating a baseline vecter and normalizing it ;baseline=fit[0]+fit[1]*x+fit[2]*(x)^2+fit[3]*(x)^3+fit[4]*(x)^4+fit[5]*(x)^5+fit[6]*(x)^6+fit[7]*(x)^7+fit[8]*(x)^8+fit[9]*(x)^9+fit[10]*(x)^10 ;basen=baseline/max(baseline) ;looping through very 8th spectrum and putting it into a row of the array 'image'. Once we add in the baseline calibration ;we will divide by 'basen' from the above polynomial fit. for i=0,numRows-8,8 do begin image[*,i/8.]=arr[i].data endfor ;Here we write the image into a fits file and open it with my program 'fitsview.pro', which is a very basic GUI for looking at ;fits files. writefits, 'spectral_flag_baseline.fits',image fitsview,'spectral_flag_baseline.fits' end