-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_bad_scrip_points.py
executable file
·162 lines (125 loc) · 4.67 KB
/
check_bad_scrip_points.py
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/usr/bin/python
#
# Python module to plot the hwsd dat on EMEP grid
#
# Edard Comyn-Platt
# Centre for Ecology and Hydrology
# January 2015
#
# Contains
#
import os, sys
import numpy as np
import netCDF4 as nc
import matplotlib.pyplot as plot
INFILE = '/users/eow/edwcom/EMEP/hwsd2emep/input_data/grid_files/EMEP4UK_EUROPE_gridfile.nc'
INFILE = '/users/eow/edwcom/EMEP/hwsd2emep/input_data/grid_files/EMEP4UK_gridfile.nc'
INFILE = '/users/eow/edwcom/EMEP/hwsd2emep/input_data/grid_files/hwsd_30arcsec_rebinned.nc'
INFILE = '/users/eow/edwcom/EMEP/hwsd2emep/input_data/grid_files/hwsd_30arcsec_EMEP4UK.nc'
INFILE='/users/eow/edwcom/EMEP/topo2emep/x1y1/input_data/grid_files/EMEP4UK_EUROPE_gridfile.nc'
INFILE='/users/eow/edwcom/EMEP/topo2emep/x1y1/input_data/topidx.nc'
INFILE='/users/eow/edwcom/EMEP/chess2emep/input_data/grid_files/chess_1km.nc'
INFILE='/users/eow/edwcom/EMEP/chess2emep/input_data/grid_files/EMEP4UK_gridfile.nc'
inf=nc.Dataset(INFILE,'r')
dims = inf.variables['grid_dims'][:]
mask = inf.variables['grid_imask'][:]
lats = inf.variables['grid_center_lat'][:]
lons = inf.variables['grid_center_lon'][:]
latcors = inf.variables['grid_corner_lat'][:]
loncors = inf.variables['grid_corner_lon'][:]
inf.close()
plot.figure(1,figsize=(20,10))
plot.subplot(1,3,1)
plot.imshow(lats.reshape(dims[::-1]),origin='bottom')
plot.colorbar(fraction=0.04)
plot.subplot(1,3,2)
plot.imshow(lons.reshape(dims[::-1]),origin='bottom')
plot.colorbar(fraction=0.04)
plot.subplot(1,3,3)
plot.imshow(mask.reshape(dims[::-1]),origin='bottom')
plot.colorbar(fraction=0.04)
plot.show()
vmin,vmax=-0.01,0.01
vmin,vmax=-0.5,0.5
plot.figure(1,figsize=(25,10))
plot.subplot(3,4,1)
plot.imshow(latcors[:,0].reshape(dims[::-1])-lats.reshape(dims[::-1]),origin='bottom',vmin=vmin,vmax=vmax)
plot.colorbar(fraction=0.04)
plot.subplot(3,4,2)
plot.imshow(latcors[:,1].reshape(dims[::-1])-lats.reshape(dims[::-1]),origin='bottom',vmin=vmin,vmax=vmax)
plot.colorbar(fraction=0.04)
plot.subplot(3,4,3)
plot.imshow(latcors[:,2].reshape(dims[::-1])-lats.reshape(dims[::-1]),origin='bottom',vmin=vmin,vmax=vmax)
plot.colorbar(fraction=0.04)
plot.subplot(3,4,4)
plot.imshow(latcors[:,3].reshape(dims[::-1])-lats.reshape(dims[::-1]),origin='bottom',vmin=vmin,vmax=vmax)
plot.colorbar(fraction=0.04)
plot.subplot(3,4,5)
plot.imshow(loncors[:,0].reshape(dims[::-1])-lons.reshape(dims[::-1]),origin='bottom',vmin=vmin,vmax=vmax)
plot.colorbar(fraction=0.04)
plot.subplot(3,4,6)
plot.imshow(loncors[:,1].reshape(dims[::-1])-lons.reshape(dims[::-1]),origin='bottom',vmin=vmin,vmax=vmax)
plot.colorbar(fraction=0.04)
plot.subplot(3,4,7)
plot.imshow(loncors[:,2].reshape(dims[::-1])-lons.reshape(dims[::-1]),origin='bottom',vmin=vmin,vmax=vmax)
plot.colorbar(fraction=0.04)
plot.subplot(3,4,8)
plot.imshow(loncors[:,3].reshape(dims[::-1])-lons.reshape(dims[::-1]),origin='bottom',vmin=vmin,vmax=vmax)
plot.colorbar(fraction=0.04)
plot.subplot(3,4,9)
plot.imshow(mask.reshape(dims[::-1]),origin='bottom')
plot.colorbar(fraction=0.04)
plot.subplot(3,4,10)
plot.imshow(lats.reshape(dims[::-1]),origin='bottom')
plot.colorbar(fraction=0.04)
plot.subplot(3,4,11)
plot.imshow(lons.reshape(dims[::-1]),origin='bottom')
plot.colorbar(fraction=0.04)
plot.show()
log_file='/users/eow/edwcom/code/shell_scripts/EMEP/scrip2.log'
log_file='/users/eow/edwcom/EMEP/chess2emep/scrip.log'
l_file=open(log_file)
l_data=l_file.readlines()
l_file.close()
l_data=l_data[6:-2]
index1=[]
index2=[]
extremity=[]
mapnum=[]
for line in l_data:
index1.append(line.split()[5])
index2.append(line.split()[6])
extremity.append(line.split()[-1])
mapnum.append(line.split()[1])
mapnum=np.array(mapnum,dtype='int')
extremity=np.array(extremity,dtype='float32')
index1=np.array(index1,dtype='int64')
index2=np.array(index2,dtype='int64')
index1=index1[mapnum==2]
index2=index2[mapnum==1]
index2=np.sort( np.array( list(set(index2)), dtype='int' ) )
index1=np.sort( np.array( list(set(index1)), dtype='int' ) )
#index2=[]
#for line in l_data:
# index2.append(line.split()[6])
#
#index2=np.sort( np.array( list(set(index2)), dtype='int' ) )
for pt in index1:
print lats[pt], latcors[pt,:]
print lons[pt], loncors[pt,:]
mask1=mask_BU.copy()
mask1[index1]=-1
plot.imshow(mask1.reshape(dims1[::-1]),origin='bottom')
plot.colorbar(fraction=0.04)
plot.show()
mask2=mask.copy()
mask2[index2]=-1
plot.imshow(mask2.reshape(dims2[::-1]),origin='bottom')
plot.colorbar(fraction=0.04)
plot.show()
# the histogram of the data with histtype='step'
n, bins, patches = plot.hist(extremity, 50, normed=1, histtype='stepfilled')
plot.setp(patches, 'facecolor', 'g', 'alpha', 0.75)
## add a line showing the expected distribution
#y = P.normpdf( bins, mu, sigma)
#l = P.plot(bins, y, 'k--', linewidth=1.5)