1 | #!/usr/bin/env python |
---|
2 | # -*- coding: utf-8 -*- |
---|
3 | import string |
---|
4 | import numpy as np |
---|
5 | import matplotlib.pyplot as plt |
---|
6 | from pylab import * |
---|
7 | from mpl_toolkits.basemap import Basemap |
---|
8 | from mpl_toolkits.basemap import shiftgrid, cm |
---|
9 | from netCDF4 import Dataset |
---|
10 | import scipy.special |
---|
11 | from matplotlib import colors |
---|
12 | import arctic_map |
---|
13 | import map_cartesian_grid |
---|
14 | |
---|
15 | |
---|
16 | |
---|
17 | |
---|
18 | ########################## |
---|
19 | # time period parameters # |
---|
20 | ########################## |
---|
21 | MONTH = np.array(['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']) |
---|
22 | month = np.array(['JANUARY', 'FEBRUARY', 'MARCH', 'APRIL', 'MAY', 'JUNE', 'JULY', 'AUGUST', 'SEPTEMBER', 'OCTOBER', 'NOVEMBER', 'DECEMBER']) |
---|
23 | month_day = np.array([31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]) |
---|
24 | M = len(month) |
---|
25 | |
---|
26 | |
---|
27 | |
---|
28 | ######################## |
---|
29 | # grid characteristics # |
---|
30 | ######################## |
---|
31 | x0 = -3000. # min limit of grid |
---|
32 | x1 = 2500. # max limit of grid |
---|
33 | dx = 40. # resolution for AMSUA data = 40km // resultion for AMSUB data = 20km |
---|
34 | xvec = np.arange(x0, x1+dx, dx) |
---|
35 | nx = len(xvec) |
---|
36 | y0 = -3000. # min limit of grid |
---|
37 | y1 = 3000. # max limit of grid |
---|
38 | dy = 40. # resolution for AMSUA data = 40km // resultion for AMSUB data = 20km |
---|
39 | yvec = np.arange(y0, y1+dy, dy) |
---|
40 | ny = len(yvec) |
---|
41 | |
---|
42 | |
---|
43 | frequ = np.array(['23', '30', '50', '89']) |
---|
44 | for ifr in range (3, 4): |
---|
45 | print 'frequency ' + str(frequ[ifr]) + 'GHz' |
---|
46 | ################### |
---|
47 | # Read AMSUA data # |
---|
48 | ################### |
---|
49 | es_month = np.zeros([M, ny, nx], float) |
---|
50 | el_month = np.zeros([M, ny, nx], float) |
---|
51 | esl_month = np.zeros([M, ny, nx], float) |
---|
52 | std_es_month = np.zeros([M, ny, nx], float) |
---|
53 | std_el_month = np.zeros([M, ny, nx], float) |
---|
54 | std_esl_month = np.zeros([M, ny, nx], float) |
---|
55 | for imo in range (0, M): |
---|
56 | print 'open file ' + str(month[imo]) |
---|
57 | fichier = Dataset('/net/argos/data/parvati/lahlod/ARCTIC/monthly_GLACE/gridded_data/cartesian_grid/res_40/cartesian_grid_monthly_data_lamb_spec_near_nadir_AMSUB' + str(frequ[ifr]) + '_' + month[imo] + '2009.nc', 'r', format='NETCDF3_CLASSIC') |
---|
58 | lon = fichier.variables['longitude'][:] |
---|
59 | lat = fichier.variables['latitude'][:] |
---|
60 | days = fichier.variables['days'][:] |
---|
61 | es = fichier.variables['e_spec'][:] |
---|
62 | el = fichier.variables['e_lamb'][:] |
---|
63 | esl = fichier.variables['e_spec_lamb'][:] |
---|
64 | fichier.close() |
---|
65 | print 'compute monthly mean and std of data for mapping' |
---|
66 | for ilon in range (0, len(lon)): |
---|
67 | for ilat in range (0, len(lat)): |
---|
68 | es_month[imo, ilat, ilon] = mean(es[ilat, ilon, :][nonzero(isnan(es[ilat, ilon, :]) == False)]) |
---|
69 | el_month[imo, ilat, ilon] = mean(el[ilat, ilon, :][nonzero(isnan(el[ilat, ilon, :]) == False)]) |
---|
70 | esl_month[imo, ilat, ilon] = mean(esl[ilat, ilon, :][nonzero(isnan(esl[ilat, ilon, :]) == False)]) |
---|
71 | std_es_month[imo, ilat, ilon] = sqrt((1. / (month_day[imo] - 1)) * sum((es[ilat, ilon, :][nonzero(isnan(es[ilat, ilon, :]) == False)] - es_month[imo, ilat, ilon])**2)) |
---|
72 | std_el_month[imo, ilat, ilon] = sqrt((1. / (month_day[imo] - 1)) * sum((el[ilat, ilon, :][nonzero(isnan(el[ilat, ilon, :]) == False)] - el_month[imo, ilat, ilon])**2)) |
---|
73 | std_esl_month[imo, ilat, ilon] = sqrt((1. / (month_day[imo] - 1)) * sum((esl[ilat, ilon, :][nonzero(isnan(esl[ilat, ilon, :]) == False)] - esl_month[imo, ilat, ilon])**2)) |
---|
74 | ################################## |
---|
75 | # stack std data in netcdf files # |
---|
76 | ################################## |
---|
77 | print 'start stacking' |
---|
78 | for imo in range (0, M): |
---|
79 | print 'stack in file month ' + str(month[imo]) |
---|
80 | rootgrp = Dataset('/net/argos/data/parvati/lahlod/ARCTIC/monthly_GLACE/gridded_data/cartesian_grid/res_40/cartesian_grid_monthly_mean-std_data_lamb_spec_near_nadir_AMSUB' + str(frequ[ifr]) + '_' + month[imo] + '2009.nc', 'w', format='NETCDF3_CLASSIC') |
---|
81 | rootgrp.createDimension('longitude', nx) |
---|
82 | rootgrp.createDimension('latitude', ny) |
---|
83 | nc_lon = rootgrp.createVariable('longitude', 'f', ('longitude',)) |
---|
84 | nc_lat = rootgrp.createVariable('latitude', 'f', ('latitude',)) |
---|
85 | nc_mean_spec = rootgrp.createVariable('mean_spec', 'f', ('latitude', 'longitude')) |
---|
86 | nc_mean_lamb = rootgrp.createVariable('mean_lamb', 'f', ('latitude', 'longitude')) |
---|
87 | nc_mean_lamb_spec = rootgrp.createVariable('mean_lamb_spec', 'f', ('latitude', 'longitude')) |
---|
88 | nc_std_spec = rootgrp.createVariable('std_spec', 'f', ('latitude', 'longitude')) |
---|
89 | nc_std_lamb = rootgrp.createVariable('std_lamb', 'f', ('latitude', 'longitude')) |
---|
90 | nc_std_lamb_spec = rootgrp.createVariable('std_lamb_spec', 'f', ('latitude', 'longitude')) |
---|
91 | nc_lon[:] = xvec |
---|
92 | nc_lat[:] = yvec |
---|
93 | nc_mean_spec[:] = es_month[imo, :, :] |
---|
94 | nc_mean_lamb[:] = el_month[imo, :, :] |
---|
95 | nc_mean_lamb_spec[:] = esl_month[imo, :, :] |
---|
96 | nc_std_spec[:] = std_es_month[imo, :, :] |
---|
97 | nc_std_lamb[:] = std_el_month[imo, :, :] |
---|
98 | nc_std_lamb_spec[:] = std_esl_month[imo, :, :] |
---|
99 | rootgrp.close() |
---|
100 | ''' |
---|
101 | print 'map of data' |
---|
102 | ion() |
---|
103 | x_ind, y_ind, z_ind, volume = arctic_map.arctic_map_lat50() |
---|
104 | x_coast = x_ind |
---|
105 | y_coast = y_ind |
---|
106 | z_coast = z_ind |
---|
107 | colormap = cm.s3pcpn_l_r |
---|
108 | for imo in range (0, M): |
---|
109 | print 'map month ' + month[imo] |
---|
110 | # emiss SPEC |
---|
111 | print 'emis spec' |
---|
112 | map_cartesian_grid.draw_map_cartes_l(x_coast, y_coast, z_coast, volume, xvec, yvec, es_a_month[imo, :, :], 0.45, 1.02, 0.01, colormap, 'emissivity SPEC') |
---|
113 | title(month[imo] + ' 2009 - AMSUA 30GHz') |
---|
114 | savefig('/usr/home/lahlod/twice_d/fig_output_ARCTIC/fig_output_sea_ice_study/comparison_lamb_spec/space_evolution/EMIS/cartesian_grid/emis_spec_AMSUA' + str(frequ[ifr]) + '_' + month[imo] + '2009.png') |
---|
115 | # emis SPEC-LAMB |
---|
116 | print 'emis lamb-spec' |
---|
117 | map_cartesian_grid.draw_map_cartes_l(x_coast, y_coast, z_coast, volume, xvec, yvec, esl_a_month[imo, :, :], 0., 0.03, 0.001, colormap, 'emissivity LAMB - SPEC') |
---|
118 | title(month[imo] + ' 2009 - AMSUA 30GHz') |
---|
119 | savefig('/usr/home/lahlod/twice_d/fig_output_ARCTIC/fig_output_sea_ice_study/comparison_lamb_spec/space_evolution/EMIS/cartesian_grid/emis_spec-lamb_AMSUA' + str(frequ[ifr]) + '_' + month[imo] + '2009.png') |
---|
120 | # std SPEC |
---|
121 | print 'std emis spec' |
---|
122 | map_cartesian_grid.draw_map_cartes_l(x_coast, y_coast, z_coast, volume, xvec, yvec, std_es_month[imo, :, :], 0., std_es_month[nonzero(isnan(std_es_month) == False)].max(), 0.001, colormap, 'std of emissivity SPEC') |
---|
123 | title(month[imo] + ' 2009 - AMSUA ' + str(frequ[ifr]) + 'GHz') |
---|
124 | savefig('/usr/home/lahlod/twice_d/fig_output_ARCTIC/fig_output_sea_ice_study/comparison_lamb_spec/space_evolution/EMIS/cartesian_grid/std_emis_spec_AMSUA' + str(frequ[ifr]) + '_' + month[imo] + '2009.png') |
---|
125 | # std LAMB |
---|
126 | print 'std emis lamb' |
---|
127 | map_cartesian_grid.draw_map_cartes_l(x_coast, y_coast, z_coast, volume, xvec, yvec, std_el_month[imo, :, :], 0., std_el_month[nonzero(isnan(std_el_month) == False)].max(), 0.001, colormap, 'std of emissivity LAMB') |
---|
128 | title(month[imo] + ' 2009 - AMSUA ' + str(frequ[ifr]) + 'GHz') |
---|
129 | savefig('/usr/home/lahlod/twice_d/fig_output_ARCTIC/fig_output_sea_ice_study/comparison_lamb_spec/space_evolution/EMIS/cartesian_grid/std_emis_lamb_AMSUA' + str(frequ[ifr]) + '_' + month[imo] + '2009.png') |
---|
130 | # std LAMB-SPEC |
---|
131 | print 'std emis lamb-spec' |
---|
132 | map_cartesian_grid.draw_map_cartes_l(x_coast, y_coast, z_coast, volume, xvec, yvec, std_esl_month[imo, :, :], 0., std_esl_month[nonzero(isnan(std_esl_month) == False)].max(), 0.0001, colormap, 'std emissivity LAMB - SPEC') |
---|
133 | title(month[imo] + ' 2009 - AMSUA ' + str(frequ[ifr]) + 'GHz') |
---|
134 | savefig('/usr/home/lahlod/twice_d/fig_output_ARCTIC/fig_output_sea_ice_study/comparison_lamb_spec/space_evolution/EMIS/cartesian_grid/std_emis_lamb-spec_AMSUA' + str(frequ[ifr]) + '_' + month[imo] + '2009.png') |
---|
135 | ''' |
---|
136 | |
---|
137 | |
---|
138 | |
---|