<br><br><div class="gmail_quote">On Tue, Jun 30, 2009 at 12:31 PM, Russell E. Owen <span dir="ltr"><<a href="mailto:rowen@u.washington.edu">rowen@u.washington.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
In article<br>
<<a href="mailto:e06186140906291710s34865590p38032012f12d0f60@mail.gmail.com">e06186140906291710s34865590p38032012f12d0f60@mail.gmail.com</a>>,<br>
<div class="im"> Charles R Harris <<a href="mailto:charlesr.harris@gmail.com">charlesr.harris@gmail.com</a>> wrote:<br>
<br>
> On Mon, Jun 29, 2009 at 4:17 PM, Russell E. Owen<br>
> <<a href="mailto:rowen@u.washington.edu">rowen@u.washington.edu</a>>wrote:<br>
><br>
> > In article<br>
> > <<a href="mailto:e06186140906291429m3cb339e8ge298f179d811e8a7@mail.gmail.com">e06186140906291429m3cb339e8ge298f179d811e8a7@mail.gmail.com</a>>,<br>
> > Charles R Harris <<a href="mailto:charlesr.harris@gmail.com">charlesr.harris@gmail.com</a>> wrote:<br>
> ><br>
> > > On Mon, Jun 29, 2009 at 3:03 PM, Russell E. Owen<br>
> > > <<a href="mailto:rowen@u.washington.edu">rowen@u.washington.edu</a>>wrote:<br>
> > ><br>
> > > > I have an old Numarray C extension (or, rather, a Python package<br>
> > > > containing a C extension) that I would like to convert to numpy<br>
> > > > (in a way that is likely to be supported long-term).<br>
> > ><br>
</div><div class="im">> > > How big is the extension and what does it do?<br>
> ><br>
> > It basically contains 2 functions:<br>
> > 1: radProfile: given a masked image (2d array), a radius and a desired<br>
> > center: compute a new 1d array whose value at index r is the sum of all<br>
> > unmasked pixels at radius r.<br>
> ><br>
> > 2: radAsymm: given the same inputs as radProfile, return a (scalar)<br>
> > measure of radial asymmetry by computing the variance of unmasked pixels<br>
> > at each radius and combining the results.<br>
> ><br>
> > The original source file is about 1000 lines long, of which 1/3 to 1/2<br>
> > is the basic C code and the rest is Python wrapper.<br>
><br>
> It sounds small enough that you should be able to update it to the numpy<br>
> interface. What functions do you need? You should also be able to attach a<br>
> copy (zipped) if it is small enough, which might help us help you.<br>
<br>
</div>It is the PyGuide package<br>
<<a href="http://www.astro.washington.edu/rowen/PyGuide/files/PyGuide.zip" target="_blank">http://www.astro.washington.edu/rowen/PyGuide/files/PyGuide.zip</a>><br>
a 525k zip file. The extension code is in the src directory.<br>
<br>
I would certainly be grateful for any pointers to how the old numarray C<br>
API functions map to the new numpy ones. I would prefer to use the new<br>
numpy API if I can figure out what to do.<br>
<div><div></div><div class="h5"></div></div></blockquote><div><br>This doesn't look too bad, I only count 5 functions/macros.<br><br>NA_InputArray<br>NA_OutputArray<br>NA_ShapeEqual<br>NA_NewArray<br>NA_OFFSETDATA<br>
<br>The quick and dirty solution would be to just copy those functions in at the top of your code. You might want to fix up the NumarrayType enum instead of including it and a few other such.<br><br>The code looks like it would go over into cython fairly nicely since it is split between interface code, which would look good in python, and a couple of pure c functions. If you have the time that might be a good way to go.<br>
<br>Chuck<br></div><br></div><br>