Commit b903d9e83a050cb4ff1c87d015a6b61dbb575d2b

Authored by Paul Nicot
1 parent bc4df3fa
Exists in master and in 2 other branches mingan, simon

ajout de la trace depuis de la saison

Showing 1 changed file with 56 additions and 24 deletions   Show diff stats
tr_snake.py
1 1 #!/usr/bin/env python
2   -#! python
  2 +# -*- coding: utf-8 -*-
3 3  
4 4 from mpl_toolkits.basemap import Basemap
5 5 from time import gmtime, strftime
... ... @@ -11,7 +11,9 @@ import pandas as pd
11 11 from mpl_toolkits.axes_grid1 import make_axes_locatable
12 12  
13 13 # parametres modifiables --------------------------
14   -snake = 24 # nombre d'heure de suivi du serpent
  14 +snake = 48 # nombre d'heure de suivi du serpent
  15 +
  16 +start = 20150611 # date de debut de suivi de la saison
15 17 # ================================================
16 18  
17 19 sday = 84600
... ... @@ -26,7 +28,7 @@ lab4 = int(snake*0.25)
26 28 lab5 = 0
27 29  
28 30 # Base de donnees ----------------------------
29   -df = pd.read_csv('/home/nicopa01/data/spot/spots_pos.csv',delimiter=';')
  31 +df = pd.read_csv('/home/nicopa01/data/spot/spots_pos_flag_clean.csv',delimiter=';')
30 32 df = df.drop_duplicates(take_last=True)
31 33  
32 34 timestamp = int(time.time())
... ... @@ -36,13 +38,18 @@ diff = timestamp - dt
36 38 strtime = datetime.datetime.fromtimestamp(int(timestamp)).strftime('%Y-%m-%d %H:%M')
37 39 nametime = datetime.datetime.fromtimestamp(int(timestamp)).strftime('%Y%m%d%H%M')
38 40  
  41 +# date de début de suivi
  42 +sT = str(start)
  43 +starT = int(time.mktime(datetime.datetime.strptime(sT, "%Y%m%d").timetuple()))
39 44  
40 45 # Golfe du Saint-Laurent ---------------------------
41 46 # traces des x derniers jours dans l'estuaire
42 47 GSL = df[(df.FLAG == "OCN") & (df.TIME <= timestamp)
43 48 & (df.TIME > timestamp - shour*snake)]
44 49  
45   -plt.clf()
  50 +GSL_start = df.loc[(df.FLAG == "OCN") & (df.TIME <= timestamp)
  51 + & (df.TIME > starT)]
  52 +
46 53 fig, ax = plt.subplots()
47 54  
48 55 # caracteristiques de la carte
... ... @@ -59,14 +66,20 @@ m.drawcoastlines(linewidth=0.7)
59 66 m.drawparallels(np.arange(40,60,2),labels=[1,0,0,0],linewidth=0.0)
60 67 m.drawmeridians(np.arange(-80,-40,2),labels=[0,0,0,1],linewidth=0.0)
61 68  
  69 +# trace depuis le début de l'ete
  70 +for spot, group in GSL_start.groupby(['SPOT']):
  71 + lat = group.LAT.values
  72 + lon = group.LON.values
  73 + x,y = m(lon, lat)
  74 + plt.plot(x,y,color='0.35',linewidth=0.7)
  75 +
62 76 # trace les chemins de bouees
63 77 for spot, group in GSL.groupby(['SPOT']):
64 78 latitude = group.LAT.values
65 79 longitude = group.LON.values
66   - t = (group.TIME.values - dt) / diff
  80 + t = (group.TIME.values - float(dt)) / diff
67 81 x,y = m(longitude, latitude)
68 82 cax = plt.scatter(x,y,c=t, s=35, cmap=cmap,linewidth=0,vmin=0, vmax=1)
69   - plt.plot(x,y,'k-',linewidth=0.5)
70 83  
71 84 # colorbar
72 85 cbar = fig.colorbar(cax,fraction=0.03, pad=0.03)
... ... @@ -79,20 +92,20 @@ cbar.set_label(&#39;heures&#39;, rotation=270,labelpad=15)
79 92 plt.annotate(strtime + ' HAE', xy=(1, 1), xycoords='data', size=20,
80 93 xytext=(0.6, 0.87), textcoords='axes fraction',
81 94 horizontalalignment='right', verticalalignment='top')
82   -plt.title("Derive de surface (" + str(snake) + " dernieres heures)")
  95 +plt.title(u"Dérive de surface (" + str(snake) + u" dernières heures)")
83 96 #enregistrement
84   -plt.savefig('/home/nicopa01/data/spot/suivi/GSL/GSL_' + nametime + '.png',dpi=300)
  97 +plt.savefig('/home/nicopa01/data/spot/suivi/GSL/GSL_' + nametime + '.jpg',dpi=300)
85 98 plt.close()
86 99  
87 100  
88   -
89   -
90 101 # Estuaire du Saint-Laurent ---------------------------
91 102 # traces des x derniers jours dans l'estuaire
92   -SLE = df[(df.SPOT > 1) & (df.SPOT < 300) & (df.FLAG == "OCN")
93   - & (df.TIME <= timestamp) & (df.TIME > timestamp - shour*snake)]
  103 +SLE = df[(df.FLAG == "OCN")
  104 + & (df.TIME <= timestamp) & (df.TIME > timestamp - shour*snake)]
  105 +
  106 +SLE_start = df.loc[(df.FLAG == "OCN") & (df.TIME <= timestamp)
  107 + & (df.TIME > starT)]
94 108  
95   -plt.clf()
96 109 fig, ax = plt.subplots()
97 110  
98 111 # caracteristiques de la carte
... ... @@ -109,14 +122,20 @@ m.drawcoastlines(linewidth=0.7)
109 122 m.drawparallels(np.arange(40,60,0.5),labels=[1,0,0,0],linewidth=0.0)
110 123 m.drawmeridians(np.arange(-80,-40,1),labels=[0,0,0,1],linewidth=0.0)
111 124  
  125 +# trace depuis le début de l'ete
  126 +for spot, group in SLE_start.groupby(['SPOT']):
  127 + lat = group.LAT.values
  128 + lon = group.LON.values
  129 + x,y = m(lon, lat)
  130 + plt.plot(x,y,color='0.35',linewidth=0.7)
  131 +
112 132 # trace les chemins de bouees
113 133 for spot, group in SLE.groupby(['SPOT']):
114 134 latitude = group.LAT.values
115 135 longitude = group.LON.values
116   - t = (group.TIME.values - dt) / diff
  136 + t = (group.TIME.values - float(dt)) / diff
117 137 x,y = m(longitude, latitude)
118 138 cax = plt.scatter(x,y,c=t, s=45, cmap=cmap,linewidth=0,vmin=0, vmax=1)
119   - plt.plot(x,y,'k-',linewidth=0.5)
120 139  
121 140 # colorbar
122 141 cbar = fig.colorbar(cax,fraction=0.03, pad=0.03)
... ... @@ -129,18 +148,25 @@ cbar.set_label(&#39;heures&#39;, rotation=270,labelpad=15)
129 148 plt.annotate(strtime + ' HAE', xy=(1, 1), xycoords='data', size=20,
130 149 xytext=(0.9, 0.1), textcoords='axes fraction',
131 150 horizontalalignment='right', verticalalignment='top')
132   -plt.title("Derive de surface (" + str(snake) + " dernieres heures)")
  151 +plt.title(u"Dérive de surface (" + str(snake) + u" dernières heures)")
133 152 #enregistrement
134   -plt.savefig('/home/nicopa01/data/spot/suivi/SLE/SLE_' + nametime + '.png',dpi=300)
  153 +plt.savefig('/home/nicopa01/data/spot/suivi/SLE/SLE_' + nametime + '.jpg',dpi=300)
135 154 plt.close()
136 155  
137 156  
138 157 # Baie des chaleurs ---------------------------
139 158 # traces des x derniers jours dans la baie
140   -BDC = df[(df.SPOT > 699) & (df.FLAG == "OCN")
141   - & (df.TIME <= timestamp) & (df.TIME > timestamp - shour*snake)]
142 159  
143   -plt.clf()
  160 +bdc = df.loc[(df.SPOT == 24) | (df.SPOT == 23) | (df.SPOT == 52) |
  161 + (df.SPOT == 53) | (df.SPOT >= 700) & (df.SPOT < 899)]
  162 +
  163 +# Baie des chaleurs ---------------------------
  164 +# traces des x derniers jours dans la baie
  165 +BDC = bdc.loc[(df.FLAG == "OCN") & (df.TIME <= timestamp)
  166 + & (df.TIME > timestamp - shour*snake)]
  167 +
  168 +BDC_start = bdc.loc[(df.FLAG == "OCN") & (df.TIME <= timestamp) & (df.TIME > starT)]
  169 +
144 170 fig, ax = plt.subplots()
145 171  
146 172 # caracteristiques de la carte
... ... @@ -157,14 +183,20 @@ m.drawcoastlines(linewidth=0.7)
157 183 m.drawparallels(np.arange(40,60,0.5),labels=[1,0,0,0],linewidth=0.0)
158 184 m.drawmeridians(np.arange(-80,-40,1),labels=[0,0,0,1],linewidth=0.0)
159 185  
  186 +# trace depuis le début de l'ete
  187 +for spot, group in BDC_start.groupby(['SPOT']):
  188 + lat = group.LAT.values
  189 + lon = group.LON.values
  190 + x,y = m(lon, lat)
  191 + plt.plot(x,y,color='0.35',linewidth=0.7)
  192 +
160 193 # trace les chemins de bouees
161 194 for spot, group in BDC.groupby(['SPOT']):
162 195 latitude = group.LAT.values
163 196 longitude = group.LON.values
164   - t = (group.TIME.values - dt) / diff
  197 + t = (group.TIME.values - float(dt)) / diff
165 198 x,y = m(longitude, latitude)
166 199 cax = plt.scatter(x,y,c=t, s=45, cmap=cmap,linewidth=0,vmin=0, vmax=1)
167   - plt.plot(x,y,'k-',linewidth=0.5)
168 200  
169 201 # colorbar
170 202 cbar = fig.colorbar(cax,fraction=0.03, pad=0.03)
... ... @@ -178,7 +210,7 @@ plt.annotate(strtime + &#39; HAE&#39;, xy=(1, 1), xycoords=&#39;data&#39;, size=20,
178 210 xytext=(0.6, 0.1), textcoords='axes fraction',
179 211 horizontalalignment='right', verticalalignment='top')
180 212  
181   -plt.title("Derive de surface (" + str(snake) + " dernieres heures)")
  213 +plt.title(u"Dérive de surface (" + str(snake) + u" dernières heures)")
182 214 #enregistrement
183   -plt.savefig('/home/nicopa01/data/spot/suivi/BDC/BDC_' + nametime + '.png',dpi=300)
  215 +plt.savefig('/home/nicopa01/data/spot/suivi/BDC/BDC_' + nametime + '.jpg',dpi=300)
184 216 plt.close()
... ...