Skip to content
Snippets Groups Projects
Commit 07174e6d authored by Powell, Scott (CIV)'s avatar Powell, Scott (CIV)
Browse files

add notebook and data

parent cee43b1c
No related branches found
No related tags found
No related merge requests found
File added
%% Cell type:markdown id: tags:
### MR3522 Lab 4: An Introduction to Microwave Data from SSMI/S
#### Description: Plot a sweep and swath of SSMI/S data at various channels over a West Pacific typhoon.
%% Cell type:markdown id: tags:
#### Import modules.
%% Cell type:code id: tags:
``` python
import numpy as np
from glob import glob
import netCDF4 as nc4
from matplotlib import pyplot as plt, cm
import ipywidgets as widgets
%matplotlib notebook
```
%% Cell type:markdown id: tags:
#### Point to directory containing data.
%% Cell type:code id: tags:
``` python
fdir = '/Users/scott.powell/Public/MR3522/Lab4/data/'
fname = glob(fdir+'*.nc')[0]
```
%% Cell type:markdown id: tags:
#### Open file and read in data.
%% Cell type:code id: tags:
``` python
Tb = {}
#%% Load the data
ncid = nc4.Dataset(fname,'r')
lat = ncid['latitude_lores'][:,:]
lon = ncid['longitude_lores'][:,:]
lat92 = ncid['latitude_hires'][:,:]
lon92 = ncid['longitude_hires'][:,:]
Tb['H19'] = ncid['fcdr_brightness_temperature_19H'][:,:]
Tb['V19'] = ncid['fcdr_brightness_temperature_19V'][:,:]
Tb['V22'] = ncid['fcdr_brightness_temperature_22V'][:,:]
Tb['H37'] = ncid['fcdr_brightness_temperature_37H'][:,:]
Tb['V37'] = ncid['fcdr_brightness_temperature_37V'][:,:]
Tb['H92'] = ncid['fcdr_brightness_temperature_92H'][:,:]
Tb['V92'] = ncid['fcdr_brightness_temperature_92V'][:,:]
```
%% Cell type:markdown id: tags:
#### Select the specific area we want. For this file, we're looking over Typhoon Jebi specifically, which was near 20N, 138E.
The first line below plots a subset of the data plotted by the second. Run the code with the first line uncommented first, then when the lab directs you to, comment out the first line below and uncomment the second line to plot a larger swath of data.
%% Cell type:code id: tags:
``` python
I = np.arange(1100,1102) #This covers just two sweeps.
#I = np.arange(1000,1200) #This covers the part of the ascending node that covered the typhoon.
```
%% Cell type:markdown id: tags:
#### Function for plotting.
%% Cell type:code id: tags:
``` python
def InteractivePlot(band):
plt.close('all')
Tbuse = Tb[band]
fig,ax = plt.subplots(1,1,figsize=(5,7.5))
if band == 'H92' or band == 'V92':
Xflat, Yflat, Zflat = lon92[I,:].flatten(), lat92[I,:].flatten(), Tbuse[I,:].flatten()
cf = ax.contourf(lon92[I,:],lat92[I,:],Tbuse[I,:],np.arange(150,290,10),extend="both",cmap=cm.get_cmap('plasma'))
else:
Xflat, Yflat, Zflat = lon[I,:].flatten(), lat[I,:].flatten(), Tbuse[I,:].flatten()
cf = ax.contourf(lon[I,:],lat[I,:],Tbuse[I,:],np.arange(150,290,10),extend="both",cmap=cm.get_cmap('plasma'))
cb = fig.colorbar(cf, ax=ax)
cb.set_label('Brightness Temperature (K)')
ax.set_xlabel('Longitude')
ax.set_ylabel('Latitude')
# Function for getting values to show up when hovering over plot.
def fmt(x, y):
# get closest point with known data
dist = np.linalg.norm(np.vstack([Xflat - x, Yflat - y]), axis=0)
idx = np.argmin(dist)
z = Zflat[idx]
return 'Longitude={x:.2f} Latitude={y:.2f} Tb={z:.2f}'.format(x=x, y=y, z=z)
ax.format_coord = fmt
```
%% Cell type:code id: tags:
``` python
bands = ['H19','V19','V22','H37','V37','H92','V92']
varnames = widgets.Dropdown(options=bands,description='SSMI/S Channels')
widgets.interactive(InteractivePlot,band=varnames)
```
%% Output
%% Cell type:code id: tags:
``` python
```
%% Cell type:code id: tags:
``` python
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment