Changeset 39


Ignore:
Timestamp:
10/19/10 02:43:42 (19 months ago)
Author:
tabel
Message:

Speed up flash reading. Debugged enclosed gas mass and masses in flash support. Optimized Aake Nordlunds powerspectrum routine (factor of 4 faster now).

Location:
trunk/TOOLS
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/TOOLS/AMRslice.pro

    r37 r39  
    616616           step = 1 
    617617           exists = '' 
    618            while ((step lt 100) and (exists[0] eq '')) do begin 
     618           while ((step lt 1000) and (exists[0] eq '')) do begin 
    619619;              findS = sp[0:ns-2] + STRING(max([LONG(timenum)-step,0]), FORMAT='(i4.4)') 
    620620              if regular then $ 
    621                  findS = sp[0:ns-2] + STRING(max([LONG(timenum)-step,0]), FORMAT='(i4.4)') $ 
     621                 findS = sp[0:((ns-2) > 0)] + STRING(max([LONG(timenum)-step,0]), FORMAT='(i4.4)') $ 
    622622              else $ 
    623623                 findS = sp[0:ns-1] + STRING(max([LONG(timenum)-step,0]), FORMAT='(i3.3)')  
     
    674674           step = 1 
    675675           exists = '' 
    676            while ((step lt 100) and (exists[0] eq '')) do begin 
     676           while ((step lt 1000) and (exists[0] eq '')) do begin 
    677677              if regular then $ 
    678                  findS = sp[0:ns-2] + STRING(LONG(timenum)+step, FORMAT='(i4.4)') $ 
     678                 findS = sp[0:((ns-2) > 0)] + STRING(LONG(timenum)+step, FORMAT='(i4.4)') $ 
    679679              else $ 
    680680                 findS = sp[0:ns-1] + STRING(LONG(timenum)+step, FORMAT='(i3.3)')  
     
    12061206       construct_cube, datacube, fieldname 
    12071207       print, '<data^2> =', mean(datacube^2) 
    1208 ;       if vel.myturn eq 0 then ps = PowerSpectrum_3D(datacube, 
    1209 ;       obin=obin) else $ 
     1208;       if vel.myturn eq 0 then ps = PowerSpectrum_3D(datacube, obin=obin)  $ 
    12101209       if vel.myturn eq 0 then $ 
    1211           power3d, reform(datacube[*,*,*]), $ 
    1212                    wavenumbers=obin, spectrum=ps,average=1,debug=verbose $ 
     1210          power3d, reform(datacube[*,*,*]), wavenumbers=obin, spectrum=ps,average=1,debug=verbose $ 
    12131211       else begin 
    12141212;          ps1 = PowerSpectrum_3D(reform(datacube[*,*,*,0]), obin=obin) 
     
    20832081  wItem = WIDGET_BUTTON(wMenu, VALUE='Color Map', UVALUE='CM_BUTTON', ACCELERATOR='Ctrl+C') 
    20842082  wItem= WIDGET_BUTTON(wMenu, VALUE='Change Min and Max', UVALUE='SET_BUTTON', ACCELERATOR='Ctrl+Shift+M') 
    2085   wItem = WIDGET_BUTTON(wMenu, VALUE='Data info', UVALUE='INFO_BUTTON', ACCELERATOR='Ctrl+Shift+I') 
     2083  wItem = WIDGET_BUTTON(wMenu, VALUE='Dataset info', UVALUE='INFO_BUTTON', ACCELERATOR='Ctrl+Shift+I') 
    20862084  wItem = WIDGET_BUTTON(wMenu, VALUE='Hierarchy file', UVALUE='VIEW_HIERARCHY') 
    20872085  wItem = WIDGET_BUTTON(wMenu, $ 
  • trunk/TOOLS/find_and_set_parent_grids.pro

    r34 r39  
    66  num_of_levels = N_elements(count)  
    77;breaki 
     8  sind = sort(grid_info.num) 
    89  for i=1, num_of_levels-1 DO BEGIN 
    910     print, 'level: ', i 
     
    1718; set parent start and end indeces  
    1819        IF (grid_info[cg].parent GT 0) THEN BEGIN 
    19            pi = where(grid_info[b].num eq grid_info[cg].parent, tcount) ; all parents 
     20;           pi = where(grid_info[b].num eq grid_info[cg].parent, tcount) ; search in all possible parents 
     21           pi = sind[grid_info[cg].parent-1] 
     22           tcount = 1 
     23;           print, grid_info[b[pi[0]]].num, grid_info[cg].parent, pi[0], b[pi[0]],  
    2024 ;          print, tcount 
    2125           if tcount gt 0 then begin 
    22               pi  = b[pi] 
     26;              pi  = b[pi] 
    2327              p = grid_info[pi] 
    2428              c = grid_info[cg] 
     
    3741 
    3842function old_set_parent_start_end_indices, grid_info 
    39   print, 'start set_parent_start_end_indices' 
     43  print, 'start old_set_parent_start_end_indices' 
    4044  b =  0 
    4145  count = histogram(grid_info.level,reverse_indices=r) 
  • trunk/TOOLS/flash2/read_all_flash2_grid_hdf5.pro

    r36 r39  
    9393           dd = double(cg.right_edge-cg.left_edge)/ra 
    9494           d = ra 
     95           dims = N_elements(d) 
    9596           this_stride= (stride_defined) ? reform(stride[cnt,*]) : (intarr(n_elements(d)) + 1) 
    9697           this_start = (start_defined) ? reform(start[cnt,*]) : intarr(n_elements(d)) 
     
    138139               ratio = this_count/this_stride > 1 
    139140;                   if total(this_start lt d) ne 3 then continue 
    140                dims = N_elements(d) 
     141               dims = N_elements(d)-1 
    141142;               print, dims 
    142143               if n_elements(d) ne 1 then begin 
    143                   H5S_SELECT_HYPERSLAB, dataspace_id, [this_start[0:dims-2],cg.num-1], [ratio[0:dims-2],1], STRIDE=[this_stride[0:dims-2],1], /RESET   
     144                  H5S_SELECT_HYPERSLAB, dataspace_id, [this_start[0:dims-1],cg.num-1], [ratio[0:dims-1],1], STRIDE=[this_stride[0:dims-1],1], /RESET   
    144145                  memory_space_id = H5S_CREATE_SIMPLE([ratio,1])   
    145146                  data = H5D_READ(dsetid, FILE_SPACE=dataspace_id, MEMORY_SPACE=memory_space_id)   
     
    154155;breaki 
    155156            ENDELSE ; not special 
    156              
     157            d = d[0:dims-1] 
    157158            all[cnt].file_name   = gident 
    158159            all[cnt].np_total    = N_elements(data) 
    159160            s = size(data) 
    160161            if (s[0] eq 2) then s[3] = 1 
     162             
    161163            all[cnt].li[*]       = this_start[*] 
    162164            all[cnt].ri[*]       = (s[1:3]+this_start-1)[*] 
     
    166168            if fields[i] eq 'particle massdensity' then data *= product(dd) 
    167169;            print,  product(dd[where(d gt 0.)]),  'dd:', dd[where(d gt 0.)], 'where ',where(d gt 0.) 
     170;            breaki 
    168171            if fields[i] eq 'mass' then data *= product(dd[where(d gt 0.)]) 
    169172            all[cnt].Data[i]     = ptr_new(data, /no_copy) 
     173     if check_cancel() then goto, enough 
    170174          ENDFOR                 ; loop over patches 
    171175 
    172176     ENDFOR                     ; loop over fields 
    173  
     177enough: 
    174178     if notspecial then H5D_CLOSE, dsetid            
    175179     H5F_CLOSE, fid 
    176      if check_cancel() then goto, enough 
     180 
    177181  ENDFOR                        ; loop over unique files 
    178182; return information in the order grids and files were specified 
    179183  all = all[revind] 
    180 enough: 
     184 
    181185  RETURN 
    182186END 
  • trunk/TOOLS/get_data.pro

    r37 r39  
    99pro pack_as_list, use_g, a 
    1010; pack all data into 1D arrays  
    11    zero = 0.D 
     11   zero = -1e30 
    1212   zero_solution_under_subgrid, use_g, a, ZERO=zero 
    1313 
     
    153153end 
    154154 
     155function fn, aa, name 
     156@common_blocks.inc 
     157ind = where(strtrim(aa[0].data_fields,2) eq strtrim(name,2)) 
     158if ind[0] eq -1 then begin 
     159   pind = where(name eq *parti.names) 
     160   if pind[0] ne -1 then return, parti.d[pind] 
     161   print, 'no field with name >'+name+'< found in ', aa 
     162   return, 0 
     163endif 
     164 
     165Num = N_elements(aa) 
     166res = (*aa[0].data[ind[0]]) 
     167for i=1UL,Num-1 do res = [res,  (*aa[i].data[ind[0]])] 
     168return,  res 
     169end 
     170 
    155171function enclosed_gas_mass, cen,x,y,z, mass 
    156172x = x-cen[0] 
     
    162178;breaki 
    163179return,Menc 
    164 end 
    165  
    166 function fn, aa, name 
    167 @common_blocks.inc 
    168 ind = where(strtrim(aa[0].data_fields,2) eq strtrim(name,2)) 
    169 if ind[0] eq -1 then begin 
    170    pind = where(name eq *parti.names) 
    171    if pind[0] ne -1 then return, parti.d[pind] 
    172    print, 'no field with name >'+name+'< found in ', aa 
    173    return, 0 
    174 endif 
    175  
    176 Num = N_elements(aa) 
    177 res = (*aa[0].data[ind[0]]) 
    178 for i=1L,Num-1 do res = [res,  (*aa[i].data[ind[0]])] 
    179 return,  res 
    180180end 
    181181 
     
    190190*a[0].data[i] = Menc 
    191191help, menc 
     192mi = MIN(Menc, max=ma) 
     193print, 'min, max:', mi, ma 
    192194;breaki 
    193195return 
     
    610612;breaki 
    611613 
    612 print, 'RRAAAAAAAAAALLL' 
    613 help, ral 
     614;print, 'RRAAAAAAAAAALLL' 
     615;help, ral 
    614616   for j=0L,N_elements(a)-1 DO BEGIN 
    615617      heap_free, a[j].data[Nvar:*]  
  • trunk/TOOLS/get_units.pro

    r34 r39  
    163163        unitfactor = densityunit*lengthunit^3/1.989d33 
    164164        unitlabel = textoidl('M')+'!D!9n!X!N' 
     165        print, 'massunit:', unitfactor 
    165166     end 
    166167     (tlabel eq 'Dynamical time (gas)'): Begin 
  • trunk/TOOLS/grid_in_cube.pro

    r1 r39  
    1818  delta_distance = (grid_info.Right_edge - grid_info.Left_edge)/(index_range) 
    1919 
    20   suff_res = delta_distance[0,*] 
     20;  suff_res = delta_distance[0,*] 
    2121  suff_res = where(delta_distance[0,*] ge b) 
    2222;  print, suff_res 
    23   print, fix(total(suff_res gt 0)), ' grids have sufficient resolution for cube'  
    24   if total(suff_res gt 0) lt 1 THEN BEGIN 
     23  print, N_elements(suff_res), ' grids have sufficient resolution for cube'  
     24  if suff_res[0] lt 0 THEN BEGIN 
    2525      grid_in_cube = grid_info[0] 
    2626      RETURN, grid_in_cube 
     
    4040          (Left_edge[2,*]   lt max_right[2])          ) 
    4141 
    42   print, 'there are ', total(help),' grids at least partially in cube' 
     42  print, 'there are ', total(help),' grids of sufficient resolution at least partially in cube' 
    4343  if total(help) gt 1 then grid_in = new_i(where(help gt 0)) 
    4444  return, grid_in 
  • trunk/TOOLS/powerspectrum.pro

    r6 r39  
    368368if n_elements(average) ne 1 then average=spectrum 
    369369 
     370hist = histogram(rad, reverse_indices=r, min=0.+o-0.5, max=imax+o-0.499, nbins=imax, locations=obin) 
     371;breaki 
    370372if keyword_set(debug) then print,'looping over shells' 
    371373t0=systime(1) 
    372374for i=0L,imax-1 do begin                                ; cut the corners? 
    373   ii=where((rad ge i+o-.5) and (rad lt i+o+.5),nw)      ; indices into shell 
    374   if keyword_set(debug) and i le 10 then print,i,nw 
     375;  ii=where((rad ge i+o-.5) and (rad lt i+o+.5),nw)      ; indices into shell 
     376   ii = [r[r[i]:r[i+1]-1]]      ;Tom Abel 2010 use this to speed up routine use line above for original 
     377   nw = N_elements(ii) 
     378  if keyword_set(debug) and i le 12 then print,i,nw; , N_elements(ij) 
    375379  if s(0) eq 3 then begin 
    376380    tmp=ta(ii) & tmp=abs(temporary(tmp))^2              ; conserve memory 
     
    380384  end 
    381385  ka(i)=aver(rad(ii))                                   ; average wave number 
     386;  print, ka(i), aver(rad[ij]) 
    382387  if keyword_set(kindex) then ka(i)=i+plo 
    383388  if n_elements(average) ne 1 then begin                ; average array or not? 
     
    401406 
    402407if n_elements(c) gt 0 then begin 
    403   power3d,c,aver=aver,compensate=compensate,kindex=kindex,sp=sp1,/noplot,offset=o,potsdam=potsdam 
     408  power3d,c,aver=aver,compensate=compensate,kindex=kindex,sp=sp1,/noplot,offset=o,potsdam=potsdam,debug=debug 
    404409  spectrum=spectrum+sp1 
    405410end 
    406411if n_elements(b) gt 0 then begin 
    407   power3d,b,aver=aver,compensate=compensate,kindex=kindex,sp=sp1,/noplot,offset=o,potsdam=potsdam 
     412  power3d,b,aver=aver,compensate=compensate,kindex=kindex,sp=sp1,/noplot,offset=o,potsdam=potsdam,debug=debug 
    408413  spectrum=spectrum+sp1 
    409414end 
  • trunk/TOOLS/print_for_xmgr.pro

    r35 r39  
    1 pro print_for_xmgr, x,y, set=set, file=filename 
     1 pro print_for_xmgr, x,y, set=set, file=filename 
    22; 
    33; print out x and y values for to be read by xmgr 
    44; 
    5  
     5Nbins = N_elements(x) 
     6if N_elements(set) eq 0 then set=0 
    67if N_elements(filename) gt 0 then begin 
    78   openw, lun, filename, /get_lun, /APPEND 
Note: See TracChangeset for help on using the changeset viewer.