Last active
December 31, 2015 17:59
-
-
Save ict4eo/8023769 to your computer and use it in GitHub Desktop.
Quick view of netCDF file (param/lat/lon type)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gdal | |
import netCDF4 | |
import sys | |
import matplotlib.pyplot as plt | |
def plot(file_path, title=""): | |
gdal_data = gdal.Open(file_path) | |
arr = gdal_data.ReadAsArray() | |
#print "shapes", arr.shape, arr.dtype | |
plt.imshow(arr) | |
plt.colorbar() | |
plt.title(title) | |
plt.show() | |
var_name = 'airtemp' | |
file_path_out = '/path/to/%s/daily/' % var_name | |
root_name = 'ecmwf_2mtemperature_fulldaily_0.125deg_-22S16E-35S33E_' | |
year = 2001 | |
day = 181 | |
file_name = root_name + str(year) + '_avg_%03d.nc' % day | |
data_path = file_path_out + file_name | |
plot(data_path, file_name) | |
file_name = root_name + str(year) + '_avg_%03d_studyarea.nc' % day | |
data_path = file_path_out + file_name | |
plot(data_path, file_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment