comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » help on optimization
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
help on optimization [message #76687] Thu, 23 June 2011 02:38
stefania is currently offline  stefania
Messages: 1
Registered: June 2011
Junior Member
Hi all,
I am writing a piece of code that is supposed to provide stacked
differential surface mass density profiles (Sigma(<r)-Sigma(r)). What
I have now it works but is way too slow since I will have to use it to
repeat the stacking ~10^5 times...
What I think can be optimized is the part of code which is doing the
following:
-select particles within a distance
-do the profile by histogramming the particles in radial bins
-sum the mass of the particles in each bin (each particle has a
different mass)

for i=0,nhalos do begin
;Pre-select only particles at a reasonable distance
jj=where((xrand[i]-file_gaspos(0,*))^2 lt 100. and (yrand[i]-
file_gaspos(1,*))^2 lt 100. )
;Distance of particles to the halo
dis=(xrand[i]-file_gaspos(0,jj))*(xrand[i]-file_gaspos(0,jj) )+
(yrand[i]-file_gaspos(1,jj))*(yrand[i]-file_gaspos(1,jj))
dis=sqrt(dis)
;histogram distances within 10Mpc
ind_gas=where(dis lt 10.)
gasmass=file_gasmass[jj[ind_gas]]
hist = histogram(dis[ind_gas],
binsize=bin_mpc,locations=xhist,reverse_indices=ri)

for ll=0,n_elements(xhist)-1 do begin
gasm[ll]=total(file_gasmass[jj[ind_gas[ ri[ ri[ll]:ri[ll
+1]-1 ] ]]])
gasm_cum[ll]=total(file_gasmass[jj[ind_gas[ ri[ ri[0]:ri[ll
+1]-1 ] ]]])
endfor
ymin_r_gas+=(gasm_cum) ; Sigma(<r)
yplot_gas+=(gasm) ; Sigma(r)
endfor

Any help/idea/feedback will be very useful!
Thanks
Stefania
[Message index]
 
Read Message
Previous Topic: Re: Xrange and yrange on log plots
Next Topic: Re: help on optimization

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:42:09 PDT 2025

Total time taken to generate the page: 0.00344 seconds