pro imf, min=mind, max=maxd, binsize=binsize, nbins=nbins @common_blocks.inc ;on_error, 2 ; plots imf. make sure to have read either particle massdensity or ; particle mass depending on which format your run had. ; most enzo runs need particle massdensity ; select the types massind = (where((*parti.names) eq 'particle mass'))[0] if parti.read[massind] ne 1 then begin print, 'please first read the "particle mass" or "particle massdensity" fields!' return endif typeind = where(*parti.names eq 'particle_type') if N_elements(mind) lt 1 then mind = 1e-4 if N_elements(maxd) lt 1 then maxd = 1e3 if N_elements(binsze) lt 1 and N_elements(nbins) lt 1 then binsize=.25 if parti.type gt 0 then begin th = histogram((*parti.d[typeind[0]])[ind]) print, N_elements(th), ' different types of particles found.' typeind = where(*parti.names eq 'particle_type') if typeind[0] gt -1 then begin nind = where((*parti.d[typeind[0]])[ind] eq parti.type) if nind[0] gt -1 then ind = ind[nind] else print, 'no matching particle types found' end else print, 'no field with name "particle_type" read' endif print, 'including, ', N_elements(ind), ' points' If N_elements(ind) lt 2 then ind = LINDGEN(N_ELEMENTS(*(parti.d[massind]))) mh = histogram(alog10((*parti.d[massind])[ind]*get_unit('particle mass')), $ min=alog10(mind), max=alog10(maxd), binsize=binsize, nbins=nbins, locations=locs) ; debug purposes: v = mh x = locs WIDGET_CONTROL, draw_area, GET_VALUE=old_win window, 5 minp = min(where(mh gt min(mh))) plot, 10^(locs), (mh) > 1, /xlog, /ylog, psym=10, $ xtitle='mass ['+get_unit('particle mass', /ulabel)+']', ytitle='dN/dlog M' wset, old_win END