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 arctic_map # function to regrid coast limits |
---|
11 | import cartesian_grid_test # function to convert grid from polar to cartesian |
---|
12 | import scipy.special |
---|
13 | import ffgrid2 |
---|
14 | import map_ffgrid |
---|
15 | from matplotlib import colors |
---|
16 | from matplotlib.font_manager import FontProperties |
---|
17 | import map_cartesian_grid |
---|
18 | |
---|
19 | |
---|
20 | |
---|
21 | |
---|
22 | MONTH = np.array(['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']) |
---|
23 | month = np.array(['JANUARY', 'FEBRUARY', 'MARCH', 'APRIL', 'MAY', 'JUNE', 'JULY', 'AUGUST', 'SEPTEMBER', 'OCTOBER', 'NOVEMBER', 'DECEMBER']) |
---|
24 | month_day = np.array([31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]) |
---|
25 | M = len(month) |
---|
26 | |
---|
27 | |
---|
28 | ######################## |
---|
29 | # grid characteristics # |
---|
30 | ######################## |
---|
31 | x0 = -3000. # min limit of grid |
---|
32 | x1 = 2500. # max limit of grid |
---|
33 | dx = 40. |
---|
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. |
---|
39 | yvec = np.arange(y0, y1+dy, dy) |
---|
40 | ny = len(yvec) |
---|
41 | |
---|
42 | ########################### for AMSUA (4 DIFFERENT FREQUENCIES) ######################### |
---|
43 | |
---|
44 | frequ = np.array(['23', '30', '50', '89']) |
---|
45 | |
---|
46 | ######################################## |
---|
47 | # reads NETCFD files of sea ice extent # |
---|
48 | ######################################## |
---|
49 | ice_spec = np.zeros([4, M, ny, nx], float) |
---|
50 | ice_lamb = np.zeros([4, M, ny, nx], float) |
---|
51 | |
---|
52 | vec_read_month = np.arange(0, 600, 50) |
---|
53 | |
---|
54 | spec_lim = np.zeros([4, M], float) |
---|
55 | lamb_lim = np.zeros([4, M], float) |
---|
56 | |
---|
57 | for ifr in range (0, 4): |
---|
58 | print 'frequency ' + frequ[ifr] |
---|
59 | fichierA_dat = open('/net/argos/data/parvati/lahlod/ARCTIC/AMSUA_ice_class/AMSUA' + frequ[ifr] + '_data_classification_parameters_ice_no-ice_2009.dat','r') |
---|
60 | numlines = 0 |
---|
61 | for line in fichierA_dat: numlines += 1 |
---|
62 | fichierA_dat.close() |
---|
63 | fichierA_dat = open('/net/argos/data/parvati/lahlod/ARCTIC/AMSUA_ice_class/AMSUA' + frequ[ifr] + '_data_classification_parameters_ice_no-ice_2009.dat','r') |
---|
64 | nbtotal=numlines-1 |
---|
65 | iligne=0 |
---|
66 | mo = np.zeros([nbtotal],object) # month |
---|
67 | spec_emis_thresh = np.zeros([nbtotal],float) # emissivity threshold with spec emis |
---|
68 | lamb_emis_thresh = np.zeros([nbtotal],float) # emissivity threshold with spec emis |
---|
69 | while (iligne < nbtotal) : |
---|
70 | line = fichierA_dat.readline() |
---|
71 | liste = line.split() |
---|
72 | mo[iligne] = str(liste[0]) |
---|
73 | spec_emis_thresh[iligne] = float(liste[7]) |
---|
74 | lamb_emis_thresh[iligne] = float(liste[8]) |
---|
75 | iligne=iligne+1 |
---|
76 | fichierA_dat.close() |
---|
77 | spec_lim[ifr, :] = spec_emis_thresh[vec_read_month] # read spec emis threshold for each month and each frequence |
---|
78 | lamb_lim[ifr, :] = lamb_emis_thresh[vec_read_month] # read lamb emis threshold for each month and each frequence |
---|
79 | for imo in range (0, M): |
---|
80 | print 'month ' + month[imo] |
---|
81 | # AMSUA NETCDF file |
---|
82 | fichierA_nc = Dataset('/net/argos/data/parvati/lahlod/ARCTIC/AMSUA_ice_class/cartesian_grid_map_ice_no-ice_' + month[imo] + '2009_AMSUA' + frequ[ifr] + '_spec_lamb_thresholds.nc', 'r', format='NETCDF3_CLASSIC') |
---|
83 | ice_spec[ifr, imo, :, :] = fichierA_nc.variables['spec_ice_area'][:] |
---|
84 | ice_lamb[ifr, imo, :, :] = fichierA_nc.variables['lamb_ice_area'][:] |
---|
85 | fichierA_nc.close() |
---|
86 | |
---|
87 | |
---|
88 | |
---|
89 | |
---|
90 | ############################################################## |
---|
91 | # map sea ice extent with lamb and spec emissivity thresholds # |
---|
92 | ############################################################## |
---|
93 | print 'start mapping' |
---|
94 | ion() |
---|
95 | x_ind, y_ind, z_ind, volume = arctic_map.arctic_map_lat50() |
---|
96 | x_coast = x_ind |
---|
97 | y_coast = y_ind |
---|
98 | z_coast = z_ind |
---|
99 | for ifr in range (0, 4): |
---|
100 | print 'map for frequency ' + frequ[ifr] + 'GHZ' |
---|
101 | for imo in range (0, M): |
---|
102 | # spec threshold |
---|
103 | print 'map with spec threshold month ' + month[imo] |
---|
104 | map_cartesian_grid.draw_map_cartes_l(x_coast, y_coast, z_coast, volume, xvec, yvec, new_ice_spec[ifr, imo, :, :], 0, 2, 1, colors.ListedColormap(['blue']), 'Sea ice extent with emis spec > ' + str(spec_lim[ifr, imo])[0:5]) |
---|
105 | title('AMSUA ' + frequ[ifr] + 'GHz - ' + month[imo] + ' 2009') |
---|
106 | plt.savefig('/usr/home/lahlod/twice_d/fig_output_ARCTIC/fig_output_sea_ice_study/ice_class_AMSUA/maps/sea_ice_extent/corrected_extent/AMSUA' + frequ[ifr] + '_ice_emis_spec_thresh_' + MONTH[imo] + month[imo] + '2009.png') |
---|
107 | # lamb threshold |
---|
108 | print 'map with lamb threshold month ' + month[imo] |
---|
109 | map_cartesian_grid.draw_map_cartes_l(x_coast, y_coast, z_coast, volume, xvec, yvec, ice_lamb[ifr, imo, :, :], -1, 2, 1, colors.ListedColormap(['0.5', 'blue']), 'Sea ice extent with emis lamb > ' + str(lamb_lim[ifr, imo])[0:5]) |
---|
110 | title('AMSUA ' + frequ[ifr] + 'GHz - ' + month[imo] + ' 2009') |
---|
111 | plt.savefig('/usr/home/lahlod/twice_d/fig_output_ARCTIC/fig_output_sea_ice_study/ice_class_AMSUA/maps/sea_ice_extent/AMSUA' + frequ[ifr] + '_ice_emis_lamb_thresh_' + MONTH[imo] + month[imo] + '2009.png') |
---|
112 | |
---|
113 | |
---|
114 | |
---|
115 | |
---|
116 | |
---|
117 | ########################### for AMSUB (1 FREQUENCY 89GHz) ######################### |
---|
118 | |
---|
119 | |
---|
120 | ######################################## |
---|
121 | # reads NETCFD files of sea ice extent # |
---|
122 | ######################################## |
---|
123 | ice_spec = np.zeros([M, ny, nx], float) |
---|
124 | ice_lamb = np.zeros([M, ny, nx], float) |
---|
125 | |
---|
126 | vec_read_month = np.arange(0, 600, 50) |
---|
127 | |
---|
128 | spec_lim = np.zeros([M], float) |
---|
129 | lamb_lim = np.zeros([M], float) |
---|
130 | |
---|
131 | fichierB_dat = open('/net/argos/data/parvati/lahlod/ARCTIC/AMSUB_ice_class/AMSUB89_data_classification_parameters_ice_no-ice_2009.dat','r') |
---|
132 | numlines = 0 |
---|
133 | for line in fichierB_dat: numlines += 1 |
---|
134 | |
---|
135 | fichierB_dat.close() |
---|
136 | fichierB_dat = open('/net/argos/data/parvati/lahlod/ARCTIC/AMSUB_ice_class/AMSUB89_data_classification_parameters_ice_no-ice_2009.dat','r') |
---|
137 | nbtotal=numlines-1 |
---|
138 | iligne=0 |
---|
139 | mo = np.zeros([nbtotal],object) # month |
---|
140 | spec_emis_thresh = np.zeros([nbtotal],float) # emissivity threshold with spec emis |
---|
141 | lamb_emis_thresh = np.zeros([nbtotal],float) # emissivity threshold with spec emis |
---|
142 | while (iligne < nbtotal) : |
---|
143 | line = fichierB_dat.readline() |
---|
144 | liste = line.split() |
---|
145 | mo[iligne] = str(liste[0]) |
---|
146 | spec_emis_thresh[iligne] = float(liste[7]) |
---|
147 | lamb_emis_thresh[iligne] = float(liste[8]) |
---|
148 | iligne=iligne+1 |
---|
149 | |
---|
150 | fichierB_dat.close() |
---|
151 | |
---|
152 | spec_lim[:] = spec_emis_thresh[vec_read_month] # read spec emis threshold for each month and each frequence |
---|
153 | lamb_lim[:] = lamb_emis_thresh[vec_read_month] # read lamb emis threshold for each month and each frequence |
---|
154 | for imo in range (0, M): |
---|
155 | print 'month ' + month[imo] |
---|
156 | # AMSUB NETCDF file |
---|
157 | fichierB_nc = Dataset('/net/argos/data/parvati/lahlod/ARCTIC/AMSUB_ice_class/cartesian_grid_map_ice_no-ice_' + month[imo] + '2009_AMSUB89_spec_lamb_thresholds.nc', 'r', format='NETCDF3_CLASSIC') |
---|
158 | ice_spec[imo, :, :] = fichierB_nc.variables['spec_ice_area'][:] |
---|
159 | ice_lamb[imo, :, :] = fichierB_nc.variables['lamb_ice_area'][:] |
---|
160 | fichierB_nc.close() |
---|
161 | |
---|
162 | |
---|
163 | print 'start mapping' |
---|
164 | #ion() |
---|
165 | x_ind, y_ind, z_ind, volume = arctic_map.arctic_map_lat50() |
---|
166 | x_coast = x_ind |
---|
167 | y_coast = y_ind |
---|
168 | z_coast = z_ind |
---|
169 | for imo in range (0, M): |
---|
170 | # spec threshold |
---|
171 | print 'map with spec threshold month ' + month[imo] |
---|
172 | map_cartesian_grid.draw_map_cartes_l(x_coast, y_coast, z_coast, volume, xvec, yvec, ice_spec[imo, :, :], -1, 2, 1, colors.ListedColormap(['0.5', 'blue']), 'Sea ice extent with emis spec > ' + str(spec_lim[imo])[0:5]) |
---|
173 | title('AMSUB 89GHz - ' + month[imo] + ' 2009') |
---|
174 | plt.savefig('/usr/home/lahlod/twice_d/fig_output_ARCTIC/fig_output_sea_ice_study/ice_class_AMSUB/maps/sea_ice_extent/AMSUB89_ice_emis_spec_thresh_' + MONTH[imo] + month[imo] + '2009.png') |
---|
175 | # lamb threshold |
---|
176 | print 'map with lamb threshold month ' + month[imo] |
---|
177 | map_cartesian_grid.draw_map_cartes_l(x_coast, y_coast, z_coast, volume, xvec, yvec, ice_lamb[imo, :, :], -1, 2, 1, colors.ListedColormap(['0.5', 'blue']), 'Sea ice extent with emis lamb > ' + str(lamb_lim[imo])[0:5]) |
---|
178 | title('AMSUB 89GHz - ' + month[imo] + ' 2009') |
---|
179 | plt.savefig('/usr/home/lahlod/twice_d/fig_output_ARCTIC/fig_output_sea_ice_study/ice_class_AMSUB/maps/sea_ice_extent/AMSUB89_ice_emis_lamb_thresh_' + MONTH[imo] + month[imo] + '2009.png') |
---|
180 | |
---|
181 | |
---|