Your Name
Due: Friday, 04/12/24\ All questions are worth 2 points.\ One bonus point for submitting your solutions as a Colab Notebook.
To answer a question that asks you to calculate the value of a physical property, please proceed as following:
When you have answered all the questions, make sure you put your name at the top of the notebook and download it: File → Download → Download .ipynb
. Rename the downloaded file to SIO173-HW1-Lastname-Firstname.ipynb
and submit through Canvas.
You should write any text that goes with your answers and mathematical derivations in a text cell. To add a text cell click on the + Text
button at the top.
The text format in Colab notebooks is called Markdown, but it should be sufficient to use the formatting toolbar at the top of the cell to format your text. You can include any math or equations in $\LaTeX$ syntax. A few useful LaTeX commands that you may need for writing up homeworks are included below, but if you don't know how to write a certain math symbol/relation you can always google how to write it in Latex, or ask a tool like chatGPT to write it for you.
You can include any mathematical symbols or equations in line with your text by wrapping it in dollar signs like this: $a^2 + b^2 = c^2$
, which will appear in the text as $a^2 + b^2 = c^2$. If you want an equation to appear on its own line you can write it like this:
\begin{align}
a^2 + b^2 = c^2.
\end{align}
which will appear in the text like this: \begin{align} a^2 + b^2 = c^2. \end{align}
If you need greek letters, you can write them in math mode as $\alpha$
, $\beta$
, $\gamma$
and so on, which will show up as $\alpha$, $\beta$, $\gamma$. Some other useful commands are
$\infty$
for the infinity symbol $\infty$.$\partial$
for a partial derivative symbol $\partial$To write a sub or superscript, you can use _
and ^
:
$a^b$
becomes $a^b$$a_b$
becomes $a_b$$a^b_c$
becomes $a^b_c$The _
and ^
only work on the next character, which means that:
$e^(a+b)$
would become $e^(a+b)$$P_surface$
would become $P_surface$.To fix this, wrap everything that you want in the sub/superscript in curly braces {}
.
$e^{(a+b)}$
becomes $e^{(a+b)}$$P_{surface}$
becomes $P_{surface}$If you want anything in a math equation to be rendered as text, use the command \textrm{}
(this one is helpful for including units):
$P_\textrm{surface}$
becomes $P_\textrm{surface}$$g = 9.81 \textrm{ m s}^{-2}$
becomes $g = 9.81 \textrm{ m s}^{-2}$To write a fraction use the \frac{}{}
command like so:
$\frac{a}{b}$
becomes $\frac{a}{b}$You can write sums or integrals using the \sum
and \int
commands, and use sub/superscripts as before:
$\sum_{i=1}^n \frac{1}{2^x} = 1$
becomes $\sum_{i=1}^n \frac{1}{2^x} = 1$$\int_{x=0}^\infty e^{-x}\ dx = 1$
becomes $\int_{x=0}^\infty e^{-x}\ dx = 1$If you want to put math into parentheses ()
or brackets []
, you may want to adjust their size to the content in between them. To do so, write \left(
before the content, and \right)
after.
x (\frac{a}{b}-1)
does not ajust the size of the parentheses:
\begin{align}
x (\frac{a}{b}-1)
\end{align}x \left(\frac{a}{b}-1\right)
properly adjusts the size of the parentheses:
\begin{align}
x \left(\frac{a}{b}-1\right)
\end{align}Using the concepts above, we can write some of the expressions that we have encountered in class:
$P = \rho R T$
\
$P = \rho R T$$\frac{\partial P}{\partial z} = -\rho_0 g$
\
$\frac{\partial P}{\partial z} = -\rho_0 g$$H = \frac{R T}{g}$
\
$H = \frac{R T}{g}$$e_s \approx Ae^{B T}$ where $T$ is temperature in °$\textrm{C}$
\
$e_s \approx Ae^{B T}$ where $T$ is temperature in °$\textrm{C}$To add a Python code cell click on the + Code
button at the top.
You can define a variable and assign a value to it like this:
my_number = 42
my_string = 'hello'
If you want to put comments in your code use the #
symbol. Anything you write on that line after the #
is just a comment and will not be executed:
# Let me define another number variable
my_other_number = 42.1234567 # this is similar to my_number, but has some more digits after the decimal point
To print the value of a variable, you can use the print()
function.
print(my_number)
print(my_other_number)
print(my_string)
42 42.1234567 hello
You can format variables for printing using formatting strings and a %
sign.
print('My number is %d, truncated to be a whole number.' % my_number)
print('My other number is %d, truncated to be a whole number.' % my_other_number)
print('My other number is %.5f, shown with 5 decimal points.' % my_other_number)
print('My other number is %.5g, rounded to 5 significant digits.' % my_other_number)
print('My number is %.2f and my other number is %.2f, shown with 2 decimal points.' % (my_number, my_other_number))
My number is 42, truncated to be a whole number. My other number is 42, truncated to be a whole number. My other number is 42.12346, shown with 5 decimal points. My other number is 42.123, rounded to 5 significant digits. My number is 42.00 and my other number is 42.12, shown with 2 decimal points.
Simple math operations are
+
: addition-
: subtraction*
: multiplication/
: division**
: powerprint('My number plus five is %d.' % (my_number + 5))
print('My number minus five is %d.' % (my_number - 5))
print('My number times five is %d.' % (my_number * 5))
print('My number divided by five is %g.' % (my_number / 5))
print('The square root of my number is %g.' % (my_number**0.5))
My number plus five is 47. My number minus five is 37. My number times five is 210. My number divided by five is 8.4. The square root of my number is 6.48074.
For more advanced mathematical expression, you need to use the library numpy
. We do so by importing it using import numpy as np
and then using the functions it provides. A few useful ones are:
np.pi
provides the value of $\pi \approx 3.1416$np.exp(x)
calculates $e^x$np.log(x)
calculates the natural logarithm $\ln(x)$np.sin(x)
calculates $\sin(x)$ for $x$ given in radiansnp.cos(x)
calculates $\cos(x)$ for $x$ given in radiansimport numpy as np
print('%g' % np.exp(my_number))
print('%g' % np.log(my_number))
1.73927e+18 3.73767
If you want to, you can also define your own functions by putting this all together.
(You won't need to define your own functions for these homeworks, but it can help you keep your code concise.)
# write a function that calculates the density of the atmosphere
# the inputs are: temperature T in Fahrenheit and pressure P in hPa
# it returns: the density of the atmosphere in kg m^-3
def calculate_atmosphere_density(T_fahrenheit, P_hectopascal):
R = 287 # define the specific gas constant for dry air, in units J kg^-1 K^-1
T_kelvin = (T_fahrenheit - 32) * 5/9 + 273.15 # convert temperature to Kelvin
P_pascal = P_hectopascal * 100 # convert pressure to Pascal
# calculate density in kg m^-3
rho = P_pascal / (R * T_kelvin)
# print the result
print('At a temperature of %g degree Fahrenheit and a pressure of %g hPa, the density of the atmosphere is %g kg m^-3.' % (T_fahrenheit, P_hectopascal, rho))
# return the result
return rho
Now you can plug whichever values you want into your own function:
rho_1 = calculate_atmosphere_density(T_fahrenheit=65, P_hectopascal=1000)
rho_2 = calculate_atmosphere_density(T_fahrenheit=55, P_hectopascal=700)
At a temperature of 65 degree Fahrenheit and a pressure of 1000 hPa, the density of the atmosphere is 1.19538 kg m^-3. At a temperature of 55 degree Fahrenheit and a pressure of 700 hPa, the density of the atmosphere is 0.853021 kg m^-3.
Calculate the density of the atmosphere at Scripps Pier today, making appropriate assumptions. Express your result in $\textrm{kg m}^{-3}.$
We can re-write the ideal gas law to solve for \begin{align} \rho = \frac{P}{RT}. \end{align}
(execute the cell to print the output)
# define all your variables and constants in appropriate units (if they are all standard SI units, the result will be in standard SI units!)
R = 287 # specific gas constant for dry air, in units J kg^-1 K^-1
T = 290 # the temperature at Scripps Pier today, in Kelvin
P = 1000 * 100 # the atmospheric pressure at Scripps Pier, in Pa (note that we multiplied by 100 to convert from hPa to Pa)
# plug these values into your derived formula to calculate the result
rho = P / (R * T)
# print the result and specify units
print('The atmospheric density at Scripps Pier today is about %.3g kg m^-3.' % rho)
The atmospheric density at Scripps Pier today is about 1.2 kg m^-3.
Note: Here, you could have also used the function calculate_atmosphere_density()
that we defined above. If the question asked you to calculate $\rho$ at (a) Scripps Pier, (b) Death Valley and (c) Mount Everest, then you could just re-use this function for every part a-c by plugging in your estimates for $T$ and $P$ in those places.
Consider an atmosphere where the density is constant everywhere, rather than varying with height as it does for Earth’s atmosphere. Assume it obeys the Ideal Gas Law and is in hydrostatic balance. Show that this atmosphere has a discrete top at a height that depends only on the surface temperature. Compute the height for a surface temperature of $T_0 = 273 \textrm{K}$. Explain physically why this atmosphere has a discrete top (as in the ocean), whereas Earth’s atmosphere continues upward infinitely (according to the equations with which we approximate it). (Hint: Consider what the surface pressure would be if this atmosphere continued upward infinitely.)
Your text answer here
# your code answer here
Using our approximation for the saturation vapor pressure and the equation of state for water vapor, calculate the maximum amount of water vapor per unit volume that air can hold at
Express your answers in $\textrm{kg m}^{-3}$.
Your text answer here
# your code answer here
Consider an isothermal atmospheric column in hydrostatic balance. The temperature of the column is $263 \textrm{K}$ and the surface pressure is $1000\textrm{hPa}$.
Your text answer here
# your code answer here
The density of seawater depends on both temperature $T$ and salinity $S$. Given an equation of state for seawater of $\rho_s = \alpha T + \beta S$, where $\alpha$ and $\beta$ are constants, write an equation for the buoyancy of a parcel of seawater. What do you expect the signs of $\alpha$ and $\beta$ to be? What are the units of $\alpha$ and $\beta$ ?
Your text answer here
Describe, in your own words, the phenomenon of shear instability and give an example of an atmospheric phenomenon generated by shear instability (bonus point for pictures). How do the energetics of shear instabilities differ from those of convection? (You can answer this last part qualitatively.)
Hint:
You can include an image from the internet in your text answer using the following Markdown code: \

Your text answer here