odr weighted residuals
Hi, this is probably a question for Robert but other people might be interested in this as well, so here it goes: Does odr support weighted residuals such that data points which are far away from the bulk of points have small weights? I could think of doing that externally by running odr once, looking at the residuals, calculating new weigths and restarting the fit but of course I'd prefer to not to do it like this. Regards, Christian
Christian Kristukat wrote:
Hi, this is probably a question for Robert but other people might be interested in this as well, so here it goes:
Does odr support weighted residuals such that data points which are far away from the bulk of points have small weights?
Nope. Whatever else ODR is, it's still least-squares. In order to do what you want, you will have to resort to iterated reweighting (Google for algorithms) or some other scheme that is built on top of least-squares. Or you can construct the appropriate non-linear optimization problem directly and use one of the fmin*() functions. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco
Robert Kern wrote:
Christian Kristukat wrote:
Hi, this is probably a question for Robert but other people might be interested in this as well, so here it goes:
Does odr support weighted residuals such that data points which are far away from the bulk of points have small weights?
Nope. Whatever else ODR is, it's still least-squares. In order to do what you want, you will have to resort to iterated reweighting (Google for algorithms) or some other scheme that is built on top of least-squares. Or you can construct the appropriate non-linear optimization problem directly and use one of the fmin*() functions.
Ok, thanks. I think I'll better remove the bad data points, but just for curiosity: when using optimize.leastsq you have to provide the residuals. Can't odr modified to calculate the residuals externally or would that break the algorithm? Christian
Christian Kristukat wrote:
Robert Kern wrote:
Hi, this is probably a question for Robert but other people might be interested in this as well, so here it goes:
Does odr support weighted residuals such that data points which are far away from the bulk of points have small weights? Nope. Whatever else ODR is, it's still least-squares. In order to do what you want, you will have to resort to iterated reweighting (Google for algorithms) or some other scheme that is built on top of least-squares. Or you can construct
Christian Kristukat wrote: the appropriate non-linear optimization problem directly and use one of the fmin*() functions.
Ok, thanks. I think I'll better remove the bad data points, but just for curiosity: when using optimize.leastsq you have to provide the residuals. Can't odr modified to calculate the residuals externally or would that break the algorithm?
It sort of breaks the algorithm of optimize.leastsq(), too. And no, it can't. One of the things that ODR does for you is calculate the minimum orthogonal distance (residual) from your data points and the function. If you could calculate those orthogonal residuals, you wouldn't need ODRPACK; you could just use optimize.leastsq(). -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco
Soon I'm going to need to interface my experiment to my computer. Can any one suggest any python tools that might exist? I've been googling for abour an hour, and haven't come up with anything. I can't afford LabView at the moment, and besides, I've never used it so it doesn't have the advantage of familiarity. I don't need a graphical environment. At first the equipment will be very simple: a couple of photodiodes, an A/D converter, perhaps a stepper motor controler. Any hints are welcome. If this strikes you as noise, please accept my apology. Thanks, gary
I'm not sure how much this helps- pyserial and pyparallel are packages for interfacing with hardware via the serial and parallel ports. If you use the Enthought disto of Python, it includes pyserial. Bryce Gary Pajer wrote:
Soon I'm going to need to interface my experiment to my computer.
Can any one suggest any python tools that might exist? I've been googling for abour an hour, and haven't come up with anything.
I can't afford LabView at the moment, and besides, I've never used it so it doesn't have the advantage of familiarity. I don't need a graphical environment. At first the equipment will be very simple: a couple of photodiodes, an A/D converter, perhaps a stepper motor controler.
Any hints are welcome. If this strikes you as noise, please accept my apology.
Thanks, gary
_______________________________________________ SciPy-user mailing list SciPy-user@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-user
Was this mentioned? <http://pyvisa.sourceforge.net/> Gary R. Bryce Hendrix wrote:
I'm not sure how much this helps- pyserial and pyparallel are packages for interfacing with hardware via the serial and parallel ports. If you use the Enthought disto of Python, it includes pyserial.
Bryce
Gary Pajer wrote:
Soon I'm going to need to interface my experiment to my computer.
Can any one suggest any python tools that might exist? I've been googling for abour an hour, and haven't come up with anything.
I can't afford LabView at the moment, and besides, I've never used it so it doesn't have the advantage of familiarity. I don't need a graphical environment. At first the equipment will be very simple: a couple of photodiodes, an A/D converter, perhaps a stepper motor controler.
Any hints are welcome. If this strikes you as noise, please accept my apology.
Thanks, gary
Hi Gary, There are a number of options, but they are hardware and/or OS dependent. On linux, the 700 pound gorilla is comedi. This supports lots of hardware and has a Python interface. (Last I checked, however, they did not support the nice and inexpensive Measurement Computing USB devices. I have some useful-for-me but not polished linux wrappers for these devices based on Warren Jasper's GPL-licensed C libraries.) On Windows, there are various Python wrappers for the manufacturer-provided C API for at least National Instruments (last I checked) and Measurement Computing (I "maintain" this one, called PyUniversalLibrary). Bryce is right that pyserial and pyparallel are great for serial and parallel, if that's all you need. Let me know if you need any more info. Cheers, Andrew Gary Pajer wrote:
Soon I'm going to need to interface my experiment to my computer.
Can any one suggest any python tools that might exist? I've been googling for abour an hour, and haven't come up with anything.
I can't afford LabView at the moment, and besides, I've never used it so it doesn't have the advantage of familiarity. I don't need a graphical environment. At first the equipment will be very simple: a couple of photodiodes, an A/D converter, perhaps a stepper motor controler.
Any hints are welcome. If this strikes you as noise, please accept my apology.
Thanks, gary
_______________________________________________ SciPy-user mailing list SciPy-user@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-user
I have used these under OS X and linux (ctypes used to access their libraries). I have used them for UI mockups, so I am not sure how well they can be calibrated for laboratory use, but if you don't need super accuracy they would probably work. http://www.phidgets.com/ On Aug 22, 2006, at 8:21 AM, Gary Pajer wrote:
Soon I'm going to need to interface my experiment to my computer.
Can any one suggest any python tools that might exist? I've been googling for abour an hour, and haven't come up with anything.
I can't afford LabView at the moment, and besides, I've never used it so it doesn't have the advantage of familiarity. I don't need a graphical environment. At first the equipment will be very simple: a couple of photodiodes, an A/D converter, perhaps a stepper motor controler.
Any hints are welcome. If this strikes you as noise, please accept my apology.
Thanks, gary
_______________________________________________ SciPy-user mailing list SciPy-user@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-user
Do you already have the a/d board? If so, what is it? By some strange coincidence, I've just been working with exactly that problem - three times. In one, I used an ancient, obsolete ISA board on an ancient, obsolete computer with Linux, comedi, swig, and Python. For the other two, I had windows .dll files, and was able to use c_types with Python to interface directly. One was Ethernet, the other was USB. For the USB device (Measurement Computing USB1208) the first part looks like: from ctypes import * # Load the cbw32.DLL file cbw = windll.LoadLibrary('c:\\MCC\\cbw32.dll') # Define the appropriate c_types RevNum = c_float(0) VxDRevNum = c_float(0) BoardNum = c_int(0) .... and so on. Then: err = cbw.cbAIn (BoardNum, Chan, Gain, byref(DataValue)) if err != 0: print "a/d error ", DataValue, err ... and the like. Really very very easy. I love Python. I can give you more details, if you're interested. john Gary Pajer wrote:
Soon I'm going to need to interface my experiment to my computer.
Can any one suggest any python tools that might exist? I've been googling for abour an hour, and haven't come up with anything.
I can't afford LabView at the moment, and besides, I've never used it so it doesn't have the advantage of familiarity. I don't need a graphical environment. At first the equipment will be very simple: a couple of photodiodes, an A/D converter, perhaps a stepper motor controler.
Any hints are welcome. If this strikes you as noise, please accept my apology.
Thanks, gary
_______________________________________________ SciPy-user mailing list SciPy-user@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-user
John Hassler wrote:
For the USB device (Measurement Computing USB1208) the first part looks like: from ctypes import *
Dear John, I would like to make the next version of PyUniversalLibrary use ctypes (instead of pyrex). Due to time constraints, this is not on my immediate-to-do list, so I have no idea when, if ever, it will happen. If you ever get around to the attempt to make a complete API wrapper for UniversalLibrary, please contact me so we can hopefully collaborate. I will do the same. Cheers! Andrew
Dear John, I believe PyUL now has analog output. You must have grabbed an older version. I'm of a different opinion about no wrapper being needed. Although I want the Python API to be as close as possible to the C API, I don't think one should be forced to manually check for errors when calling from Python. Thus, the wrapper would essentially do nothing except call the C function and check for errors. Small, simple, and nearly trivial, yes. But still a wrapper, nevertheless. And like you say, ctypes makes this very easy and that's what the next version will be based on. John Hassler wrote:
I looked at your PyUL, and would have used it, if it had had analog output. Since it didn't, I started looking deeper into the problem, and figured out that you could just use c_types. There's no "wrapper" needed, really ... once you define the .dll, then you just use the UL calls, as-is.
I'll be glad to show you what I've done, but really, there's nothing complex about it. john
Andrew Straw wrote:
John Hassler wrote:
For the USB device (Measurement Computing USB1208) the first part looks like: from ctypes import *
Dear John,
I would like to make the next version of PyUniversalLibrary use ctypes (instead of pyrex). Due to time constraints, this is not on my immediate-to-do list, so I have no idea when, if ever, it will happen. If you ever get around to the attempt to make a complete API wrapper for UniversalLibrary, please contact me so we can hopefully collaborate. I will do the same.
Cheers! Andrew _______________________________________________ SciPy-user mailing list SciPy-user@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-user
------------------------------------------------------------------------
_______________________________________________ SciPy-user mailing list SciPy-user@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-user
John Hassler wrote:
Do you already have the a/d board? If so, what is it?
Thanks to all who replied. Fabulously helpful. I placed an order for a NI USB-6009 just minutes before checking my e-mail. Not too late to cancel it if my "support group" is using Measurement Computing. (the choice was a toss-up)
By some strange coincidence, I've just been working with exactly that problem - three times. In one, I used an ancient, obsolete ISA board on an ancient, obsolete computer with Linux, comedi, swig, and Python. For the other two, I had windows .dll files, and was able to use c_types with Python to interface directly. One was Ethernet, the other was USB.
For the USB device (Measurement Computing USB1208) the first part looks like: from ctypes import *
# Load the cbw32.DLL file cbw = windll.LoadLibrary('c:\\MCC\\cbw32.dll')
# Define the appropriate c_types RevNum = c_float(0) VxDRevNum = c_float(0) BoardNum = c_int(0) .... and so on. Then: err = cbw.cbAIn (BoardNum, Chan, Gain, byref(DataValue)) if err != 0: print "a/d error ", DataValue, err ... and the like. Really very very easy. I love Python.
I can give you more details, if you're interested. john
Gary Pajer wrote:
Soon I'm going to need to interface my experiment to my computer.
Can any one suggest any python tools that might exist? I've been googling for abour an hour, and haven't come up with anything.
I can't afford LabView at the moment, and besides, I've never used it so it doesn't have the advantage of familiarity. I don't need a graphical environment. At first the equipment will be very simple: a couple of photodiodes, an A/D converter, perhaps a stepper motor controler.
Any hints are welcome. If this strikes you as noise, please accept my apology.
Thanks, gary
_______________________________________________ SciPy-user mailing list SciPy-user@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-user
_______________________________________________ SciPy-user mailing list SciPy-user@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-user
On Tuesday 22 August 2006 11:21, Gary Pajer wrote:
Soon I'm going to need to interface my experiment to my computer.
Can any one suggest any python tools that might exist? I've been googling for abour an hour, and haven't come up with anything.
I can't afford LabView at the moment, and besides, I've never used it so it doesn't have the advantage of familiarity. I don't need a graphical environment. At first the equipment will be very simple: a couple of photodiodes, an A/D converter, perhaps a stepper motor controler.
I haven't worked with it, but you might look at TACO: http://www.esrf.fr/taco/
Gary Pajer wrote:
Soon I'm going to need to interface my experiment to my computer.
Can any one suggest any python tools that might exist? I've been googling for abour an hour, and haven't come up with anything.
I can't afford LabView at the moment, and besides, I've never used it so it doesn't have the advantage of familiarity. I don't need a graphical environment. At first the equipment will be very simple: a couple of photodiodes, an A/D converter, perhaps a stepper motor controler.
I would recommend to use I2c for communication with the devices, which is an industry standard to interconnect different parts within electronic devices. There are many low cost modules available, such as DA/AD converters, stepper motor controler, digitial IO, etc. Those modules can be linked serially similar to IEEE and each module has its own ID. Using an adapter for the serial port you can control the devices using, e.g. pyserial. Christian
Christian, This looks very interesting. I'm a long time LabVIEW (National Instruments) developer, now hooked on Python. Do you have a favorite vendor for hardware that uses I2C? Thanks. Barry Drake Adaptive Computing Systems Christian Kristukat wrote: Gary Pajer wrote:
Soon I'm going to need to interface my experiment to my computer.
Can any one suggest any python tools that might exist? I've been googling for abour an hour, and haven't come up with anything.
I can't afford LabView at the moment, and besides, I've never used it so it doesn't have the advantage of familiarity. I don't need a graphical environment. At first the equipment will be very simple: a couple of photodiodes, an A/D converter, perhaps a stepper motor controler.
I would recommend to use I2c for communication with the devices, which is an industry standard to interconnect different parts within electronic devices. There are many low cost modules available, such as DA/AD converters, stepper motor controler, digitial IO, etc. Those modules can be linked serially similar to IEEE and each module has its own ID. Using an adapter for the serial port you can control the devices using, e.g. pyserial. Christian _______________________________________________ SciPy-user mailing list SciPy-user@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-user
Barry Drake wrote:
Christian, This looks very interesting. I'm a long time LabVIEW (National Instruments) developer, now hooked on Python. Do you have a favorite vendor for hardware that uses I2C?
Once we bought an usb i2c interface at http://www.diolan.com/i2c/u2c12.html Other parts we got from a local (Germany) dealer. But it's easy to find parts and vendors on google. Christian
participants (10)
-
Andrew Straw -
Barry Drake -
Bryce Hendrix -
Christian Kristukat -
Darren Dale -
Gary Pajer -
Gary Ruben -
John Hassler -
Robert Kern -
Russel Howe