from post_gnome.plotting import geo_plots reload(geo_plots) import matplotlib.pyplot as plt import datetime plt.clf() ax = geo_plots.add_map(bbox=(-125.2, -124.2, 47.7, 48.3), bna="coast_wa.bna") # if bbox not specified, this will use map bounds from bna # add particles at one time t0 = datetime.datetime(2016, 8, 18, 12) ax = geo_plots.plot_particles(ax, "WA_particles.nc", t0, color="b") t1 = t0 + datetime.timedelta(hours=24) ax = geo_plots.plot_particles(ax, "WA_particles.nc", t1, color="g") ax.legend() # add initial location t = datetime.datetime(2016, 8, 18, 1) geo_plots.plot_particles(ax, "WA_particles.nc", t, marker="+", markersize=8) plt.show()
from post_gnome.plotting import geo_plots reload(geo_plots) import matplotlib.pyplot as plt import datetime import cartopy.crs as ccrs from cartopy.io.shapereader import Reader from cartopy.feature import ShapelyFeature import cartopy.feature as cfeature import os plt.clf() #ax = geo_plots.add_map(bbox=(-89,-85,27.5,31)) ax = geo_plots.add_map(bbox=(-90, -84, 27.5, 31)) #land_10m = cfeature.NaturalEarthFeature('physical','land','50m',\ # edgecolor='face',facecolor='0.75') ##ax.add_feature(cfeature.LAND, facecolor='0.75') #ax.add_feature(land_10m) #if bbox not specified, this will use map bounds from bna bathy_file = os.path.join('gom_bathy','Bathymetry.shp') bathy = Reader(bathy_file) for rec,geo in zip(bathy.records(),bathy.geometries()): if rec.attributes['DEPTH_METR'] in ['100m','500m','1000m']: shape_feature = ShapelyFeature(geo,ccrs.PlateCarree(), facecolor='none') ax.add_feature(shape_feature) #add particles at one time t = datetime.datetime(2016, 9, 21, 1)
from post_gnome.plotting import geo_plots reload(geo_plots) import matplotlib.pyplot as plt import datetime plt.clf() ax = geo_plots.add_map(bbox=(-125.2,-124.2,47.7,48.3), bna='coast_wa.bna') #if bbox not specified, this will use map bounds from bna #add vectors from HYCOM.nc t0 = datetime.datetime(2016,8,18,12) ax = geo_plots.add_vectors(ax,'HYCOM.nc',t0,bbox=(-125.2,-124.2,47.7,48.3)) #add particles at one time ax = geo_plots.plot_particles(ax,'WA_particles.nc',t0,color='b') t1 = t0 + datetime.timedelta(hours=24) ax = geo_plots.plot_particles(ax,'WA_particles.nc',t1,color='g') ax.legend() #add initial location t = datetime.datetime(2016,8,18,1) ax = geo_plots.plot_particles(ax,'WA_particles.nc',t,marker='+',markersize=8) plt.show()
import os from os.path import join from scipy.io import loadmat from datetime import datetime, timedelta from calendar import monthrange import numpy as np import scipy.io as sio from netCDF4 import Dataset, num2date import matplotlib.pyplot as plt from pylab import figure, cm from matplotlib.colors import LogNorm from post_gnome.plotting import geo_plots reload(geo_plots) from post_gnome import nc_particles import cartopy.crs as ccrs from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER data_path = '/DATA/forecastData/' output_test='/DATA/forecastData/Output/2019-07-19/P1/output.nc' for i in range(1,72): t0 = datetime(2019,06,11,1)+timedelta(hours=i) ax = geo_plots.add_map(bbox=(-98, -80,18.1, 30), bna=data_path+'BaseMaps/gulf.bna') geo_plots.plot_particles(ax,output_test,t0,marker='+',markersize=1) #ax = geo_plots.add_vectors(ax,data_path+'Currents/hycom_forecast_20190611.nc',t0,2000,bbox=(-98, -88,18.1, 30), lonvar='lon',latvar='lat',uvar='u',vvar='v') plt.savefig('test'+str(i)+'.png')
from post_gnome.plotting import geo_plots reload(geo_plots) import matplotlib.pyplot as plt import datetime import cartopy.crs as ccrs from cartopy.io.shapereader import Reader from cartopy.feature import ShapelyFeature import cartopy.feature as cfeature import os plt.clf() #ax = geo_plots.add_map(bbox=(-89,-85,27.5,31)) ax = geo_plots.add_map(bbox=(-90, -84, 27.5, 31)) #land_10m = cfeature.NaturalEarthFeature('physical','land','50m',\ # edgecolor='face',facecolor='0.75') ##ax.add_feature(cfeature.LAND, facecolor='0.75') #ax.add_feature(land_10m) #if bbox not specified, this will use map bounds from bna bathy_file = os.path.join('gom_bathy', 'Bathymetry.shp') bathy = Reader(bathy_file) for rec, geo in zip(bathy.records(), bathy.geometries()): if rec.attributes['DEPTH_METR'] in ['100m', '500m', '1000m']: shape_feature = ShapelyFeature(geo, ccrs.PlateCarree(), facecolor='none') ax.add_feature(shape_feature) #add particles at one time
reload(geo_plots) import matplotlib.pyplot as plt from datetime import datetime, timedelta from post_gnome import nc_particles import cartopy.crs as ccrs from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER import matplotlib.pyplot as plt from post_gnome import nc_particles from netCDF4 import Dataset, num2date import numpy as np plt.clf() lat = [18.1, 30] lon = [-98, -88] ax = geo_plots.add_map(bbox=(-98, -88,18.1, 30), bna='/DATA/forecastData/BaseMaps/gulf.bna') #if bbox not specified, this will use map bounds from bna def contour_particles(ax, filename, t, depth=0, varname=None, criteria=None, levels=[0.1, 0.4, 0.8, 1]): ''' contour all LEs at one time step ax: (matplotlib.axes object) the map on which the LEs will be plotted filename: (str) complete path filename of particle file t: (datetime obj) closest time to this will be plottted depth: (float) depth of particles to include (all if None) ''' import scipy.stats as st particles = nc_particles.Reader(filename) times = particles.times dt = [np.abs(((output_t - t).total_seconds()) / 3600) for output_t in times] tidx = dt.index(min(dt))