Skip to article frontmatterSkip to article content

Homework 1 - Humidity Calculations

10 total points

Background Information: Relative humidity

  1. The measured partial pressure of water vapor in the atmosphere (vapor pressure)
  2. The “maxmimum” partial pressure of water vapor (saturation vapor pressure).

Saturation vapor pressure is sometimes simplified as the “capacity” of the air to hold water vapor, and it is directly related to temperature.

The vapor pressure is the actual amount of water vapor in the air, and it is directly related to the dew point.

Relative humidity is ratio of actual to maximum water vapor in the air, and is communicated as “percent of capacity”. In reality, it is more complex than that, but it will be fine to think of it that way for our purposes.

You can compare it to your grade in the course:

Total possible points = saturation vapor pressure

points earned = vapor pressure

Grade in the course = 100 x (points earned / total possible points)

Relative humidity = 100 x (vapor pressure / saturation vapor pressure)

Exponents with math.exp()

where e ^ (said out loud “e to the”) is a Python function called math.exp(). You have to put everything in the parentheses in (2) within the parentheses in math.exp().

Here is an example:

math.exp(x + y)  #equivalent to e ^ (x + y) "e to the x plus y"

Directions

  • Due: 10/01/2025 @ 11:59 p.m.
  • Change the name of your notebook to HW1_FirstLast.ipynb, where First is your first name and Last is your last name.
  • For each of the following prompts, write or modify Python code that fulfills the requirements.

Important information to remember

  • Periodically, you should click File -> Save Notebook
  • When you are done working for the day, click File -> Log Out
  • When you are finished, download the notebook and upload it to the submission link
  • I will reset the notebook and run each code block on its own. You will receive half credit if you rely on a variable from a previous or subsequent code block.

Summary of HW1 tasks.

Each task is to be answered below the markdown cell that has the task number. Please use the existing markdown and code cell combinations. You do not need to redefine your variables in subsequent code cells. As long as you run the code cell, the variable will be available for equations and messages.

Task 1 (1.5 points)

Set your constants by translating the following equations to Python code. I have provided the variable name you must use for each case:

e0=0.611kPa\quad e_0 = 0.611 \, kPa (use Python variable name E0; 0.5 pts)

LRv=5423K\quad \frac{L}{R_v} = 5423 \, K (use Python variable name LRV; 0.5 pts)

T0=273K\quad T_0 = 273 \, K (use Python variable name T0; 0.5 pts)

Place your code below:

Task 2 (1 point)

Set your temperature in Fahrenheit (use the Python variable temp_f; 0.5 pts)

Set your dewpoint in Fahrenheit (use the Python variable dewp_f; 0.5 pts)

Place your code below:

Task 3 (2 points)

Convert temp_f and dewp_f in Fahrenheit (F) to Kelvin (K) using the following equation:

temperatureK=(temperatureF+459.67)×59temperature_K = (temperature_F + 459.67) \times \frac{5}{9} (use Python variable temp_k; 1 pt)

dewpointK=(dewpointF+459.67)×59dewpoint_K = (dewpoint_F + 459.67) \times \frac{5}{9} (use Python variable dewp_k; 1 pt)

Place your code below:

Task 4 (2.5 points)

Calculate the partial pressure of water vapor (epe_p) and saturation vapor pressure (ese_s) based on the following equations using the constants, temperature, and dewpoint. You must use the variables you defined or calculated in Task 1 - 3. I should be able to simply change the values for your variable definitions and get the correct answer.

ep=e0eLRv(1T01DF)e_p = e_0 \cdot e^{\frac{L}{R_v} \left( \frac{1}{T_0} - \frac{1}{D_F} \right)} (use Python variable ep; 1.25 pts)

es=e0eLRv(1T01TF)e_s = e_0 \cdot e^{\frac{L}{R_v} \left( \frac{1}{T_0} - \frac{1}{T_F} \right)} (use Python variable es; 1.25 pts)

Place your code below:

Task 5 (1.5 points)

Calculate relative humidity by translating the definition of relative humidity found on wikipedia to Python code using variables from Task 4: https://en.m.wikipedia.org/wiki/Humidity#Relative_humidity (1.5 pts).

To test your code, these are a few answers you should get (approximately) if you have certain temperature and dewpoint values. Be sure to change your temperature and dewpoint values to one of these examples, see what your code outputs as relative humidity, and then try another example.

temperaturedewpointrelative humidity
332058.45
4040100.00
10063.63
2025123.36

Place your code below:

Task 6 (1.5 points)

Format your printed answers as shown in the output column using the example temperature and dewpoint data in Task 5 to test your formatting.

All spaces and formatting are required (1 pt). If the relative humidity is higher than 100%, you need to add this message: "Error! > 100" to the end of your string. You must use an if else statement to do this (HINT: what are the two cases we need to test for? 0.5 pts). Note that depending on the size of your screen, the messages might be “squished” to the next line. You are not required to deal with this issue.

Again, I only want you to print out a message that matches the formatting from the output column examples. When I grade, I will just change your dewpoint and temperature values and see if your message is formatted correctly.

temperaturedewpointrelative humidityoutput
332058.45T = 33 Td = 20 and your answer is 58.45 %
4040100.00T = 40 Td = 40 and your answer is 100.00 %
10063.63T = 10 Td = 0 and your answer is 63.63 %
2025123.36T = 20 Td = 25 and your answer is 123.36 % (Error! > 100)

Place your code below: