[ncl-talk] Using functions

Emma Andersson emma.andersson at chalmers.se
Thu Jan 15 03:35:20 MST 2015


Hi NCL-talk,

I’m having some trouble with a my own written function that I call within a loop. 

The function I’ve written converts quality flags from a satellite data set into an array of integers with zeros and ones.
The quality flags are given in ushort and corresponds to a 16-bit number. What I do is that I check each pixels
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
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, 
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.

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, 
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 
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 
the output in the main script after it being used? Would it be better to use a procedure instead of a function?

Kind regards,
Emma Andersson

-----------------------------------------------------------------------------------
PhD student
Global Environmental Measurement Techniques and Modelling
Earth and Space Sciences
Chalmers University of Technology
Gothenburg, Sweden
emma.andersson(at)chalmers.se <http://chalmers.se/>
-----------------------------------------------------------------------------------




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150115/df615b20/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: myfunctions.ncl
Type: application/octet-stream
Size: 1280 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150115/df615b20/attachment.obj 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150115/df615b20/attachment-0001.html 


More information about the ncl-talk mailing list