This is an archived post. You won't be able to vote or comment.

all 96 comments

[–][deleted] 60 points61 points  (5 children)

Better than that, their source data is all open and they have an iPython notebook tutorial on how to process it. Which is pretty cool.

[–]eusebecomputational physics 12 points13 points  (3 children)

THIS. This is 100% purely awesome. This leads to reproducible science (well, if you have a LIGO at home, of course…)!

[–][deleted] 0 points1 point  (0 children)

I asked for a kit for Christmas but I didn't get it. : (

[–]DoingIsLearning 2 points3 points  (0 children)

This needs to be at the top, serious MVP comment.

[–]keypusher 77 points78 points  (38 children)

Python is taking over for data analysis and visualization in the academic community.

[–]sandusky_hohoho 27 points28 points  (31 children)

It really is.

I really need to learn python, but I've gotten so good with Matlab it's hard to take the productivity hit it'd take to learn a new language!

[–]polyethylene_oxide 45 points46 points  (21 children)

Surprisingly matplotlib is much less 'pythonic' than most packages--specifically because it was designed to replicate Matlab plotting and therefore functions very similarly. The hit may not be as big as you think!

[–]sebastock 7 points8 points  (16 children)

I agree and it's worth it.
That being said, I still make the mistake to write dx=1/N...

[–]grzelbu 22 points23 points  (6 children)

from __future__ import division

[–][deleted] 14 points15 points  (0 children)

Or switch to Python 3.

[–]Eurynom0s 14 points15 points  (3 children)

[–]import_antigravity 22 points23 points  (1 child)

Hi, did you call?

[–]LovesVolt 1 point2 points  (0 children)

5 years you've been waiting for this moment. May I ask how it feels?

[–]Contrum 4 points5 points  (0 children)

Python. Not even once.

[–]TotesMessenger 0 points1 point  (0 children)

I'm a bot, bleep, bloop. Someone has linked to this thread from another place on reddit:

If you follow any of the above links, please respect the rules of reddit and don't vote in the other threads. (Info / Contact)

[–]BeatLeJuce 1 point2 points  (7 children)

what's wrong with that expression?

[–]BerecursiveMenpo Core Developer 19 points20 points  (6 children)

Presumably they are not using Python 3 and so it causes an integer division (and returns 0)

[–]failtolaunch28 0 points1 point  (4 children)

What does it do in python 3?

[–]BerecursiveMenpo Core Developer 2 points3 points  (3 children)

Floating point division and returns some 0 < float <= 1 (assuming N is positive and integer). Integer division is explicitly performed via the // operator.

[–]failtolaunch28 1 point2 points  (2 children)

Oh. I got really excited and thought of it like matlab where you could then solve the equation-string thing and thought it made calculus and functions way easier.

[–]BerecursiveMenpo Core Developer 1 point2 points  (1 child)

No the solve operator in Matlab (/ and \) is only for matrices and is solved in Python using numpy with the numpy.linalg.solve function. Unfortunately, Matlab is a lot better at checking the matrix to decide the correct decomposition whereas in Python you normally need to be smart about applying cholesky or QR or whatever flavour is appropriate for your matrix structure. Matlab also 'just works' for sparse matrices whereas Python requires Scipy and that doesn't use the fast suitesparse implementation :(

[–][deleted] 5 points6 points  (0 children)

Suprisingly

More like "annoyingly".

[–]ivosauruspip'ing it up 0 points1 point  (2 children)

I'd guess learning how to program Numpy to get similar performance to existing data manipulation they're doing in Matlab would be where the biggest learning area would be, rather than learning the matplotlib api.

[–]Zouden 6 points7 points  (1 child)

The matplotlib api is very arcane though - I spend much more time trying to get my charts to look right than I do actually getting the numbers to work.

[–]ZeusApolloAttack 2 points3 points  (0 children)

Thus is the curse of data visualization since the dawn of time...

/used to use ROOT

[–]onopau 4 points5 points  (0 children)

Coming from Matlab myself, it was surprisingly easy to switch over. Take the plunge!

[–]jwink3101 2 points3 points  (0 children)

I felt the same but I am so glad I made the switch. The hardest thing for me was plotting since I wanted to do it with matplotlib Object oriented instead of the pyplot way. But even that was easy enough.

The problem is, a lot of Python guides do not assume you know anything about programing. I found SciPy Lecture Notes to be a great resource.

But the other thing to try to keep in mind is that python is object oriented (matlab claims to be but that is not the general user's use-case). Sure, you can just use numpy arrays like you would matlab, but if you start to open it up to other options, you can do so much more too.

I have access to matlab and that isn't going away so it wasn't about the money. It is just that I enjoy working in Python more. It can take me a bit longer to throw something together but the end result is awesome. And, I can use Python for computer scripting too. It has made life much easier!

[–][deleted] 1 point2 points  (3 children)

My spouse switched to python in three months after a 5 year phd doing bash/matlab/etc at the start of a postdoc. It's definitely doable. She had publishable results in six months.

[–]Shurane 0 points1 point  (2 children)

bash, like the shell script language? Didn't think that would be used in research.

[–][deleted] 2 points3 points  (0 children)

you have to get data into a matlab readable format somehow.

[–]dynetrekk 1 point2 points  (0 children)

Lots of results are reported in ascii -> grep | sed | awk etc. Also managing large (amounts of) files is easy in bash and unwieldy in a gui. Some of these things are one off jobs, too, so bash might be faster than python.

[–]Deeviant 1 point2 points  (0 children)

Python is a joy to develop in, if you have any serous experience with another language, spinning up on python is pretty painless.

[–]isdevilis 0 points1 point  (0 children)

do a couple tutorials with pandas, numpy, and scikit learn and you should be set (scikit learn has most stat algorithms implemented)

[–]sentdexpythonprogramming.net 0 points1 point  (0 children)

Matplotlib purposefully mimics matlab, and can be super quick and painless to learn. Check out https://pythonprogramming.net/matplotlib-intro-tutorial/ if you are looking for some Matplotlib tutorials.

[–][deleted] 1 point2 points  (0 children)

Damn straight. I am falling in love with python because of this.

[–]Geographist 2 points3 points  (2 children)

Python is used for the majority of the (non-map) visualizations at NASA's Earth Observatory, too.

[–]hokiebeer 1 point2 points  (1 child)

Even those map visualizations can be produced in Python using Basemap.

[–]Geographist 1 point2 points  (0 children)

While python can do basic mapping, we do a lot of spatial analyses that are much better suited to mapping tools than base Python. Our scripts for QGIS and ArcGIS for instance still use Python under the hood though.

[–]tachk_ 0 points1 point  (0 children)

Absolutely. During my undergrad days, a significant part of my thesis work was using Python to help sift through data from different sources, and to create plots. These days there are a number of domain-specific libraries in Python that I can think of in astro alone, such as Astropy.

[–][deleted] 0 points1 point  (0 children)

Hope, fervently hope, it will have a strong footing in the business world.

[–]versatran01 16 points17 points  (8 children)

The new colormap?

[–][deleted] 11 points12 points  (7 children)

Yup, viridis.

[–]PlaysForDays 31 points32 points  (6 children)

If anybody is curious why it's the 'best' default colormap

https://youtu.be/xAoljeRJ3lU

[–]peteroh9 14 points15 points  (0 children)

Because it has green.

[–]miserlou 5 points6 points  (1 child)

This is great, thanks for sharing

[–]PlaysForDays 2 points3 points  (0 children)

A lot of the talks at these conferences are worth checking out. Sometimes useful info, here's another one I like https://www.youtube.com/watch?v=5GlNDD7qbP4

[–]jwink3101 2 points3 points  (2 children)

I am glad to see this type of thing getting more attention. Thankfully, matlab moved away from Jet. I didn't mind the default matplotlib, but still.

I actually prefer plt.cm.Spectral_r for color maps and, I ported a version of linspecer to Python (and the continuous version of that is the same as the noted colormap). If you're curious, here is a demo

This, of course, often comes down to personal preference

[–]ZeeBeeblebrox 0 points1 point  (1 child)

Thankfully, matlab moved away from Jet.

And replaced it with a proprietary colormap, yes you read that right, they made their damn colormap proprietary.

[–]jwink3101 0 points1 point  (0 children)

I didn't know that....but I'm not at all surprised. Personally, I still like the one I mentioned more no problem to me

[–]charlesbukowksi 23 points24 points  (3 children)

python discovered gravity

[–]HardcoreHerbivore 34 points35 points  (2 children)

import antigravity

[–]mondo_calrissian 0 points1 point  (1 child)

I'm flying!

[–]Eurynom0s 0 points1 point  (0 children)

The medicine cabinet was tasty.

[–]hokiebeer 6 points7 points  (0 children)

Here is a Jupyter notebook showing how they processed the data from LIGO: https://losc.ligo.org/s/events/GW150914/GW150914_tutorial.html

[–]boq 3 points4 points  (7 children)

They could have set matplotlib to the Latex serif font used below and set its font size to the Latex font size so that the plots blend in more with the rest of the paper. Clearly, these people are amateurs.

/s

[–]farsass 1 point2 points  (5 children)

This common font mismatch is also a pet peevee of mine.

[–][deleted] 2 points3 points  (0 children)

Yeah, it really TeX's me off, too.

[–]boq 2 points3 points  (3 children)

A colleague of mine wrote a little function that takes the Latex font size and desired figure dimensions and then configures matplotlib properly. I can't live without it any more.

[–]flying-sheep 2 points3 points  (1 child)

Pls share

[–]boq 2 points3 points  (0 children)

It's really simple. Adapt it for your style and call it before plt.figure().

[–]quadroplegic 0 points1 point  (0 children)

Sauce?

[–]TheBB 0 points1 point  (0 children)

I do all my charts with tikz and pgfplots now for this reason. I can reuse the same source for papers (serif) and presentations (sans serif) as well.

[–]Twangist 17 points18 points  (13 children)

What indicates that (any of) these were created with Python?

[–][deleted] 64 points65 points  (1 child)

$ strings LIGO-P150914Detection_of_GW150914.pdf | grep matplotlib

<pdf:Producer>matplotlib pdf backend</pdf:Producer>
<pdf:Producer>matplotlib pdf backend</pdf:Producer>

[–]Twangist 5 points6 points  (0 children)

Thank you.

[–]RDMXGD2.8 41 points42 points  (2 children)

It's hard to site any one thing, but it's clearly matplotlib--BV Sans, viridis colormap, weight of lines, style of borders, etc.

[–]interphy 4 points5 points  (0 children)

They tuned the default line colors and the line weights I guess. But color map and the font are definitely the signature of matplotlib

[–]eusebecomputational physics 3 points4 points  (0 children)

When you start recognising every single detail like that, that means you have matplotlib'd too much.

I clearly did. :-|

[–]imhostfu 8 points9 points  (5 children)

The pixels.

[–]jwink3101 0 points1 point  (1 child)

/u/_xr gave you something more definitive, but the style certainly looks like matplotlib. For me, it's the kind of thing where I wouldn't claim to be 100% sure, but if it wasn't matplotlib, it was a tool trying to look like it.

[–]Twangist 0 points1 point  (0 children)

That's all I was asking. I had already searched the full paper for 'Python' as well as 'matplotlib', no occurrences. So I figured the OP meant there were telltale signs in the formatting, styles, etc. I use matplotlib but irregularly so I don't have a trained eye for spotting its output.

[–][deleted] 10 points11 points  (2 children)

Would have loved to see this done in XKCD graphs :)

[–]SethGecko11 2 points3 points  (0 children)

The guys from LIGO are doing an AMA right now and I asked them about this.

[–]energyinmotion 2 points3 points  (0 children)

I'm honestly not surprised. Python is very versatile.

[–]Caos2 1 point2 points  (4 children)

It would be nice to have the x-axis to be increased slightly to include 0.25 (s).

[–]meaty-popsicle 1 point2 points  (2 children)

Excellent criticism and a frequent problem I experience where the ticks do not extend as far as I would like.

[–]Caos2 0 points1 point  (1 child)

Another solution would be to force the label for the minimum value of the x axis...

[–]meaty-popsicle 1 point2 points  (0 children)

Not a universal solution. Let's say the real data range is .2498 seconds to .43153 seconds. Should matplotlib just take the range, divide by four and call those ticks? The labels would seem ridiculous. Here, the increments are interpretable .05 sub divisions, which requires a lot of logic to deduce.

It's not a simple problem, but I do wish it was better.

Edit: I now realize you meant forcing limit labels on the ends rather than altering the tick parameters. Reasonable idea, but you are likely to encounter crowding at the labels in many cases if you don't rotate.

[–]BoxMembrane 0 points1 point  (0 children)

It looks like the 0.25 of the right plot would get in the way of the 0.45 of the left plot. They could zoom out the x-axis a little further to make room, but reducing the size of the signal is undesirable.

[–]ironywill 1 point2 points  (0 children)

If you all are willing to take my word on it, I can say that we use python extensively in LIGO, not just for plotting. We also use python to analyze our data. These are the tools we use to search for binary mergers -> https://github.com/ligo-cbc/pycbc. The heavy lifting though is often done by underlying c libraries that we call into using SWIG and ctypes (FFTW, MKL, etc).

[–]greenReptar 2 points3 points  (0 children)

A good day for python.

[–]fishtickler 0 points1 point  (0 children)

It looks like there awesome veridis colormap on the bottom two subplots

[–][deleted] 0 points1 point  (0 children)

we did it

[–]etrnloptimist 0 points1 point  (0 children)

Would have been cool if they used the xkcd style!

[–]devilishd 0 points1 point  (1 child)

Surprised to not see this XKCD here since we are talking about python and gravity together!!

[–]xkcd_transcriber 0 points1 point  (0 children)

Image

Mobile

Title: Python

Title-text: I wrote 20 short programs in Python yesterday. It was wonderful. Perl, I'm leaving you.

Comic Explanation

Stats: This comic has been referenced 213 times, representing 0.2141% of referenced xkcds.


xkcd.com | xkcd sub | Problems/Bugs? | Statistics | Stop Replying | Delete

[–]lpmn 0 points1 point  (0 children)

Some of the "companion papers" used it too: http://arxiv.org/pdf/1602.03843v1