3.  Bragg Crystal Spectrometer (BCS)

3.1  Routines for Data Selection

3.1.1 LIST_BDA

A sample call would be:
IDL >  list_bda, roadmap, start, nrec, ss=ss
where roadmap is the input.

3.1.2 SELECT_BDA

Use SELECT_BDA to plot the roadmap light curve of a selected channel and select the time period of interest using the cursors. (Note: there is an option to read the data in with SELECT_BDA if required). A sample call would be:


IDL >  .run select_bda
where roadmap is the input.

3.2  Routines for Making Time Plots

3.2.1 BCS_24HR_PLOT

If you interested only in whether the BCS has seen anything, use BCS_24HR_PLOT. This works using only roadmap data and allows intervals to de selected by date (all files covering this data are then used). By default, channel 3 (Ca XIX) is plotted. Note: YODAT does NOT need to have been run before BCS_24HR_PLOT. In its default mode, BCS_24HR_PLOT uses the observing log files. Samples are:
IDL >  bcs_24hr_plot, '15-nov-91'

IDL >  bcs_24hr_plot, '15-nov-91', chan=4

3.2.2 PLOTT_BDA

PLOTT_BDA will make a light curve plot using either the index or roadmap. The second `T' signifies that it is a time plotting routine. Four plots are made on the page, one for each channel. Some sample calls are:
IDL >  plott_bda, index

IDL >  plott_bda, roadmap

IDL >  plott_bda, roadmap(100:200), psym=10

3.2.3 LCBDA [*]

LCBDA will make a light curve plot using either the index or roadmap. It is almost identical to PLOTT_BDA except that you can specify a channel and only get that channel plotted. Some sample calls are:
IDL >  lcbda, index

IDL >  lcbda, roadmap, chan=1

3.3  Routines for Making Spectral Plots

3.3.1 PLOTS_BDA

PLOTS_BDA allows for the spectra for all four channels to be plotted to one page. A sample calling sequence is:
IDL >  plots_bda, index, data

3.3.2 PLOTBDA

The light curve and spectra from the BDA file may be plotted using PLOTBDA. This is an interactive program and it will read its own data.
IDL >  .run plotbda

3.3.3 BCS_MULTI

Many spectra may be plotted on a page with BCS_MULTI.
IDL >  bcs_multi, index, data

IDL >  bcs_multi, index, data, chan=1

3.3.4 BCS_CONT

The evolution of spectra against time can be displayed as a contour map using the routine BCS_CONT. Note: The time axis of BCS_CONT is uniform, but those of DISP_BDA and GS are not.
IDL >  bcs_cont, index, data

IDL >  bcs_cont, index, data, chan=1

3.4  Routines for 2-D Spectral Display

3.4.1 DISP_BDA

The evolution of spectra against time can be displayed as a pseudo-image using the routine DISP_BDA. Note: The time axis of DISP_BDA is not uniform.
IDL >  disp_bda, index, data

3.4.2 BCS_SPMOVIE

After selecting a time interval, a movie of the changing spectra for a given channel may be displayed by BCS_SPMOVIE. Note: This program will only run on an X-windows workstation.
IDL >  bcs_spmovie, index, data

IDL >  bcs_spmovie, index, data, chan=1

3.4.3 GS [*]

If you are interested in more detail of what spectra the BCS has observed, use GS - this routine must be run after the data has been read in with YODAT. There is an upper limit on how much data can be handled at a time (about 900 spectra), and some selection of the required time interval may be needed using the methods described above, but for the per-orbit files, this limit may not be a problem. The advantage of GS is that you can get a good idea of what has been seen in the spectra - a particularly useful tool if you are trawling for data. Warning: The time axis on the greyscale plot is not uniform!
IDL >  .run gs
All the routines that run from GS require that spectra be selected first using the cursor routine.
IDL >  .run gs_cur

3.5  Routines for Data and Information Extraction

3.5.1 EXT_BCSCHAN

The spectra for a single channel may be extracted with EXT_BCSCHAN
IDL >  data_out = ext_bcschan(index, data, chan)

3.5.2 LIST_BDA

If you are interested in what modes the BCS was executing, or what the count rate in a particular channel has observed at a particular time, this can be determined by using LIST_BDA. By default the count rate for channel 3 (Ca XIX) is given in the listing. Sample calls are:
IDL >  list_bda, roadmap, start, nrec

IDL >  list_bda, roadmap, start, nrec, chan=4
where roadmap is the input.

3.5.3 GT_TOTAL_CNTS

GT_TOTAL_CNTS extracts the information from the TOTAL_CNTS field which used the actual spectra to calculate the total number of counts. The routine also normalizes so that it returns counts/sec. In the first example below, all four channels are returned, so the output is 4xN. In the second example, only channel 1 is extracted. It is possible to get a string defining the channel selected by using the title keyword option.
IDL >  x = gt_total_cnts(roadmap)

IDL >  x = gt_total_cnts(roadmap,1)

IDL >  x = gt_total_cnts(index,2,title=title)

3.5.4 GT_BLOCKID

GT_BLOCKID returns information on how the BCS data were blocked.
IDL >  x = gt_blockid(roadmap)
0 Normal Queue Data Block
1 Fast Queue Data Block
2 Micro Dump Block (fixed extraction)
3 Cal Data Block (fixed extraction)
4 Queue data where the modeID in the header is not recognized
5 Normal or fast queue data which have fill data (garbage)

3.6  Routines for Calibration and Analysis

3.6.1 BCS_DECOMP

The BCS data are normally compressed from a 12-bit word to an 8-bit word. BCS_DECOMP takes the compressed data array (data) and creates a floating point array (ndat) of the decompressed numbers by typing:
IDL >  ndat = bcs_decomp(data)

3.6.2 BCS_NORM

BCS_NORM normalizes data recorded by the BCS for integration time, and extracts the Fast Queue data if present. A sample call is:
IDL >  dspec = bcs_norm(index, data)

3.6.3 SUM_BDA

All spectra with mode ID modeid will be summed by SUM_BDA with the following command:
IDL >  data_out = sum_bda(index, data, modeid, nsum)

3.6.4 PLOT_REF [*]

Overplot several spectra to show evolution of blue wing and line width.
IDL >  plot_ref, index, data, channel, dset_arr

3.6.5 BCS_DTFAC

The dead-time correction factors can be calculated with BCS_DTFAC:
IDL >  dd = bcs_dtfac(index,dp_sync,type,stime,etime)

3.6.6 BCS_POINT

The position of a source on the solar disk may be determined from the bin number of the resonance line with BCS_POINT. If the epoch is provided, this routine will also return the heliocentric latitude:
IDL >  dd = bcs_point(wbin [,chan=n [,date=date, etc.]])

3.6.7 BCS_SYNTHETIC

BCS_SYNTHETIC is a simple main program to compute BCS synthetic spectra in flux units. The program will prompt the user for the BCS channel number (1,2,3,4 = Fe XXVI, Fe XXV, Ca XIX, S XV), the electron temperature (MK) and the Doppler temperature (MK). To run the program type:
IDL >  .run bcs_synthetic
The program calls the procedure BCS_SPEC to perform the spectral calculations. It defaults to a wavelength coverage which is appropriate for mid-latitude observations. The BCS_SPEC defaults for atomic code, ionization balance and abundance will be used. The computation is made for an emission measure of EM = 1050 cm-3.

3.6.8 BCS_SPEC

BCS_SPEC is a procedure to compute a BCS synthetic spectrum in flux units. Sample calling sequences are:
IDL >  flux = bcs_spec(Chan,Te6) ; Use Td6=Te6 and default wavelengths

IDL >  flux = bcs_spec(Chan,Te6,Td6,Wave,Waveo=Waveo,Ainfo=Ainfo,Vel=Vel)
where the inputs are Chan (the BCS channel number of a BSC structure), Te6 and Td6 (electron and ``Doppler'' temperatures in MK), and Wave is a vector of the edges of the BCS wavelength bins. Returned will be flux (assuming EM = 1050 cm-3), Waveo (wavelengths at the centers of the bins), and Ainfo (a structure variable containing information about the calculated spectrum). Vel is an optional input keyword to specify the bulk velocity in km/s. More information is available in the documentation header. BCS_SPEC is called by BCS_SYNTHETIC and FIT_BSC.

Three routines control the defaults for the atomic data used in the calculation. These are GET_ELEMABUN (abundances), GET_IONBAL (ionization balance) and GET_ATOMIC (the atomic data for the line calculation).

3.7  BSC Routines

3.7.1 HELP_BSC

To get quick on-line help for various BSC procedures and functions, type:
IDL >  help_bsc

3.7.2 MK_BSC

MK_BSC makes BSC_INDEX and BSC_DATA structures from the BDA INDEX and DATA. These structures contain instrumentally corrected BCS data for selected channels and accumulation times. A typical run would look like:
IDL >  mk_bsc,index,data,bsc_index,bsc_data,dp_sync=dp_sync
To analyze BCS data, you would begin by using YODAT to read the BDA data file for the dates and times you are interested in. Yodat will return a BDA index structure INDEX, a BDA data array DATA, and a structure DP_SYNC which contains the DP synchronous data needed for deadtime corrections.

MK_BSC will prompt for various inputs such as start and stop times, channels to process, integration times, and which corrections (deadtime, crystal curvature, flux calibration) to apply. The DP_SYNC keyword is optional, but must be entered the first time if deadtime corrections are required. Subsequent calls to MK_BSC will use the last values of DP_SYNC data passed via this keyword.

The following keywords are also accepted:

/LAST - run using the information stored in the latest BSC_INDEX.
/DEF - run using the default settings.
/WID - run via a widget interface.
/BSA - run to make BSA index only (do not make BSC_DATA).
/SAVE - save BSC (or BSA) index (and data) in a file.
(The file will be named BSCyymmdd.hhmm, based on the time of the
first data interval).
/VERBOSE - echo extra information about SAA/NIGHT or MODEID/BLOCKID
BDAFILE - input BDAFILE to read.

The instrumentally corrected data will be output to a new set of structures BSC_INDEX and BSC_DATA. The data in BSC_DATA are stored as 256 element floating point arrays in fields with the following definitions:

.COUNTS - accumulated counts (per detector bin)
.BIN - physical detector position
.ERROR - spectral uncertainties (in counts)
.WAVE - nominal wavelength array (Å)
.FLUX - flux-calibrated data (ph cm-2 s-1 Å-1)
.WAVE_FIT - wavelength array for the fitted spectra (Å)
.FLUX_FIT - fitted spectra

Not all the above fields will be present. The fields that are present will depend on the corrections requested in MK_BSC. The actual data in each field array will occupy the first 0:NBINS-1 locations, where NBINS is the number of actual detector bins containing valid data. The value of NBINS is stored in BSC_INDEX.BSC.NBINS.

3.7.3 SEL_BSC

SEL_BSC extracts wavelength and flux fields from BSC_DATA.
IDL >  sel_bsc,bsc_index,bsc_data,new_index,new_data,wave,flux,eflux
The selected index and data structures are returned in NEW_INDEX and NEW_DATA. The wavelength, flux, and uncertainties in the flux are returned in the arrays WAVE, FLUX, and EFLUX.

The following keywords are also accepted:

CHAN (in) - BCS channel (def is all)
TSTART (in) - start time to extract (UTPLOT format)
TEND (in) - end time to extract
BIN (out) - Physical detector positions
COUNTS (out) - observed counts (per bin) in the accumulation interval
SS (out) - indices matching requested channel
FWAVE (out) - fitted wavelength array
FIT (out) - fitted spectrum array
SFIT (out) - fitted second component array

3.7.4 LIST_BSC

LIST_BSC lists times, total counts, and accumulation times of BSC spectra.
IDL >  list_bsc,bsc_index,chan
where CHAN is the desired channel to list.

3.7.5 SAV_BSC

To save BSC index and data to a BSC file, use:
IDL >  sav_bsc,'bsc_file_name',bsc_index,bsc_data
Note that MK_BSC will also save the data if the /FILE switch is set.

3.7.6 RD_BSC

To read a BSC file, use:
IDL >  rd_bsc,'bsc_file_name',ss,bsc_index,bsc_data
This procedure will return the BSC index and data structures. SS is a vector with indices of a particular subset of data within the BSC file. For example, using SS=INDGEN(10) will extract the first 10 data sets from the BSC file. To extract ALL the data sets, use SS = -1.

3.7.7 BSC2BSD

To convert a BSC file to a BSD file, use:
IDL >  bsc2bsd,'bsc_file_name','bsd_file_name'
The BSD file name is optional, and will be created from the BSC file name if not supplied.

3.7.8 MAP_BSC

MAP_BSC plots a pseudo-map of BSC spectra by stacking successive spectra.
IDL >  map_bsc,bsc_index,bsc_data
The following keywords are accepted:

CHAN BCS channel to plot.
XSPACE the value by which to shift successive spectra in the x-direction.
[def=0]
YSPACE the value by which to shift successive spectra in the y-direction.
[def=0]
TSTART the time of the first spectrum to plot (with date optional).
[sample format,TSTART='9:32', def = first spectrum in BSC_DATA]
TEND the time of the last spectrum to plot.
[def = last spectrum in BSC_DATA]

3.7.9 LC_BSC

LC_BSC plots light curves of selected spectral regions.
IDL >  lc_bsc, bsc_index, bsc_data, t, y, chan=chan,/flux
This program first plots a spectrum at the peak of the flare. The user can select a spectral region with the cursor. The light curve derived from the sum of wavelength points within this region is returned in the array Y. The time (UT) is returned in T. If the BSC data are flux calibrated, then using the FLUX keyword will return the light curve in units of photons cm-2 s-1. The optional keyword over will overplot successive light curves.

3.7.10 WBDA

WBDA provides a simple widget interface that allows browsing of BDA files. It is invoked by:
IDL >  wbda
The program will provide a set of menus from which BDA files can be selected either by date, filename, or directory location. WBDA will plot light curves and spectra for a specific channel, accumulate spectra for selected integration times, and apply dead-time, curvature, and flux corrections. The BDA INDEX and DATA variables produced by YODAT can be also input directly to WBDA:
IDL >  wbda,index,data

3.7.11 GT_BSC_BINCAL

This function returns a structure containing miscellaneous calibration information for specified BCS channels: For example, for channel 1,
IDL >  bincal=gt_bsc_bincal(1)
will return the following structure:

.CHAN - channel number
.NBINS - number of bins per channel
.MODEID - mode id
.WAVE - nominal wavelength array (Å)
.PHYSPOS - physical detector position array
.FLUXFAC - conversion factor array for counts/bin to photons/cm/Å
.SENSIT - mean sensitivity array for grouped bins
.DBIN - detector bin width
.W0 - start wavelength of spectrum
.DW - dispersion (angstrom/bin)
.BINARC - conversion factor for arcmin to bin (bins/arcmin)
.GAUSSW - FWHM Gaussian detector width (Å)
.RWID - FWHM rocking width (Å)
.EFAREA - effective area (cm2)
.NSTART - first valid bin
.NEND - last valid bin
.VERSION - version number of BCS calibration file used

3.7.12 FIT_BSC

FIT_BSC fits synthetic spectra to observed spectra in BSC_DATA:
IDL >  fit_bsc,bsc_index,bsc_data,fit_index,fit_data,chan=chan
In the above call, the fitted results are returned in the new structures FIT_INDEX and FIT_DATA for the channel specified by the keyword CHAN. If CHAN is not specified, then all channels will be fit (not recommended).

The FIT_DATA structure contains two additional fields:

.FLUX_FIT a 256-element floating point array containing the fitted model spectrum matching the observed spectrum in the .FLUX field
.WAVE_FIT a 256-element floating point array containing computed wavelengths of the fitted model spectrum in .FLUX_FIT.
.FLUX_FIT2 a 256-element floating point array containing the fitted model spectrum corresponding to a secondary velocity shifted spectrum in the .FLUX field

The FIT_INDEX structure contains an additional .FIT field that contains important fit information (parameters fit, number of iterations, chi squared, etc).

FIT_BSC accepts the following optional keywords:

SS index selection vector or scalar (e.g. SS=[45,46] to fit only spectra 45 and 46)
TSTART UT string (e.g. '9:45'). Only spectra at or after TSTART will be fit.
TEND Only spectra at or before TEND will be fit.
LRANGE 2-element wavelength vector range (Å) within which to limit line fitting [Default is entire range]
CRANGE 2-element wavelength vector range (Å) within which to limit continuum fitting [Default is entire range]
TE6 input starting guess for electron temperature (MK)   [Default is to use internal values]
TD6 input starting guess for resonance line Doppler broadening (MK) [Default is to infer from observed width]

ATTEMPT level of fit attempt
  1. solve only for primary emission measure (EM50) and line to continuum normalization factor (CNORM). Electron temperature and (TE6) and total Doppler broadening (TD6) fixed.
  2. solve for TE6, TD6, EM50, CNORM.
  3. solve for primary+secondary shifted component.
/BLUE equivalent to attempt=3
/NEWGUES set to NOT use results of previous fit as starting input for fit to next spectrum
/PLOT set to plot progress of fits
/VERB set for more information about fitting progress
/LAST set to use last converged parameters as starting guess for fitting next spectrum.

For example, to fit a Ca XIX spectrum at UT='09:04' use:
IDL >  fit_bsc,index,data,findex,fdata,chan=3,tstart='09:04'
To fit a blueshifted secondary component:
IDL >  fit_bsc,index,data,findex,fdata,chan=3,tstart='09:04',/blue

3.7.13 BCS_BROAD

The relation between BCS line broadening and velocity can be computed with BCS_BROAD. Some example calling sequences are:
; Return temperature in (MK)

; Return velocity (km/s)

; Return Doppler FWHM (Ang)
where TD6 is the equivalent Doppler Temperature (MK) and CHAN is the BCS channel number. The parameter TDOPPW does not include the contribution due to the crystal (Lorentz) broadening, but is included by BCS_BROAD when it makes its calculations, based on the value of CHAN. There are several additional options available and there is a keyword to return the crystal rocking curve width. Most conversions between BCS line width and velocity or between line width and temperature can probably be accomplished using this routine.

3.7.14 PLOT_BSC

The results of MK_BSC and FIT_BSC can be examined with PLOT_BSC.
IDL >  plot_bsc,bsc_index,bsc_data
PLOT_BSC will plot light curves and spectra for user selected channels and times, as well as fitted spectra from FIT_BSC.

Optional keywords:

CHAN - channel to plot
SS - selected indicies of spectra to plot (default is all)
/NOWID - to not use widget mode (def is widgets, if more than 1 spectrum)

The following keywords apply only when /NOWID is set:

/EBAR - oplot spectral uncertainties
/HC - make a hard copy (single spectrum only)
/PS - make a PostScript file (single spectrum)

The following keywords apply only when /NOWID is set, and BSC_INDEX and DATA contain fitted spectra:

/BLUE - to oplot second blueshift component (if fitted by FIT_BSC)
/VUNIT - to print fitted Doppler widths in km/s units (default is MK)
/NOFIT - inhibit oplot of fitted spectra (default is oplot fit)
/NOOBS - inhibit plot of observed spectra (default is plot obs)

3.7.15 FIT_BSC_PLOT

FIT_BSC_PLOT produces time series plot results from FIT_BSC. The routine will plot total counts, electron temperature, emission measure, and turbulent velocity as a function of time. Example calling statements are:
IDL >  fit_bsc_plot,bsc_index

IDL >  fit_bsc_plot,bsc_index,tstart=tstart

; Produce hardcopy output
Consult the document header for additional options.

3.7.16 MK_FIT_BSC_EPS

MK_FIT_BSC_EPS will produce a BCS spectrum in portrait mode. It optionally will specify the output file to be an EPS (encapsulated PostScript file). Some sample calls are given below:
; Send plot to the printer

; Make file but don't print

; Create an EPS file

; Suppress atomic code label
MK_FIT_BSC_EPS sets up the parameters to call BCS_SPEC_PLOT correctly.

The default X and Y size is about right for an A4 page. The optional xoffs=xoffs and yoffs=yoffs enable the user to position the plot at the desired location on the page.