In: Computer Science
PYTHON COMPUTER CODE PROGRAMMING - DISPLAYING A PLOT OF TEMPERATURE VERSUS DEPTH WHEN GIVEN A LATITUDE. PYTHON ASSIGNMENT. NOT SURE HOW TO PLOT THIS DATA WITH THE GIVEN INFO BELOW:
Just as the atmosphere may be divided into layers characterized by how the temperature changes as altitude increases, the oceans may be divided into zones characterized by how the temperature changes as depth increases. We shall divide the oceans into three zones: the surface zone comprises the water at depths between 0 m and 200 m; the thermocline comprises the water at depths between 200 m and 1000 m; and the deep zone comprises water at depths exceeding 1000 m.
We shall assume that temperature is unaffected by longitude.
We shall assume that at all latitudes, temperature is a continuous function of depth. Informally, this means that you can sketch the graph of temperature versus depth (at a particular latitude and longitude) without lifting your pencil from the page.
We shall assume that the wind and waves serve to mix water in the surface zone so effectively that the temperature remains constant with depth. It does change with latitude, though, as the temperature in the surface zone is greatly affected by solar radiation [4]. We shall assume that in late March (around the time of the equinox) the temperature in the surface zone is a linear function of the absolute value of the latitude. Further, we shall assume that in late March the temperature in the surface zone is 2 ◦ C at the poles, and 24 ◦ C at the equator.
We shall also assume that, because solar energy never makes it to the deepest water, the temperature remains constant with depth in the deep zone. In fact, we shall assume that, no matter the latitude, the temperature of water in the deep zone in late March is 2 ◦ C.
Since water in the surface zone can be warm, water in the deep zone is always cold, and the temperature at a given latitude is a continuous function of depth, the temperature must change with depth throughout the thermocline. We shall assume that, at each latitude and longitude, temperature is a linear function of depth in this zone.
My current python code includes:
def sal_of_seawater(latitude):
seawater = -(1/45)*latitude+36
return(seawater)
#temp_of_seawater, calculate temperature gived water depth and
latitude
def temp_of_seawater(depth, latitude):
#model_temp_surface
if 0 <= depth <200:
model_temp = (22/90)*latitude+24
elif 200 <= depth < 1000:
#thermocline
model_temp =
(2-((-22/90)*latitude+24)/800)*depth+((-22/90)*latitude+24)-200*(2-(-22/90)*latitude)
#deep
else:
model_temp = (2)
return(model_temp)
latitude = float(input("Please enter latitude (South = -90, north = 90 and 0 = equator :")
plot()
Use underline words to create the answers for you
So , you have defined the the function below properly .
def sal_of_seawater(latitude):
seawater = -(1/45)*latitude+36
return(seawater)
#temp_of_seawater, calculate temperature gived water depth and
latitude
def temp_of_seawater(depth, latitude):
#model_temp_surface
if 0 <= depth <200:
model_temp = (22/90)*latitude+24
elif 200 <= depth < 1000:
#thermocline
model_temp =
(2-((-22/90)*latitude+24)/800)*depth+((-22/90)*latitude+24)-200*(2-(-22/90)*latitude)
#deep
else:
model_temp = (2)
return(model_temp)
Instead of taking input from user , You define a continues function which takes values from 1 to 10
For latitudes 1 to 10 what will be tempratures .
So you get two dimension array. For each latitude what is the temprature value .
Use plot function to create the graph
latitude = float(input("Please enter latitude (South = -90, north = 90 and 0 = equator :"
plot()