-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlvt_sample.py
More file actions
60 lines (45 loc) · 1.57 KB
/
Copy pathlvt_sample.py
File metadata and controls
60 lines (45 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 1 16:34:29 2018
Plot some netcdf output from the LVT test cases
@author: dvalters
"""
from netCDF4 import Dataset
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
nc_file = './LVT_RCORR_FINAL.200612310000.d01.nc'
#nc_file = '/disk/scratch/local/dvalters/LVT/LVT_latest_7.2/STATS/LVT_MEAN_FINAL.201012310000.d01.nc'
#File handle
fh = Dataset(nc_file, mode='r')
lons = fh.variables['longitude'][:]
lats = fh.variables['latitude'][:]
soilmoist_vs_nvdi = fh.variables['SoilMoist_v_NDVI'][:]
soilmoist_vs_nvdi_units = fh.variables['SoilMoist_v_NDVI'].units
# Get some parameters for the Stereographic Projection
#lon_0 = lons.mean()
#lat_0 = lats.mean()
m = Basemap(width=5000000,height=3500000,
resolution='l',projection='cyl')
# If our lat and longs were 1D, we would need to meshgrid them
# here to create 2D arrays.
"""
lon, lat = np.meshgrid(lons, lats)
xi, yi = m(lon, lat)
"""
# Plot Data
#cs = m.pcolor(lons,lats,np.squeeze(soilmoist_vs_nvdi))
cs = m.imshow(soilmoist_vs_nvdi, cmap='RdYlGn', vmin=-1.0, vmax=1.0)
# Add Grid Lines
m.drawparallels(np.arange(-90., 90., 30.), labels=[1,0,0,0], fontsize=16)
m.drawmeridians(np.arange(-180., 181., 60.), labels=[0,0,0,1], fontsize=16)
# Add Coastlines, States, and Country Boundaries
m.drawcoastlines()
#m.drawstates()
#m.drawcountries()
# Add Colorbar
cbar = m.colorbar(cs, location='bottom', pad="10%")
cbar.set_label("Raw Correlation", fontsize=18)
# Add Title
plt.title('Soil Moisture (ESA CCI) vs NDVI (GIMMS)', fontsize=28)
plt.show()