;--------------------------------------------------------------------------- ; Document name: hsi_monitor_rate__define.pro ; Created by: Andre Csillaghy, February 17, 1999 ; ; Last Modified: Tue Feb 12 17:42:08 2002 (csillag@delsol) ;--------------------------------------------------------------------------- ; ;+ ; PROJECT: ; HESSI ; ; NAME: ; HESSI MONITOR RATE CLASS DEFINITION ; ; PURPOSE: ; Allows to read monitor rate data out of telemetry packets and ; plot some of them. ; ; CATEGORY: ; Utilities ; ; CONSTRUCTION: ; obj = Obj_New( 'hsi_monitor_rate' ) ; obj = HSI_Monitor_Rate() ; ; GENERIC METHODS: ; ; OBJECT METHODS: ; ; KEYWORDS: ; ; ; EXAMPLES: ; ; SEE ALSO: ; ; HISTORY: ; ; jimm's adaptations, ; Dev. for Release 3, July 1999 ; Release 2, June 1999 ; Version 1, February 17, 1999, ; A Csillaghy, csillag@ssl.berkeley.edu ; 10-apr-02, default to no_102 of 0, ras ; 8-Dec-2003, Kim. Added @hsi_insert_catch in getdata ; 27-May-2005, Kim. Rewrote plot method. Added plotman method. ; 10-Jun-2005, Kim. Plot particle data as count/sec and ylog ; 5-Jul-2008, Kim. Changed plotman calls to use new simplified version. ;- ;-------------------------------------------------------------------- FUNCTION HSI_Monitor_Rate::INIT, SOURCE = source, _EXTRA=_extra IF NOT Obj_Valid( source ) THEN source = HSI_Packet( ) ret=self->Framework::INIT( CONTROL = {hsi_monitor_rate_control}, $ INFO={hsi_monitor_rate_info}, $ SOURCE=source ) self->Set, no_102 = 0 ;Initialize to use real monitor rates, ras, 10-apr-02 IF Keyword_Set( _EXTRA ) THEN self->Set, _EXTRA = _extra RETURN, ret END ;-------------------------------------------------------------------- FUNCTION HSI_Monitor_Rate::GetData, $ HI_PARTICLE=hi_particle, $ LO_PARTICLE=lo_particle, $ PARTICLE_DETECTOR=particle_detector, $ CORRECT_LTIME=correct_ltime, $ THIS_SEG_INDEX=this_seg_index, $ THIS_DET_INDEX=this_det_index, $ THIS_TIME_RANGE=this_time_range, $ _EXTRA=_extra @hsi_insert_catch IF Keyword_Set( THIS_DET_INDEX ) THEN CheckVar, this_seg_index, this_det_index IF Keyword_Set( _EXTRA ) THEN self->Set, _EXTRA = _extra monrate=self->Framework::GetData( ) n_monrate = N_Elements( monrate ) IF Keyword_Set( THIS_TIME_RANGE ) THEN BEGIN limits = Value_Locate( monrate.time, this_time_range ) IF limits[0] EQ -1 THEN limits[0] = 0 IF limits[1] EQ -1 THEN limits[1] = n_monrate-1 IF limits[0] GT limits[1] THEN BEGIN Message, 'No monitor rates can be selected for the time range ' + $ String( this_time_range ), /CONTINUE RETURN, -1 ENDIF monrate = monrate[limits[0]:limits[1]] n_monrate = N_Elements( monrate ) ENDIF IF Keyword_Set( PARTICLE_DETECTOR ) OR $ Keyword_Set( HI_PARTICLE ) OR $ Keyword_Set( LO_PARTICLE ) THEN BEGIN n_el = 8*n_monrate time = Interpol( monrate.time, n_el ) yes_partlo = Keyword_Set( LO_PARTICLE ) yes_parthi = Keyword_Set( HI_PARTICLE ) IF Keyword_Set( PARTICLE_DETECTOR ) OR (yes_partlo AND yes_parthi ) THEN BEGIN RETURN, { time: time, $ particle_lo: Reform( monrate.particle_lo, n_el ), $ particle_hi: Reform( monrate.particle_hi, n_el ) } ENDIF ELSE IF Keyword_Set( HI_PARTICLE ) THEN BEGIN RETURN, { time: time, $ particle_lo: Reform( monrate.particle_lo, n_el ) } ENDIF ELSE BEGIN RETURN, { time: time, $ particle_hi: Reform( monrate.particle_hi, n_el ) } ENDELSE ENDIF if keyword_set(correct_ltime) then $ for seg=0,17 do monrate.live_time[seg] = $ (hsi_corrected_livetime(monrate.live_time[seg],seg) - .15) / .85 IF N_Elements( THIS_SEG_INDEX ) NE 0 THEN BEGIN n_det = N_Elements( this_seg_index ) monrate = {time:monrate.time, $ preamp_reset:monrate.preamp_reset[ this_seg_index, * ], $ shaper_valid:monrate.shaper_valid[ this_seg_index, * ], $ shaper_over_uld:monrate.shaper_over_uld[ this_seg_index, * ], $ delay_line_valid:monrate.delay_line_valid[ this_seg_index, * ], $ live_time:monrate.live_time[ this_seg_index, * ] } ENDIF RETURN, monrate END ;-------------------------------------------------------------------- PRO HSI_Monitor_Rate::Process, $ _EXTRA=_extra IF self.debug THEN Message, 'Processing the Monitor Rate', /INFO source = self->Get( /SOURCE ) no_102 = self->Get( /no_102 ) filename = self->Get( /filename ) dummy1 = Str_Find( filename, 'vc1', count=c ) dummy1 = Str_Find( filename, 'BGS', count=c2 ) IF c NE 0 OR c2 NE 0 THEN no_102 = 1 HSI_Monitor_Rate_Read, PACKET_OBJ=source, $ monrate, n_cycles, dtime, $ NO_102=no_102, $ UT_REF=ut_ref, $ /NO_ADP_TEST, $ _EXTRA=_extra self->SetData, monrate self->Set, MON_UT_REF = ut_ref self->Set, NCYCLES = n_cycles, DTIME=dtime END ;-------------------------------------------------------------------------- PRO HSI_Monitor_Rate::Plot, $ plotman_obj=plotman_obj, $ this_seg_index=this_seg_index, $ show_flags_obj=flags_obj, $ ltime=ltime, $ correct_ltime=correct_ltime, $ reset=reset, $ slow=slow, $ fast=fast, $ uld=uld, $ front=front, $ rear=rear, $ particle=particle, $ status=status, err_msg=err_msg, $ _EXTRA = _extra ;orig_p = !p ;mon = self->GetData( _EXTRA=_extra ) ;n_mon = N_Elements( mon.time ) ;ut_ref = self->Get( /MON_UT_REF ) ; ;yes_part_lo = Tag_Exist( mon, 'PARTICLE_LO' ) ;yes_part_hi = Tag_Exist( mon, 'PARTICLE_HI' ) ;IF yes_part_lo OR yes_part_hi THEN BEGIN ; IF yes_part_lo AND yes_part_hi THEN BEGIN ; !p.multi = [0, 1, 2] ; ENDIF ; IF yes_part_lo THEN BEGIN ; time=Keyword_Set( INTEGRATION_TIME ) ? $ ; Interpol( mon.time, n_mon/(8.*Float( integration_time )) ) : mon.time ; partlo=Keyword_Set( INTEGRATION_TIME ) ? $ ; Interpol( mon.particle_lo, n_mon/(8.*Float( integration_time)) ) : mon.particle_lo ; UtPlot, time, partlo, ut_ref, psym=10, xs=3, ys=3 ; ENDIF ; IF yes_part_hi THEN BEGIN ; time=Keyword_Set( INTEGRATION_TIME )? $ ; Interpol( mon.time, n_mon/(8.*Float( integration_time )) ) : mon.time ; parthi=Keyword_Set( INTEGRATION_TIME ) ? $ ; Interpol( mon.particle_hi, n_mon/(8.*Float( integration_time)) ) : mon.particle_hi ; UtPlot, time, Abs(parthi-partlo)/Max(Float(partlo)), ut_ref, psym=10, xs=3, ys=3 ; ENDIF ;ENDIF ; ;!p = orig_p status = 1 err_msg = '' err = 0 catch, err If(err Ne 0) Then Begin catch, /cancel message, /info, 'Error, ' + !error_state.msg err_msg = !error_state.msg Return Endif front = keyword_set(front) rear = keyword_set(rear) if front+rear eq 0 then front=1 checkvar, this_seg_index, [bytarr(9)+front,bytarr(9)+rear] seg = this_seg_index if keyword_set(correct_ltime) then ltime = 1 part = keyword_set(particle) if keyword_set(_extra) then self -> set, _extra=_extra data = part ? self -> getdata(/particle) : self -> getdata(correct_ltime=correct_ltime) if not is_struct(data) then message, 'No data accumulated.' time = data.time utbase = self -> get(/mon_ut_ref) dim1_ids = hsi_a2d_list (bytarr(9), seg, bytarr(27)+1, /separate) yind = where (seg) ;if front then begin ; yind = indgen(9) ; dim1_ids = trim(indgen(9)+1) + 'F' ; fr = '(Front)' ;endif else begin ; yind = indgen(9) + 9 ; dim1_ids = trim(indgen(9)+1) + 'R' ; fr = '(Rear)' ;endelse ylog = 1 case 1 of keyword_set(reset): begin ydata = transpose(data.preamp_reset(yind)) title = 'Monitor Rate: Reset ' ytitle = '?' end keyword_set(slow): begin ydata = transpose(data.shaper_valid(yind)) title = 'Monitor Rate: Slow ' ytitle = '?' end keyword_set(fast): begin ydata = transpose(data.delay_line_valid(yind)) title = 'Monitor Rate: Fast ' ytitle = '?' end keyword_set(uld): begin ydata = transpose(data.shaper_over_uld(yind)) title = 'Monitor Rate: ULD ' ytitle = '?' end keyword_set(ltime): begin ydata = transpose(data.live_time(yind)) title = 'Monitor Rate: Livetime ' if keyword_set(correct_ltime) then title = 'Monitor Rate: Corrected Livetime ' ytitle = 'seconds' ylog = 0 end keyword_set(part): begin ;convert to counts per sec. Data is every 1/8 second ydata = [[data.particle_lo], [data.particle_hi]] * 8. title = 'Monitor Rate: Particle Data ' ytitle = 'Counts / sec' dim1_ids = ['Lo', 'Hi'] ylog = 1 end endcase if not exist(flags_obj) then flags_obj = hsi_show_flags(_extra=_extra) flags_selected = flags_obj -> get(/selected) if total (flags_selected) gt 0 then begin timerange = utbase + minmax(time) flag_text = flags_obj -> getlabel (timerange, n_bar=n_bar) if n_bar gt 0 then label = [replicate('',n_bar), flag_text] addplot_name = 'hsi_draw_flags' addplot_arg = {flags_obj: flags_obj, utbase: utbase} endif utplot_obj = obj_new('utplot', time, ydata, utbase=anytim(utbase,/vms)) utplot_obj -> set, $ id=title, $ label=label, $ dim1_ids=dim1_ids, $ data_unit=ytitle, $ dim1_use = dim1_use, $ dim1_vals = dim1_vals, $ /dim1_enab_sum, $ ylog=ylog, $ addplot_name=addplot_name, $ addplot_arg=addplot_arg, $ _extra=_extra if is_class(plotman_obj,'plotman',/quiet) then begin ; status = plotman_obj -> setdefaults (input=utplot_obj, plot_type='utplot') ; if status then begin ; plotman_obj -> set, _extra=_extra ; plotman_obj -> new_panel, title ; endif plotman_obj -> new_panel, desc=title, input=utplot_obj, plot_type='utplot', _extra=_extra endif else utplot_obj -> plot, status=status, err_msg=err_msg, _extra=_extra if err_msg ne '' then print,err_msg if not status then return END ;--------------------------------------------------------------------------- pro hsi_monitor_rate::plotman, plotman_obj=plotman_obj, $ status=status, err_msg=err_msg, _extra=_extra status = 1 err_msg = '' valid_plotman = is_class(plotman_obj,'plotman', /quiet) ? plotman_obj->valid() : 0 ;valid_plotman = 0 ;if obj_valid(plotman_obj) then $ ; if is_class(plotman_obj,'plotman') then if xalive (plotman_obj->get(/plot_base)) then valid_plotman=1 if not valid_plotman then begin plotman_obj = obj_new('plotman', error=error) status = error eq 0 if error then return endif self -> plot, plotman_obj=plotman_obj, status=status, err_msg=err_msg, _extra=_extra end ;--------------------------------------------------------------------------- PRO HSI_Monitor_Rate__Define self = { HSI_Monitor_Rate, $ INHERITS Framework } END ;--------------------------------------------------------------------------- ; End of 'hsi_Monitor_Rate__define.pro'. ;---------------------------------------------------------------------------