Introduction to Python as a Powerful Scientific Language

python as a scientific language a brief n.w
1 / 11
Embed
Share

Learn about Python, a multi-paradigm language that is popular in the scientific community due to its versatility and ease of use. Discover why Python is a top choice for scientific programming, its benefits, resources for further learning, and how to start using Python for your scientific projects.

  • Python
  • Scientific Language
  • Programming
  • Data Science
  • Open Source

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Python as a Scientific Language A Brief Introduction D. T. Welling U. of Michigan Climate and Space Play along at home: www-personal.umich.edu/~dwelling/python/

  2. Python is a multi-paradigm (procedural, object oriented, etc.) general purpose language. named after a Flying Circus. relatively young: vers. 1.0 in 1994; version 2 in 2000 (IDL->1977; MatLab->1984). extremely popular. Open source and FREE! Current versions: 2.7.11 and 3.5.1 https://xkcd.com/353/ 6/5/2025 2 GEM-CEDAR 2016

  3. TIOBE Rankings Python: #4 MatLab: #17 IDL: >50 6/5/2025 3 GEM-CEDAR 2016

  4. Why Python? Powerful scripting rivaling Perl, Bash, etc. Batteries included (GUI, Regex, web scripting, datetime, etc. out of the box.) Ubiquitous across platforms (Win, *nix, OSX, and many more). Extensible with C, C++, and FORTRAN Emphasizes clarity of source code Natural, easy, powerful Object Oriented IT S FREE and I m cheap. 6/5/2025 4 GEM-CEDAR 2016

  5. Why Python for Science? Numpy (array algebra), SciPy (common scientific functions), and Matplotlib (plotting) combine to rival IDL, MatLab. Easy to drop into C, F90 for heavy lifting . Combines scripting with numerics, visualization for complete scientific solution. IT S FREE and I m cheap. 6/5/2025 5 GEM-CEDAR 2016

  6. Resources Source, documentation, other resources. Style guide (suggested coding conventions) Python think-tank; Canopy Python Distribution www.python.org /dev/peps/pep-0008/ enthought.com Dive Into Python (Mark Pilgrim) Core Python Programming (Wesley Chun) GDS My Crap Open-source introduction (.net for website) Excellent introduction and reference; very thorough. Google Dat Shtuff for nearly any issue www-personal.umich.edu/~dwelling/python/ 6/5/2025 6 GEM-CEDAR 2016

  7. Getting Python Already Done! Use your package manager to get additional modules. *nix Use internal installation (WARNING: non-standard!) OS X Use package manager (Fink, MacPorts, Homebrew). Use Enthought Canopy Python distribution. Get software from python.org and install. Windows Use Enthought Canopy Python distribution. Scientists will want Python, Numpy, SciPy, Matplotlib, and IPython. 6/5/2025 7 GEM-CEDAR 2016

  8. Interfacing with Python There are many, many ways to work with Python. Scripting and executing from the system shell. Command line interfaces through a Python shell, such as the default shell or IPython. Interactive Development Environments that combine text editors with shell prompts, such as Spyder. Jupyter Notebook, a web-based interactive session that combines mark-up and code. 6/5/2025 GEM-CEDAR 2016 8

  9. An Example: example_imf.py #!/usr/bin/env python shebang tells shell how to execute. docstring long form comments/documentation Imports include code from other python files Function & variable definitions (note docstrings associated with definitions) An example module [ ] import numpy as np def format_ax(ax, ylabel=None): '' Format an axes object [ ] ''' <commands> # Comments start with hashtags! 6/5/2025 9 GEM-CEDAR 2016

  10. example_imf.py class ImfData(dict): '' A class for handling Imf [ ] ''' def __init__(self, filename): <commands> Class definitions: Class-level docstring Special method definitions: define basic object behavior Method definitions: functions that leverage object attributes NOTE NESTED TABBING ''' Calculate [ ] ''' <commands> def calc_v(self): 6/5/2025 10 GEM-CEDAR 2016

  11. example_imf.py Optional code that runs in the __main__ namespace (when file is executed, not imported). if __name__ == '__main__ : <commands> <commands> <commands> 6/5/2025 11 GEM-CEDAR 2016

More Related Content