imspec [1] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 this is the main event handler, which handles all but time-selection
 events. (For technical reasons, these are treated in "time_setps.pro")
 CALLS:


imspec [2] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 handles forward/backward time stepping events
 CALLS:


imspec [3] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 handles movie events. Uses program-driven events (interrupts) in conjecture
 with a logical flip-flop constructed from two flags: "movie_flag" and
 "movie_killed", which are stored in the event.top data structure (because
 the program-driven events can not carry user values). The possible state
 of [movie_flag,movie_killed] are [0,0] (initial), [1,0] (running),
 [1,1] (running, to be killed by next intrerrupt) and [0,1] (killed).
 CALLS:


imspec [4] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 user instructions - needs the file `imspec_help.txt'
 CALLS:


imspec [5] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 least-square fit to a straight line in either linlog or loglog coorinates
 of the energy spectrum S(E).
 CALLS:


imspec [6] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 follow a closed contour F=F(x0,y0). Follows the array
 boundary,if hit.
 INPUT:	F = fltarr(Nx,Ny), x0,y0 = float
 OUTPUT:	x_,y_ = fltarr(N_steps)
 CALLS:


imspec [7] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 defines the (closed) boundary of a simply connected region in which
 the average spectrum is determined. The boundary is defined in terms
 of its x/y coordinates. (x1,y1,x2,y2) and (x_r,y_r) are in device
 coordinates. A minimum size of 8 arc sec is required.
 CALLS:


imspec [8] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 draws and annotates a selected region
 CALLS:


imspec [9] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 redraws region boxes, spectra and spectral and fits
 CALLS:


imspec [10] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 gets the identities of all spectrum widgets [id1,id2,...] and
 returns -1 if no valid spectrum widget is found. The spectrum
 widgets must be childs of event.top.
 CALLS:


imspec [11] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 gets the identity of the spectral evolution widget, which must
 be a child of "event.top". Returns -1 if no evolution widget exists.


evol_id	= -1
next_spec = widget_info(event.top,find_by_uname='evol')
if next_spec ne 0 then evol_id = next_spec
end



pro get_lightcurve_w, event,lightcurve_id

+
 gets the identity of the lightcurve widget, which must
 be a child of "event.top". Returns -1 if no evolution widget exists.


lightcurve_id	= -1
next_spec = widget_info(event.top,find_by_uname='lightcurve')
if next_spec ne 0 then lightcurve_id = next_spec
end



pro mk_lightcurve_w,event

+
 creates a new lightcurve widget
 CALLS:


imspec [12] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 PURPOSE: Extracts the lightcurves of all selected regions.
 INPUT: a valid event rooting to the main (base) widget.
 OUTPUT: lightcurves = array of structures, each with tags
  	source label and intensity (total counts, all energies).
 CALLS:


imspec [13] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 shows the time light curves of the selected regions
 CALLS:


imspec [14] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 Creates a PS file of image and spectra
 CALLS:


imspec [15] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 creates IDL SAVE file with spectrum data - see file for an explantion.
 CALLS:


imspec [16] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 prints the fit results into an ASCII file - see file for an explantion.
 CALLS:


imspec [17] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 Reads a HESSI fits file with an image cube of format [N_x,N_y,N_E,N_t],
 as provided by Kim.
 CALLS:


imspec [18] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 creates 3 filter curves, from which the (r,g,b) components
 of the true color image are computed.


N_E	= n_elements(E)

S	= total(total(im,1),1)		; S=fltarr(N_E) ...... 	spectrum, integrated over the
					; 			whole image at the actual time.
if N_E eq 3 then begin

 rfilter = [1,0,0]
 gfilter = [0,1,0]
 bfilter = [0,0,1]

endif

if N_E gt 3 then begin

 i	= 0				; divide S into three parts of equal counts
 while (total(S[0:i]) le 0.333*total(S)) do i = i+1
 i_rg	= i>1
 while (total(S[0:i]) le 0.666*total(S)) do i = i+1
 i_gb	= (i>i_rg+1)<(N_E-2)

 rfilter	= fltarr(N_E) & rfilter[0:i_rg] = 1.
 gfilter	= fltarr(N_E) & gfilter[i_rg+1:i_gb] = 1.
 bfilter	= fltarr(N_E) & bfilter[i_gb:N_E-1] = 1.

endif

rfilter = rfilter/total(rfilter)
gfilter = gfilter/total(gfilter)
bfilter	= bfilter/total(bfilter)

end


pro spec2rgb, im,E,img

+
 PURPOSE: reduces the 3D image cube at fixed time to an RGB image of
 the format bytarr(N_x,N_y,3), where the last index indicates red, green
 and blue components.
 CALLS:


imspec [19] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 defines size/positioning of RGB image draw widget (device coordinates)
 CALLS:


imspec [20] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 defines size/positioning of spectrum draw widget (device coordinates)
 CALLS:


imspec [21] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 defines size/positioning of time evolution draw widget (device coordinates)
 CALLS:


imspec [22] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 creates color image after reading of new fits file
 CALLS:


imspec [23] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 displays and annotates HESSI image on TRUE COLOR device
 CALLS:


imspec [24] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 converts device to physical units
 CALLS:


imspec [25] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 converts device to physical units
 CALLS:


imspec [26] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 converts physical to device units
 CALLS:


imspec [27] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 converts spatial image cube indices to device coordinates
 CALLS:


imspec [28] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 converts spatial image cube indices to device coordinates
 CALLS:


imspec [29] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 extracts spectrum from selected region. Input: (region.x,region.y) = closed
 countour surrounding the selected region
 CALLS:


imspec [30] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 creates and adds a spectrum widget
 CALLS:


imspec [31] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 plots spectrum in selected position box
 CALLS:


imspec [32] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 creates a new time evolution widget
 CALLS:


imspec [33] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 Extracts all available results of spectral fits. Fills in zeros at
 non-computed times.
 INPUT: a valid event rooting to the main (base) widget.
 OUTPUT: fit_results = array of structures, each with tags style
  	(loglog or linlog), source label, and the fitted coefficients
  	coefs = fltarr(2,Nt).
 CALLS:


imspec [34] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 shows the time evolution of the fitted parameters alpha, T, and A.
 CALLS:


imspec [35] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]

 PURPOSE:
   	"imspec" is a widget-based user interface which graphically displays
   	the position-dependent spectrum of HESSI HXR/Gamma ray iamges.
   	The program shows the image in a color code, where hard (soft)
   	spectra correspond to blue (red) colors. The color lookup table is
   	is defined in terms of RGB filters (see subroutine "spec2rgb").
   	Rectangular regions may be selected interactively, and the average spectrum
   	within each reagion is displayed using either linlog or loglog scales,
   	to which interactive curve fits for exponentoals/powerlaws can be made.
	Each region allows for up to two curve fits, such as to represent "broken
	powerlaws" or thermal spectra. The number of selectable regions is unlimited.
	If the image cube contains several time bins, the user is allowed to
	step (or flow) through a movie, and compute the temporal evolution of the
	fitted values such as powerlaw exponents or intensities.

 INPUT: an image cube of the format fltarr(N_x,N_y,N_E) or (N_x,N_y,N_E,N_t).
	The image cube can be obtained (1) from a HESSI style FITS file
	(e.g., 'hsi_imagecube_flare8_12x10.fits'), or from an ad hoc simulation
	(for testing purposes).

 OUTPUT: the primary output devise is the screen, with optional output to a
	PostScript, ASCII and IDL SAVE files.

 SOFTWARE/HARDWARE REQUIREMENTS: the program makes use of several SSW hessi solar soft
	routines, and should be started from the same environment as the usual hessi
	software. The color output is designed for TRUE COLOR devices.

 CALLS: ***
	CONGRID [1], CONGRID [2], CONGRID [3], DEFINE_EV_W, DEFINE_IMG_W, DEFINE_SPEC_W
	DEVICE2IMGCOORD, DEVICE2IMGINDX, DEVICE2SPECCOORD, DRAWBOX, FOLLOW, GET_EVOL
	GET_EVOL_W, GET_LIGHTCURVES, GET_LIGHTCURVE_W, GET_REGION, GET_RGB_FILTERS
	GET_SPEC, GET_SPEC_W, HSI_LOC_FILE, IMGINDX2DEVICE, IMSPEC_EVENT, LINFIT, LOADCT, MEAN
	MK_ASCII, MK_EVOL_W, MK_FIT, MK_IDLSAVE, MK_IMG_CACHE, MK_LIGHTCURVE_W, MK_PS
	MK_SPEC_W, MOVIE [1], MOVIE [2], NORM, PLOT_EVOL, PLOT_LIGHTCURVES, RD_ASCII [1]
	RD_ASCII [2], READ_IMAGE_CUBE_FITS, REDRAW, SHOW_HELP, SHOW_IMG, SHOW_SPEC, SPEC2RGB
	SPECCOORD2DEVICE, TIME_STEPS, UTPLOT [1], UTPLOT [2], UTPLOT [3], UTPLOT [4]
	UTPLOT [5], UTPLOT [6], XALIVE, XMANAGER, anytim [1], anytim [2], anytim [3]
	anytim [4], anytim [5], hsi_image_fitsread
 SIDE EFFECTS:
   	"imspec" starts its own Xmanager, which might interfer with pre-existing Xmanagers
	and the HESSI GUI when ruinning in the same session. The "decomposed" keyword
	(transiently) set to commode with WIN devices.

 HISTORY:
   -written for simulated data by KA, Summer 2001.
   -Adapted for real data, March/April 2002.
   -New functionality added on behalf of Brian Dennis: broken powerlaw fits,
    	movie capability, KA, April/Mai, 2002.
   -Added IDL SAVE output, and general debugging, KA, June 2002.
   -Improved drawing graphics (PixMap buffer instead of XOR mode) and more general
	integration domains (rectangles, ellipses, simply connected iso-intensity contours)
	added, KA, August 2002.
   -Color (RGB) table improved, KA, Sept. 2002.
   -Catching up single energy band case, KA, October 2002.


imspec [36] $SSW/hessi/idl/image_spec/imspec.pro
[Previous] [Next]
 Creates main level widget and starts xmanager
 CALLS:


Insert Lookup Table Entry $SSW/hessi/offline/hsi_lookuptableinsertentry.pro
[Previous] [Next]
 PROJECT:
      HESSI
 NAME: 
      Insert Lookup Table Entry

 PURPOSE:
      Inserts information about a single packet into the packet lookup table

 CATEGORY:
      Utilities (hessi/util)

 CALLING SEQUENCE:
      InsertLookupTableEntry, packet, lookupTable, rowNr

 CALLS: ***
	HSI_LOOKUPTABLEINSERTENTRY, HSI_SCTIME2ANY, MASK
 INPUTS:
      packet: a single packet for which the information will be
              stored
      lookupTable: 

 OPTIONAL INPUTS:
	xAxis:
       yAxis:

 OUTPUTS:
       none


 OPTIONAL OUTPUTS:
	none

 KEYWORDS:
       

 SIDE EFFECTS:
	none

 RESTRICTIONS:
	none

 PROCEDURE:
	none

 MODIFICATION HISTORY:
	Version 1, A.Csillaghy, csillag@ssl.berkeley.edu, Sept. 1998


INT_TABULATED_PIECEWISE $SSW/hessi/idl/image/int_tabulated_piecewise.pro
[Previous] [Next]
 NAME:
       INT_TABULATED_PIECEWISE

 PURPOSE:
       This function integrates a tabulated set of data { x(i) , f(i) },
       on the closed interval [min(X) , max(X)], assuming a piecewise linear fit
		between successive tabulated data points.

 CATEGORY:
       HESSI-utility

 CALLING SEQUENCE:
       Result = INT_TABULATED_PIECEWISE(X, F)

 INPUTS:
       X:  The tabulated X-value data. This data may be irregularly
           gridded and in random order. If the data is randomly ordered
	    	you must set the SORT keyword to a nonzero value.
       F:  The tabulated F-value data. Upon input to the function
           X(i) and F(i) must have corresponding indices for all
	    	values of i. If X is reordered, F is also reordered.

       X and F must be of floating point or double precision type.

 KEYWORD PARAMETERS:
       SORT:   A zero or non-zero scalar value.
               SORT = 0 (the default) The tabulated x-value data is
                        already in ascending order.
               SORT = 1 The tabulated x-value data is in random order
                        and requires sorting into ascending order. Both
						 input parameters X and F are returned sorted.
       DOUBLE: If set to a non-zero value, computations are done in
               double precision arithmetic.

 OUTPUTS:
       This fuction returns the integral of F computed from the tabulated
			data in the closed interval [min(X) , max(X)].

 CALLED BY:
	hessi_grm
 RESTRICTIONS:
		This algorithm is designed for use with functions with discontinuous first derivatives.
       This routine is not recommeneded for fitting smooth functions for which
			IDL's INT_TABULATED will be more accurate.
		The INT_TABULATED restriction against duplicate values does not apply here, so long as
			values are sorted.  In case of duplicate x values, X, the 1st y-value of the pair
			will be used for x<X and the second y-value will be used for x>X.

 MODIFICATION HISTORY:
	14-May-01:	Hurford	Adapted from IDL5.4 INT_TABULATED.


interpu_2d [1] $SSW/hessi/idl/qlook_archive/hsi_qlook_spec_bck.pro
[Previous] [Next]
 NAME:
       interpu_2d.pro
 PURPOSE:
       Linearly interpolates in 2 dimensions, similar to the 
       Users Library routine Interpol. 
 CALLING SEQUENCE:
       f = interpu_2d(a, x, y, x_new, y_new, inp_unc=inp_unc, $
                     ux_new=ux_new, uy_new=uy_new, out_unc=out_unc)
 INPUT:
       a = the array to be interpolated on.
       x= grid values for the vector a, need not be monotonic.
           N_ELEMENTS(X) must equal N_ELEMENTS(A(*,0))
       y= grid values for the vector a, need not be monotonic.
           N_ELEMENTS(Y) must equal N_ELEMENTS(A(0,*))
       x_new= values of x for the result
       y_new= values of y for the result
 OUTPUT:
       f= an nxXny array, determined by linear interpolation.
 KEYWORDS:
       inp_unc= uncertainty in the input array, can be a scalar
       ux_new= uncertainty in x_new
       uy_new= uncertainty in y_new
       out_unc= output uncertainty, only calculated if one or
                more of the input uncertainties are set.
 CALLED BY:
	align_hxi
 HISTORY:
       19-APR-93 by JM
       Interpol calls removed and uncertainties added, 1/26/95, jmm
       Sorts the data to monotonically increase, 5-apr-1996, jmm
       18-nov-2002, jmm, uses value_locate to get interp points