Commit c0cb8ae6 authored by Paul Nicot's avatar Paul Nicot

ajout de la carte du golfe + ajustement

parent 509db604
......@@ -5,82 +5,93 @@ from mpl_toolkits.basemap import Basemap
from time import gmtime, strftime
import matplotlib.pyplot as plt
import time
import datetime
import numpy as np
import pandas as pd
from mpl_toolkits.axes_grid1 import make_axes_locatable
strtime = strftime("%Y-%m-%d %H:%M", gmtime())
nametime = strftime("%Y%m%d%H%M", gmtime())
# temps unix
timestamp = int(time.time())
# sec dans une journee
sday = 60 * 60 * 24
# intervalle de temps
dd = 5 # nombre de jours
dt = timestamp - 5*sday # intervalle de temps depuis dd jours
diff = timestamp - dt #
# parametres modifiables --------------------------
snake = 24 # nombre d'heure de suivi du serpent
# ================================================
sday = 84600
shour = 3600
# colormap
cmap=plt.get_cmap('OrRd')
lab1 = int(snake)
lab2 = int(snake*0.75)
lab3 = int(snake*0.5)
lab4 = int(snake*0.25)
lab5 = 0
# Base de donnees ----------------------------
df = pd.read_csv('/home/nicopa01/data/spot/spots_pos.csv',delimiter=';')
df = df.drop_duplicates(take_last=True)
timestamp = int(time.time())
dt = timestamp - shour * snake
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')
# 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)]
# Baie des Chaleurs ---------------------------
# traces des x derniers jours dans la baie
BDC = df[(df.SPOT > 699) & (df.SPOT < 800) & (df.FLAG == "OCN")
& (df.TIME > dt)]
plt.clf()
fig, ax = plt.subplots()
# caracteristiques de la carte
m = Basemap(projection='stere',lon_0=-68.5,lat_0=48,\
llcrnrlat=47.5,urcrnrlat=48.7,\
llcrnrlon=-66.9,urcrnrlon=-64.2,\
m = Basemap(projection='stere',lon_0=-64.5,lat_0=48,\
llcrnrlat=45.2,urcrnrlat=51.6,\
llcrnrlon=-70,urcrnrlon=-56.5,\
rsphere=6371.2,resolution='h')
m.drawmapboundary(fill_color='lightblue') # fill to edge
m.drawcountries()
m.fillcontinents(color='grey',lake_color='lightblue',zorder=0)
m.drawrivers()
m.drawcoastlines(linewidth=0.8)
m.drawparallels(np.arange(40,60,0.5),labels=[1,0,0,0])
m.drawmeridians(np.arange(-80,-40,1),labels=[0,0,0,1])
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 les chemins de bouees
for spot, group in BDC.groupby(['SPOT']):
for spot, group in GSL.groupby(['SPOT']):
latitude = group.LAT.values
longitude = group.LON.values
t = (group.TIME.values - dt) / diff
x,y = m(longitude, latitude)
cax = plt.scatter(x,y,c=t, s=45, cmap=cmap,linewidth=0,vmin=0, vmax=1)
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)
cbar.set_ticks([0,0.2,0.4,0.6,0.8,1])
cbar.set_ticks([0,0.25,0.5,0.75,1])
cbar.update_ticks()
cbar.ax.set_yticklabels(['5','4','3','2','1','0'])
cbar.set_label('jours', rotation=270)
cbar.ax.set_yticklabels([lab1,lab2,lab3,lab4,lab5])
cbar.set_label('heures', rotation=270,labelpad=15)
# legende
plt.annotate(strtime + ' UTC', xy=(1, 1), xycoords='data', size=20,
xytext=(0.55, 0.1), textcoords='axes fraction',
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(str(dd) + " derniers jours de derive de surface (BDC)")
# enregistrement
plt.savefig('/home/nicopa01/data/spot/suivi/BDC/BDC' + str(dd) + '_' + nametime + '.png',dpi=300)
plt.title("Derive de surface (" + str(snake) + " dernieres heures)")
#enregistrement
plt.savefig('/home/nicopa01/data/spot/suivi/GSL/GSL_' + nametime + '.png',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 > dt) | (df.SPOT > 899) & (df.FLAG == "OCN")
& (df.TIME > dt)]
& (df.TIME <= timestamp) & (df.TIME > timestamp - shour*snake)]
plt.clf()
fig, ax = plt.subplots()
......@@ -95,9 +106,9 @@ m.drawmapboundary(fill_color='lightblue') # fill to edge
m.drawcountries()
m.fillcontinents(color='grey',lake_color='lightblue',zorder=0)
m.drawrivers()
m.drawcoastlines(linewidth=0.8)
m.drawparallels(np.arange(40,60,0.5),labels=[1,0,0,0])
m.drawmeridians(np.arange(-80,-40,1),labels=[0,0,0,1])
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 les chemins de bouees
for spot, group in SLE.groupby(['SPOT']):
......@@ -107,64 +118,68 @@ for spot, group in SLE.groupby(['SPOT']):
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)
cbar.set_ticks([0,0.2,0.4,0.6,0.8,1])
cbar.set_ticks([0,0.25,0.5,0.75,1])
cbar.update_ticks()
cbar.ax.set_yticklabels(['5','4','3','2','1','0'])
cbar.set_label('jours', rotation=270)
cbar.ax.set_yticklabels([lab1,lab2,lab3,lab4,lab5])
cbar.set_label('heures', rotation=270,labelpad=15)
# legende
plt.annotate(strtime + ' UTC', xy=(1, 1), xycoords='data', size=20,
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(str(dd) + " derniers jours de derive de surface (SLE)")
plt.title("Derive de surface (" + str(snake) + " dernieres heures)")
#enregistrement
plt.savefig('/home/nicopa01/data/spot/suivi/SLE/SLE' + str(dd) + '_' + nametime + '.png',dpi=300)
# Old Harry ---------------------------
# traces des x derniers jours autour de Old Harry
OHA = df[(df.FLAG == "OCN") & (df.TIME > dt)]
plt.savefig('/home/nicopa01/data/spot/suivi/SLE/SLE_' + nametime + '.png',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()
fig, ax = plt.subplots()
# caracteristiques de la carte
m = Basemap(projection='stere',lon_0=-60.5,lat_0=49,\
llcrnrlat=47.1,urcrnrlat=51.2,\
llcrnrlon=-62.9,urcrnrlon=-56.2,\
m = Basemap(projection='stere',lon_0=-68.5,lat_0=48,\
llcrnrlat=47.5,urcrnrlat=48.7,\
llcrnrlon=-66.9,urcrnrlon=-64.2,\
rsphere=6371.2,resolution='h')
m.drawmapboundary(fill_color='lightblue') # fill to edge
m.drawcountries()
m.fillcontinents(color='grey',lake_color='lightblue',zorder=0)
m.drawrivers()
m.drawcoastlines(linewidth=0.8)
m.drawparallels(np.arange(40,60,1),labels=[1,0,0,0])
m.drawmeridians(np.arange(-80,-40,2),labels=[0,0,0,1])
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 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
x,y = m(longitude, latitude)
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)
cbar.set_ticks([0,0.2,0.4,0.6,0.8,1])
cbar.set_ticks([0,0.25,0.5,0.75,1])
cbar.update_ticks()
cbar.ax.set_yticklabels(['5','4','3','2','1','0'])
cbar.set_label('jours', rotation=270)
cbar.ax.set_yticklabels([lab1,lab2,lab3,lab4,lab5])
cbar.set_label('heures', rotation=270,labelpad=15)
# legende
plt.annotate(strtime + ' UTC', xy=(1, 1), xycoords='data', size=20,
xytext=(0.92, 0.1), textcoords='axes fraction',
horizontalalignment='right', verticalalignment='top')
plt.title(str(dd) + " derniers jours de derive de surface (BDC)")
# enregistrement
plt.savefig('/home/nicopa01/data/spot/suivi/OHA/OHA' + str(dd) + '_' + nametime + '.png',dpi=300)
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)")
#enregistrement
plt.savefig('/home/nicopa01/data/spot/suivi/BDC/BDC_' + nametime + '.png',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