-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCase_Profs.py
More file actions
74 lines (58 loc) · 2.39 KB
/
Case_Profs.py
File metadata and controls
74 lines (58 loc) · 2.39 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from netCDF4 import Dataset
import glob,os.path
import numpy as np
from scipy.interpolate import UnivariateSpline
import matplotlib
import matplotlib.pyplot as plt
import site
site.addsitedir('/tera/phil/nchaparr/python')
#import sys
#sys.path.insert(0, '/tera/phil/nchaparr/python')
import nchap_fun as nc
ncFiles=glob.glob("/tera2/nchaparr/Nov302013/runs/sam_case1/OUT_3D/keep/NCHAPP1*.nc") #3 D snaphsot files that have been converted to nc files
print ncFiles
"""
Plots from some 3D snapshots,
initial sounding from setdata.f90
and potential temperature derived from abs temp from initial nc file
have made changes tracer conc
Don't use it anymore
"""
#set up plot
theAx = nc.Do_Plot(1, 'Potential Temperature Profile Evolution', 'Height (m)', 'Potential Temperature (K)', 111)
index = 1
#loop over nc snapshot files
for theFile in ncFiles:
print theFile
ncdata = Dataset(theFile,'r')
press = ncdata.variables['p'][...]
height = ncdata.variables['z'][...]
temp = np.squeeze(ncdata.variables['TABS'][...])
tracer = np.squeeze(ncdata.variables['TRACER'][...])
ncdata.close()
meanpress = press
meantemp = np.mean(temp, axis = 1)#get the horizontal mean temperature
meantemp = np.mean(meantemp, axis = 1)
thetafact = np.array([(1.0*1000/i)**0.286 for i in meanpress]) #calculate potential temperature
theta = np.multiply(meantemp, thetafact)
print 'theta 0 from out3d', theta[0]
theAx.plot(theta, height) #, label = str(theFile)
#plt.legend(loc = 'upper left', prop={'size':8})
index = index + 1
#array1 = np.genfromtxt('initial1.txt') #get t0 dump from SAM
array2 = np.genfromtxt('/tera/phil/nchaparr/python/Pert_Files/snd')
initial_height2 = array2[:,0]
initial_theta2 = array2[:,1]
print 'theta 0 from snd', initial_theta2[0]
#initial_height = array1[:,0]
#initial_theta = array1[:,6]
ncFile1= "/tera/phil/nchaparr/sam_ensemble/sam_case1/NCHAPP1/nchap1.nc" #initial nc file
#theAx.plot(initial_theta, initial_height,'*', label = 'Initial Sounding from setdata.f90')
#theAx.plot(initial_theta2, initial_height2,'bs', label = 'Initial Sounding from snd')
#plt.legend(loc = 'upper left', prop={'size':8})
#nc.Plot_nc(ncFile1, 1, theAx) #getting absolute temperatures from initial
#nc file and converting to potential temperature
plt.legend(loc = 'upper left', prop={'size':8})
plt.ylim(0, 2500)
plt.xlim(295, 310)
plt.show()