Commit b903d9e8 authored by Paul Nicot's avatar Paul Nicot

ajout de la trace depuis de la saison

parent bc4df3fa
#!/usr/bin/env python
#! python
# -*- coding: utf-8 -*-
from mpl_toolkits.basemap import Basemap
from time import gmtime, strftime
......@@ -11,7 +11,9 @@ import pandas as pd
from mpl_toolkits.axes_grid1 import make_axes_locatable
# parametres modifiables --------------------------
snake = 24 # nombre d'heure de suivi du serpent
snake = 48 # nombre d'heure de suivi du serpent
start = 20150611 # date de debut de suivi de la saison
# ================================================
sday = 84600
......@@ -26,7 +28,7 @@ lab4 = int(snake*0.25)
lab5 = 0
# Base de donnees ----------------------------
df = pd.read_csv('/home/nicopa01/data/spot/spots_pos.csv',delimiter=';')
df = pd.read_csv('/home/nicopa01/data/spot/spots_pos_flag_clean.csv',delimiter=';')
df = df.drop_duplicates(take_last=True)
timestamp = int(time.time())
......@@ -36,13 +38,18 @@ diff = timestamp - dt
strtime = datetime.datetime.fromtimestamp(int(timestamp)).strftime('%Y-%m-%d %H:%M')
nametime = datetime.datetime.fromtimestamp(int(timestamp)).strftime('%Y%m%d%H%M')
# date de début de suivi
sT = str(start)
starT = int(time.mktime(datetime.datetime.strptime(sT, "%Y%m%d").timetuple()))
# Golfe du Saint-Laurent ---------------------------
# traces des x derniers jours dans l'estuaire
GSL = df[(df.FLAG == "OCN") & (df.TIME <= timestamp)
& (df.TIME > timestamp - shour*snake)]
plt.clf()
GSL_start = df.loc[(df.FLAG == "OCN") & (df.TIME <= timestamp)
& (df.TIME > starT)]
fig, ax = plt.subplots()
# caracteristiques de la carte
......@@ -59,14 +66,20 @@ m.drawcoastlines(linewidth=0.7)
m.drawparallels(np.arange(40,60,2),labels=[1,0,0,0],linewidth=0.0)
m.drawmeridians(np.arange(-80,-40,2),labels=[0,0,0,1],linewidth=0.0)
# trace depuis le début de l'ete
for spot, group in GSL_start.groupby(['SPOT']):
lat = group.LAT.values
lon = group.LON.values
x,y = m(lon, lat)
plt.plot(x,y,color='0.35',linewidth=0.7)
# trace les chemins de bouees
for spot, group in GSL.groupby(['SPOT']):
latitude = group.LAT.values
longitude = group.LON.values
t = (group.TIME.values - dt) / diff
t = (group.TIME.values - float(dt)) / diff
x,y = m(longitude, latitude)
cax = plt.scatter(x,y,c=t, s=35, cmap=cmap,linewidth=0,vmin=0, vmax=1)
plt.plot(x,y,'k-',linewidth=0.5)
# colorbar
cbar = fig.colorbar(cax,fraction=0.03, pad=0.03)
......@@ -79,20 +92,20 @@ cbar.set_label('heures', rotation=270,labelpad=15)
plt.annotate(strtime + ' HAE', xy=(1, 1), xycoords='data', size=20,
xytext=(0.6, 0.87), textcoords='axes fraction',
horizontalalignment='right', verticalalignment='top')
plt.title("Derive de surface (" + str(snake) + " dernieres heures)")
plt.title(u"Dérive de surface (" + str(snake) + u" dernières heures)")
#enregistrement
plt.savefig('/home/nicopa01/data/spot/suivi/GSL/GSL_' + nametime + '.png',dpi=300)
plt.savefig('/home/nicopa01/data/spot/suivi/GSL/GSL_' + nametime + '.jpg',dpi=300)
plt.close()
# Estuaire du Saint-Laurent ---------------------------
# traces des x derniers jours dans l'estuaire
SLE = df[(df.SPOT > 1) & (df.SPOT < 300) & (df.FLAG == "OCN")
& (df.TIME <= timestamp) & (df.TIME > timestamp - shour*snake)]
SLE = df[(df.FLAG == "OCN")
& (df.TIME <= timestamp) & (df.TIME > timestamp - shour*snake)]
SLE_start = df.loc[(df.FLAG == "OCN") & (df.TIME <= timestamp)
& (df.TIME > starT)]
plt.clf()
fig, ax = plt.subplots()
# caracteristiques de la carte
......@@ -109,14 +122,20 @@ m.drawcoastlines(linewidth=0.7)
m.drawparallels(np.arange(40,60,0.5),labels=[1,0,0,0],linewidth=0.0)
m.drawmeridians(np.arange(-80,-40,1),labels=[0,0,0,1],linewidth=0.0)
# trace depuis le début de l'ete
for spot, group in SLE_start.groupby(['SPOT']):
lat = group.LAT.values
lon = group.LON.values
x,y = m(lon, lat)
plt.plot(x,y,color='0.35',linewidth=0.7)
# trace les chemins de bouees
for spot, group in SLE.groupby(['SPOT']):
latitude = group.LAT.values
longitude = group.LON.values
t = (group.TIME.values - dt) / diff
t = (group.TIME.values - float(dt)) / diff
x,y = m(longitude, latitude)
cax = plt.scatter(x,y,c=t, s=45, cmap=cmap,linewidth=0,vmin=0, vmax=1)
plt.plot(x,y,'k-',linewidth=0.5)
# colorbar
cbar = fig.colorbar(cax,fraction=0.03, pad=0.03)
......@@ -129,18 +148,25 @@ cbar.set_label('heures', rotation=270,labelpad=15)
plt.annotate(strtime + ' HAE', xy=(1, 1), xycoords='data', size=20,
xytext=(0.9, 0.1), textcoords='axes fraction',
horizontalalignment='right', verticalalignment='top')
plt.title("Derive de surface (" + str(snake) + " dernieres heures)")
plt.title(u"Dérive de surface (" + str(snake) + u" dernières heures)")
#enregistrement
plt.savefig('/home/nicopa01/data/spot/suivi/SLE/SLE_' + nametime + '.png',dpi=300)
plt.savefig('/home/nicopa01/data/spot/suivi/SLE/SLE_' + nametime + '.jpg',dpi=300)
plt.close()
# Baie des chaleurs ---------------------------
# traces des x derniers jours dans la baie
BDC = df[(df.SPOT > 699) & (df.FLAG == "OCN")
& (df.TIME <= timestamp) & (df.TIME > timestamp - shour*snake)]
plt.clf()
bdc = df.loc[(df.SPOT == 24) | (df.SPOT == 23) | (df.SPOT == 52) |
(df.SPOT == 53) | (df.SPOT >= 700) & (df.SPOT < 899)]
# Baie des chaleurs ---------------------------
# traces des x derniers jours dans la baie
BDC = bdc.loc[(df.FLAG == "OCN") & (df.TIME <= timestamp)
& (df.TIME > timestamp - shour*snake)]
BDC_start = bdc.loc[(df.FLAG == "OCN") & (df.TIME <= timestamp) & (df.TIME > starT)]
fig, ax = plt.subplots()
# caracteristiques de la carte
......@@ -157,14 +183,20 @@ m.drawcoastlines(linewidth=0.7)
m.drawparallels(np.arange(40,60,0.5),labels=[1,0,0,0],linewidth=0.0)
m.drawmeridians(np.arange(-80,-40,1),labels=[0,0,0,1],linewidth=0.0)
# trace depuis le début de l'ete
for spot, group in BDC_start.groupby(['SPOT']):
lat = group.LAT.values
lon = group.LON.values
x,y = m(lon, lat)
plt.plot(x,y,color='0.35',linewidth=0.7)
# trace les chemins de bouees
for spot, group in BDC.groupby(['SPOT']):
latitude = group.LAT.values
longitude = group.LON.values
t = (group.TIME.values - dt) / diff
t = (group.TIME.values - float(dt)) / diff
x,y = m(longitude, latitude)
cax = plt.scatter(x,y,c=t, s=45, cmap=cmap,linewidth=0,vmin=0, vmax=1)
plt.plot(x,y,'k-',linewidth=0.5)
# colorbar
cbar = fig.colorbar(cax,fraction=0.03, pad=0.03)
......@@ -178,7 +210,7 @@ plt.annotate(strtime + ' HAE', xy=(1, 1), xycoords='data', size=20,
xytext=(0.6, 0.1), textcoords='axes fraction',
horizontalalignment='right', verticalalignment='top')
plt.title("Derive de surface (" + str(snake) + " dernieres heures)")
plt.title(u"Dérive de surface (" + str(snake) + u" dernières heures)")
#enregistrement
plt.savefig('/home/nicopa01/data/spot/suivi/BDC/BDC_' + nametime + '.png',dpi=300)
plt.savefig('/home/nicopa01/data/spot/suivi/BDC/BDC_' + nametime + '.jpg',dpi=300)
plt.close()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment