source: trunk/src/scripts_Laura/ARCTIC/Travail_CEN/read_sea_ice_extent.py @ 56

Last change on this file since 56 was 54, checked in by lahlod, 10 years ago

modifs

File size: 8.0 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
12import scipy.special
13import ffgrid2
14import map_ffgrid
15from matplotlib import colors
16from matplotlib.font_manager import FontProperties
17import map_cartesian_grid
18
19
20
21
22MONTH = np.array(['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'])
23month = np.array(['JANUARY', 'FEBRUARY', 'MARCH', 'APRIL', 'MAY', 'JUNE', 'JULY', 'AUGUST', 'SEPTEMBER', 'OCTOBER', 'NOVEMBER', 'DECEMBER'])
24month_day = np.array([31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31])
25M = len(month)
26
27
28########################
29# grid characteristics #
30########################
31x0 = -3000. # min limit of grid
32x1 = 2500. # max limit of grid
33dx = 40.
34xvec = np.arange(x0, x1+dx, dx)
35nx = len(xvec) 
36y0 = -3000. # min limit of grid
37y1 = 3000. # max limit of grid
38dy = 40.
39yvec = np.arange(y0, y1+dy, dy)
40ny = len(yvec)
41
42########################### for AMSUA (4 DIFFERENT FREQUENCIES) #########################
43
44frequ = np.array(['23', '30', '50', '89'])
45
46########################################
47# reads NETCFD files of sea ice extent #
48########################################
49ice_spec = np.zeros([4, M, ny, nx], float)
50ice_lamb = np.zeros([4, M, ny, nx], float)
51
52vec_read_month = np.arange(0, 600, 50)
53
54spec_lim = np.zeros([4, M], float)
55lamb_lim = np.zeros([4, M], float)
56
57for 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##############################################################   
93print 'start mapping'
94ion()
95x_ind, y_ind, z_ind, volume = arctic_map.arctic_map_lat50()
96x_coast = x_ind
97y_coast = y_ind
98z_coast = z_ind
99for 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########################################
123ice_spec = np.zeros([M, ny, nx], float)
124ice_lamb = np.zeros([M, ny, nx], float)
125
126vec_read_month = np.arange(0, 600, 50)
127
128spec_lim = np.zeros([M], float)
129lamb_lim = np.zeros([M], float)
130
131fichierB_dat = open('/net/argos/data/parvati/lahlod/ARCTIC/AMSUB_ice_class/AMSUB89_data_classification_parameters_ice_no-ice_2009.dat','r')
132numlines = 0
133for line in fichierB_dat: numlines += 1
134
135fichierB_dat.close()
136fichierB_dat = open('/net/argos/data/parvati/lahlod/ARCTIC/AMSUB_ice_class/AMSUB89_data_classification_parameters_ice_no-ice_2009.dat','r')
137nbtotal=numlines-1
138iligne=0
139mo = np.zeros([nbtotal],object) # month
140spec_emis_thresh = np.zeros([nbtotal],float) # emissivity threshold with spec emis
141lamb_emis_thresh = np.zeros([nbtotal],float) # emissivity threshold with spec emis
142while (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
150fichierB_dat.close()
151
152spec_lim[:] = spec_emis_thresh[vec_read_month] # read spec emis threshold for each month and each frequence
153lamb_lim[:] = lamb_emis_thresh[vec_read_month] # read lamb emis threshold for each month and each frequence
154for 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   
163print 'start mapping'
164#ion()
165x_ind, y_ind, z_ind, volume = arctic_map.arctic_map_lat50()
166x_coast = x_ind
167y_coast = y_ind
168z_coast = z_ind
169for 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
Note: See TracBrowser for help on using the repository browser.