Ipython: a System for Interactive Scientific
Total Page:16
File Type:pdf, Size:1020Kb
Load more
Recommended publications
-
Alternatives to Python: Julia
Crossing Language Barriers with , SciPy, and thon Steven G. Johnson MIT Applied Mathemacs Where I’m coming from… [ google “Steven Johnson MIT” ] Computaonal soPware you may know… … mainly C/C++ libraries & soPware … Nanophotonics … oPen with Python interfaces … (& Matlab & Scheme & …) jdj.mit.edu/nlopt www.w.org jdj.mit.edu/meep erf(z) (and erfc, erfi, …) in SciPy 0.12+ & other EM simulators… jdj.mit.edu/book Confession: I’ve used Python’s internal C API more than I’ve coded in Python… A new programming language? Viral Shah Jeff Bezanson Alan Edelman julialang.org Stefan Karpinski [begun 2009, “0.1” in 2013, ~20k commits] [ 17+ developers with 100+ commits ] [ usual fate of all First reacBon: You’re doomed. new languages ] … subsequently: … probably doomed … sll might be doomed but, in the meanBme, I’m having fun with it… … and it solves a real problem with technical compuBng in high-level languages. The “Two-Language” Problem Want a high-level language that you can work with interacBvely = easy development, prototyping, exploraon ⇒ dynamically typed language Plenty to choose from: Python, Matlab / Octave, R, Scilab, … (& some of us even like Scheme / Guile) Historically, can’t write performance-criBcal code (“inner loops”) in these languages… have to switch to C/Fortran/… (stac). [ e.g. SciPy git master is ~70% C/C++/Fortran] Workable, but Python → Python+C = a huge jump in complexity. Just vectorize your code? = rely on mature external libraries, operang on large blocks of data, for performance-criBcal code Good advice! But… • Someone has to write those libraries. • Eventually that person may be you. -
Data Visualization in Python
Data visualization in python Day 2 A variety of packages and philosophies • (today) matplotlib: http://matplotlib.org/ – Gallery: http://matplotlib.org/gallery.html – Frequently used commands: http://matplotlib.org/api/pyplot_summary.html • Seaborn: http://stanford.edu/~mwaskom/software/seaborn/ • ggplot: – R version: http://docs.ggplot2.org/current/ – Python port: http://ggplot.yhathq.com/ • Bokeh (live plots in your browser) – http://bokeh.pydata.org/en/latest/ Biocomputing Bootcamp 2017 Matplotlib • Gallery: http://matplotlib.org/gallery.html • Top commands: http://matplotlib.org/api/pyplot_summary.html • Provides "pylab" API, a mimic of matlab • Many different graph types and options, some obscure Biocomputing Bootcamp 2017 Matplotlib • Resulting plots represented by python objects, from entire figure down to individual points/lines. • Large API allows any aspect to be tweaked • Lengthy coding sometimes required to make a plot "just so" Biocomputing Bootcamp 2017 Seaborn • https://stanford.edu/~mwaskom/software/seaborn/ • Implements more complex plot types – Joint points, clustergrams, fitted linear models • Uses matplotlib "under the hood" Biocomputing Bootcamp 2017 Others • ggplot: – (Original) R version: http://docs.ggplot2.org/current/ – A recent python port: http://ggplot.yhathq.com/ – Elegant syntax for compactly specifying plots – but, they can be hard to tweak – We'll discuss this on the R side tomorrow, both the basics of both work similarly. • Bokeh – Live, clickable plots in your browser! – http://bokeh.pydata.org/en/latest/ -
Writing Mathematical Expressions with Latex
APPENDIX A Writing Mathematical Expressions with LaTeX LaTeX is extensively used in Python. In this appendix there are many examples that can be useful to represent LaTeX expressions inside Python implementations. This same information can be found at the link http://matplotlib.org/users/mathtext.html. With matplotlib You can enter the LaTeX expression directly as an argument of various functions that can accept it. For example, the title() function that draws a chart title. import matplotlib.pyplot as plt %matplotlib inline plt.title(r'$\alpha > \beta$') With IPython Notebook in a Markdown Cell You can enter the LaTeX expression between two '$$'. $$c = \sqrt{a^2 + b^2}$$ c= a+22b 537 © Fabio Nelli 2018 F. Nelli, Python Data Analytics, https://doi.org/10.1007/978-1-4842-3913-1 APPENDIX A WRITING MaTHEmaTICaL EXPRESSIONS wITH LaTEX With IPython Notebook in a Python 2 Cell You can enter the LaTeX expression within the Math() function. from IPython.display import display, Math, Latex display(Math(r'F(k) = \int_{-\infty}^{\infty} f(x) e^{2\pi i k} dx')) Subscripts and Superscripts To make subscripts and superscripts, use the ‘_’ and ‘^’ symbols: r'$\alpha_i > \beta_i$' abii> This could be very useful when you have to write summations: r'$\sum_{i=0}^\infty x_i$' ¥ åxi i=0 Fractions, Binomials, and Stacked Numbers Fractions, binomials, and stacked numbers can be created with the \frac{}{}, \binom{}{}, and \stackrel{}{} commands, respectively: r'$\frac{3}{4} \binom{3}{4} \stackrel{3}{4}$' 3 3 æ3 ö4 ç ÷ 4 è 4ø Fractions can be arbitrarily nested: 1 5 - x 4 538 APPENDIX A WRITING MaTHEmaTICaL EXPRESSIONS wITH LaTEX Note that special care needs to be taken to place parentheses and brackets around fractions. -
SSWGDL Installation on Ubuntu 10.04 Using VMWARE Player
SSWGDL Installation on Ubuntu 10.04 using VMWARE Player 1. Install ubuntu 10.04 on vmware a) ubuntu-10.04.1-desktop-i386.iso, 32 bit b) configure with 1-2 GB mem, 20-40 GB disk c) vmware tools - d) shared folders e) do not enable multiple processors even if your machines supports many f) pword yourpassword g) /home/yourname - that's the way I did it - h) login name is yourchoice 2. Configure Ubuntu a) do default system update via system update manager b) install vmware tools using easy install, run the perl scipt (.pl), let it compile and install c) use ubuntu software center d) cvs, plplot x11 driver, tcsh, wxidgets I grabbed wx2.8 dev and lib packages, see package- manager-installs.txt for details. 3. Download and install GDL with dependencies a) Download and unpack 0.90 release tar.gz into gdl-0.9 (use current release from gdl) b) Get dependencies using sudo apt-get build-dep gnudatalanguage c) cd to gdl-0.9 d) Configure using “./configure --with-Magick=no --with-python=no --with-openmp=no – with-hdf=no” e) Does anyone know how to install numarray so we don't have to use python=no switch f) Here is the message of success after configure: GDL - GNU Data Language • ----- compilation options: --------------------------- • System: i686-pc-linux-gnu • Installation prefix: /usr/local • C++ compiler: g++ -g -O2 • OpenMP support: no • Build type: standalone (other: Python module) • ----- optional libraries (consult README/INSTALL): --- • wxWidgets: yes • Magick: no • NetCDF: yes • HDF4: no • HDF5: yes • FFTW: yes • libproject: no (see also -
Jazyk Gdl Na Spracovanie Vedeckých Dát
JAZYK GDL NA SPRACOVANIE VEDECKÝCH DÁT ŠECHNÝ, Martin (SK) Abstrakt. GNU Data Language (GDL) je jazyk na spracovanie vedeckých dát a zároveň prostredie na spúšťanie programov v tomto jazyku. GDL je slobodný softvér kompatibilný s komerčne licencovaným Interactive Data Language (IDL). GDL je platformovo nezávislé prostredie a využíva iné dostupné nainštalované knižnice a aplikácie. Jazyk GDL umožňuje spracovávať vstupy z klávesnice, dátové súbory, obrázky a dokáže vizualizovať dáta tabuľkami, grafmi, obrázkami. GDL je efektívny pri numerickej analýze dát, vektorovej reprezentácii, použití matematických funkcií a procedúr. Tento nástroj je vhodný pre široké použitie vo vede, výskume, aj ako alternatíva k známym matematickým a vizualizačným nástrojom. Kľúčové slová. GDL, IDL, vedecké dáta, programovanie, vizualizácia. GDL LANGUAGE FOR SCIENTIFIC DATA PROCESSING Abstract. GNU Data Language (GDL) is a language for scientific data processing and also the environment for launching programs in that language. GDL is a free software that is compatible with commercially licensed Interactive Data Language (IDL). GDL is a platform-independent environment and uses other available libraries and applications installed. GDL language enables to process keyboard input, data files, images and can visualize data tables, charts, pictures. GDL is effective in the analysis of numerical data, vector representation, the use of mathematical functions and procedures. This tool is suitable for wide use in science, research, and as an alternative to known mathematical and visualization tools. Key words and phrases. GDL, IDL, scientific data, programming, visualization. 1 Úvod GNU Data Language (GDL)1 je jazyk na spracovanie vedeckých dát a zároveň prostredie (interpreter a inkrementálny prekladač) na spúšťanie programov v tomto jayzku. -
Ipython Documentation Release 0.10.2
IPython Documentation Release 0.10.2 The IPython Development Team April 09, 2011 CONTENTS 1 Introduction 1 1.1 Overview............................................1 1.2 Enhanced interactive Python shell...............................1 1.3 Interactive parallel computing.................................3 2 Installation 5 2.1 Overview............................................5 2.2 Quickstart...........................................5 2.3 Installing IPython itself....................................6 2.4 Basic optional dependencies..................................7 2.5 Dependencies for IPython.kernel (parallel computing)....................8 2.6 Dependencies for IPython.frontend (the IPython GUI).................... 10 3 Using IPython for interactive work 11 3.1 Quick IPython tutorial..................................... 11 3.2 IPython reference........................................ 17 3.3 IPython as a system shell.................................... 42 3.4 IPython extension API..................................... 47 4 Using IPython for parallel computing 53 4.1 Overview and getting started.................................. 53 4.2 Starting the IPython controller and engines.......................... 57 4.3 IPython’s multiengine interface................................ 64 4.4 The IPython task interface................................... 78 4.5 Using MPI with IPython.................................... 80 4.6 Security details of IPython................................... 83 4.7 IPython/Vision Beam Pattern Demo............................. -
Easybuild Documentation Release 20210907.0
EasyBuild Documentation Release 20210907.0 Ghent University Tue, 07 Sep 2021 08:55:41 Contents 1 What is EasyBuild? 3 2 Concepts and terminology 5 2.1 EasyBuild framework..........................................5 2.2 Easyblocks................................................6 2.3 Toolchains................................................7 2.3.1 system toolchain.......................................7 2.3.2 dummy toolchain (DEPRECATED) ..............................7 2.3.3 Common toolchains.......................................7 2.4 Easyconfig files..............................................7 2.5 Extensions................................................8 3 Typical workflow example: building and installing WRF9 3.1 Searching for available easyconfigs files.................................9 3.2 Getting an overview of planned installations.............................. 10 3.3 Installing a software stack........................................ 11 4 Getting started 13 4.1 Installing EasyBuild........................................... 13 4.1.1 Requirements.......................................... 14 4.1.2 Using pip to Install EasyBuild................................. 14 4.1.3 Installing EasyBuild with EasyBuild.............................. 17 4.1.4 Dependencies.......................................... 19 4.1.5 Sources............................................. 21 4.1.6 In case of installation issues. .................................. 22 4.2 Configuring EasyBuild.......................................... 22 4.2.1 Supported configuration -
Intro to Jupyter Notebook
Evan Williamson University of Idaho Library 20160302 Introducing Jupyter Notebook for Python and R Three questions: http://goo.gl/forms/uYRvebcJkD Try Jupyter https://try.jupyter.org/ Install Jupyter ● Get Python (suggested: Anaconda, Py3, 64bit, https://www.continuum.io/downloads ) ● Manually install (if necessary), http://jupyter.readthedocs.org/en/latest/install.html pip3 install jupyter Install R for Jupyter ● Get R, https://cran.cnr.berkeley.edu/ (suggested: RStudio, https://www.rstudio.com/products/RStudio/#Desktop ) ● Open R console and follow: http://irkernel.github.io/installation/ Start a Notebook ● Open terminal/command prompt jupyter notebook ● Notebook will open at http://127.0.0.1:8888 ● Exit by closing the browser, then typing Ctrl+C in the terminal window Create Slides ● Open terminal/command prompt jupyter nbconvert slideshow.ipynb --to slides --post serve ● Note: “post serve” locally serves the file so you can give a presentation in your browser. If you only want to convert, leave this option off. The resulting HTML file must be served to render correctly. Slides use Reveal.js, http://lab.hakim.se/revealjs/ Reference ● Jupyter docs, http://jupyter.readthedocs.org/en/latest/index.html ● IPython docs, http://ipython.readthedocs.org/en/stable/index.html ● List of kernels, https://github.com/ipython/ipython/wiki/IPythonkernelsforotherlanguages ● A gallery of interesting IPython Notebooks, https://github.com/ipython/ipython/wiki/AgalleryofinterestingIPythonNotebooks ● Markdown basics, -
Numpy for MATLAB Users – Mathesaurus
NumPy for MATLAB users Help MATLAB/Octave Python Description doc help() Browse help interactively help -i % browse with Info help help or doc doc help Help on using help help plot help(plot) or ?plot Help for a function help splines or doc splines help(pylab) Help for a toolbox/library package demo Demonstration examples Searching available documentation MATLAB/Octave Python Description lookfor plot Search help files help help(); modules [Numeric] List available packages which plot help(plot) Locate functions Using interactively MATLAB/Octave Python Description octave -q ipython -pylab Start session TAB or M-? TAB Auto completion foo(.m) execfile('foo.py') or run foo.py Run code from file history hist -n Command history diary on [..] diary off Save command history exit or quit CTRL-D End session CTRL-Z # windows sys.exit() Operators MATLAB/Octave Python Description help - Help on operator syntax Arithmetic operators MATLAB/Octave Python Description a=1; b=2; a=1; b=1 Assignment; defining a number a + b a + b or add(a,b) Addition a - b a - b or subtract(a,b) Subtraction a * b a * b or multiply(a,b) Multiplication a / b a / b or divide(a,b) Division a .^ b a ** b Power, $a^b$ power(a,b) pow(a,b) rem(a,b) a % b Remainder remainder(a,b) fmod(a,b) a+=1 a+=b or add(a,b,a) In place operation to save array creation overhead factorial(a) Factorial, $n!$ Relational operators MATLAB/Octave Python Description a == b a == b or equal(a,b) Equal a < b a < b or less(a,b) Less than a > b a > b or greater(a,b) Greater than a <= b a <= b or less_equal(a,b) -
Status of GDL-GNU Data Language
Astronomical Data Analysis Software and Systems XIX O14.3 ASP Conference Series, Vol. XXX, 2009 Y. Mizumoto, K.-I. Morita, and M. Ohishi, eds. Status of GDL - GNU Data Language A. Coulais LERMA, Obs. de Paris, ENS, UPMC, UCP, CNRS, Paris, France M. Schellens1 J. Gales Goddard Space Flight Center, Greenbelt, MD, USA S. Arabas Institute of Geophysics, University of Warsaw, Poland M. Boquien University of Massachusetts, Dep. of Astronomy, Amherst, MA, USA P. Chanial P. Messmer, D. Fillmore Tech-X GmbH, Zurich, Switzerland; Tech-X Corp, Boulder, CO, USA O. Poplawski Colorado Div. (CoRA) of NorthWest Res. Ass. Inc., Boulder, CO, USA S. Maret LAOG, Obs. de Grenoble, UJF, CNRS, Grenoble, France G. Marchal2, N. Galmiche2, T. Mermet2 arXiv:1101.0679v1 [astro-ph.IM] 4 Jan 2011 Abstract. Gnu Data Language (GDL) is an open-source interpreted language aimed at numerical data analysis and visualisation. It is a free implementation of the Interactive Data Language (IDL) widely used in Astronomy. GDL has a full syntax compatibility with IDL, and includes a large set of library routines targeting advanced matrix manipulation, plotting, time-series and image analy- sis, mapping, and data input/output including numerous scientific data formats. We will present the current status of the project, the key accomplishments, and the weaknesses - areas where contributions are welcome! 1Head of the project 2Former students at LERMA CNRS and Observatoire de Paris 1 2 Coulais et al. 1. Dependencies GDL is written in C++ and can be compiled on systems with GCC (≥ 3.4) and X11 or equivalents. The code, under GNU GPL, is hosted by SourceForge. -
GNU Data Language (GDL) - a Free and Open-Source Implementation of IDL
Geophysical Research Abstracts Vol. 12, EGU2010-924-1, 2010 EGU General Assembly 2010 © Author(s) 2009 GNU Data Language (GDL) - a free and open-source implementation of IDL Sylwester Arabas (1), Marc Schellens (), Alain Coulais (2), Joel Gales (3), and Peter Messmer (4) (1) Institute of Geophysics, University of Warsaw, Warsaw, Poland ([email protected] / +48225546882), (2) LERMA, CNRS and Observatoire de Paris, Paris, France, (3) NASA Goddard Space Flight Center, Greenbelt, Maryland, USA, (4) Tech-X Corporation, Boulder, Colorado, USA GNU Data Language (GDL) is developed with the aim of providing an open-source drop-in replacement for the ITTVIS’s Interactive Data Language (IDL). It is free software developed by an international team of volunteers led by Marc Schellens - the project’s founder (a list of contributors is available on the project’s website). The development is hosted on SourceForge where GDL continuously ranks in the 99th percentile of most active projects. GDL with its library routines is designed as a tool for numerical data analysis and visualisation. As its proprietary counterparts (IDL and PV-WAVE), GDL is used particularly in geosciences and astronomy. GDL is dynamically-typed, vectorized and has object-oriented programming capabilities. The library routines handle numerical calculations, data visualisation, signal/image processing, interaction with host OS and data input/output. GDL supports several data formats such as netCDF, HDF4, HDF5, GRIB, PNG, TIFF, DICOM, etc. Graphical output is handled by X11, PostScript, SVG or z-buffer terminals, the last one allowing output to be saved in a variety of raster graphics formats. -
Sage Tutorial (Pdf)
Sage Tutorial Release 9.4 The Sage Development Team Aug 24, 2021 CONTENTS 1 Introduction 3 1.1 Installation................................................4 1.2 Ways to Use Sage.............................................4 1.3 Longterm Goals for Sage.........................................5 2 A Guided Tour 7 2.1 Assignment, Equality, and Arithmetic..................................7 2.2 Getting Help...............................................9 2.3 Functions, Indentation, and Counting.................................. 10 2.4 Basic Algebra and Calculus....................................... 14 2.5 Plotting.................................................. 20 2.6 Some Common Issues with Functions.................................. 23 2.7 Basic Rings................................................ 26 2.8 Linear Algebra.............................................. 28 2.9 Polynomials............................................... 32 2.10 Parents, Conversion and Coercion.................................... 36 2.11 Finite Groups, Abelian Groups...................................... 42 2.12 Number Theory............................................. 43 2.13 Some More Advanced Mathematics................................... 46 3 The Interactive Shell 55 3.1 Your Sage Session............................................ 55 3.2 Logging Input and Output........................................ 57 3.3 Paste Ignores Prompts.......................................... 58 3.4 Timing Commands............................................ 58 3.5 Other IPython