[SciPy-User] *****SPAM***** SciPy-User Digest, Vol 73, Issue 54
Marco Nicoletti
nicoletti@consorzio-innova...
Wed Oct 7 02:44:21 CDT 2009
Dear Joe,
what I want to do is to interpolate the position array adding the
constrain about the first derivative (the velocity array) whiche I
already have.
An example: I have t = [0,2,4,6] (the definition domain), p(t) =
[10,13,16,18] (the position array) and v(t) = [1.1, 0.8, 0.7, 0.4].
I have this new domain t1 = [0,1,2,3,4,5,6] and I want to obtain p1(t1)
imposing the constrain about the velocities v1(t) = v(t).
I want the spline interpolation.
Any ideas?
Thanks in advanced for your advices.
Marco Nicoletti
Il giorno mer, 30/09/2009 alle 17.15 -0500, scipy-user-request@scipy.org
ha scritto:
> Send SciPy-User mailing list submissions to
> scipy-user@scipy.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://mail.scipy.org/mailman/listinfo/scipy-user
> or, via email, send a message with subject or body 'help' to
> scipy-user-request@scipy.org
>
> You can reach the person managing the list at
> scipy-user-owner@scipy.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of SciPy-User digest..."
>
>
> Today's Topics:
>
> 1. Re: Forced derivative interpolation?? (Joe Kington)
> 2. memoryError when i have plenty of available ram (Gustaf Nilsson)
> 3. Re: Forced derivative interpolation?? (Anne Archibald)
> 4. scipy.reddit.com (David Warde-Farley)
> 5. numpy.squeeze not squeezing (Bruce Ford)
> 6. Re: numpy.squeeze not squeezing (Robert Kern)
> 7. Re: numpy.squeeze not squeezing (Bruce Ford)
> 8. Re: numpy.squeeze not squeezing (Robert Kern)
> 9. Re: numpy.squeeze not squeezing (Bruce Ford)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 30 Sep 2009 13:18:53 -0500
> From: Joe Kington <jkington@wisc.edu>
> Subject: Re: [SciPy-User] Forced derivative interpolation??
> To: SciPy Users List <scipy-user@scipy.org>
> Message-ID:
> <f6951adf0909301118m4a48ac88rf75bd3e10a77af7a@mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hi Marco,
>
> Exactly what sort of constraints are you wanting to apply?
> i.e.
> Do you want a specific velocity or acceleration everywhere (and get a least
> squares fit to the other parameters)?
> Do you want to minimize the acceleration or velocity while still fitting the
> data?
> Does the interpolation need to fit the data exactly at each point where you
> have data, or the best fit between your constraints and the data values?
>
> Basically, as far as I know, there isn't a pre-built function in scipy to do
> what you want, but it's not hard to write code to do what you want. If you
> can describe what you need in a bit more detail, I'm pretty sure I can point
> you in the right direction.
>
> -Joe
>
> On Wed, Sep 30, 2009 at 3:09 AM, Marco Nicoletti <
> nicoletti@consorzio-innova.it> wrote:
>
> > Dear all,
> >
> > I want to implement a spline interpolation forcing the condition on the
> > first or second derivative.
> > In other words I have a vector of position (p), velocity (v) and
> > acceleration (a) values;
> > I want to interpolate the position (p) vector imposing the conditions on
> > the velocity and acceleration values.
> >
> > The class UnivariateSpline() or intrp1D() in scipy.interpolate package
> > don't take as parameter the derivatives
> > (they export a method to evaluate derivatives).
> >
> > Any suggestions?
> >
> > Thanks very much and have a nice day!
> >
> > Marco Nicoletti
> >
> > _______________________________________________
> > SciPy-User mailing list
> > SciPy-User@scipy.org
> > http://mail.scipy.org/mailman/listinfo/scipy-user
> >
> >
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20090930/6567f5e7/attachment-0001.html
>
> ------------------------------
>
> Message: 2
> Date: Wed, 30 Sep 2009 20:58:46 +0200
> From: Gustaf Nilsson <gustaf@laserpanda.com>
> Subject: [SciPy-User] memoryError when i have plenty of available ram
> To: SciPy Users List <scipy-user@scipy.org>
> Message-ID:
> <f82cec4e0909301158s313993d0rb66d6e4a80318d4a@mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Hiya
>
> I know someone just started a memory thread, but i didnt wanna hijack it..
> My image processing app that im working on seems to crash with "memoryError"
> when it hits about 1.1gb of mem usage (same on two computers; has 2/4gb ram,
> xp 32bit)
> Im working with 12mpixel images at 32bit floating point, so each block of
> memory used in different operations is about 140mb (if that helps)
>
> Is it actually because it runs out of memory or can the error mean something
> else?
>
> cheers
> Gusty
> --
> ? ? ? ? ? ? ? ? ? ?
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20090930/ef357136/attachment-0001.html
>
> ------------------------------
>
> Message: 3
> Date: Wed, 30 Sep 2009 15:12:40 -0400
> From: Anne Archibald <peridot.faceted@gmail.com>
> Subject: Re: [SciPy-User] Forced derivative interpolation??
> To: SciPy Users List <scipy-user@scipy.org>
> Message-ID:
> <ce557a360909301212l667a0093tde59aa73493a8970@mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> 2009/9/30 Marco Nicoletti <nicoletti@consorzio-innova.it>:
> > Dear all,
> >
> > I want to implement a spline interpolation forcing the condition on the
> > first or second derivative.
> > In other words I have a vector of position (p), velocity (v) and
> > acceleration (a) values;
> > I want to interpolate the position (p) vector imposing the conditions on the
> > velocity and acceleration values.
> >
> > The class UnivariateSpline() or intrp1D() in scipy.interpolate package don't
> > take as parameter the derivatives
> > (they export a method to evaluate derivatives).
> >
> > Any suggestions?
>
> If I have correctly understood your question, what you want to do is
> produce an interpolating spline with not just specified point values
> but specified derivative values at the given points. Scipy has at
> least two different pieces of code that might help. The first is, in
> recent versions of scipy, scipy.interpolate.PiecewisePolynomial. This
> allows you to fit a piecewise polynomial through a set of points,
> specifying derivatives at each point. It doesn't allow you to impose a
> spline-like constraint that higher derivatives must be continuous at
> the points. Its evaluation is also implemented in pure python, so it
> won't be terribly fast.
>
> A second option, useful if you need fast evaluation, is to abuse
> scipy's spline functions. scipy.interpolate.splrep doesn't take
> derivatives, but what it returns is a triple t, c, k. Given a t, c, k,
> you can then call splev, splint, splder, etcetera to get nice fast
> evaluation in compiled code. So what you can do is fabricate your own
> t, c, and k values. t is the list of knots, c is some sort of
> coefficients, and k is the order of the spline. The brute-force way I
> found to get these splines to produce the derivatives I wanted
> required me to repeat values in the t array. But once you've fixed the
> t array, the result is linear in the c values, so a little trial and
> error will give you formulas to produce any curve you need.
>
> Good luck,
> Anne
> > Thanks very much and have a nice day!
> >
> > Marco Nicoletti
> > _______________________________________________
> > SciPy-User mailing list
> > SciPy-User@scipy.org
> > http://mail.scipy.org/mailman/listinfo/scipy-user
> >
> >
>
>
> ------------------------------
>
> Message: 4
> Date: Wed, 30 Sep 2009 16:51:59 -0400
> From: David Warde-Farley <dwf@cs.toronto.edu>
> Subject: [SciPy-User] scipy.reddit.com
> To: Discussion of Numerical Python <numpy-discussion@scipy.org>, SciPy
> Users List <scipy-user@scipy.org>, ipython-user@scipy.net
> Message-ID: <2F5DD634-70CB-4A5B-ADD8-F3FFCDF41A1B@cs.toronto.edu>
> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
>
> In the spirit of the 'advice' site, and given that we're thinking of
> moving scipy.org to more static content (once I have some free time on
> my hands again, which should be soon!), I set up a 'subreddit' on
> reddit.com for Python-in-Science related links. I even came up with a
> somewhat spiffy logo for it.
>
> Think of it as a communal, collaboratively filtered (via up/down
> votes, using the arrows next to each submission) bookmarks folder/news
> site/etc.
>
> I'd encourage people to use it and add to it if they feel it might be
> of use to the community.
>
> The address is http://scipy.reddit.com/ , or equivalently http://www.reddit.com/r/scipy
>
> David
>
>
>
>
> ------------------------------
>
> Message: 5
> Date: Wed, 30 Sep 2009 16:44:29 -0400
> From: Bruce Ford <bruce@clearscienceinc.com>
> Subject: [SciPy-User] numpy.squeeze not squeezing
> To: scipy-user@scipy.org
> Message-ID:
> <bebb7fa10909301344j6165bed4j79269c1839f8915e@mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Squeeze doesn't seem to be squeezing. What am I missing?
>
> An array extracted from a NetCDF3 file using NetCDF4 is shaped: (248,1,181.360)
>
> I want it to be shaped (248,181,360)
>
> out = np.squeeze(in)
> print out.shape
>
> yeilds ()
>
> Am I missing a step?
>
> Any assistance would be appreciated!
>
> Bruce
> ---------------------------------------
> Bruce W. Ford
> Clear Science, Inc.
> bruce@clearscienceinc.com
>
>
> ------------------------------
>
> Message: 6
> Date: Wed, 30 Sep 2009 16:16:39 -0500
> From: Robert Kern <robert.kern@gmail.com>
> Subject: Re: [SciPy-User] numpy.squeeze not squeezing
> To: SciPy Users List <scipy-user@scipy.org>
> Message-ID:
> <3d375d730909301416w4eb6dbbei9b47a22bd141b91a@mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> On Wed, Sep 30, 2009 at 15:44, Bruce Ford <bruce@clearscienceinc.com> wrote:
> > Squeeze doesn't seem to be squeezing. ?What am I missing?
> >
> > An array extracted from a NetCDF3 file using NetCDF4 is shaped: ?(248,1,181.360)
> >
> > I want it to be shaped (248,181,360)
> >
> > out = np.squeeze(in)
> > print out.shape
> >
> > yeilds ?()
> >
> > Am I missing a step?
>
> It works for me:
>
> In [1]: x = np.empty((248,1,181,360))
>
> In [2]: np.squeeze(x).shape
> Out[2]: (248, 181, 360)
>
> Can you give us a minimal, self-contained script that demonstrates the
> problem? Being self-contained will probably be impossible, but even
> seeing such a minimal script will be helpful even if we can't run it
> with your data file.
>
> --
> 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
>
>
> ------------------------------
>
> Message: 7
> Date: Wed, 30 Sep 2009 18:03:25 -0400
> From: Bruce Ford <bruce@clearscienceinc.com>
> Subject: Re: [SciPy-User] numpy.squeeze not squeezing
> To: SciPy Users List <scipy-user@scipy.org>
> Message-ID:
> <bebb7fa10909301503t26bc656ag528786d82e94000e@mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Robert, thanks for responding. Your response makes me things
> something in my array is preventing squeeze form working correctly.
> Here's a cleaned up version of my script:
>
>
> #!/usr/local/env python
> from mpl_toolkits.basemap import Basemap
> import numpy as np #used to preform simple math functions on data
> from netCDF4 import Dataset
> #decide which file to open
> year = 1995
> month = "%02d" % 5
>
> #Set up file names
> filename = "/data/ww3/NetCDF/3_hourly/ww3."+str(year)+str(month)+ ".nc"
> opennc = Dataset(filename, mode="r")
>
> swh = opennc.variables['sig_wav_ht']
> print swh.shape #gives (248,1,181,360)
> swh1 = np.squeeze(swh)
>
> print 'SWH shape: ', swh1.shape #gives ()
> x = np.zeros((248,1,181,360))
> y = np.squeeze(x)
> print y.shape #give (248,181,369)
>
>
> ---------------------------------------
> Bruce W. Ford
> Clear Science, Inc.
> bruce@clearscienceinc.com
> bruce.w.ford.ctr@navy.smil.mil
> http://www.ClearScienceInc.com
> Phone/Fax: 904-379-9704
> 8241 Parkridge Circle N.
> Jacksonville, FL 32211
> Skype: bruce.w.ford
> Google Talk: fordbw@gmail.com
>
>
>
> On Wed, Sep 30, 2009 at 5:16 PM, Robert Kern <robert.kern@gmail.com> wrote:
> > On Wed, Sep 30, 2009 at 15:44, Bruce Ford <bruce@clearscienceinc.com> wrote:
> >> Squeeze doesn't seem to be squeezing. ?What am I missing?
> >>
> >> An array extracted from a NetCDF3 file using NetCDF4 is shaped: ?(248,1,181.360)
> >>
> >> I want it to be shaped (248,181,360)
> >>
> >> out = np.squeeze(in)
> >> print out.shape
> >>
> >> yeilds ?()
> >>
> >> Am I missing a step?
> >
> > It works for me:
> >
> > In [1]: x = np.empty((248,1,181,360))
> >
> > In [2]: np.squeeze(x).shape
> > Out[2]: (248, 181, 360)
> >
> > Can you give us a minimal, self-contained script that demonstrates the
> > problem? Being self-contained will probably be impossible, but even
> > seeing such a minimal script will be helpful even if we can't run it
> > with your data file.
> >
> > --
> > 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
> > _______________________________________________
> > SciPy-User mailing list
> > SciPy-User@scipy.org
> > http://mail.scipy.org/mailman/listinfo/scipy-user
> >
>
>
> ------------------------------
>
> Message: 8
> Date: Wed, 30 Sep 2009 17:05:58 -0500
> From: Robert Kern <robert.kern@gmail.com>
> Subject: Re: [SciPy-User] numpy.squeeze not squeezing
> To: SciPy Users List <scipy-user@scipy.org>
> Message-ID:
> <3d375d730909301505q221473d6i450fcb23b14cfd58@mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> On Wed, Sep 30, 2009 at 17:03, Bruce Ford <bruce@clearscienceinc.com> wrote:
> > Robert, thanks for responding. ?Your response makes me things
> > something in my array is preventing squeeze form working correctly.
> > Here's a cleaned up version of my script:
> >
> >
> > #!/usr/local/env python
> > from mpl_toolkits.basemap import Basemap
> > import numpy as np #used to preform simple math functions on data
> > from netCDF4 import Dataset
> > #decide which file to open
> > year = 1995
> > month = "%02d" % 5
> >
> > #Set up file names
> > filename = "/data/ww3/NetCDF/3_hourly/ww3."+str(year)+str(month)+ ".nc"
> > opennc = Dataset(filename, mode="r")
> >
> > swh = opennc.variables['sig_wav_ht']
> > print swh.shape ?#gives (248,1,181,360)
> > swh1 = np.squeeze(swh)
> >
> > print 'SWH shape: ', swh1.shape ?#gives ()
>
> print type(swh1)
>
> I'm not sure that swh1 is actually an ndarray. It might be a different
> class that masquerades as a numpy array.
>
More information about the SciPy-User
mailing list