<div dir="ltr">this is the profile for a sample of 1000 elements<div><br></div><div><div>Fri Apr 11 10:21:21 2014    restats</div><div><br></div><div>         31594963 function calls in 103.708 seconds</div><div><br></div>
<div>   Ordered by: internal time</div><div>   List reduced from 47 to 20 due to restriction <20></div><div><br></div><div>   ncalls  tottime  percall  cumtime  percall filename:lineno(function)</div><div>        1   57.133   57.133  103.692  103.692 skymapsI.py:44(mymain)</div>
<div>   176832    9.898    0.000   11.710    0.000 interpolate.py:394(_call_linear)</div><div> 18101000    7.808    0.000    7.808    0.000 {method 'write' of 'file' objects}</div><div><br></div><div>  1237824    3.794    0.000    3.794    0.000 {numpy.core.multiarray.array}</div>
<div>  1001000    3.610    0.000   38.383    0.000 instruments.py:10(kappa)</div><div>   353664    3.314    0.000    3.314    0.000 {method 'reduce' of 'numpy.ufunc'</div><div>objects}</div><div>   176832    3.157    0.000    7.428    0.000 interpolate.py:454(_check_bounds)</div>
<div>   176832    2.074    0.000   10.213    0.000 interpolate.py:330(__init__)</div><div>   176832    2.053    0.000   21.522    0.000 interpolate.py:443(_evaluate)</div><div>   176832    1.253    0.000    4.404    0.000 polyint.py:82(_set_yi)</div>
<div>   176832    0.769    0.000    0.769    0.000 {method 'clip' of 'numpy.ndarray'</div><div>objects}</div><div>   353664    0.706    0.000    0.706    0.000 {method 'reshape' of 'numpy.ndarra</div>
<div>y' objects}</div><div>   353664    0.667    0.000    1.205    0.000 numerictypes.py:735(issubdtype)</div><div>   707328    0.637    0.000    2.451    0.000 numeric.py:392(asarray)</div><div>   176832    0.601    0.000   23.555    0.000 polyint.py:37(__call__)</div>
<div>   353664    0.569    0.000    3.883    0.000 _methods.py:31(_any)</div><div>   176832    0.504    0.000    1.429    0.000 polyint.py:74(_reshape_yi)</div><div>   176832    0.473    0.000    0.473    0.000 {method 'searchsorted' of 'numpy.n</div>
<div>darray' objects}</div><div>   176832    0.440    0.000    1.645    0.000 polyint.py:102(_set_dtype)</div><div>   176832    0.426    0.000    4.830    0.000 polyint.py:30(__init__)</div><div><br></div></div><div>thanks</div>
<div><br></div><div>Gabriele</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-04-11 10:18 GMT-04:00 Gabriele Brambilla <span dir="ltr"><<a href="mailto:gb.gabrielebrambilla@gmail.com" target="_blank">gb.gabrielebrambilla@gmail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">ok<div>modifying the for in this way (zipping an array of matrix drive it crazy) it works</div><div><br>
<div><div>dko=0</div><div><br></div><div>                for gammar in gmils:        </div><div class=""><div><br></div>
<div>                        </div><div>                        omC = (1.5)*(gammar**3)*c/(rho*rlc)</div><div><br></div><div>                        gig = omC*hcut/eVtoErg         </div><div><br></div><div>                                           </div>

<div>                #check the single emission</div><div><br></div><div>                                       </div><div><br></div><div>                        for w in eel:        </div><div><br></div><div>                                omega = (10**(w*stepENE+Lemin))*eVtoErg/hcut       </div>

<div><br></div><div>                                x = omega/omC</div><div><br></div><div>                                kap = instruments.kappa(x)                </div><div><br></div><div>                                Iom = (1.732050808/c)*(e**2)*gammar*kap #jackson dI/domega</div>

<div><br></div><div>                                P = Iom*(c/(rho*rlc))/(2*pi) #jackson P</div><div><br></div><div>                                phps = P/(hcut*omega) #photons per second</div><div><br></div><div>                                www =  phps/(stepPHA*sin(zobs)*stepOB) </div>

<div><br></div></div><div>                                MYMAPS[dko][i,j,w] += www</div><div>                                </div><div>                        dko += 1 </div><div class=""><div><br></div><div>                        </div>
<div>
<br></div><div>                count = count + 1</div><div><br></div></div><div>Now I will tell you how  much it takes.</div><div><br></div><div>Thanks</div><div><br></div><div>Gabriele</div><div>                </div></div>
</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-04-11 10:05 GMT-04:00 Gabriele Brambilla <span dir="ltr"><<a href="mailto:gb.gabrielebrambilla@gmail.com" target="_blank">gb.gabrielebrambilla@gmail.com</a>></span>:<div>
<div class="h5"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">ok, it seems that the code don't enter in this for loop<div><div><span style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px"><br>

</span></div><div><span style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px">for gammar, MYMAP in zip(gmlis, MYMAPS): </span><br>
</div><div><span style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px"><br></span></div></div><div><span style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px">I don't understand why.</span></div>


<div><span style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px">Thanks</span></div><div><span style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px"><br>


</span></div><div><span style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px">Gabriele</span></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-04-11 9:56 GMT-04:00 Gabriele Brambilla <span dir="ltr"><<a href="mailto:gb.gabrielebrambilla@gmail.com" target="_blank">gb.gabrielebrambilla@gmail.com</a>></span>:<div>

<div><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi, I'm sorry but there is a big problem.<div>the code is producing empty file.dat.</div><div><br></div>


<div>I think it's because of this that previously I have done that strange trick of myinternet...</div>
<div><br></div><div>So:</div><div><br></div><div>for my_line in open('data.dat'):</div><div><div><br></div><div>                myinternet = []                </div><div><br></div><div>                gmlis = []        </div>



<div><br></div><div>                print('reading the line', count, '/599378')        </div><div><br></div><div>                my_parts = [float(i) for i in my_line.split()]</div><div><br></div><div>                phase = my_parts[4]</div>



<div><br></div><div>                zobs = my_parts[5]</div><div><br></div><div>                rho = my_parts[6]</div><div><br></div><div>        </div><div><br></div></div><div>                gmils=[my_parts[7], my_parts[8], my_parts[9], my_parts[10], my_parts[11]]</div>


<div>
<div><br></div><div>                </div><div><br></div><div>                i = int((phase-phamin)/stepPHA)        </div><div><br></div><div>                j = int((zobs-obamin)/stepOB)</div><div><br></div><div>                </div>



<div><br></div></div><div><div>                for gammar, MYMAP in zip(gmlis, MYMAPS):        </div><div><br></div><div>                </div><div><br></div></div><div><div>                        omC = (1.5)*(gammar**3)*c/(rho*rlc)</div>


<div>
<br></div><div>                        gig = omC*hcut/eVtoErg         </div><div><br></div></div><div>                #check the single emission</div><div><div><br></div><div>                                       </div>


<div><br></div>
<div>                        for w in eel:        </div><div><br></div><div>                                omega = (10**(w*stepENE+Lemin))*eVtoErg/hcut       </div><div><br></div><div>                                x = omega/omC</div>



<div><br></div><div>                                kap = instruments.kappa(x)                </div><div><br></div></div><div>                                Iom = (1.732050808/c)*(e**2)*gammar*kap #jackson dI/domega</div>


<div>
<br></div><div>                                P = Iom*(c/(rho*rlc))/(2*pi) #jackson P</div><div><br></div><div>                                phps = P/(hcut*omega) #photons per second</div><div><br></div><div>                                www =  phps/(stepPHA*sin(zobs)*stepOB) </div>



<div><br></div><div>                                MYMAP[i,j,w] += www </div><div><div><br></div><div>                        </div><div><br></div><div>                count = count + 1</div><div><br></div></div>
<div>when I exit here the MYMAP matrix has all the cells = 0.</div>
<div><br></div><div>Now I will try to fiugre it out why.</div><div><br></div><div>Thanks</div><div><br></div><div>Gabriele</div><div>         </div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-04-11 9:20 GMT-04:00 Gabriele Brambilla <span dir="ltr"><<a href="mailto:gb.gabrielebrambilla@gmail.com" target="_blank">gb.gabrielebrambilla@gmail.com</a>></span>:<div>


<div><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Danny,<div>I'm quiet impressed.</div><div>the program takes near 30 minutes instead of more than 8 hours!</div>



<div><br></div><div>this is the profile:</div><div><div>Fri Apr 11 09:14:04 2014    restats</div>
<div><br></div><div>         19532732 function calls in 2105.024 seconds</div><div><br></div><div>   Ordered by: internal time</div><div><br></div><div><div>   ncalls  tottime  percall  cumtime  percall filename:lineno(function)</div>




</div><div>        1 2087.606 2087.606 2105.006 2105.006 skymapsI.py:44(mymain)</div><div> 18101000   12.757    0.000   12.757    0.000 {method 'write' of 'file' objects}</div><div><br></div><div>   715853    3.473    0.000    3.473    0.000 {method 'split' of 'str' objects}</div>




<div>   715854    1.162    0.000    1.162    0.000 {zip}</div><div>        1    0.018    0.018 2105.024 2105.024 <string>:1(<module>)</div><div>        6    0.006    0.001    0.006    0.001 {open}</div><div>        5    0.002    0.000    0.002    0.000 {method 'close' of 'file' objects}</div>




<div><br></div><div>        1    0.000    0.000    0.000    0.000 function_base.py:8(linspace)</div><div><div>        5    0.000    0.000    0.000    0.000 {numpy.core.multiarray.zeros}</div></div><div>        1    0.000    0.000    0.000    0.000 function_base.py:93(logspace)</div>




<div>        1    0.000    0.000    0.000    0.000 {numpy.core.multiarray.arange}</div><div>        3    0.000    0.000    0.000    0.000 {range}</div><div><div>        1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Prof</div>




<div>iler' objects}</div></div></div><div><br></div><div>I hope to have similar problems in the future to learn better how to do with them!</div><div>but in the profile I don't see any operation regarding reading the file or the mathematical operations...are them hidden in mymain()?</div>




<div><br></div><div>thanks</div><div><br></div><div>Gabriele</div><div> </div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-04-10 21:38 GMT-04:00 Danny Yoo <span dir="ltr"><<a href="mailto:dyoo@hashcollision.org" target="_blank">dyoo@hashcollision.org</a>></span>:<div>



<div><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>> Comment:  You are looping over your sliced eel five times.  Do you<br>
>    need to?  I like eel salad a great deal, as well, but, how about:<br>
><br>
><br>
>        for k in eel:<br>
>            MYMAP1[i, j, k] = MYMAP1[i, j, k] + myinternet[oo]<br>
>            MYMAP2[i, j, k] = MYMAP2[i, j, k] + myinternet[oo]<br>
>            MYMAP3[i, j, k] = MYMAP3[i, j, k] + myinternet[oo]<br>
>            MYMAP4[i, j, k] = MYMAP4[i, j, k] + myinternet[oo]<br>
>            MYMAP5[i, j, k] = MYMAP5[i, j, k] + myinternet[oo]<br>
>            oo = oo + 1<br>
<br>
<br>
</div>Hi Gabriele,<br>
<br>
Also note that, when Martin looked at this part of the code, he<br>
unfortunately misinterpreted its effect; Martin's proposed rewrite<br>
here does not preserve the meaning of the original code.  But rather<br>
than wag my finger at how Martin interpreted the code, I'd rather make<br>
the observation that this is a warning sign that the original code<br>
here was not easy to understand.<br>
</blockquote></div></div></div><br></div>
</blockquote></div></div></div><br></div>
</blockquote></div></div></div><br></div>
</blockquote></div></div></div><br></div>
</blockquote></div><br></div>