PHYS-4007/5007 Python Web Page


This web page contains the links of useful web links to help you learn to program in Python. The first link takes you to the official Python Documents web page. The second link takes you to a nice free online tutorial to teach you python programming.



Python Plotting Tutorials and Programs

Please note that the Python codes below have filenames ending in`.txt'. Once you download them, please rename these files from "filename".txt to "filename".py (minus the double quotes). For instance, the first Python code below you would rename this file from myplot1.txt to myplot1.py.

Finally note that all of these programs load the numpy and the matplotlib utilities and require Python version 3+. As such, you would run these codes from the Linux prompt with

      python3   myplot1.py

and

      python3   myplot2.py

  pythonplot.pdf       Plotting in Python    
  myplot1.py       Sample Python Plotting program #1 from the above tutorial    
  myplot2.py       Sample Python Plotting program #2 from the above tutorial    


Python Spectrum Plotting Tutorials, Program, and Spectral Files

Please note that the Python code below has a filename ending in`.txt'. Once you have clipped and paste the text of this file to the file you opened on your Linux emacs GUI that you have opened, save this file as "specplot.py" (minus the double quotes).

Now do the exact same thing for each of the spectrum files, saving each file with the filename listed in the table below.

Finally note that this program loads the numpy and the matplotlib utilities and require Python version 3+. As such, you would run these codes from the Linux prompt with

      python3   specplot.py   sun981.wvc for each of the spectrum files listed below.

  specplot.pdf       Python Spectrum Tutorial #1    
  specplot2.pdf       Python Spectrum Tutorial #2    
  specplot.py       Python Spectrum Plotting program from the above tutorial    
  sun981.wvc       Solar Spectrum, Ca II H & K    
  sun997.wvc       Solar Spectrum, Ca II IR-triplet    
  betleo634.wvc       Beta Leo, Ca II H & K    
  betleo540.wvc       Beta Leo, H-alpha line    
  betleo543.wvc       Beta Leo, Ca II IR-triplet    
  alboo638.wvc       Alpha Boo, Ca II H & K    
  alboo560.wvc       Alpha Boo, Ca II IR-triplet    
  delvir636.wvc       Delta Vir, Ca II H & K    
  uuaur620.wvc       UU Aur, Ca II IR-triplet    


Python Orbit Program

Please note that the Python code below has a filename ending in '.txt'. On your Linux box, cd to your Python subdirectory, then make a new subdirectory called orbits, then cd to that subdirectory. From there, open an emacs GUI session with

      emacs   orbits.py   &

Now from your web browser, click on the following file: orbits.py. Then copy and paste the program from your web browser screen to your emacs GUI screen. Following this, save this file.

Now run then program with

      python3   orbits.py

Finally note that this program loads the numpy and the matplotlib utilities and requires Python version 3+. This code will calculate the orbits of the Earth and Halley's comet using the 4th-order Runge-Kutta ODE method. Run the code for both Earth and Halley's comet, paying attention to the plots generated. I will explain the details of this code in class.


Click here to go back to the Computational Physics home page.


Last modified: November 15, 2021 by D.G. Luttermoser