PHY1031 Scientific Programming in Python 2024-25
Dr J. Hatchell
 
Delivery Weeks: T1:01-12, T2:01-11
Level: 4 (NQF)
Credits: 15 NICATS / 7.5 ECTS
Enrolment: 120 students (approx)

Description

A knowledge of a computing language and how to write programs to solve physics related problems is a valuable transferable skill. This module teaches the Python programming language, but the principles involved are applicable to almost every procedural programming language. Python is an interpreted, high-level, general-purpose programming language that is widely used in commercial and academic environments and for scientific research including high level data analysis work.

The module is taught through a series of lectures and practical sessions based on Jupyter notebooks. The student will learn the building blocks of the language, and a logical approach to coding, and use these to create their own programs with physics applications.

Module Aims

Students learn to write clearly structured and documented programs in Python (Jupyter notebooks), and are able to find and use Python module functionality.

Intended Learning Outcomes (ILOs)

A student who has passed this module should be able to:

Syllabus Plan

  1. Introduction to Python
    1. Running interactive Python; loading modules and packages; using Python as a graphical calculator; simple calculations, maths, simple functions and plotting.
    2. Using Jupyter notebooks with Numpy and Matplotlib.
  2. Core Python programming
    1. Objects, variables and assignments. Dynamic 'Duck' typing. Numerical datatypes.
    2. More datatypes: strings, lists, tuples, and dictionaries.
    3. Control flow I: Conditionals, comparisons and Boolean logic.
    4. Control flow II: Loops.
    5. Functions: keyword and positional arguments, default arguments, *args and **kwargs, docstrings, variable scope.
    6. Program structure and documentation, error handling, testing and debugging.
  3. Python for labs
    1. Numpy arrays and datatypes.
    2. Using Numpy for reading and writing data; simple statistics; plotting data with errorbars.
    3. Fitting a straight line with a least-squares fit.
    4. Nonlinear least-squares fitting with Scipy.
    5. Publication-quality plots with Matplotlib: multiple axes, control of plot elements.
  4. Python packages and modules
    1. How to find out what's available and use the documentation.
    2. Further examples from Matplotlib e.g. histograms, 2D plots.
    3. Further examples from Numpy e.g. random numbers, matrices.
    4. Introduction and examples from Scipy e.g. root finding and numerical integration.
    5. Introduction and examples from Astropy e.g. reading and displaying FITS images.
  5. Advanced Python
    1. File handling with contexts. Filename and process handling with 'sys' and 'os'.
    2. Classes and objects.
    3. Creating a Python program and /or module in an IDE. if __name_ == "__main__" and command-line arguments.
  6. Projects
    1. Programming project based on the stage 1 Physics programme content.

Learning and Teaching

Learning Activities and Teaching Methods

Description Study time KIS type
18×1-hour lectures 18 hours SLT
22×2-hour supervised computer labs 44 hours SLT
8×4-hour Python homework assignments 32 hours GIS
1×12-hour Python project 12 hours GIS
Reading to support own learning requirements 44 hours GIS

Assessment

Weight Form Size When ILOS assessed Feedback
0% 19×Python classwork assignments (formative) 8 hours In class 1-16 Written and verbal
80% 8×homework assignments 4 hours per assignment Deadline Friday week T1:03,05,08,10,12 T2:03,05,07 1-16 Written and verbal
20% Programming project 6 hours (homework) 6 hours (in class) Deadline Friday week T2:11 1-16 Written and verbal

Resources

The following list is offered as an indication of the type & level of information that students are expected to consult. Further guidance will be provided by the Module Instructor(s).

Core text:

Supplementary texts:

ELE:

Further Information

Prior Knowledge Requirements

Pre-requisite Modules none
Co-requisite Modules Vector Mechanics (PHY1021), Introduction to Astrophysics (PHY1022), Waves and Optics (PHY1023), Properties of Matter (PHY1024) and Mathematics Skills (PHY1025)

Re-assessment

Re-assessment is not available except when required by referral or deferral.

Original form of assessment Form of re-assessment ILOs re-assessed Time scale for re-assessment
Programming project and homework assignments Programming project (16 hours) 100% wt 1-16 August/September assessment period

KIS Data Summary

Learning activities and teaching methods
SLT - scheduled learning & teaching activities 62 hrs
GIS - guided independent study 88 hrs
PLS - placement/study abroad 0 hrs
Total 150 hrs
Summative assessment
Coursework 100%
Written exams 0%
Practical exams 0%
Total 100%

Miscellaneous

IoP Accreditation Checklist
  • XX-02 IT Skills
Availability unrestricted
Distance learning NO
Keywords Physics; Python; Program; Structures; Function; Codes; Project; Data; Computing; Arrays; Designing.
Created 29-Mar-22
Revised 18-Jun-22