;+ ;NAME: ; tclip ;PURPOSE: ; wapper for xclip.pro allowing input of tplot variable names ;CALLING SEQUENCE: ; tclip, varnames, amin, amax, _extra=_extra ;INPUT: ; varnames = an array (or scalar) of tplot variable names ; amin, amax = the minumum and maximum values ;KEYWORDS: ; flag = the value that clipped data are set to, the default is ; 6.8792e28 ; new_varnames = if set,give these names to the clipped data, the ; default is to append '_clip' to the input names and ; pass out the names in the new_varnames variables, ; Unless /overwrite is set ; overwrite = if set, write the new data back to the old tplot ; variables, do not set this with new_varnames ;HISTORY: ; 2-feb-2007, jmm, jimm.ssl.berkeley.edu ; ;$LastChangedBy$ ;$LastChangedDate$ ;$LastChangedRevision$ ;$URL$ ;- Pro tclip, varnames, amin, amax, new_varnames = new_varnames, $ overwrite = overwrite, _extra = _extra ;First extract the data n = n_elements(varnames) If(keyword_set(new_varnames)) Then begin If(keyword_set(overwrite)) Then begin message, /info, 'Do not set both the new_varnames and overwrite keywords' return Endif If(n_elements(new_varnames) Ne n) Then Begin message, /info, 'Incompatible varnames, new_varnames input' Return Endif nvn = new_varnames Endif Else nvn = varnames+'_clip' ;Now do the clipping For j = 0, n-1 Do Begin get_data, varnames[j], data = d, dlim = dlim, lim = lim If(is_struct(d)) Then Begin y = d.y xclip, amin, amax, y, _extra = _extra d.y = temporary(y) If(keyword_set(overwrite)) Then new_name = varnames[j] $ Else new_name = nvn[j] store_data, new_name, data = d, dlim = dlim, lim = lim Endif Else Begin message, /info, 'No Clipping of: '+varnames[j] Endelse Endfor new_varnames = nvn Return End