Python in astronomy + Monte-Carlo techniques

Slides:



Advertisements
Similar presentations
Guy Griffiths. General purpose interpreted programming language Widely used by scientists and programmers of all stripes Supported by many 3 rd -party.
Advertisements

MatLab API in C++ Christopher Dabney. Purpose MatLab … MatLab … is an interpreted scripting language is an interpreted scripting language conversion to.
Python for Science Shane Grigsby. What is python? Why python? Interpreted, object oriented language Free and open source Focus is on readability Fast.
Network Design and Optimization Python Introduction
Python Lab Proteomics Informatics, Spring 2014 Week 1 28 th Jan, 2014 Himanshu Grover
Jonathan Huelman CSC 415 – Programming Languages
Dr. Chris Musselle – Consultant R Meets Julia Dr Chris Musselle.
Introduction to Python By Neil Cook Twitter: njcuk Slides/Notes:
Scientific Computing Beyond Matlab Nov 19, 2012 Jason Su.
Pattern Recognition Software CS855 Week 1. Matlab Commercial Very fast matrix operations Many open source functions Portability limited Free Interpreted.
Earth System Modeling Framework Python Interface (ESMP) October 2011 Ryan O’Kuinghttons Robert Oehmke Cecelia DeLuca.
DATA MINING Pandas. Python Data Analysis Library A library for data analysis of (mostly) tabular data Gives capabilities similar to Excel and SQL but.
Python  Monty or Snake?. Monty?  Spam, spam, spam and eggs  Dead parrots  Eric Idle, John Cleese, Michael Palin, etc.
Practical Kinetics Exercise 0: Getting Started Objectives: 1.Install Python and IPython Notebook 2.print “Hello World!”
1. Starting 1 Let’s Learn Saenthong School, January – February 2016 Teacher: Aj. Andrew Davison, CoE, PSU Hat Yai Campus
The Cockroft Institute
MET4750 Techniques for Earth System Modeling MET 5990 Techniques for Earth System Modeling and Research (
Victoria Manfredi September 27, 2016.
Part I: Python. Part I: Python Guido van Rossum Over six years ago, in December 1989, I was.
How to Get Started With Python
The Emergent Structure of Development Tasks
Python Data Analytics & Visualization
Python for data analysis Prakhar Amlathe Utah State University
Development Environment
CST 1101 Problem Solving Using Computers
MET4750 Techniques for Earth System Modeling
Licenses and Interpreted Languages for DHTC Thursday morning, 10:45 am
PyTimber & CO M. Betz, R. De Maria, M. Fitterer, C. Hernalsteens, T. Levens Install: $ pip install pytimber Sources:
CSC391/691 Intro to OpenCV Dr. Rongzhong Li Fall 2016
Jim Fawcett CSE687 – Object Oriented Design Spring 2016
ITCS-3190.
PH2150 Scientific Computing Skills
IST256 Python Install Fest!!!!
Spark Presentation.
DATA MINING Python.
Basic machine learning background with Python scikit-learn
Python Data Structures & Algorithms in Python
Prepared by Kimberly Sayre and Jinbo Bi
SVTRAININGS. SVTRAININGS Python Overview  Python is a high-level, interpreted, interactive and object-oriented scripting language. Python is designed.
IST256 : Applications Programming for Information Systems
Network Visualization
Introduction to Python programming
Sussex Neuroscience Coding Club title slide
Let's Learn Python and Pygame
How to enter the world of Python Programming for ArcGIS
مهارات الاتصال والتواصل Communication Skills
مهارات الاتصال والتواصل Communication Skills
Objects First with Java
Winter 2018 CISC101 12/1/2018 CISC101 Reminders
Brief Intro to Python for Statistics
Transforming Data (Python®)
BSc in Digital Media, PSUIC
EMSE 6574 – Programming for Analytics: Python 101 – Python Enviornments Joel Klein.
Accomplishing Executables
Option One Install Python via installing Anaconda:
Extending Languages.
Numpy, pylab, matplotlib (follow-up)
Matplotlib and Pandas
LING/C SC 581: Advanced Computational Linguistics
Submitted by Jayaprakash Rao
PyWBEM Python WBEM Client: Overview #2
DATA MINING Python.
Jim Fawcett CSE687 – Object Oriented Design Spring 2015
C++ Object Oriented 1.
Games Development 2 Entity / Architecture Review
Installations for Course
Igor Stančin, Alan Jović to: {igor.stancin,
Open data in teaching and education
Installations for Course
Presentation transcript:

Python in astronomy + Monte-Carlo techniques Michael Ireland (RSAA)

Interpreted languages in astronomy For complex data analysis, we want to: Interact with our data – an interpreted language helps. Be moderately fast, and have an option to be very fast. Have the ability to write and test complex code more quickly than our competitors. Have great astronomy libraries. Gain skills relevant for employment.

What are the options and their popularity? Yorick (unknown language with some die-hard fans) IDL (ranked between #51 and #100)*. Julia (ranked #47 and rising) R (ranked #18) MATLAB (ranked #15) Python (ranked #5) * Rankings from http://www.tiobe.com/tiobe-index/.

Python is the right combination of career-relevant skills for students/postdocs, speed and ease of use. https://gooroo.io/GoorooTHINK/Article/16225/

Python – the good and bad Python is free, with the first version with community support python 2.0 (2000). Python is minimalist in many aspects of the language. There are only 34 keywords in the global namespace (many of which you’d never use). Python has lightweight object-oriented programming. Lightweight because there is no explicit C++ style declarations (no public, private, virtual, overloaded functions, pointers…) Python is designed from the ground up for powerful data structures: lists, dictionaries and tuples (and sets). However, Python requires external modules to have more than basic functionality. If only all useful modules were packaged and available in a neat way…

Demo python here

Use a Python distribution or package manager Most popular for Mac and Windows is probably anaconda (https://www.continuum.io/downloads) Anaconda comes with astropy, which is a great general purpose astronomy package (V1.0 last year). Under Ubuntu, you can just use apt-get. Most additional packages can be installed with pip, e.g. pip install sick (Andy Casey’s spectroscopic inference crank) Given that python is open-source, many packages are on github or other public repositories.

Most Important Packages Numpy: From 2006*, a set of structures and routines designed to make python roughly as powerful as Matlab. Scipy: Mostly wrappers for powerful libraries such as LAPACK, plus other bits and pieces. From 2001, but still version “0.17”. Matplotlib: A great 2D plotting package. Astropy: version 1.2.1 – only a few years old in a useable form. All of these are on github, and you can also contribute to python itself if you are keen (in C)

numpy example from the command prompt. “vectorised” code – style and speed N-body example code using the semi-implicit Euler’s method: Update velocity to timestep (n+1) Use velocity at timestep (n+1) to update position a timestep (n) Conserves energy.

Excercise (non-assessed) If you are not a python expert yet: Learn python for fun, e.g. https://learnpythonthehardway.org/book/ Play with the N-body code. Try a different algorithm, better plotting… Read in Gaia DR1 and . Maybe download and plot distributions of your favourite type of star, with: from astropy.table import Table …or… from astroquery.vizier import Vizier Small assignment given out on Friday.