<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi NCL-talk,<div class=""><br class=""></div><div class="">I’m having some trouble with a my own written function that I call within a loop.&nbsp;</div><div class=""><br class=""></div><div class="">The function I’ve written converts quality flags from a satellite data set into an array of integers with zeros and ones.</div><div class="">The quality flags are given in ushort and corresponds to a 16-bit number. What I do is that I check each pixels</div><div class="">bit number if certain flags has been set. I compare with a reference bit number which contains the flags that I don’t want to be set</div><div class="">and then determines whether my new array value should be set to a one or a zero. I have basically written a kind of “bitand” function,&nbsp;</div><div class="">where if the output from the comparison are all zeros then I set my new array value to zero. I hope this description was understandable.</div><div class=""><br class=""></div><div class="">What happens when I call my function from a main script, is that it goes slower and slower for each step in the loop. My question is,&nbsp;</div><div class="">why it goes slower? Is something accumulating inside the function for each time I call it? I’m quite sure it doesn’t accumulate outside&nbsp;</div><div class="">in the main script, because I did some print statements inside the function and it was clearly there it was going slower. I also delete&nbsp;</div><div class="">the output in the main script after it being used? Would it be better to use a procedure instead of a function?</div><div class=""><br class=""></div><div class="">Kind regards,</div><div class="">Emma Andersson</div><div class=""><br class=""></div><div class=""><div class="">-----------------------------------------------------------------------------------</div><div class="">PhD student</div><div class="">Global Environmental Measurement Techniques and Modelling</div><div class="">Earth and Space Sciences</div><div class="">Chalmers University of Technology</div><div class="">Gothenburg, Sweden</div><div class="">emma.andersson(at)<a href="http://chalmers.se" class="">chalmers.se</a></div><div class=""><div class="">-----------------------------------------------------------------------------------</div><div class=""><br class=""></div></div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""></div></body></html>