In [2]:
import os # this package allows us to use terminal window commands from within python
import numpy as np
In [3]:
d = np.load('../data/cascadia.npz') # data was saved in compressed numpy format
What is contained in this file?
In [4]:
d.keys() # notice that d is a dictionary!
Out[4]:
In [5]:
d['z'].shape # this is an array instead of a list, so it can have more than 1 dimension
Out[5]:
Let's start with a quick look at the data. We'll keep it simple since we aren't to the plotting section yet.
In [6]:
%matplotlib inline
import matplotlib.pyplot as plt
import cmocean.cm as cmo
plt.figure(figsize=(10, 8))
plt.pcolormesh(d['lon'], d['lat'], d['z'], cmap=cmo.delta)
plt.colorbar()
plt.xlabel('Longitude [deg]')
plt.ylabel('Latitude [deg]')
plt.title('Topography and bathymetry [m]')
Out[6]:
Anyone recognize this?
Let's do a few calculations using numpy.
How about a mean:
In [7]:
z = d['z'] # we can rename the vertical data information to save a little space
z.mean()
Out[7]:
So overall we have a mean value of about -5 meters. But how meaningful is this? Let's break it down further.
We have both positive and negative values, and they represent pretty distinct areas: above and below water. It is logical that we separate the two.
In [ ]:
iabove = z > 0 # indices of the z values that are above water
ibelow = z < 0 # indices of z values that are below water
In [ ]:
print('above water: ', z[iabove])
print('below water: ', z[ibelow])
Look good! Now let's do something with them.
First, how about the mean vertical level, separate for above and below water.
In [ ]:
z[iabove].mean()
In [ ]:
z[ibelow].mean()
So, the average topographic height in this region of western Washington and Canada is about 550 meters above sea level, and the average depth is about 700 meters.
In [ ]: