Carefully review the course material from today’s workshop. Ensure that conda, python, and our conda environment scipro2025 are installed and properly working on your laptop. Create a directory for our course, where you will put all the code and exercises (I refer to this directory as $SCIPRO in the lecture material). Do the exercises embedded in the slide decks, if you haven’t done so in class.
In addition, do the following two exercises. No need to hand them in, but be prepared to present your code.
#01-01: conda
Create a new conda environment testenv without specifying a python version for it, and also install the packages ipython and numpy into the environment. Do not yet activate it.
Run conda --help in the terminal and examine the available conda commands.
Run conda info --help and read the documentation.
Use conda info to display a list of all environments currently installed on your computer.
How many environments are there?
Where are they installed?
Activate testenv.
Find out which version of python was installed in testenv. Use conda --help to find the correct command!
Deactivate testenv. Make sure that no environment is activated anymore (i.e., no parentheses with an environment name are displayed before your command line).
Remove testenv by running conda remove -n testenv --all.
#01-02: The solar elevation angle
Using https://www.online-python.com/, write a program that computes and prints the solar elevation angles for Sept 16, 2023 at noon true local time (i.e., tau = 0, delta = 2.86) for all latitudes from the equator to the north pole in 5\(^\circ\) intervals. Use version 2 of our second program (in the slide deck First steps in python) to guide you.
Be aware that the webiste online-python.com cannot plot figures. Just ignore that part for now.
Solutions
Exercise 01-01: conda
# 1. create testenv
conda create -n testenv python ipython numpy
# 4. display a list of environments that are installed on your computer
conda info --envs
# 5. activate the new environment
conda activate testenv
# 6. which python version was installed in testenv? --> the following output will tell you:
conda list
# 7. deactivate the environment
conda deactivate
# 8. remove the test environment
conda remove -n testenv --all
Exercise 01-02: The solar elevation angle v4–latitudes
# Program for computing the solar elevation angle# Version 4: for all latitudes, incl. figureimport numpy as npimport matplotlib.pyplot as plt# Define variablesdelta =2.86# declination of the sun at Sept 16, 2023 tau =0# hour angle at noon true local timephi = np.arange(0, 95, 5) # vector of latitudes from equator (0) to north pole (90) in steps of 5 degrees# Convert degree to radiansdelta_rad = np.deg2rad(delta)tau_rad = np.deg2rad(tau)phi_rad = np.deg2rad(phi)# Compute solar elevation angleh_rad = np.arcsin(np.cos(delta_rad)*np.cos(tau_rad)*np.cos(phi_rad) + np.sin(delta_rad)*np.sin(phi_rad))h = np.rad2deg(h_rad)## plot resultsplt.figure()plt.plot(phi, h)plt.grid()plt.xlabel("latitude (degrees)")plt.ylabel("solar elevation angle (degrees)")
Text(0, 0.5, 'solar elevation angle (degrees)')
Assignment until workshop 2 (03.10.2025)
Group presentations
Starting to learn python comes with a steep learning curve. The concepts might be entirely new to you, and there’s a lot of them all at once! To get you up to speed, we will divide and conquer:
Form 4 groups. Each group will work on a set of tasks and prepare a 10-minute presentation. We will listen to the presentations during the second workshop. Please upload your presentation files to the ILIAS folder Abgaben/01_workshop.
The goal of this exercise is for you to work in-depth on the tasks assigned to your group and elicit the most important take-home messages. Everyone will have to work through all the material eventually, but with your peer’s presentation to guide you this will be a lot faster and more effective!