mock brown dwarf idl routines

Last modified: Thu Mar 16 13:07:05 2023.


List of Routines


Routine Descriptions

BDWF_GETSCANINFO - GET SCAN INFO FOR A SET OF FNMI FILES

[Next Routine] [List of Routines]
NAME:
bdwf_getscaninfo - get scan info for a set of fnmI files
SYNTAX: nscans=bdwf_getscaninfo(fnmi,rcvNum,scanIAr,maxDfileScan=maxDfileScan,useposonoff=useposonoff)
ARGS:
fnmI[]:{}  array of fnmI structs to search. This is returned from 
           masgetfilelist()
rcvNum: int  receiver number to use
KEYWORDS:
maxDfileScan: long Limit the maximum data files per scan. If not 
                   supplied, then the program searches for the maximum.
useposonoff    : if set the look for position on,off on scans and use the on..
RETURNS:
 scanIAr[nscans]: {} array holding info on all the scans found 

(See /pkg/rsi/local/libao/phil/bdwf/bdwf_getscaninfo.pro)


BDWF_HRDISPLAYIMAGE - DISPLAY AN IMAGE

[Previous Routine] [Next Routine] [List of Routines]
NAME:
bdwf_hrdisplayimage - display an image
SYNTAX: bdwf_hrmakeimage,savDirNm,savInpNm,yyymmdd,srcToGet,freqChanToAvg,pol,
  			baseline=baseline,gifname=gifname,
           img_tf=img_tf,tmI=tmI,freqI=freqI
ARGS:
savDirNmr  : string directory to read the save file, and where to write
                    the hdr and binary files.
savInpNm   : string name of input save file (without the directory).
yyyymmdd   : long   date. becomes part of output filename
srcToGet   : string srcname. becomes part of output filename
freqChanToAvg:long  number of frequency channels to avg. eg 64,or 128
pol        : int    1..4 (stokes i,q,u,v) make,store image of this pol
KEYWORDS:
baseline:    int    0--> baseline the  image after combining the 7 bands
                    1--> baseline each of the 7 bands separately
                         (this is the default) 
gifname : string    if provided then write the image to a gif file with
                    this  name (in the current directory)
RETURNS:
img_tm[ntm,nfrq]:float  created image
tmI[ntm]     :float   time (counting from 0) for each spectra in the image.
freqI[nfrq]  :float   freq channels for the image (Mhz).
DESCRIPTION:
	1.input the save file created by bdwf_hrmakesavefile.
   2.make a dynamic spectra image for the specified polarization (1..4)
     - combine all 7 frequency channels
     - average, decimate in frequency
     - interpolate to a fixed frequency grid
     - write the binary image and ascii header to two files
	 The output file names will be :

		   binfileNm=savDirNm + srcToGet + "_polN_.bin"
		   hdrfileNm=savDirNm + srcToGet + "_polN_.hdr"

(See /pkg/rsi/local/libao/phil/bdwf/bdwf_hrdisplayimage.pro)


BDWF_HRDOITMOCK - INPUT MOCK FILES,CREATE SAVEFILE

[Previous Routine] [Next Routine] [List of Routines]
NAME:
bdwf_hrdoitmock - input mock files,create savefile
SYNTAX:istat=bdwf_hrdoitmock(hrI,scanIar,savBase,iscanRange=iscanRange,$
             wait=wait)
ARGS:
hrI : {}   struct loaded by bdwf_hrinit()
scanIar[]:{} returned by getscaninfo(). contain info on data scans
             for the flare. normally it will have 1 entry.
             If the flare spans multiple scans,then all the scans 
             should be included here.
             we want to process
savBase  : string base name for save file. It will be 
             used by this routine to generate hrI.savFileNm
             contains: "srcToGet_yyyymmdd_scanInStrip"
             this routine then adds _0,_1 if more than one
             scan.(i think it is always 1 scan).
KEYWORDS:
iscanRange[2]:long If scanIar[] has more than one entry, then 
                   this you can use this to limit the entries
                  of scanIar[] to use . holds, first,last index
                  to use (count form 0). Or you could just
                  limit scanIar[] to the files you want.
wait         : int  if not zero then wait after displaying image

RETURNS:
hrI.savFileNm: string is loaded with the name of the save file.
               the following data is saved in hrI.savFileNm:
 		  save,tpAr,freqAr,rmsMask,jdAr,azAr,zaAr,scanI,sclGain,boutSave
DESCRIPTION:
	Read in the mock fits files for the filenum of interest (all 7 bands).
If hrI.avgrow =1 then average all the spectra in each row (usually)
ends up giving .9 sec resolution). If hrI.avgrow=0 then keep the 
.1 sec time resolution.
	calibrate all of the spectra using masstokes (bpc,cal,gain)
	Use masrms to compute an rms by channel. This will later be
used to exclude frequency channels when averaging over freq.
	Then display an image of stokes V
   Also display the rms by channel that was computed
	Compute the total power for each 170 Mhz band (using
the rms computed above to exclude rfi.)
  save the computed info in the save file

(See /pkg/rsi/local/libao/phil/bdwf/bdwf_hrdoitmock.pro)


BDWF_HRINIT - INITIALIZE FOR HIGH RES RUN

[Previous Routine] [Next Routine] [List of Routines]
NAME:
bdwf_hrinit - initialize for high res run
SYNTAX:bdwf_hrinit,avgrow,yyyymmdd,rcvnum,srcToGet,proj,fileNumDat,$
			savFileDir,hrI
ARGS:
  avgRow: int    1-->average spectra in row. gives .9 sec resolution
                 0-->do not avg spectra in row. gives .1 sec resolution
yyyymmdd:long    date for file
rcvNum  :long    rcvr number (5=lbw, 7=sbw,8=sbh,9=cb,10=cbh,11=xb)
srcToGet:string  srcname (in file header)
proj    :string  project id (in filename)
fileNumDat:int   file number for data (in file to process)
                 (this is the data number, not the cal number)
savDirNm:string  directory that holds save files (and 
                 created binary files).

RETURNS:
   hrI :   struct containing above info;
DESCRIPTION:
	Call bdwf_hrinit to load the hrI struct with parameters for this run.
On return the hrI struct will contain:

This struct is then passed to the other bdwf_hr routines for processing.

(See /pkg/rsi/local/libao/phil/bdwf/bdwf_hrinit.pro)


BDWF_HRMAKEBIN - MAKE BINARY IMAGE FILE

[Previous Routine] [Next Routine] [List of Routines]
NAME:
bdwf_hrmakebin - make binary image file
SYNTAX: bdwf_hrmakebin,hrI,freqI,img_tf,pol,baseline,fnamePre
ARGS:
hri        :{}       struct holing info. 
freqI[m]   : float   frequency for each channel of image
img_tf[n,m]: float   n=#tmsteps,m=#freq bins. image to store
pol        : int      1..4 which pol (i,q,u,v)
baseline   : int     how the 7 (170 Mhz) bands were baselined
                     0= all bands at once together
                     1= each band was baselined separately
fnamePre   : string  prefix for filnames

DESCRIPTION:
	write dynamic spectra for a single polarization to a binary file.
Also output an ascii header file
Example:
	pol=4 ; stokesV 
   baseline=0
   fnamePre="TVLM513_20140523"

   freqI,img_tf will come from the call to bdwf_hrsmointerpscan.

   bdwf_hrmakebin,hri,freqI,img_tf,pol,baseline,fnamePre

	will generate the files:
  TVLM513_20140523_pol4.bin
  TVLM513_20140523_pol4.hdr
  in the hrI.savDirNm  directory

(See /pkg/rsi/local/libao/phil/bdwf/bdwf_hrmakebin.pro)


BDWF_HRMAKEIMAGE - MAKE IMAGE, OUTPUT TO BIN FILE AND ASCII HDR

[Previous Routine] [Next Routine] [List of Routines]
NAME:
bdwf_hrmakeimage - make image, output to bin file and ascii hdr
SYNTAX: bdwf_hrmakeimage,savDirNm,savInpNm,yyymmdd,srcToGet,freqChanToAvg,pol,
  			baseline=baseline,
           img_tf=img_tf,tmI=tmI,freqI=freqI
ARGS:
savDirNmr  : string directory to read the save file, and where to write
                    the hdr and binary files.
savInpNm   : string name of input save file (without the directory).
yyyymmdd   : long   date. becomes part of output filename
srcToGet   : string srcname. becomes part of output filename
freqChanToAvg:long  number of frequency channels to avg. eg 64,or 128
pol        : int    1..4 (stokes i,q,u,v) make,store image of this pol
KEYWORDS:
baseline:    int    0--> baseline the  image after combining the 7 bands
                    1--> baseline each of the 7 bands separately
                         (this is the default) 
RETURNS:
img_tm[ntm,nfrq]:float  created image
tmI[ntm]     :float   time (counting from 0) for each spectra in the image.
freqI[nfrq]  :float   freq channels for the image (Mhz).
DESCRIPTION:
	1.input the save file created by bdwf_hrmakesavefile.
   2.make a dynamic spectra image for the specified polarization (1..4)
     - combine all 7 frequency channels
     - average, decimate in frequency
     - interpolate to a fixed frequency grid
     - write the binary image and ascii header to two files
	 The output file names will be :

		   binfileNm=savDirNm + srcToGet + "_polN_.bin"
		   hdrfileNm=savDirNm + srcToGet + "_polN_.hdr"

(See /pkg/rsi/local/libao/phil/bdwf/bdwf_hrmakeimage.pro)


BDWF_HRMAKESAVEFILE - MAKE HIRES SAVE FILE

[Previous Routine] [Next Routine] [List of Routines]
NAME:
bdwf_hrmakesavefile - make hires save file
SYNTAX:istat=bdwf_hrmakesavefile(hrI,hdcopytp=hdcopytp)
ARGS:
hrI : {}  struct initialized by bdef_hrinit();
keywords: 
 hdrcopytp: int if set then make total power hardcopy
                (calling bdwf_hrplottp
RETURNS:
istat: int 0 ok, -1 we had an error processing the
             requested data (files not there?)
hrI : {}  some of the elements in this structure
          get loaded:
          hrI.nsavfiles, hrI.savFileNms[], hrI.pntsEachScan

DESCRPTION:
	The user first calls bdwf_hrinit(..) to initialize hrI
structure with the scan to process. This routine then
searches for the mock datafiles, inputs them,calibrates
the data, optionally averages over the spectra in 1 row 
(giving .9 sec resolution vs .1 sec resolution),
 computes the rms by freq channel, computes the total
power for each mock band, and then stores all of this
info in a save file.
	This save file is later used by the other bdwf_xxx routines
to create the binary image file, and display the spectra.
 do hires processing for a detection
 user must set when the detection occurred.

(See /pkg/rsi/local/libao/phil/bdwf/bdwf_hrmakesavefile.pro)


BDWF_HRSMOINTERPSCAN - SMOOTH AND INTERPOLATE IMAGE

[Previous Routine] [List of Routines]
NAME:
bdwf_hrsmointerpscan - smooth and interpolate image
SYNTAX:  istat=bdwf_hrsmointerpscan(savFileInp,freqChanToAvg,
               tmI,freqI,img_tf,$
		       median=median,baseline=baseline,zx=zx,zy=zy,$
		       nsigclip=nsigclip,pol=pol)
ARGS  : 
savFileInp: string name of save file holding outputof doitmockhr()
freqChanToAvg: long number of frequency channels to avg.
               probably best if divides into total number of
               channels (8192)
KEYWORDS:
	pol: int	polarization to use. 1-4
               1-stokesI, 2=stokesQ,3=stokesU,4=stokesV
               default is stokes V.
 median:       if keyword set (/median) then use median rather than
               mean when averaging freq channels
 baseline:     if set then for each band:
                  -compute median frequency for band and subtract
                   it frome each spectra.
               If not set, then  remove the median of all spectra in 
               band.
 zx:    int    scale img display in x direction (-2 is 1/2 ,
               +2 is twice the width"
 zy:    int    scale img display in y direction
 nsigclip: float clip image to Nsig . def=3.
RETURNS:
	istat: int  1 ok, -1 error
     tmI[nt]: float   values for the time axis. unit = secs.
   freqI[nf]: float   value for the interpolated freq axis. unit=Mhz.
   img_tf[nt,nf]:float image with x axis=time
   
DESCRIPTION:
	Create an image of the calibrated stokes data. The routine does:
 - input the save file created from doitmockhr(). This contains the
   calibrated full frequency resolution data of the 7 bands.
 - smooth, decimate each of the 7 bands by freqChanToAvg
 - combine the 7 decimated bands into 1 image
   - make sure each band is in increasing freq order
   - interpolate the data to a fixed frequency grid.
 - return the image in img_tf (time is x axis),
    as well as the tm and freqI keywords.

(See /pkg/rsi/local/libao/phil/bdwf/bdwf_hrsmointerpscan.pro)