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

Home » Public Forums » archive » Re: 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
Re: help on optimization [message #76685 is a reply to message #76684] Thu, 23 June 2011 05:44 Go to previous message
Wout De Nolf is currently offline  Wout De Nolf
Messages: 194
Registered: October 2008
Senior Member
On Thu, 23 Jun 2011 02:38:00 -0700 (PDT), stefania
<stefania.giodini@gmail.com> wrote:

> Any help/idea/feedback will be very useful!


1. I don't think the preselection speeds things up, so skip it.

2. Avoid using WHERE by specifying a MAX in histogram (use 100^ to
avoid SQRT).

3. Remove some redundancy in total / cumulative total.


xgaspos=file_gaspos[0,*]
ygaspos=file_gaspos[1,*]

for i=0,nhalos do begin
;Distance of particles to the halo
dis2=(xrand[i]-xgaspos)^2+(yrand[i]-ygaspos)^2

;histogram distances within 10Mpc
hist =histogram(dis2[ind_gas],binsize=bin_mpc,$
max=10000,reverse_indices=ri)

gasmass=file_gasmass[ind_gas]
for ll=0,n_elements(hist)-1 do $
if ri[ll] eq ri[ll+1] then gasm[ll]=0 $
else gasm[ll]=total(gasmass[ ri[ ri[ll]:ri[ll+1]-1 ] ])

ymin_r_gas+=total(gasm,/cumul,/pres) ; Sigma(<r)
yplot_gas+=gasm ; Sigma(r)
endfor


4. You can think of calculating "dis" outside the loop but it depends
on how many columns file_gaspos has (memory issues). Assume xrand en
yrand are row vectors:

dis=sqrt((rebin(xrand,nhalos,np,/sample)-rebin(file_gaspos[0 ,*],nhalos,np,/sample))^2+$

(rebin(yrand,nhalos,np,/sample)-rebin(file_gaspos[1,*],nhalo s,np,/sample))^2)

You can also devide nhalos in smaller chunks. However you still need
to do the histogram and mass summation for each column separatly.
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: help on optimization
Next Topic: New Graphics Reference Arrow

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

Current Time: Sun Oct 12 00:02:04 PDT 2025

Total time taken to generate the page: 0.00991 seconds