Showing posts with label pandas. Show all posts
Showing posts with label pandas. Show all posts

Saturday, May 30, 2015

Moire with Spyre (a Python web framework)

By Vasudev Ram




The image above is of Uppsala Cathedral, Sweden, with its spires.

From the Spyre site:

Spyre is a Web Application Framework for providing a simple user interface for Python data projects. It is by Adam Hajari

I had come across Spyre recently via this post by Ian Oszvald:

Data Science Deployed – Opening Keynote for PyConSE 2015. More about Ian Oszvald here.

So I installed Spyre with the command:
pip install dataspyre
which in turn installed NumPy, pandas and matplotlib, all of which went through okay, though I saw some compiler / linker error messages scroll by as some compilation of C modules was happening (as part of the installation).

Then I tried it out a little, this time just using one of the simple applications on the Spyre site, without any modifications, like I sometimes do.
from spyre import server

import matplotlib.pyplot as plt
import numpy as np

class SimpleSineApp(server.App):
    title = "Simple Sine App"
    inputs = [{ "input_type":"text",
                "variable_name":"freq",
                "value":5,
                "action_id":"sine_wave_plot"}]

    outputs = [{"output_type":"plot",
                "output_id":"sine_wave_plot",
                "on_page_load":True }]

    def getPlot(self, params):
        f = float(params['freq'])
        x = np.arange(0,2*np.pi,np.pi/150)
        y = np.sin(f*x)
        fig = plt.figure()
        splt1 = fig.add_subplot(1,1,1)
        splt1.plot(x,y)
        return fig

app = SimpleSineApp()
app.launch()
As you can see, the structure / model of the code for a Spyre app does not seem to be very similar to that of, say, a Flask or a Bottle app. But then, there is no reason that it should be.
Anyway, I ran this app with the command:

python simple_sine_example.py

and then browsed to:

http://127.0.0.1:8080/

where I then gave different values for the input parameter freq, to see what would happen. I found that running it with certain values of freq created interesting Moire patterns in the output; hence the title of this post.

Here are a few screenshots below that show those moire patterns:

With freq = 764:


With freq = 472:


With freq = 475:


With freq = 479:


Notice that in some cases, such as with the values of 472, 475 and 479 for freq, the small changes between those values results in significant changes in the output image. Not only that: for 472 and 479, the images are similar (look sine-wave-y), but for 475 (which is between the other two values), the image looks almost like straight vertical lines. (It isn't, of course; it's still a sine wave, but more compressed along the horizontal axis.) I've not analyzed the reason for this in detail; something to do with the periodicity of the sine function, is my rough guess, but I have seen similar phenomena when drawing other kinds of computer graphics on the screen; those also involved trigonometric functions such as sine and cosine.

Spyre away :)

P.S. In other news, I was recently profiled in PyDev of the Week.

- Vasudev Ram - Online Python training and programming

Dancing Bison Enterprises

Signup to hear about new products or services that I create.

Posts about Python  Posts about xtopdf

Contact Page

Wednesday, October 1, 2014

Cloudera acquires Datapad; has Python client for Impala (SQL on Hadoop)

By Vasudev Ram


Saw this via a tweet by GigaOm.

Cloudera has acquired Datapad.

GigaOm article about it:

Cloudera bought DataPad because data scientists need tooling, too

Summary of the GigaOm article about the acquisition:

[ Cloudera has acquired a data-visualization startup called DataPad, the founding team of which specializes in data analysis using the Python programming language [1]. As Hadoop competition heats up, Cloudera might be ramping up its Python tooling in order to attract more data scientists and developers. ]

[1] The founders of DataPad (Wes McKinney and Chang She) are also the creators of the pandas Python library for data analysis.

Here are a few other interesting links related to Cloudera buying Datapad:

A New Python Client for Impala

I had blogged earlier about Cloudera's Impala engine that allows SQL querying of Hadoop data:

Cloudera's Impala engine - SQL querying of Hadoop data

SQL coming to Hadoop

Cloudera: Impala’s it for interactive SQL on Hadoop; everything else will move to Spark

Apache Spark - "Lightning-fast cluster computing"

Apache Spark page on Wikipedia

WIRED magazine article about Apache Spark:

Open Source Superstar Rewrites Future of Big Data

- Vasudev Ram - Dancing Bison Enterprises

Click here to signup for email notifications about new products and services from Vasudev Ram.

Contact Page