#!/usr/bin/env python #------------- # Load modules #------------- from netCDF4 import Dataset import numpy as np # Numpy import import scipy.io as spio import scipy.linalg as linalg import scipy.fftpack as fft import scipy.stats as stats import sys from bmContourMod import * #---------------------- # Provide the file name #---------------------- dirName = '/discover/nobackup/jkouatch/gmiMetFields/MERRA/2x2.5/' fileName = dirName+'MERRA300.prod.assim.20080316.2x2.5x72.nc' #------------------ # Opening the file #------------------ ncFid = Dataset(fileName, mode='r') #---------------------- # Extracting dimensions #---------------------- time = ncFid.variables['time'][:] lev = ncFid.variables['lev'][:] lat = ncFid.variables['lat'][:] lon = ncFid.variables['lon'][:] #------------------------------------ # Extracting the temperature variable #------------------------------------ temp = ncFid.variables['T'][:] #------------- # Closing file #------------- ncFid.close() #-------------------------- # Set the level of interest #-------------------------- level500 = 29 T500 = temp[:,level500,:,:] # time, lat, lon #------------------------------ # Compute the mean and variance #------------------------------ T500mean = np.mean(T500,0) T500var = np.var(T500,0) #--------------------------- # Plot the mean and variance #--------------------------- bmContourPlot(T500mean, lat, lon, 'fig_TempMean', 'Spatial Temperature Mean') bmContourPlot(T500var, lat, lon, 'fig_TempVariance', 'Spatial Temperature Variance')