; example script ; here we make frames for a movie doing a density projection ; while first finding a particular particle ID on which we center pro follow_particle_movie @TOOLS/common_blocks.inc center_particle_id = 1182L ; use the particle with this id as center for the movie (-1 for static useing current center widget_control, base2, sensitive = 0 ; sets the GUI insensitive while script is working ntimes = N_ELEMENTS(times) old_log = image_log ; remember previous settings old_log_num = image_log_number old_log_string = image_log_string oldpindex = parti.index image_log = 1 ; make sure an image gets written every time image_log_number = 0L ; image_log_string = "spframe" ; use this as file base name ; delete all existing frames with same name spawn, 'rm '+image_log_directory+image_log_string+'*' starttime = 0L if time_index lt ntimes-1 then starttime = time_index ;start movie at current timestep ; unless it is the last timestep for which it will strt witht the first loded one mh = 0 for time_index=starttime,ntimes-1,astep DO BEGIN ; loop over all loaded timesteps widget_control, TIME_LIST_WIDGET, set_combobox_select=time_index select_current_grids check_cancel, stopit=stopit if stopit then begin stopit = 0 break endif parti.read[*] = 0 ; new time step so old particle data not reelvant vel.read = 0 ; read in the current particle data particleindex = (where((*parti.names) eq 'particle_index'))[0] fields= [0,1,2, parti.index, particleindex] read_particle_data, fields=fields ; parti.index = where((*parti.names) eq 'particle mass') ; read_particle_data pi = where( (*parti.d[particleindex]) eq center_particle_id) ; find particle sidelength = slice_size[2] - slice_size[0] sh = sidelength/2. ot = where(slice_ori lt 1.e-15) os = where(slice_ori gt 1.e-15) if pi ge 0 then begin center[ot] = [(*parti.d[ot[0]])[pi], (*parti.d[ot[1]])[pi]] ; center on it print, 'center on:', (*parti.d[0])[pi], (*parti.d[1])[pi], (*parti.d[2])[pi] endif else printf, 'PARTICLE NOT FOUND WITH ID:', center_particle_id slice_size[*] = [center[ot]-sh, center[ot]+sh] slice_value[*] = 0.D slice_value[os] = center[os] image_log = 0 ; J_event, 'NO_VEL' ; J_EVENT, 'DRAW_BUTTON' ; J_event, 'VEL_BUTTON' J_event, 'DRAW_BUTTON' image_log = 1 a = total(*parti.d[parti.index]) print, 'total mass value:', a mh = [mh[*], a] ; mark the center particle plots, xy_sl_size/2,xy_sl_size/2, [0.5], psym=4, /device, THICK=2 save_image_log ; save frame if verbose then print, 'memory use in Mb', memory()/1024./1e3 endfor mh = mh[1:*] time_index = N_elements(times)-1 image_log = old_log image_log_number = old_log_num image_log_string = old_log_string parti.index = oldpindex widget_control, base2, sensitive = 1 return end follow_particle_movie end