pro export_particles_to_partiview, only_current=ocurrent @TOOLS/common_blocks.inc if N_ELEMENTS(*parti.names) eq 0 or (*parti.names)[0] eq '' then return names = (*parti.names) filename = DIALOG_PICKFILE(FILTER="*.speck", PATH=data_dir, $ FILE=default_filename, DIALOG_PARENT=BASE2, $ TITLE="Select partiview particles speck Export Filename", $ GET_PATH=data_dir, /NOCONFIRM, /WRITE, $ /OVERWRITE_PROMPT) if filename eq '' then return if N_elements(ocurrent) eq 0 then begin ocurrent = 0 these_grids = all_grid_info endif else these_grids=grid_info ind = where(these_grids.num_particle gt 0, count) if count gt 0 then these_grids = these_grids[ind] else begin print, 'export_particles_to_partiview: no grids with particles found' return endelse h = these_grids.timestep if N_elements(these_grids.timestep) gt 1 then $ h = histogram(these_grids.timestep, reverse_indices=r) $ else begin r = [0,1] h = 1 endelse ntimesteps = N_elements(where(h gt 0)) openw, lun, filename, /get_lun nfields = N_elements(names) for i=3, nfields-1 do printf, lun, 'datavar'+strcompress(i-3)+' '+strcompress(names[i], /remove_all) typeind = where(*parti.names eq 'particle_type', count) if count gt 0 then begin printf, lun, 'texturevar particle_type' printf, lun, 'texture -M 1 halo.sgi' printf, lun, 'texture -M 2 halo.sgi' endif cnt = 0L for i=0L, Ntimesteps-1 do begin if h[i] ge 1 then begin ngrids = r[i+1]-r[i] cg = get_particle_data(these_grids[r[r[i]]:r[(r[i+1]-1)]], (*parti.names)) ; printf, lun, 'timestep ', these_grids[r[r[i]]].timestep,' ', ; ngrids, ' grids' ts = these_grids[r[r[i]]].time printf, lun, 'datatime ', strcompress(i),' # time:', strcompress(ts), ' ',strcompress(ngrids), ' grids' for j=0L,N_elements(cg)-1 do begin ca = cg[j] if ptr_valid(ca.data[0]) then nparticles = N_elements(*ca.data[0]) else nparticles=-1 for k=0L,nparticles-1 do begin line = '' if typeind[0] ge 0 then ctype = (*ca.data[typeind[0]])[k] else ctype = parti.type if ((parti.type eq 0) or (ctype eq parti.type)) and (cnt mod parti.every) eq 0 then begin for ii=0, nfields-1 do line = line + strcompress((*ca.data[ii])[k]) printf, lun, line endif cnt += cnt endfor endfor printf, lun, '' endif endfor printf, lun, '# fake data entry to let partiview loop and spend the same amount of time on every step.' printf, lun, 'datatime ', strcompress(i),' # time:', strcompress(ts), ' ',strcompress(ngrids), ' grids' printf, lun, line close, lun free_lun, lun return end