[SciPy-dev] Module Submission: Orthogonal Distance Regression
eric jones
eric at enthought.com
Tue Nov 19 10:38:19 EST 2002
Hey Robert,
Thanks for the submission!
I had to make a few changes to setup.py and test.py to get it flying on
windows. The diffs are below.
Here's a change summary:
I turned off blas optimization, stuck an import of mingw32_support at
the top of the file, and changed the odr package path from '' to '.'.
On test.py, there as a syntax error on line 64 -- it needed a line
continuation character.
As we move forward with this, should we group the odr tools in a package
with other data fitting tools such as leastsq fit, spline fits, etc.?
While they use different methods, they all serve similar purposes.
eric
-----------------------------------------------------------------------
C:\third\odr-0.6>diff -c setup.py setup_eric.py
*** setup.py Sun Nov 10 01:28:40 2002
--- setup_eric.py Tue Nov 19 09:16:19 2002
***************
*** 13,24 ****
# separately-compiled LINPACK. Edit the Extension instances
# below to reflect where your libraries are.
! opt_blas = 1
# We need to compile FORTRAN files, so check if we would be
# using gcc anyways: then we can use g77 with impunity.
# Man, this is such a hack. I'm really, really sorry.
!
cc = new_compiler()
sysconfig.customize_compiler(cc)
--- 13,24 ----
# separately-compiled LINPACK. Edit the Extension instances
# below to reflect where your libraries are.
! opt_blas = 0
# We need to compile FORTRAN files, so check if we would be
# using gcc anyways: then we can use g77 with impunity.
# Man, this is such a hack. I'm really, really sorry.
! from scipy_distutils import mingw32_support
cc = new_compiler()
sysconfig.customize_compiler(cc)
***************
*** 104,110 ****
# platforms=["POSIX", "Windows"],
packages=['odr'],
! package_dir={'odr': ''},
ext_modules=[ext]
)
--- 104,110 ----
# platforms=["POSIX", "Windows"],
packages=['odr'],
! package_dir={'odr': '.'},
ext_modules=[ext]
)
-----------------------------------------------------------------------
C:\third\odr-0.6\test>diff -c test.py test_eric.py
*** test.py Sun Nov 10 04:26:08 2002
--- test_eric.py Tue Nov 19 09:18:50 2002
***************
*** 61,67 ****
# Implicit Example
def impl_fcn(B, x, power=power):
! return B[2]*power(x[0]-B[0], 2) + 2.0*B[3]*(x[0]-B[0])*(x[1]-B[1])
+
B[4]*power(x[1]-B[1], 2) - 1.0
impl_mod = Model(impl_fcn, implicit=1, meta={'name': 'Sample Implicit
Model',
--- 61,67 ----
# Implicit Example
def impl_fcn(B, x, power=power):
! return B[2]*power(x[0]-B[0], 2) + 2.0*B[3]*(x[0]-B[0])*(x[1]-B[1])
+ \
B[4]*power(x[1]-B[1], 2) - 1.0
impl_mod = Model(impl_fcn, implicit=1, meta={'name': 'Sample Implicit
Model',
----------------------------------------------
eric jones 515 Congress Ave
www.enthought.com Suite 1614
512 536-1057 Austin, Tx 78701
> -----Original Message-----
> From: scipy-dev-admin at scipy.net [mailto:scipy-dev-admin at scipy.net] On
> Behalf Of Robert Kern
> Sent: Tuesday, November 19, 2002 12:29 AM
> To: scipy-dev at scipy.org
> Subject: [SciPy-dev] Module Submission: Orthogonal Distance Regression
>
> Some time ago, I wrote an extension module to use ODRPACK, a FORTRAN
> library that performs Orthogonal Distance Regression (ODR) as well as
> non-linear Ordinary Least-Squares (OLS) and implicit regression
(fitting
> to, say, an ellipse).
>
> ODRPACK is very flexible. It can handle multi-dimensional input
> and output variables, weighted observations (with correlations between
> dimensions). It solves the ODR problem, i.e. finding "parameter
> estimates that minimize the sum of the squares of the weighted
> orthogonal distances between each observed data point and the curve
> described by a nonlinear equation" [1] as well as the nonlinear OLS
> problem, where uncertainties on the input variables are assumed to be
> negligible. Further, the model equation can be implicit, e.g.
> x0^2+x1^2-r^2 = 0 will fit the data to a circle and estimate the
radius.
> ODRPACK will estimate the uncertainties and covariances of the
estimated
> parameters. ODRPACK has a flexible reporting system to generate
reports
> on all stages of the computation.
>
> SciPy issues:
> I have wrapped the base extension module in a set of classes to
> facilitate the handling of all the options. These classes model my use
> of the module: fitting experimental data and fiddling on the
interactive
> interpreter to get it right. Perhaps this is leads to a cumbersome
API,
> or another needs to be exposed in addition.
>
> I believe I have followed the SciPy style guide except for the
classes,
> which are MixedCase.
>
> I think the docstrings are pretty thorough, but I might need to write
a
> tutorial to get people jump-started.
>
> Tests: I have tests based on ODRPACK's FORTRAN examples and some of my
> own data. They are not in unittest form yet, nor do they completely
> cover all features. ODRPACK comes with a comprehensive FORTRAN
testsuite
> which could be converted to Python, but it will be a fair bit of work.
>
> I use Numeric's LinearAlgebra to do a matrix inversion. If adopted
into
> SciPy, that would change to scipy.inv .
>
> Availability:
> http://starship.python.net/crew/kernr/source/odr-0.6.tar.gz
> License:
> Public Domain
>
> References:
> [1] http://www.boulder.nist.gov/mcsd/Staff/JRogers/odrpack.html
>
> ODRPACK comes from http://www.netlib.org/odrpack/index.html and is
> public domain.
>
> --
> Robert Kern
> Ruddock House President
> kern at caltech.edu
>
> "In the fields of hell where the grass grows high
> Are the graves of dreams allowed to die."
> -- Richard Harter
> _______________________________________________
> Scipy-dev mailing list
> Scipy-dev at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-dev
More information about the SciPy-Dev
mailing list