Python-lectures-Notebooks
Python-lectures-Notebooks copied to clipboard
Files for the Python lecture I give at IA-UNAM
Python lectures Notebooks
This is the repository of my Python lectures give at Instituto de Astronomia - UNAM since 2012
The available lectures are the following:
I. Introduction to python <Notebooks/intro_Python.ipynb>
_ (PDF version) <Notebooks/intro_Python.pdf>
_
- Using python as a calculator
- assignments
- comments
- types
- complex numbers
- booleans
- printing strings
- strings
- Tuples, lists and dictionaries
- Blocks
- List and dictionary comprehension
- Functions, procedures
- Scripting
- Importing libraries
-
Introduction to Numpy <Notebooks/intro_numpy.ipynb>
_(PDF version) <Notebooks/intro_numpy.pdf>
_
- The Array class
- create an array
- 1D, 2D 3D arrays
- creating array from scratch
- arrays share memory (views)
- random generator
- timing a command
- slicing arrays
- assignments
- using masks
- the where function
- some operations with arrays
- broadcasting
- calling scripts
- structured arrays and record arrays
- NaN other ANSI values.
-
Interacting with files <Notebooks/Interact%20with%20files.ipynb>
_(PDF version) <Notebooks/Interact%20with%20files.pdf>
_
- Reading a simple ASCII file
- How to treat special rows (comments, header)
- classical way
- using numpy.loadtxt
- using numpy.genfromtxt
- Dealing with missing data
- Data in a fixed size format
- Writing files
- simple method
- Pickle files (python format)
- FITS files
-
How to make plots, images, 3D, etc, using Matplotlib <Notebooks/intro_Matplotlib.ipynb>
_(PDF version) <Notebooks/intro_Matplotlib.pdf>
_
- Simple plot
- Controlling colors and symbols
- Overplot
- Fixing axes limits
- Labels, titles
- Legends
- The object oriented way to use Matplotlib
- Scatter
- log plots
- Multiple plots
- Everything is object
- Error bars
- Sharing axes
- Histograms
- Boxplots
- Ticks, axes and spines
- A plot inside a plot
- Play with all the objects of a plot
- Filled regions
- 2D-histograms
- 2D data sets and images
- Contour
- 3D scatter plots
- Saving plots
- Access and clear the current figure and axe
- What's happen when not in a Notebook? plt.show() and plt.ion() commands
-
Introduction to Scipy <Notebooks/intro_Scipy.ipynb>
_(PDF version) <Notebooks/intro_Scipy.pdf>
_
- Some useful methods
- nanmean
- constants
- Integrations
- Interpolations
- 2D-interpolations
- data fitting
- multivariate estimation
-
Usefull libraries <Notebooks/Useful_libraries.ipynb>
_(PDF version) <Notebooks/Useful_libraries.pdf>
_
- time and datetime
- timeit
- os
- sys
- subprocess
- glob
- re
- urllib2
-
The astropy library <Notebooks/Using_astropy.ipynb>
_(PDF version) <Notebooks/Using_astropy.pdf>
_
- constants and units
- data table
- Downloading from CDS
- Coordinates
- Modeling
-
Object Oriented programing <Notebooks/OOP.ipynb>
_(PDF version) <Notebooks/OOP.pdf>
_
- use functions to do simple jobs
- but use objects when things start to be more complex
- define classes, objects, attributes, methods, etc...
- use *args and **kwargs in functions calls
- use the class variables
- add functionalities to classes and objects
- use class inheritance
- use attributes properties
-
Optimization <Notebooks/Optimization.ipynb>
_(PDF version) <Notebooks/Optimization.pdf>
_ -
Calling Fortran <Notebooks/Calling%20Fortran.ipynb>
_(PDF version) <Notebooks/Calling%20Fortran.pdf>
_ -
Sending requests to MySQL and receiving the result from python, using PyMySQL <Notebooks/Using_PyMySQL.ipynb>
_(PDF version) <Notebooks/Using_PyMySQL.pdf>
_
- See
MySQL.pdf <Notebooks/MySQL.pdf>
_ - connect to database
- using pandas to easy access
-
Using astroquery <Notebooks/Using_astroquery.ipynb>
_(PDF version) <Notebooks/Using_astroquery.pdf>
_
- querying Vizier
- querying MAST
- catalogs
- Machine Learning
- See
Machine Learning.pdf <Notebooks/Machine%20Learning.pdf>
_ - One Notebook
comparing Artificial Neural Network to Polynomial fit <Notebooks/ANN.ipynb>
_ - Notebook from Miguel Angel Aragon lecture on
redshift determination <Notebooks/Redshifts.ipynb>
_ - Notebook from Miguel Angel Aragon lecture on
Galaxy classification <Notebooks/Galaxies_classification.ipynb>
_