source: trunk/src/scripts_Laura/ARCTIC/read_emis_glace.py @ 55

Last change on this file since 55 was 39, checked in by lahlod, 10 years ago

modifs

File size: 21.9 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3import string
4import numpy as np
5import matplotlib.pyplot as plt
6from pylab import *
7from mpl_toolkits.basemap import Basemap
8from mpl_toolkits.basemap import shiftgrid, cm
9from netCDF4 import Dataset
10import arctic_map # function to regrid coast limits
11import cartesian_grid_test # function to convert grid from polar to cartesian
12
13
14le_mois=np.array(['NOVEMBER2009', 'DECEMBER2009', 'JANUARY2010', 'FEBRUARY2010'])
15month_days = np.array([30, 31, 31, 28])
16
17
18
19for imo in range (0, 1):
20    fichier=open("/net/argos/data/parvati/lahlod/ARCTIC/AMSUA_EMIS_GLACE_"+str(le_mois[imo])+".DAT",'r')
21    numlines = 0
22    for line in fichier: numlines += 1
23    fichier.close()
24    fichier=open("/net/argos/data/parvati/lahlod/ARCTIC/AMSUA_EMIS_GLACE_"+str(le_mois[imo])+".DAT",'r')
25    nbtotal=numlines-1
26    iligne=0
27    lat=np.zeros([nbtotal],float)
28    lon=np.zeros([nbtotal],float)
29    jjr=np.zeros([nbtotal],float)
30    zen=np.zeros([nbtotal],float)
31    fov=np.zeros([nbtotal],float)
32    ts=np.zeros([nbtotal],float)
33    emis=np.zeros([4,nbtotal],float)
34    tb=np.zeros([4,nbtotal],float)
35    tup=np.zeros([4,nbtotal],float)
36    tdn=np.zeros([4,nbtotal],float)
37    #trans=np.zeros([4,nbtotal],float)
38    while (iligne < nbtotal) :
39         line = fichier.readline()
40         # exemple : line = "0.22 2.3 5.0 6"
41         liste = line.split()
42         # exemple : listeCoord ['0.22', '2.3', '5.0', '6'] (liste de chaine de caract?es)
43         lat[iligne] = float(liste[1])
44         lon[iligne] = float(liste[0])
45         jjr[iligne] = float(liste[4])
46         ts[iligne] = float(liste[8])
47         fov[iligne] = float(liste[10])
48         #trans[iligne] = float(liste[17])
49         for ki in range(0,4):
50             emis[ki,iligne] = float(liste[12+ki])
51             tb[ki,iligne] = float(liste[16+ki])
52             tdn[ki,iligne] = float(liste[20+ki])
53             tup[ki,iligne] = float(liste[24+ki])
54             #trans[ki,iligne] = float(liste[28+ki])
55             #tup_ssmis[ki,iligne] = float(liste[28+ki])
56             #tdn_ssmis[ki,iligne] = float(liste[37+ki])
57             #trans_ssmis[ki,iligne] = float(liste[44+ki])
58         iligne=iligne+1
59    fichier.close()
60    jour = jjr
61    month = month_days[imo] #number of days in month
62    longi = lon
63    lati = lat
64    z_ini = tb[0,:]
65    z0 = min(z_ini)
66    z1 = max(z_ini)
67    dx = 50.
68    dy = 50.
69    zgrid_output, ngrid_output, z2grid_output, sigmagrid_output, xvec, yvec, xgrid_cart, ygrid_cart = cartesian_grid_test.new_cartesian_grid(jour, month, longi, lati, z_ini, z0, z1, dx, dy) 
70    tbch1_nov2009 = zgrid_output
71
72   
73
74
75## study zone 1 (ice after summer melt) ##
76# x around -587.198 // y around 1187.5
77index_x = np.where(xvec == -550.)[0][0]
78index_y = np.where(yvec == 1150.)[0][0]
79a = tbch1_nov2009[index_y, index_x, :]
80b = ngrid_output[index_y, index_x, :]
81c = sigmagrid_output[index_y, index_x, :]
82
83
84plt.ion()
85plt.figure()
86plt.plot(a, 'r', label = 'Tb ch1')
87legend()
88plt.figure()
89plt.plot(b, 'g', label = 'n values in cell')
90legend()
91plt.figure()
92plt.plot(c, 'b', label = 'variance Tb values in cell' )
93legend()
94
95## interessant de comparer les Tb avec une resolution plus ou moins fine ##
96
97
98
99tbmean = np.zeros([len(yvec), len(xvec)], float)
100nmean = np.zeros([len(yvec), len(xvec)], float)
101sigmamean = np.zeros([len(yvec), len(xvec)], float)
102for ix in range (0, len(xvec)):
103    for iy in range (0, len(yvec)):
104        tbmean[iy, ix] = tbch1_nov2009[iy, ix, :][nonzero(isnan(tbch1_nov2009[iy, ix, :]) == False)].mean()
105        nmean[iy, ix] = ngrid_output[iy, ix, :][nonzero(isnan(ngrid_output[iy, ix, :]) == False)].mean()
106        sigmamean[iy, ix] = sigmagrid_output[iy, ix, :][nonzero(isnan(sigmagrid_output[iy, ix, :]) == False)].mean()
107
108
109
110
111x_ind, y_ind, z_ind, volume = arctic_map.arctic_map_lat50()
112plt.figure()
113plt.scatter(x_ind, y_ind, c = z_ind, s = volume)
114clevs = np.arange(137., 269., 1.)
115cs = plt.contourf(xgrid_cart,ygrid_cart, tbmean, clevs, cmap=cm.s3pcpn_l_r) 
116cbar = colorbar(cs)
117xlim(-2500., 3000.)
118ylim(-3000., 3000.)
119#txt = 'variance - spatial resolution = ' + str(delta_xy[idel]) + 'km'   
120#cbar.set_label(txt)
121plt.figure()
122plt.scatter(x_ind, y_ind, c = z_ind, s = volume)
123clevs = np.arange(0, 30, 1)
124cs = plt.contourf(xgrid_cart,ygrid_cart, nmean, clevs, cmap=cm.s3pcpn_l_r) 
125cbar = colorbar(cs)
126xlim(-2500., 3000.)
127ylim(-3000., 3000.)
128plt.figure()
129plt.scatter(x_ind, y_ind, c = z_ind, s = volume)
130clevs = np.arange(0., 16., 0.1)
131cs = plt.contourf(xgrid_cart,ygrid_cart, sigmamean, clevs, cmap=cm.s3pcpn_l_r) 
132cbar = colorbar(cs)
133xlim(-2500., 3000.)
134ylim(-3000., 3000.)
135
136
137
138
139
140
141#for canal in range(0,4):
142#    for ii in range (0,size(emis[canal,:])):
143#        if (emis[canal,ii] > 1): emis[canal,ii] = NaN
144bblat_nov2009 = nonzero(lat >= 65.) 
145#bbfov = nonzero(fov[bblat] == 0.)
146#ijr = 0
147bbjr_nov2009 = nonzero(jjr[bblat_nov2009] == 15.)
148lon_zon_nov2009 = lon[bblat_nov2009][bbjr_nov2009]
149lat_zon_nov2009 = lat[bblat_nov2009][bbjr_nov2009]
150#emisch4 = emis[3,:][bblat][bbjr]
151#emisch3 = emis[2,:][bblat][bbjr]
152tbch1_nov2009 = tb[0,:][bblat_nov2009][bbjr_nov2009]
153tbch2_nov2009 = tb[1,:][bblat_nov2009][bbjr_nov2009]
154tbch3_nov2009 = tb[2,:][bblat_nov2009][bbjr_nov2009]
155tbch4_nov2009 = tb[3,:][bblat_nov2009][bbjr_nov2009]
156#tsurf = ts[bblat][bbjr]   
157#tdnch4 = tdn[3,:][bblat][bbjr]
158#tdnch3 = tdn[2,:][bblat][bbjr]
159#tupch4 = tup[3,:][bblat][bbjr]
160#tupch3 = tup[2,:][bblat][bbjr]
161
162
163
164# DECEMBER2009
165imo = 1
166fichier=open("/net/argos/data/parvati/lahlod/ARCTIC/AMSUA_EMIS_GLACE_"+str(le_mois[imo])+".DAT",'r')
167numlines = 0
168for line in fichier: numlines += 1
169
170fichier.close()
171fichier=open("/net/argos/data/parvati/lahlod/ARCTIC/AMSUA_EMIS_GLACE_"+str(le_mois[imo])+".DAT",'r')
172nbtotal=numlines-1
173iligne=0
174lat=np.zeros([nbtotal],float)
175lon=np.zeros([nbtotal],float)
176jjr=np.zeros([nbtotal],float)
177zen=np.zeros([nbtotal],float)
178fov=np.zeros([nbtotal],float)
179ts=np.zeros([nbtotal],float)
180emis=np.zeros([4,nbtotal],float)
181tb=np.zeros([4,nbtotal],float)
182tup=np.zeros([4,nbtotal],float)
183tdn=np.zeros([4,nbtotal],float)
184#trans=np.zeros([4,nbtotal],float)
185while (iligne < nbtotal) :
186     line = fichier.readline()
187     # exemple : line = "0.22 2.3 5.0 6"
188     liste = line.split()
189     # exemple : listeCoord ['0.22', '2.3', '5.0', '6'] (liste de chaine de caract?es)
190     lat[iligne] = float(liste[1])
191     lon[iligne] = float(liste[0])
192     jjr[iligne] = float(liste[4])
193     ts[iligne] = float(liste[8])
194     fov[iligne] = float(liste[10])
195     #trans[iligne] = float(liste[17])
196     for ki in range(0,4):
197         emis[ki,iligne] = float(liste[12+ki])
198         tb[ki,iligne] = float(liste[16+ki])
199         tdn[ki,iligne] = float(liste[20+ki])
200         tup[ki,iligne] = float(liste[24+ki])
201         #trans[ki,iligne] = float(liste[28+ki])
202         #tup_ssmis[ki,iligne] = float(liste[28+ki])
203         #tdn_ssmis[ki,iligne] = float(liste[37+ki])
204         #trans_ssmis[ki,iligne] = float(liste[44+ki])
205     iligne=iligne+1
206
207fichier.close()
208#for canal in range(0,4):
209#    for ii in range (0,size(emis[canal,:])):
210#        if (emis[canal,ii] > 1): emis[canal,ii] = NaN
211bblat_dec2009 = nonzero(lat >= 65.) 
212#bbfov = nonzero(fov[bblat] == 0.)
213#ijr = 0
214bbjr_dec2009 = nonzero(jjr[bblat_dec2009] == 15.)
215lon_zon_dec2009 = lon[bblat_dec2009][bbjr_dec2009]
216lat_zon_dec2009 = lat[bblat_dec2009][bbjr_dec2009]
217#emisch4 = emis[3,:][bblat][bbjr]
218#emisch3 = emis[2,:][bblat][bbjr]
219tbch1_dec2009 = tb[0,:][bblat_dec2009][bbjr_dec2009]
220tbch2_dec2009 = tb[1,:][bblat_dec2009][bbjr_dec2009]
221tbch3_dec2009 = tb[2,:][bblat_dec2009][bbjr_dec2009]
222tbch4_dec2009 = tb[3,:][bblat_dec2009][bbjr_dec2009]
223#tsurf = ts[bblat][bbjr]   
224#tdnch4 = tdn[3,:][bblat][bbjr]
225#tdnch3 = tdn[2,:][bblat][bbjr]
226#tupch4 = tup[3,:][bblat][bbjr]
227#tupch3 = tup[2,:][bblat][bbjr]
228
229
230# JANUARY2009
231imo = 2
232fichier=open("/net/argos/data/parvati/lahlod/ARCTIC/AMSUA_EMIS_GLACE_"+str(le_mois[imo])+".DAT",'r')
233numlines = 0
234for line in fichier: numlines += 1
235
236fichier.close()
237fichier=open("/net/argos/data/parvati/lahlod/ARCTIC/AMSUA_EMIS_GLACE_"+str(le_mois[imo])+".DAT",'r')
238nbtotal=numlines-1
239iligne=0
240lat=np.zeros([nbtotal],float)
241lon=np.zeros([nbtotal],float)
242jjr=np.zeros([nbtotal],float)
243zen=np.zeros([nbtotal],float)
244fov=np.zeros([nbtotal],float)
245ts=np.zeros([nbtotal],float)
246emis=np.zeros([4,nbtotal],float)
247tb=np.zeros([4,nbtotal],float)
248tup=np.zeros([4,nbtotal],float)
249tdn=np.zeros([4,nbtotal],float)
250#trans=np.zeros([4,nbtotal],float)
251while (iligne < nbtotal) :
252     line = fichier.readline()
253     # exemple : line = "0.22 2.3 5.0 6"
254     liste = line.split()
255     # exemple : listeCoord ['0.22', '2.3', '5.0', '6'] (liste de chaine de caract?es)
256     lat[iligne] = float(liste[1])
257     lon[iligne] = float(liste[0])
258     jjr[iligne] = float(liste[4])
259     ts[iligne] = float(liste[8])
260     fov[iligne] = float(liste[10])
261     #trans[iligne] = float(liste[17])
262     for ki in range(0,4):
263         emis[ki,iligne] = float(liste[12+ki])
264         tb[ki,iligne] = float(liste[16+ki])
265         tdn[ki,iligne] = float(liste[20+ki])
266         tup[ki,iligne] = float(liste[24+ki])
267         #trans[ki,iligne] = float(liste[28+ki])
268         #tup_ssmis[ki,iligne] = float(liste[28+ki])
269         #tdn_ssmis[ki,iligne] = float(liste[37+ki])
270         #trans_ssmis[ki,iligne] = float(liste[44+ki])
271     iligne=iligne+1
272
273fichier.close()
274#for canal in range(0,4):
275#    for ii in range (0,size(emis[canal,:])):
276#        if (emis[canal,ii] > 1): emis[canal,ii] = NaN
277bblat_jan2009 = nonzero(lat >= 65.) 
278#bbfov = nonzero(fov[bblat] == 0.)
279#ijr = 0
280bbjr_jan2009 = nonzero(jjr[bblat_jan2009] == 15.)
281lon_zon_jan2009 = lon[bblat_jan2009][bbjr_jan2009]
282lat_zon_jan2009 = lat[bblat_jan2009][bbjr_jan2009]
283#emisch4 = emis[3,:][bblat][bbjr]
284#emisch3 = emis[2,:][bblat][bbjr]
285tbch1_jan2009 = tb[0,:][bblat_jan2009][bbjr_jan2009]
286tbch2_jan2009 = tb[1,:][bblat_jan2009][bbjr_jan2009]
287tbch3_jan2009 = tb[2,:][bblat_jan2009][bbjr_jan2009]
288tbch4_jan2009 = tb[3,:][bblat_jan2009][bbjr_jan2009]
289#tsurf = ts[bblat][bbjr]   
290#tdnch4 = tdn[3,:][bblat][bbjr]
291#tdnch3 = tdn[2,:][bblat][bbjr]
292#tupch4 = tup[3,:][bblat][bbjr]
293#tupch3 = tup[2,:][bblat][bbjr]
294
295
296
297
298
299## test of variance distribution with different spatial resolution #####################################
300imo = 0
301longitude = lon_zon_nov2009
302latitude = lat_zon_nov2009
303z = tbch1_nov2009
304z0 = min(z)
305z1 = max(z)
306delta_xy = np.array([25., 30., 35., 40., 45., 50.])
307Lxy = len(delta_xy)
308plt.ion()
309nber_val = np.zeros([6], float)
310for idel in range (0, Lxy):
311    dx = delta_xy[idel]
312    dy = delta_xy[idel]
313    x_ind, y_ind, z_ind, volume = arctic_map.arctic_map_lat50()
314    ZGRID, ngrid, z2grid, sigmagrid, xvec, yvec, xgrid_cart, ygrid_cart = cartesian_grid_test.new_cartesian_grid(longitude, latitude, z, z0, z1, dx, dy)
315    plt.figure()
316    plt.scatter(x_ind, y_ind, c = z_ind, s = volume)
317    clevs = np.arange(137., 269, 1.)
318    cs = plt.contourf(xgrid_cart,ygrid_cart, zgrid_output[:, :, 0], clevs, cmap=cm.s3pcpn_l_r) 
319    cbar = colorbar(cs)
320    txt = 'variance - spatial resolution = ' + str(delta_xy[idel]) + 'km'   
321    cbar.set_label(txt)
322    xlim(-4000., 3000.)
323    ylim(-4000., 4000.)
324    plt.savefig('/usr/home/lahlod/twice_d/figure_output_ARCTIC/variance_new_grid_spatial_res_'+ str(delta_xy[idel]) + 'km_' + le_mois[imo] + '.png')
325########################################################################################################
326
327## new grid parameters for mapping ##
328dx=50.
329dy=50.
330longitude = lon_zon_nov2009
331latitude = lat_zon_nov2009
332z = tbch1_nov2009
333z0 = min(z)
334z1 = max(z)
335ZGRID, ngrid, z2grid, sigmagrid, xvec, yvec, xgrid_cart, ygrid_cart = cartesian_grid_test.new_cartesian_grid(longitude, latitude, z, z0, z1, dx, dy)
336tb_mesh_nov2009 = ZGRID
337x_mesh = xvec
338y_mesh = yvec
339## map parameters for arctic coast limits mapping ##
340x_ind, y_ind, z_ind, volume = arctic_map.arctic_map_lat50()
341## mapping ##
342plt.ion()
343plt.figure()
344plt.scatter(x_ind, y_ind, c = z_ind, s = volume)
345clevs1 = np.arange(0, 30, 1.)
346cs = plt.contourf(xgrid_cart,ygrid_cart, ngrid, clevs1, cmap=cm.s3pcpn_l_r) 
347cbar = colorbar(cs)
348txt = 'number of values per grid - Tb ch1 (16th, november 2009) - AMSU-A'
349cbar.set_label(txt)
350xlim(-3000., 2500.)
351ylim(-3000., 3000.)
352
353
354
355
356## calculation of standard deviation for november in each new_grid cell ##
357## 1 ## matrix of new gridded Tb per day ####
358x0 = -3000.
359x1 = 2500.
360dx=25.
361xvec = np.arange(x0, x1+dx, dx)
362nx = len(xvec)
363y0 = -3000.
364y1 = 3000.
365dy=25.
366yvec = np.arange(y0, y1+dy, dy)
367ny = len(yvec)
368tbch1_mesh_nov2jan009 = np.zeros([ny, nx, 30], float)
369tbch2_mesh_jan2009 = np.zeros([ny, nx, 30], float)
370tsurf_mesh_jan2009 = np.zeros([ny, nx, 30], float)
371for ijr in range (0, 30):
372    bbjr_jan2009 = nonzero(jjr[bblat_jan2009] == ijr + 1.)
373    print 'date: ' + str(ijr + 1) + ' nov 2009'
374    lon_zon_nov2009 = lon[bblat_nov2009][bbjr_nov2009]
375    lat_zon_nov2009 = lat[bblat_nov2009][bbjr_nov2009]
376    tbch1_nov2009 = tb[0,:][bblat_nov2009][bbjr_nov2009]
377    #tbch2_nov2009 = tb[1,:][bblat_nov2009][bbjr_nov2009]
378    #tbch3_nov2009 = tb[2,:][bblat_nov2009][bbjr_nov2009]
379    #tbch4_nov2009 = tb[3,:][bblat_nov2009][bbjr_nov2009]
380    tsurf_nov2009 = ts[bblat_nov2009][bbjr_nov2009] 
381    longitude = lon_zon_nov2009
382    latitude = lat_zon_nov2009
383    z = tbch1_nov2009 # channel 1
384    z0 = min(z)
385    z1 = max(z)
386    ZGRID, ngrid, z2grid, sigmagrid, xvec, yvec, xgrid_cart, ygrid_cart = cartesian_grid_test.new_cartesian_grid(longitude, latitude, z, z0, z1, dx, dy)
387    tbch1_mesh_nov2009[:, :, ijr] = ZGRID
388    print 'channel 1'
389    x_mesh = xvec
390    y_mesh = yvec
391    z = tbch2_nov2009 # channel 2
392    z0 = min(z)
393    z1 = max(z)
394    ZGRID, ngrid, z2grid, sigmagrid, xvec, yvec, xgrid_cart, ygrid_cart = cartesian_grid_test.new_cartesian_grid(longitude, latitude, z, z0, z1, dx, dy)
395    tbch2_mesh_nov2009[:, :, ijr] = ZGRID
396    print 'channel 2'
397    z = tsurf_nov2009 # surface temperature
398    z0 = min(z)
399    z1 = max(z)
400    ZGRID, ngrid, z2grid, sigmagrid, xvec, yvec, xgrid_cart, ygrid_cart = cartesian_grid_test.new_cartesian_grid(longitude, latitude, z, z0, z1, dx, dy)
401    tsurf_mesh_nov2009[:, :, ijr] = ZGRID
402    print 'surf temp'
403
404
405
406## 2 ## std in each grid cell ####
407tbsum_tbch1 = np.zeros([241, 261], float)
408tbsum_tbch2 = np.zeros([241, 261], float)
409tbsum_tsurf = np.zeros([241, 261], float)
410for ix in range (0, 261):
411    for iy in range (0, 241):
412        bb_value_tbch1 = nonzero(isnan(tbch1_mesh_nov2009[iy, ix, :]) == False)
413        bb_value_tbch2 = nonzero(isnan(tbch2_mesh_nov2009[iy, ix, :]) == False)
414        bb_value_tsurf = nonzero(isnan(tsurf_mesh_nov2009[iy, ix, :]) == False)
415        # channel 1
416        if (bb_value_tbch1[0] == np.array([])):
417            tbsum_tbch1[iy, ix] = NaN # take out grid cells where no obs in the month
418        else:
419            tbsum_tbch1[iy, ix] = sum((tbch1_mesh_nov2009[iy, ix, :][bb_value_tbch1] - mean(tbch1_mesh_nov2009[iy, ix, :][bb_value_tbch1])) ** 2) 
420        # channel 2     
421        if (bb_value_tbch2[0] == np.array([])):
422            tbsum_tbch2[iy, ix] = NaN # take out grid cells where no obs in the month
423        else:
424            tbsum_tbch2[iy, ix] = sum((tbch2_mesh_nov2009[iy, ix, :][bb_value_tbch2] - mean(tbch2_mesh_nov2009[iy, ix, :][bb_value_tbch2])) ** 2)
425        # surface temperature
426        if (bb_value_tsurf[0] == np.array([])):
427            tbsum_tsurf[iy, ix] = NaN # take out grid cells where no obs in the month
428        else:
429            tbsum_tsurf[iy, ix] = sum((tsurf_mesh_nov2009[iy, ix, :][bb_value_tsurf] - mean(tsurf_mesh_nov2009[iy, ix, :][bb_value_tsurf])) ** 2)
430
431
432
433std_tbch1_nov2009 = sqrt((1. / (30. - 1.)) * tbsum_tbch1)
434std_tbch2_nov2009 = sqrt((1. / (30. - 1.)) * tbsum_tbch2)
435std_tsurf_nov2009 = sqrt((1. / (30. - 1.)) * tbsum_tsurf)
436
437for ix in range (0, 261):
438    for iy in range (0, 241):
439        if (std_tbch1_nov2009[iy, ix] < 0.):
440            std_tbch1_nov2009[iy, ix] == NaN # take out the negative values of std
441        if (std_tbch2_nov2009[iy, ix] < 0.):
442            std_tbch2_nov2009[iy, ix] == NaN # take out the negative values of std
443        if (std_tsurf_nov2009[iy, ix] < 0.):
444            std_tsurf_nov2009[iy, ix] == NaN # take out the negative values of std
445
446
447tbch1_mean_nov2009 = np.zeros([241, 261], float)
448tbch2_mean_nov2009 = np.zeros([241, 261], float)
449tsurf_mean_nov2009 = np.zeros([241, 261], float)
450for ix in range (0, 261):
451    for iy in range (0, 241):
452        bb_val_tbch1 = nonzero(isnan(tbch1_mesh_nov2009[iy, ix, :]) == False)
453        bb_val_tbch2 = nonzero(isnan(tbch2_mesh_nov2009[iy, ix, :]) == False)
454        bb_val_tsurf = nonzero(isnan(tsurf_mesh_nov2009[iy, ix, :]) == False)
455        tbch1_mean_nov2009[iy, ix] = tbch1_mesh_nov2009[iy, ix, :][bb_val_tbch1].mean()
456        tbch2_mean_nov2009[iy, ix] = tbch2_mesh_nov2009[iy, ix, :][bb_val_tbch2].mean()
457        tsurf_mean_nov2009[iy, ix] = tsurf_mesh_nov2009[iy, ix, :][bb_val_tsurf].mean()
458
459## study zone ##
460## 1 ## monthly mean (temporal) values ####
461study_x = np.where((xvec >= -800.) & (xvec <= -350.))[0]
462study_y = np.where((yvec >= 950.) & (yvec <= 1300.))[0]
463Sx = len(study_x)
464Sy = len(study_y)
465tbch1_mean_zone_nov2009 = tbch1_mean_nov2009[study_y[0]: study_y[Sy - 1] + 1, study_x[0]: study_x[Sx - 1] + 1]
466tbch2_mean_zone_nov2009 = tbch2_mean_nov2009[study_y[0]: study_y[Sy - 1] + 1, study_x[0]: study_x[Sx - 1] + 1]
467tsurf_mean_zone_nov2009 = tsurf_mean_nov2009[study_y[0]: study_y[Sy - 1] + 1, study_x[0]: study_x[Sx - 1] + 1]
468## 2 ## daily mean (spatial) values ####
469tbch1_mean_day_nov2009 = np.zeros([30], float)
470tbch2_mean_day_nov2009 = np.zeros([30], float)
471tsurf_mean_day_nov2009 = np.zeros([30], float)
472for ijr in range (0, 30):
473    a = np.reshape(tbch1_mesh_nov2009[:, :, ijr], size(tbch1_mesh_nov2009[:, :, ijr]))
474    bba = nonzero(isnan(a) == False)
475    moy_a = mean(a[bba])
476    tbch1_mean_day_nov2009[ijr] = moy_a
477    b = np.reshape(tbch2_mesh_nov2009[:, :, ijr], size(tbch2_mesh_nov2009[:, :, ijr]))
478    bbb = nonzero(isnan(b) == False)
479    moy_b = mean(b[bbb])
480    tbch2_mean_day_nov2009[ijr] = moy_b
481    c = np.reshape(tsurf_mesh_nov2009[:, :, ijr], size(tsurf_mesh_nov2009[:, :, ijr]))
482    bbc = nonzero(isnan(c) == False)
483    moy_c = mean(c[bbc])
484    tsurf_mean_day_nov2009[ijr] = moy_c
485    anom_tbch1_nov2009[ijr]
486
487
488plt.figure()
489plt.plot(tbch1_mean_day_nov2009, 'b', label = 'Tb ch1')
490plt.plot(tbch2_mean_day_nov2009, 'g', label = 'Tb ch2')
491legend()
492twinx()
493plt.plot(tsurf_mean_day_nov2009, 'r', label = 'Tsurf')
494legend()
495
496
497# channel 1
498plt.ion()
499plt.figure()
500plt.scatter(x_ind, y_ind, c = z_ind, s = volume)
501clevs1 = np.arange(140., 255., 1.)
502cs = plt.contourf(xgrid_cart,ygrid_cart, tbch1_mesh_nov2009[:, :, ijr], clevs1, cmap=cm.s3pcpn_l_r) 
503cbar = colorbar(cs)
504txt = 'std Tb ch1 (november 2009) - AMSU-A'
505cbar.set_label(txt)
506xlim(-3000., 2500.)
507ylim(-2500., 3500.)
508
509# channel 2
510plt.figure()
511plt.scatter(x_ind, y_ind, c = z_ind, s = volume)
512clevs1 = np.arange(0.8, 39, 1.)
513cs = plt.contourf(xgrid_cart,ygrid_cart,std_tbch2_nov2009, clevs1, cmap=cm.s3pcpn_l_r) 
514cbar = colorbar(cs)
515txt = 'std Tb ch2 (november 2009) - AMSU-A'
516cbar.set_label(txt)
517xlim(-4000., 3000.)
518ylim(-4000., 4000.)
519
520# surface temperature
521plt.figure()
522plt.scatter(x_ind, y_ind, c = z_ind, s = volume)
523clevs1 = np.arange(0., 10., 0.1)
524cs = plt.contourf(xgrid_cart,ygrid_cart,std_tsurf_nov2009, clevs1, cmap=cm.s3pcpn_l_r) 
525cbar = colorbar(cs)
526txt = 'std Tsurf (november 2009) - AMSU-A'
527cbar.set_label(txt)
528xlim(-4000., 3000.)
529ylim(-4000., 4000.)
530
531
532
533
534
535
536longitude = lon_zon_nov2009
537latitude = lat_zon_nov2009
538
539delta_xy = np.array([25., 30., 35., 40., 45., 50.])
540idel = 0
541x0 = -3000.
542x1 = 2500.
543dx = delta_xy[idel]
544xvec = np.arange(x0, x1+dx, dx)
545nx = len(xvec)
546y0 = -3000.
547y1 = 3000.
548dy= delta_xy[idel]
549yvec = np.arange(y0, y1+dy, dy)
550ny = len(yvec)
551for ix in range (0, nx):
552    for iy in range (0, ny):
553        tbch1_moy_nov2009[iy, ix] = tbch1_mesh_nov2009[iy, ix, :].mean
554z = tbch1_moy_nov2009
555z0 = min(z)
556z1 = max(z)
557ZGRID, ngrid, z2grid, sigmagrid, xvec, yvec, xgrid_cart, ygrid_cart = cartesian_grid_test.new_cartesian_grid(longitude, latitude, z, z0, z1, dx, dy)
558moy_ZGRID = ZGRID[nonzero(isnan(ZGRID) == False)].mean()
559good_points = np.zeros([ny, nx], float)
560for ix in range (0, nx):
561    for iy in range (0, ny):
562        if (sigmagrid[iy, ix] > ((1. * moy_ZGRID) / 100.)):
563            good_points[iy, ix] = NaN
564        else: 
565            good_points[iy, ix] = sigmagrid[iy, ix]
566
567
568plt.figure()
569plt.scatter(x_ind, y_ind, c = z_ind, s = volume)
570clevs1 = np.arange(143, 255, 1)
571cs = plt.contourf(xgrid_cart,ygrid_cart,ZGRID, clevs1, cmap=cm.s3pcpn_l_r) 
572cbar = colorbar(cs)
573txt = 'best_grid cells: std < 1% of Tbch1 - res' + str(delta_xy[idel]) + 'km (november 2009, AMSU-A)'
574cbar.set_label(txt)
575xlim(-3000., 2500.)
576ylim(-3000., 3000.)
577
578
579
580
581
582
583
584
585
586
587nber_val_res25 = ngrid
588idel = 1
589dx = delta_xy[idel]
590dy = delta_xy[idel]
591ZGRID, ngrid, z2grid, sigmagrid, xvec, yvec, xgrid_cart, ygrid_cart = cartesian_grid_test.new_cartesian_grid(longitude, latitude, z, z0, z1, dx, dy)
592nber_val_res30 = ngrid
593idel = 2
594dx = delta_xy[idel]
595dy = delta_xy[idel]
596ZGRID, ngrid, z2grid, sigmagrid, xvec, yvec, xgrid_cart, ygrid_cart = cartesian_grid_test.new_cartesian_grid(longitude, latitude, z, z0, z1, dx, dy)
597nber_val_res35 = ngrid
598idel = 3
599dx = delta_xy[idel]
600dy = delta_xy[idel]
601ZGRID, ngrid, z2grid, sigmagrid, xvec, yvec, xgrid_cart, ygrid_cart = cartesian_grid_test.new_cartesian_grid(longitude, latitude, z, z0, z1, dx, dy)
602nber_val_res40 = ngrid
603idel = 4
604dx = delta_xy[idel]
605dy = delta_xy[idel]
606ZGRID, ngrid, z2grid, sigmagrid, xvec, yvec, xgrid_cart, ygrid_cart = cartesian_grid_test.new_cartesian_grid(longitude, latitude, z, z0, z1, dx, dy)
607nber_val_res45 = ngrid
608idel = 5
609dx = delta_xy[idel]
610dy = delta_xy[idel]
611ZGRID, ngrid, z2grid, sigmagrid, xvec, yvec, xgrid_cart, ygrid_cart = cartesian_grid_test.new_cartesian_grid(longitude, latitude, z, z0, z1, dx, dy)
612nber_val_res50 = ngrid
613
614
615ngrid_25km_vec = reshape(nber_val_res25, size(nber_val_res25))
616ngrid_30km_vec = reshape(nber_val_res30, size(nber_val_res30))
617ngrid_35km_vec = reshape(nber_val_res35, size(nber_val_res35))
618ngrid_40km_vec = reshape(nber_val_res40, size(nber_val_res40))
619ngrid_45km_vec = reshape(nber_val_res45, size(nber_val_res45))
620ngrid_50km_vec = reshape(nber_val_res50, size(nber_val_res50))
621
622plt.figure()
623hist([ngrid_25km_vec, ngrid_30km_vec, ngrid_35km_vec, ngrid_40km_vec, ngrid_45km_vec, ngrid_50km_vec], histtype = 'bar', label = ['25km', '30km', '35km', '40km', '45km', '50km'])
624
625
Note: See TracBrowser for help on using the repository browser.