[AstroPy] Linearity correction by polynomial fitting

Joe Philip Ninan indiajoe@gmail....
Thu Apr 18 10:34:01 CDT 2013


I have a data cube, which is from an up-the-ramp readout of a detector.
(i.e. data cube with the axis X pixel,Y pixel and Time)
In order to fit a linearity correction function which maps from detector
counts to actual count, I was planning to fit a straight line on the time
axis (for each pixel), upto a threshold and then fit a 2 or 3 degree
polynomial to map the difference between the extrapolated straight line and
the non-linear counts of the pixel above the threshold (till it hits hard

Now, the issue: [I want to avoid any python loops.]
Calculating the slope and difference could be easily implemented by numpy
masked array multiplications and other ndarray arithmetic.
But I couldn't find anything for fitting a polynomial for every pixel along
an axis of an ndarray.
Is there a tool to do this? Without implementing a python loop to loop
through each pixel and calculate coefficients?
Worst case scenario, i think i will have to write a C routine to do
polynomial fit and call it from python. But i would really love if a pure
python alternative exists.


"GNU/Linux: because a PC is a terrible thing to waste" -  GNU Generation

Joe Philip Ninan    http://sites.google.com/site/jpninan/
Research Scholar        /________________\
DAA,                            | Vadakeparambil |
TIFR,                           | Pullad P.O.         |
Mumbai-05, India.      | Kerala, India      |
Ph: +917738438212   | PIN:689548       |
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/astropy/attachments/20130418/6e1fb794/attachment.html 

More information about the AstroPy mailing list