function shouldbe_logged, stringarr @common_blocks.inc ns = N_elements(stringarr) if ns gt 0 then logit = bytarr(ns) + 1 for i=0,ns-1 do begin string = stringarr[i] IF (((strpos(string, 'elocity') GE 0) and not (strpos(string, 'rms') GE 0)) OR $ ((strpos(string, 'elocity') GE 0) and not (strpos(string, 'abs') GE 0)) OR $ (strpos(string, 'orticity') GE 0) OR $ (strpos(string, 'Entropy') GE 0) OR $ (strpos(string, 'AccelerationField') GE 0) OR $ (strpos(string, 'PotentialField') GE 0) OR $ (strpos(string, 'Grav_Potential') GE 0) OR $ (strpos(string, 'particle_pos') GE 0) OR $ (strpos(string, 'particle id') GE 0) OR $ (strpos(string, '_time') GE 0) OR $ (strpos(string, '_type') GE 0) OR $ (strpos(string, '_index') GE 0) OR $ (strpos(string, 'B_Div') GE 0) OR $ (strpos(string, 'div V') GE 0) OR $ (strpos(string, 'density slope') GE 0) OR $ (strpos(string, 'DM density slope') GE 0) OR $ (string eq 'x') OR $ (string eq 'y') OR $ (string eq 'z') OR $ (strpos(string, 'Phi') GE 0) OR $ ; (strpos(string, '(kinetic)') GE 0) OR $ (strpos(string, 'Rotation') GE 0) OR $ (strpos(string, 'MagneticField') GE 0) OR $ (strpos(string, 'Bx') GE 0) OR $ (strpos(string, 'By') GE 0) OR $ (strpos(string, 'Bz') GE 0) OR $ (strpos(string, 'DrivingField') GE 0) OR $ (strpos(string, 'dM/dt') GE 0) OR $ ; (strpos(string, 'almer') GE 0) OR $ (strpos(string, 'Intensity') GE 0)) then logit[i] = 0 $ ELSE logit[i] = 1 ; default is to log ; default behavior overridden by user? if N_elements(log_fields_flag) gt 0 then begin ind = where(log_fields_flag.name eq string) if ind[0] ge 0 then logit[i] = log_fields_flag[ind[0]].logit endif endfor if ns eq 1 then logit = logit[0] return, logit end function shouldbe_histogram, string histit = 0 IF ((strpos(string, 'particle_pos') GE 0) OR $ (strpos(string, 'particle mass') GE 0) OR $ (strpos(string, 'particle massdensity') GE 0) ) then histit = 1 return, histit end pro will_take_log @common_blocks.inc ; provide a widget with the list of all variable names allowing to ; choose whether the field gets logged or not def = {willlog, name: '', logit: 0B} initialize_list = 0 nparti = N_elements((*parti.names)) nvar = (size(list_str(where(list_str ne ''))))[3] if N_elements(log_fields_flag) eq 0 then initialize_list = 1 $ else $ if N_Elements(log_fields_flag.name) ne nvar + nparti then initialize_list = 1 ;initialize_list = 1 if initialize_list then begin default_values = shouldbe_logged(list_str) log_fields_flag = replicate(def,nvar+nparti) for i=0,nvar-1 do begin log_fields_flag[i].name = list_str[i] log_fields_flag[i].logit = default_values[i] endfor ; particle fields if nparti gt 0 then begin default_values = shouldbe_logged(*parti.names) for i=nvar,nvar+nparti-1 do begin log_fields_flag[i].name = (*parti.names)[i-nvar] log_fields_flag[i].logit = default_values[i-nvar] endfor endif s = nvar + nparti endif else begin s = N_elements(log_fields_flag) endelse boldfont = '-*-fixed-bold-*-normal--*-*-*-*-*-*-*-*' num_dim = 3 fbase = widget_base(title='Select whether to take log10 or not of a vairable', /ROW) fbase1 = widget_base(fbase, /COLUMN, /FRAME) templabel = widget_label(fbase1, $ value = 'Select data sets to take log10 of', $ FONT = boldfont) fbase2 = widget_base(fbase1, /COLUMN, /FRAME,/scroll, x_scroll_size=400, y_scroll_size=700) fbase3 = widget_base(fbase, /COLUMN, /FRAME) field_names = log_fields_flag.name default_values = log_fields_flag[*].logit entries = s options = 1 junk = LONARR(entries) basejunk = LONARR(entries) b_uvalues = indgen(entries) basejunk = widget_base(fbase2, /ROW) ;breaki junk = CW_BGROUP(basejunk, column = 2, /NONEXCLUSIVE, $ field_names+' log10', UVALUE = "BUTTONS", $ BUTTON_UVALUE = b_uvalues, set_value=default_values) didit = WIDGET_BUTTON( FBASE3, $ FONT='-adobe-helvetica-bold-r-normal--14-100-100-100-p-82-iso8859-1', $ UVALUE='didit', $ VALUE='DONE') WIDGET_CONTROL, fbase, /REALIZE ;WSHOW, win WHILE 1 DO BEGIN ;Internal event loop ev = WIDGET_EVENT(fbase) WIDGET_CONTROL,Ev.id,GET_UVALUE=Event CASE event OF 'didit' : BEGIN WIDGET_CONTROL, fbase, /DESTROY RETURN END ; ; Do it ; 'BUTTONS': BEGIN selected = BYTARR(options, entries) WIDGET_CONTROL, GET_VALUE = theval , junk log_fields_flag.logit = theval END ELSE : ENDCASE ENDWHILE END