From clj72 at cornell.edu Mon Aug 1 08:47:38 2016 From: clj72 at cornell.edu (Colin Jermain) Date: Mon, 1 Aug 2016 08:47:38 -0400 Subject: [SciPy-User] ANN: PyMeasure package for instrument control and measurements Message-ID: <5ae071be-7f5f-2f3e-8836-6b5f19023949@cornell.edu> Hey Scipy users, I'd like to introduce you to a new scientific package, PyMeasure , which we have been working on at Cornell for performing experimental measurements. The goal of the project is to help scientists make measurement software quickly and allow that software to be easy to maintain. You can get up an running with a full dynamic GUI with live-plotting in less than 150 lines of code (most of which can be copied from the examples). There are a number of instruments defined with their SCPI/GPIB commands, so that you can start using them right out of the box. We've taken advantage of a number of dependency packages from the Scipy community that make our high-level approach possible (PyVISA, PySerial, PyQtGraph, PyQt/PySide, etc.). We would love your feedback and suggestions for improvement. Feel free to email me, or strike up an issue on GitHub . GitHub: https://github.com/ralph-group/pymeasure Documentation: http://pymeasure.readthedocs.io/en/latest/ Regards, Colin -------------- next part -------------- An HTML attachment was scrubbed... URL: From tritemio at gmail.com Mon Aug 1 10:23:18 2016 From: tritemio at gmail.com (Antonino Ingargiola) Date: Mon, 1 Aug 2016 16:23:18 +0200 Subject: [SciPy-User] ANN: Pybroom, a python broom for tidying up messy fit results Message-ID: Hi all, (sorry for cross posting) =================== Announcing pybroom 0.1 =================== I'm announcing the first public release of pybroom (version 0.1). Any feedback or suggestions are welcome! What is pybroom? ============== Pybroom is a small python 3 library for converting fitting results (curve fitting or other optimizations) to Pandas DataFrame in tidy format (or long-form). DataFrames in tidy format follow a simple rule: one ?observation? per row and one ?variable? per column. This simple structure makes it easy to process the data with clear and well-understood idioms (for filtering, aggregation, etc.) and allows plot libraries to automatically generate complex plots in which many variables are compared. Plotting libraries supporting tidy DataFrames include seaborn, recent versions of matplotlib, bokeh and altair. Pybroom was inspired by the R library broom. See this video for details of the philosophy behind broom: https://www.youtube.com/watch?v=eM3Ha0kTAz4 Example notebooks are included in the pybroom documentation: http://pybroom.readthedocs.io/en/latest/#example-notebooks For more details see pybroom homepage: http://pybroom.readthedocs.io/ Enjoy! -- Antonino Ingargiola -------------- next part -------------- An HTML attachment was scrubbed... URL: From newville at cars.uchicago.edu Mon Aug 1 15:53:10 2016 From: newville at cars.uchicago.edu (Matt Newville) Date: Mon, 1 Aug 2016 14:53:10 -0500 Subject: [SciPy-User] ANN: Pybroom, a python broom for tidying up messy fit results In-Reply-To: References: Message-ID: Hi Antonino, This looks really nice - I will definitely use this. Is there anything we should add to lmfit to make these tasks easier? Do you think there is anything that could be done to make ModelResult or similar "result" of a fit be made more "tidy" in this sense? Would it make sense to add a "tidy()" method to a ModelResult that did some of this work? --Matt -------------- next part -------------- An HTML attachment was scrubbed... URL: From peter.zamb at gmail.com Wed Aug 10 08:31:13 2016 From: peter.zamb at gmail.com (Pietro) Date: Wed, 10 Aug 2016 14:31:13 +0200 Subject: [SciPy-User] ANN: PhD student position on energy system modelling with EURAC & UNITN (Italy) Message-ID: EURAC in collaboration with the University of Trento , propose a PhD on energy system modelling. This opportunity is offered to high-achieving students looking to begin a PhD programme in November 2016. Students from anywhere in the world can apply. Here you can find the PhD studentship description and the details on how to apply . *TOPIC*: "Multi-dimensional energy system modeling: Methods and tools for the optimization of energy systems considering spatial, temporal and social-economic features" *DEADLINE FOR APPLICATIONS*: 25th August 2016, hrs. 4.00 PM (Italian time) In the application form you must select the B2 - topic. *MANDATORY ATTACHMENTS*: 1. Identifying document (ID): 2. Academic certificate 3. Summary of the degree thesis 4. Curriculum vitae et studiorum 5. Description of the research proposal and statement of purpose in English (maximum 3 pages) *OPTIONAL ATTACHMENTS*: - List of research outputs; - any certificates attesting the knowledge of foreign languages; - any other documents useful to assess the research skills of the applicant (prizes, scholarships, postgraduate research and work activity, etc.) - Up to two names of referees working at universities or national and international research institutions, with details of their e-mail addresses For any further information please contact me. Best regards Pietro --- Pietro Zambelli EURAC Research Institute for Renewable Energy Via G. Di Vittorio 16, I-39100 Bolzano pietro.zambelli @ skype www.eurac.edu -------------- next part -------------- An HTML attachment was scrubbed... URL: From andyfaff at gmail.com Wed Aug 10 23:40:16 2016 From: andyfaff at gmail.com (Andrew Nelson) Date: Thu, 11 Aug 2016 13:40:16 +1000 Subject: [SciPy-User] Interpolated Univariate Spline - what are coefs, and how is integral calculated? Message-ID: I have a few questions about interpolate.InterpolatedUnivariateSpline (IUS). My ultimate aim, given an IUS object, a lower definite integration limit, and an area, is to obtain the upper definite integration limit by the fastest route possible. The application is to do with probability distribution functions. The IUS represents the PDF. I can quickly work out the CDF using IUS.integral(a, x) = q, where a is the lower limit of support and x is the value for which you want to work out the CDF. However, I would like the quickest way to calculate the percent probability function (PPF). I.e. given q, work out x. One way used in scipy.stats is to use optimize.brentq to find this value - It's known that the CDF is a monotonically increasing function. It strikes me that brentq might not be the fastest way of achieving this. For example, I could cache the integral at each of the datapoints for the IUS, which would immediately allow me to bracket the location of x. Given that I know the degree of the smoothing spline I am hoping to calculate x quickly if I know the polynomial coefficients of the spline in the bracketing interval. This would done by integrating the polynomial and using the roots of the integral. My question is: Is there a way of getting those polynomial coefficients for each interval from the output of the IUS.get_coeffs method? -- _____________________________________ Dr. Andrew Nelson _____________________________________ -------------- next part -------------- An HTML attachment was scrubbed... URL: From evgeny.burovskiy at gmail.com Fri Aug 12 17:38:21 2016 From: evgeny.burovskiy at gmail.com (Evgeni Burovski) Date: Fri, 12 Aug 2016 22:38:21 +0100 Subject: [SciPy-User] Interpolated Univariate Spline - what are coefs, and how is integral calculated? In-Reply-To: References: Message-ID: On Thu, Aug 11, 2016 at 4:40 AM, Andrew Nelson wrote: > I have a few questions about interpolate.InterpolatedUnivariateSpline (IUS). > > My ultimate aim, given an IUS object, a lower definite integration limit, > and an area, is to obtain the upper definite integration limit by the > fastest route possible. > > The application is to do with probability distribution functions. The IUS > represents the PDF. I can quickly work out the CDF using IUS.integral(a, x) > = q, where a is the lower limit of support and x is the value for which you > want to work out the CDF. > > However, I would like the quickest way to calculate the percent probability > function (PPF). I.e. given q, work out x. > > One way used in scipy.stats is to use optimize.brentq to find this value - > It's known that the CDF is a monotonically increasing function. It strikes > me that brentq might not be the fastest way of achieving this. For example, > I could cache the integral at each of the datapoints for the IUS, which > would immediately allow me to bracket the location of x. Given that I know > the degree of the smoothing spline I am hoping to calculate x quickly if I > know the polynomial coefficients of the spline in the bracketing interval. > This would done by integrating the polynomial and using the roots of the > integral. My question is: Is there a way of getting those polynomial > coefficients for each interval from the output of the IUS.get_coeffs method? > First of all, you likely cannot beat an inverse interpolation if raw speed is what you're after (i.e., interpolate cdf(x) vs x). Spefically, to your question about IUS: * note that IUS is *not* guaranteed to be monotonic even if you tabulate what looks like a monotonic function * IUS is defined in the B-spline basis, so .get_coeffs() returns the coeficients of B-spline basis elements, not polynomial representation coefficients. If you want polynomial representation, you can use `PPoly.from_spline()` with knots and coefficients from IUS --- check the docstring of LSQUnivariateSpline for a possible catch with the boundary knots though. If you go that route, you might use `splrep(x, y, s=0)` rather than IUS though, because it's equivalent and gives directly tck (knots, coefficients and order) which `PPoly.from_spline` takes as a parameter. However, if you convert to polynomials, you might as well just use the `CubicSpline` (new in scipy 0.18.0) which constructs the spline directly in the polynomial basis. Unless you want to make sure you get a monotonic interpolator and can tolerate C1 continuity, in which case you can use instead PCHIP or Akima1DInterpolator. For integrals specifically, one thing which might (or might not) help is to use Bernstein polynomials (which e.g. PchipInterpolator is), and use the fact that $\int_0^{1} b_{j, n} = \frac{1}{n+1} $, so that you know the cumulative integrals at each breakpoint. HTH, Evgeni From mviljamaa at kapsi.fi Mon Aug 29 09:56:38 2016 From: mviljamaa at kapsi.fi (Matti Viljamaa) Date: Mon, 29 Aug 2016 16:56:38 +0300 Subject: [SciPy-User] freqz -style plot of "window design" FIR? Message-ID: <264D827E-547C-49A9-94B5-919C956697D8@kapsi.fi> I?m trying to design an arbitrary frequency response filter as described here: http://www.dspguide.com/ch17/1.htm The technique is said to result in an impulse response in time domain and later in to a filter kernel. I?ve been using scipy.signal.freqz to make magnitude response plots: e.g. fs = 44100 # Design a low-pass filter using remez. cutoff = 2000.0 transition_width = 200 bands = np.array([0, cutoff - 0.5*transition_width, cutoff + 0.5*transition_width, fs/2.0]) / fs desired = [1, 0] lpf = remez(513, bands, desired) # Plot the frequency response of the filter. w, h = freqz(lpf) plt.figure(1) plt.plot(fs*w/(2*np.pi), 20*np.log10(abs(h))) plt.xlim(0, fs/2) plt.xlabel('Frequency (Hz)') plt.ylabel('Gain (dB)') plt.grid(True) But my question is, if using the above arbitrary frequency response design technique, would I be able to use freqz? freqz takes as a parameter ?numerator of a linear filter? and remez is returning an array of coefficients, which I read to be the same thing. But in the case of the arbitrary frequency response filter, what can I put into freqz? Is filter kernel perhaps the same as coefficients? -------------- next part -------------- An HTML attachment was scrubbed... URL: From mviljamaa at kapsi.fi Mon Aug 29 09:57:14 2016 From: mviljamaa at kapsi.fi (Matti Viljamaa) Date: Mon, 29 Aug 2016 16:57:14 +0300 Subject: [SciPy-User] Does/how does ifft expect frequencies (on x-axis)? Message-ID: <7C33BF9B-3312-431B-AED5-7333C1F96752@kapsi.fi> I was trying to ifft a filter magnitude response that?s simply drawn into an array of filter length, e.g. 64 samples. So I have the array of 64 samples and this obviously means that the x-axis is in samples, not frequencies. ifft:ing this array does give me something that looks like the impulse response, but I didn?t give ifft any frequency data, just samples 0-64 in the x-axis. What I think I could?ve done is rather specify the magnitude response in 2D array or something so that the frequency runs from [0.0, 1.0] (0.5 corresponding to the Nyquist frequency) and then specify the magnitudes in 64 samples evenly spread on [0.0, 1.0], which is what I _intend_ with my array. So does ifft expect frequencies somehow or does it also work in the way that I used it, i.e. that the frequency response going into it is in samples rather than in frequencies? The functions I?m interested are any ifft in SciPy. From mviljamaa at kapsi.fi Tue Aug 30 05:35:36 2016 From: mviljamaa at kapsi.fi (Matti Viljamaa) Date: Tue, 30 Aug 2016 12:35:36 +0300 Subject: [SciPy-User] Difference equation to frequency response? In-Reply-To: <7C33BF9B-3312-431B-AED5-7333C1F96752@kapsi.fi> References: <7C33BF9B-3312-431B-AED5-7333C1F96752@kapsi.fi> Message-ID: What?s a simple way to get the frequency response of a filter that?s expressed as difference equation using SciPy? Such as this lowpass filter: https://kiritchatterjee.wordpress.com/2014/11/10/a-simple-digital-low-pass-filter-in-c/ y[i] = b * x[i] + (1-b) * y[i-1] -------------- next part -------------- An HTML attachment was scrubbed... URL: From ndbecker2 at gmail.com Tue Aug 30 06:54:44 2016 From: ndbecker2 at gmail.com (Neal Becker) Date: Tue, 30 Aug 2016 06:54:44 -0400 Subject: [SciPy-User] Difference equation to frequency response? References: <7C33BF9B-3312-431B-AED5-7333C1F96752@kapsi.fi> Message-ID: Matti Viljamaa wrote: > What?s a simple way to get the frequency response of a filter that?s > expressed as difference equation using SciPy? > > Such as this lowpass filter: > > https://kiritchatterjee.wordpress.com/2014/11/10/a-simple-digital-low-pass-filter-in-c/ > > > y[i] = b * x[i] + (1-b) * y[i-1] 1st step is to get the z-transform y = bx + (1-b) y z^{-1} Solve for y/x. Then your question is how to plot a frequency response from a z transform. Plug in z=e^(j 2 pi f t) From robert.kern at gmail.com Tue Aug 30 07:55:30 2016 From: robert.kern at gmail.com (Robert Kern) Date: Tue, 30 Aug 2016 12:55:30 +0100 Subject: [SciPy-User] Difference equation to frequency response? In-Reply-To: References: <7C33BF9B-3312-431B-AED5-7333C1F96752@kapsi.fi> Message-ID: On Tue, Aug 30, 2016 at 10:35 AM, Matti Viljamaa wrote: > > What?s a simple way to get the frequency response of a filter that?s expressed as difference equation using SciPy? > > Such as this lowpass filter: > > https://kiritchatterjee.wordpress.com/2014/11/10/a-simple-digital-low-pass-filter-in-c/ > > y[i] = b * x[i] + (1-b) * y[i-1] This is a so-called Infinite Impulse Response (IIR) filter. In the terms that scipy.signal works with, we need to convert it to a transfer function, which is just a ratio of polynomials. https://en.wikipedia.org/wiki/Infinite_impulse_response#Transfer_function_derivation To avoid confusion, let me rename your variables (the transfer function convention uses `b` to mean the array of coefficients of the numerator polynomial). y[i] = alpha * x[i] + (1-alpha) * y[i-1] So we get: b = [alpha] a = [1.0, -(1-alpha)] scipy.signal has a handy class for filters defined in terms of transfer functions: # http://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.TransferFunction.html#scipy.signal.TransferFunction from scipy import signal tf = signal.TransferFunction(b, a) And it has a handy method for computing the frequency response (magnitude and phase): http://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.dlti.freqresp.html#scipy.signal.dlti.freqresp -- Robert Kern -------------- next part -------------- An HTML attachment was scrubbed... URL: From sebastian at sipsolutions.net Tue Aug 30 11:08:52 2016 From: sebastian at sipsolutions.net (Sebastian Berg) Date: Tue, 30 Aug 2016 17:08:52 +0200 Subject: [SciPy-User] "obvious" simple linear program with integral constrains solver Message-ID: <1472569732.1982.8.camel@sipsolutions.net> Hi all, I wanted to solve a small integer problem today. Now I have done this before and I know that there are some options available in python, but I was wondering if there is a solver with support for linear problems with integer constraints available in the more basic "scientific python stack"? Nothing fancy, but something that can be installed quickly (best included in things like Anaconda). Basically is there an "obvious" solution, at least for non-demanding tasks one could/should recommend? Best, Sebastian -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: This is a digitally signed message part URL: From tritemio at gmail.com Tue Aug 30 13:42:24 2016 From: tritemio at gmail.com (Antonino Ingargiola) Date: Tue, 30 Aug 2016 10:42:24 -0700 Subject: [SciPy-User] ANN: pybroom 0.2 released Message-ID: Hi, version 0.2 of pybroom has been released. See below for the details. What is pybroom? ============== Pybroom is a small python 3+ library for converting collections of fit results (curve fitting or other optimizations) to Pandas DataFrame in tidy format (or long-form) (Wickham 2014). Once fit results are in tidy DataFrames, it is possible to leverage common patterns for tidy data analysis. Furthermore powerful visual explorations using multi-facet plots becomes easy thanks to libraries like seaborn natively supporting tidy DataFrames. Homepage: http://pybroom.readthedocs.io/ Release Notes ============ - Improved support for scipy.optimize fit result. - In addition to list of fit results, pybroom now supports: - dict of fit results, - dict of lists of fit results - any other nested combination of dict and list. - When input contains a dict, pybroom adds ?key? column of type pandas.Categorical. - When input contains a list, pybroom adds a ?key? column (i.e. list index) of type int64. - Updated and expanded documentation and notebooks. Installation ======== You can install pybroom from PyPI using the following command: pip install pybroom or from conda-forge using: conda install -c conda-forge pybroom Dependencies are python 3.4+, pandas and lmfit (0.9.5+, which in turn requires scipy). However, matplotlib and seaborn are strongly recommended (and necessary to run the example notebooks). -------------- next part -------------- An HTML attachment was scrubbed... URL: From mviljamaa at kapsi.fi Wed Aug 31 03:11:33 2016 From: mviljamaa at kapsi.fi (Matti Viljamaa) Date: Wed, 31 Aug 2016 10:11:33 +0300 Subject: [SciPy-User] Is the second half of np.fft.fft the negative frequencies? Message-ID: I?m having the following problem http://dsp.stackexchange.com/questions/33982/problem-with-windowing-method-result-seems-shifted My question is: in http://i.stack.imgur.com/fYFvx.png are samples [0, 512] the positive frequencies and [513, 1024] the negative frequencies (in two-sided FFT). I.e. that to be correct the plot should actually look like [513, 1024] is [-512, 0] and [0,512] is [0,512], but is this the np.fft.fft way to return the negative frequencies (i.e in the latter half of the fft result)? -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.kern at gmail.com Wed Aug 31 03:54:52 2016 From: robert.kern at gmail.com (Robert Kern) Date: Wed, 31 Aug 2016 08:54:52 +0100 Subject: [SciPy-User] Is the second half of np.fft.fft the negative frequencies? In-Reply-To: References: Message-ID: On Wed, Aug 31, 2016 at 8:11 AM, Matti Viljamaa wrote: > > I?m having the following problem > > http://dsp.stackexchange.com/questions/33982/problem-with-windowing-method-result-seems-shifted > > My question is: > > in > > http://i.stack.imgur.com/fYFvx.png > > are samples [0, 512] the positive frequencies and [513, 1024] the negative frequencies (in two-sided FFT). > I.e. that to be correct the plot should actually look like [513, 1024] is [-512, 0] and [0,512] is [0,512], but is this the np.fft.fft way to return the negative frequencies (i.e in the latter half of the fft result)? Yes, this is a standard convention used by many (most?) FFT implementations. http://docs.scipy.org/doc/numpy/reference/routines.fft.html#implementation-details -- Robert Kern -------------- next part -------------- An HTML attachment was scrubbed... URL: