Python workflow for experimental data analysis

In summary, you are using a combo of sublime text 3 (plus Anaconda plugins) and Spyder IDE for data visualization and running code on its Ipython interpreter. You are not satisfied with your workflow specifically for plotting needs and would like to save plots and processed data in a tidy way. However, you find yourself more productive for plotting and light data processing on Originpro.
  • #1
franciobr
13
0
Hello!

I have been using python for my data analysis and processing needs as an experimental physicist for an year now. I have used MATLAB and originpro before and python provides me everything I need.
But I am not satisfacted with my worflow specifically for plotting needs. I often find myself looking for old plots (images) that I did and having to rewrite code to do them over again, which is counterproductive.

I am currently using a combo of sublime text 3 (plus Anaconda plugins) and Spyder IDE for data visualization and running code on its Ipython interpreter (I like the variable explorer and the Ipython interpreter is much superior to SublimeREPL) . It works great for data processing and general coding but saving plots and processed data in a tidy way has been a hassle. If I could save all my workspace like in MATLAB it would be much better (Spyder's implementation of this is limited).

Originpro in contrast automatically saves all the data and plots in the same project which is a great workflow for plotting and saving your work. I must say that even having a decent background with python I find myself more productive for plotting and light data processing on originpro.

I am aware that there are alternatives such as Jupyter and Pycharm. Maybe I should give Jupyter notebook another shot.

I wanted to have some insight from you guys. What is your workflow for data analysis/plotting with python? Do you have a hard time going back and editting plots and datasets? How do you save your work?
 
Technology news on Phys.org
  • #2
from your post, you appear to not be saving your python scripts. Sure in Matlab you can save the workspace, but I never do, I write everything as a .m file and rerun later if I have to. I also work my imagery/plots then save a copy to refer back to later and include in presentations and reports, so why aren't you doing the same with your python.
 
  • #3
Well, I do save most of my python scripts but some work I do in the form of interactive programming (ipython interpreter). Specially when I am exploring the data and testing different visualizations. And sometimes I do batches of plot that involve running a combination of custom function several times and it is time consuming to document everything in such way I can recreate that specific workspace by running a single script. I wish I could just pick it up from where I left and easily edit the work instead of having to recreate it every time.
 
  • #4
Can you programmatically create a log of your selected options [as a text file],
together with accompanying plot images, possibly dumped into a folder with a timestamp label?
You might consider outputting in that text file the python code of your options [e.g. function calls with parameters] that you could copy-paste to reproduce the plot.
(Later, you could write a script that will [say] create an html page that can show all of the plot images (sitting in the various folders) so that you can survey the variations.)
 
  • #5
When I do a new analysis in matlab, I will comment out lines, document and add to the file until I get what I want, I don't really ever delete lines of code, if you did that in your scripts then you'd have your log of keystrokes...
 
  • #6
I suggest using an ipython notebook. I typically use the nohup command so that the ipython server persists if the terminal is closed

nohup jupyter notebook &

You can embed live plots (that is, they can be zoomed, panned, saved to disc, etc) using the %matplotlib magic command

%matplotlib notebook
 
  • #7
I was on vacation and away from data analysis and science for a while, sorry for the long time without showing up. Thank you robphy and Dr. Transport for the thoughtful answers. I could use the history from my commands or thoroughly document everything but it seems to be too much trouble to me.

Daverz said:
I suggest using an ipython notebook. I typically use the nohup command so that the ipython server persists if the terminal is closed

nohup jupyter notebook &

You can embed live plots (that is, they can be zoomed, panned, saved to disc, etc) using the %matplotlib magic command

%matplotlib notebook

Turns out the jupyter notebook is really good for plotting! I did not know about the %matplotlib notebook (just the inline magic command) and it is very helpful. I had tried the notebook before for general programming and felt it lacking some IDE features for lots of coding. Having all the plots and their code right next to each other is great for editing and documenting my work. I can also add some code and latex equations with the notebook and do some sharing of the analysis. Still not ditching sublime for some "serious" coding but for light coding and plotting Jupyter is awesome! It also supports R which I use from time to time. Thanks for the tip Daverz.

it seems the jupyter team is working on a project to turn jupyter notebook into a "full featured" IDE called jupyter lab http://blog.jupyter.org/2016/07/14/jupyter-lab-alpha/. Looks promising, will definitely check it out once version 1.0 comes out.
 

1. What is Python workflow for experimental data analysis?

Python workflow for experimental data analysis refers to the process of using the Python programming language to analyze and interpret data collected from scientific experiments. It involves using a series of steps, tools, and techniques to clean, process, and analyze data in order to gain insights and make conclusions.

2. Why is Python a popular choice for experimental data analysis?

Python is a popular choice for experimental data analysis because it is a versatile and powerful programming language with a wide range of libraries and tools specifically designed for data analysis and scientific computing. It also has a simple and intuitive syntax, making it easier for researchers to write and understand code.

3. What are some common tools and libraries used in Python workflow for experimental data analysis?

Some common tools and libraries used in Python workflow for experimental data analysis include NumPy, Pandas, SciPy, and Matplotlib. These libraries offer a wide range of functions and methods for data manipulation, analysis, and visualization, making them essential for any data analysis project.

4. How can Python improve the efficiency of experimental data analysis?

Python can improve the efficiency of experimental data analysis by providing a streamlined and automated workflow. With the help of libraries and tools, repetitive tasks can be automated, reducing the time and effort required for data analysis. Additionally, the simplicity of the language allows for faster development and troubleshooting.

5. Are there any challenges associated with using Python for experimental data analysis?

While Python offers many advantages for experimental data analysis, there are also some challenges to consider. One potential challenge is the learning curve, as Python may be new to some researchers. There may also be compatibility issues with existing data analysis tools and systems. However, with practice and proper training, these challenges can be overcome.

Similar threads

  • Programming and Computer Science
Replies
1
Views
253
  • Programming and Computer Science
Replies
17
Views
1K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
7
Views
2K
  • Programming and Computer Science
Replies
5
Views
3K
  • Programming and Computer Science
Replies
1
Views
1K
Replies
5
Views
2K
Replies
6
Views
1K
  • STEM Career Guidance
Replies
3
Views
1K
  • Programming and Computer Science
Replies
2
Views
1K
Back
Top