;+ ; ; NAME: ; HXISREAD ; ; PURPOSE: ; Reads HXIS data from a disk file. ; ; CATEGORY: ; HXIS display ; ; CALLING SEQUENCE: ; var = HXISREAD, A ; ; CALLED BY: ; HXISWIDGET ; ; CALLS TO: ; HXISGETTIME, HXISSEL_PRC, HXISSTRLABEL, HXISSTRTIME, HXISDEFAULTS, ; HXISPOINT, HXISWRITE_TIME, CONV_VAX_UNIX2 ; ; INNPUTS: ; A: character string containing file name to read ; and through common blocks ; ; OPTIONAL INPUTS: ; none ; ; OUTPUT: ; Returns value of 0 if normal completion else returns a 1 ; and through common blocks ; ; COMMON BLOCKS: ; hxiswidget.common ; hxisasread.common ; hxisdata_info.common ; hxispass.common ; hxistime.common ; ; SIDE EFFECTS: ; Opens an associated file. ; ; RESTRICTIONS: ; none ; ; PROCEDURE: ; Opens the data file and associates it to array DATA and assigns file ; parameters. ; ; For flare mode 0 (normal mode) no DFM data (DFM=0) ; Bands 2 and 6: DFM data for both flare mode 1 and 2 ; Bands 1 and 5: DFM data for flare mode 2 only (for mode 1 DFM=-16) ; Bands 3 and 4: no DFM data ; ; MODIFICATION HISTORY: ; DEC-1990/JAN-1991, Paul Hick (ARC) ; DEC 1992, E. Einfalt (HSTX) - converted to widgets ; Jan 1994 E. Einfalt (HSTX) - fixed for UNIX ;- function HXISREAD, A @hxiswidget.common @hxisasread.common @hxisdata_info.common @hxispass.common @hxistime.common @hxiswindow.common ; Open file widget_control, comment, set_value = 'Reading file ' + A, /append close, /all openr, /GET_LUN, IU , A, error=B if B ne 0 then begin ; error with file widget_control, comment, set_value='Error reading ' + a, /append if n_elements(iu) ne 0 then free_lun, iu return, 1 endif INFO.FNAME = A ; successful, so store file name new_file = 1 ; needed in winup for new banner hxisdefaults ; reset ; Get info about file size and record length STATUS = fstat(IU) ; RECL = STATUS.REC_LEN ; RECS = STATUS.SIZE/STATUS.REC_LEN recl = 7680 ; 7680 bytes=3840 words (the size of ; one image) recs = status.size / recl ; number record this file widget_control, comment, set_value = strtrim(RECS,1) + ' images of ' + $ strtrim(RECL/2,1) + $ ' words (' + strtrim(STATUS.SIZE,1)+ $ ' bytes)', /append widget_control, comment, set_value='Total of ' + strcompress(RECS,/rem) + $ ' images' ,/append ; RECL = STATUS.REC_LEN/2 ; Record length in words RECL = RECL/2 ; Record length in words A = min([RECL,3648])-192 ; Number of words reserved for counts IBND = A/576 ; # energy bands if IBND*576 ne A then begin widget_control, comment,set_value='Invalid record length',/append return,1 endif DATA = assoc(IU,intarr(RECL)) ; Associated read connection with input file A = DATA(0) ; 1st image in record 1 ; file_start_time = ( float(A(12:13),0)/3600d0+A(11) )/24. ; in units of DOY file_start_time = ( conv_vax_unix2(float(A(12:13),0))/3600d0+A(11) )/24. ; in units of DOY usestart_time = file_start_time A = DATA(RECS-1) ; last image in record "RECS" ; file_end_time = ( float(A(12:13),0) / 3600d0+A(11) )/24. ; in units of DOY file_end_time = ( conv_vax_unix2(float(A(12:13),0)) / 3600d0+A(11) )/24. ; in units of DOY useend_time = file_end_time ; save file start as DOY:HH... start_doy = fix(file_start_time) start_hour = (file_start_time - start_doy) * 24d start_min = (start_hour - fix(start_hour)) * 60d start_sec = (start_min - fix(start_min)) * 60d start_mil = hxisnint((start_sec - fix(start_sec)) * 1000) ; start time to common file_start = string(start_doy, '(i3.3)') + ':' + $ string(start_hour, '(i2.2)') + ':' + $ string(start_min, '(i2.2)') + ':' + $ string(start_sec, '(i2.2)') + '.' + $ string(start_mil, '(i3.3)') ; save file end as DOY:HH... end_doy = fix(file_end_time) end_hour = (file_end_time - end_doy) * 24d end_min = (end_hour - fix(end_hour)) * 60d end_sec = (end_min - fix(end_min)) * 60d end_mil = hxisnint((end_sec - fix(end_sec)) * 1000) ; end time to common file_end = string(end_doy, '(i3.3)') + ':' + $ string(end_hour, '(i2.2)') + ':' + $ string(end_min, '(i2.2)') + ':' + $ string(end_sec, '(i2.2)') + '.' + $ string(end_mil, '(i3.3)') STRT = file_start_time & EIND = file_end_time I1 = 0 & I2 = RECS-1 repeat begin ; Find first image after START time I = (I1+I2)/2 A = DATA(I) ; B = ( float(A(12:13),0)/3600d0+A(11) )/24. B = ( conv_vax_unix2(float(A(12:13),0))/3600d0+A(11) )/24. if B gt STRT then I2 = I else I1 = I endrep until I2-I1 le 1 B = DATA(I1) ; index of first image to display ; B = ( float(B(12:13),0)/3600d0+B(11) )/24. ; it's time B = ( conv_vax_unix2(float(B(12:13),0))/3600d0+B(11) )/24. ; it's time if B ge STRT-1E-6 then I2 = I1 INFO.BOT_IMG = I2 ; First image and start doy A = DATA(I2) ; INFO.DOY = fix( (float(A(12:13),0)/3600d0+A(11))/24 ) INFO.DOY = fix( (conv_vax_unix2(float(A(12:13),0))/3600d0+A(11))/24 ) I1 = I2 & I2 = RECS-1 repeat begin ; Find last image before EIND time I = (I1+I2)/2 A = DATA(I) ; B = ( float(A(12:13),0)/3600d0+A(11) )/24. B = ( conv_vax_unix2(float(A(12:13),0))/3600d0+A(11) )/24. if B gt EIND then I2 = I else I1 = I endrep until I2-I1 le 1 A = DATA(I2) ; A = ( float(A(12:13),0)/3600d0+A(11) )/24. A = ( conv_vax_unix2(float(A(12:13),0))/3600d0+A(11) )/24. if A le EIND+1E-6 then I1 = I2 INFO.TOP_IMG = I1 ; Last image info.NIMG = INFO.TOP_IMG-INFO.BOT_IMG+1 ; # images extracted from file TIMG = dblarr(info.NIMG) ; IFLAG = bytarr(info.NIMG) ; all flags to 0 IDUR = bytarr(info.NIMG) ; Image duration (in 0.125 ; secs) FLR_MOD = bytarr(info.NIMG) DFM = fltarr(info.NIMG) B = 192+1*576+528 & C = 192+5*576+528 widget_control, comment, set_value= 'Scanning data file ...', /append for I = INFO.BOT_IMG, INFO.TOP_IMG do begin ; assign info about ea. image cur_img = i+1 if (cur_img mod 100) eq 0 then widget_control, comment, $ set_value= 'Scanning image ' + strtrim(cur_img,2) + ' of ' $ + strtrim(info.top_img,2),/append A = DATA(I) I2 = I-INFO.BOT_IMG ; index for this series ; TIMG(I2) = float(A(12:13),0)/3600d0+(A(11)-INFO.DOY*24) TIMG(I2) = conv_vax_unix2(float(A(12:13),0))/3600d0+(A(11)-INFO.DOY*24) ; IFLAG(I2) = A(14) IDUR(I2) = A(21) ; image duration in units of 0.125 sec FLR_MOD(I2) = A(29) if FLR_MOD(I2) ne 0 then $ DFM(I2) = (36./IDUR(I2))*(total(A(B:B+15))+total(A(C:C+15))) endfor widget_control, comment, set_value= 'Scan complete', /append INFO.FRST_IMG = INFO.BOT_IMG INFO.LAST_IMG = INFO.FRST_IMG - 1 case IBND of ; Check which bands are present 1: begin A = DATA(0) & A = A(16) & INFO.FRST_BND = A & INFO.LAST_BND = A hxisstrlabel, 0,A,A,B widget_control, comment, set_value= 'Only energy band ' + $ strtrim(A,1)+' ('+B+')', /append end else: begin INFO.FRST_BND = 1 & INFO.LAST_BND = IBND ; Lowest and highest energy band widget_control, comment, set_value= 'There are ' + strtrim(IBND,1) + $ ' energy bands available', /append end endcase if info.last_bnd - info.frst_bnd lt 0 then begin widget_control, comment, set_value='No bands available',/append return, 1 endif ; ; What time is file start and default duration ; hxiswrite_times, newstart=info.frst_img, /newdurate widget_control, pass_file_start, set_value=file_start widget_control, pass_file_end, set_value=file_end ; ; Calculate pointing for middle image in file. ; error = 0 hxispoint, error=error ; get new pointing information if error then widget_control, comment, set_value='Error determining ' + $ 'pointing values.', /append return, 0 ; valid read end