import cmocean.cm as cm
import h5py
import matplotlib as mpl
import matplotlib.colorbar as colorbar
import matplotlib.colors as mplcolours
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import xarray as xr
%matplotlib inline
mesh = xr.open_dataset('~/MEOPAR/grid/mesh_mask201702.nc')
oil0d2000 = pd.read_csv('/data/sallen/results/MIDOSS/ParticleNoTests/SB_2000_bunkerc/resOilOutput.sro', sep='\s+', skiprows=4)
oil0d2000 = oil0d2000.drop([0], axis=0)
length =len(oil0d2000)
oil0d2000 = oil0d2000.drop([length-3, length-2, length-1, length], axis=0)
oil0d5000 = pd.read_csv('/data/sallen/results/MIDOSS/ParticleNoTests/SB_5000_bunkerc/resOilOutput.sro', sep='\s+', skiprows=4)
oil0d5000 = oil0d5000.drop([0], axis=0)
length =len(oil0d5000)
oil0d5000 = oil0d5000.drop([length-3, length-2, length-1, length], axis=0)
oil0d10k = pd.read_csv('/data/sallen/results/MIDOSS/ParticleNoTests/SB_10000_bunkerc/resOilOutput.sro', sep='\s+', skiprows=4)
oil0d10k = oil0d10k.drop([0], axis=0)
length =len(oil0d10k)
oil0d10k = oil0d10k.drop([length-3, length-2, length-1, length], axis=0)
oil0d20k = pd.read_csv('/data/sallen/results/MIDOSS/ParticleNoTests/SB_20000_bunkerc/resOilOutput.sro', sep='\s+', skiprows=4)
oil0d20k = oil0d20k.drop([0], axis=0)
length =len(oil0d20k)
oil0d20k = oil0d20k.drop([length-3, length-2, length-1, length], axis=0)
fig, ax = plt.subplots(1, 1, figsize=(15,5))
oil0d2000.Area.plot(ax=ax, label="2000");
oil0d5000.Area.plot(ax=ax, label="5000");
oil0d10k.Area.plot(ax=ax, label="10000");
oil0d20k.Area.plot(ax=ax, label="20000");
plt.grid();
plt.legend();
fig, ax = plt.subplots(1, 1, figsize=(15,5))
oil0d2000.MDissolved.plot();
oil0d2000.MEvaporated.plot();
oil0d2000.MassOil.plot();
oil0d2000.MDispersed.plot();
oil0d2000.MBio.plot()
massbeached2 = (oil0d2000.VolOilBeached*oil0d2000.Density/(1-oil0d2000.VWaterContent)
*(1-oil0d2000.MWaterContent))
massbeached2.plot(label="Beached")
plt.plot(oil0d2000.MDissolved + oil0d2000.MEvaporated + oil0d2000.MassOil
+ massbeached2 + oil0d2000.MDispersed + oil0d2000.MBio);
oil0d20k.MDissolved.plot(style='--x');
oil0d20k.MEvaporated.plot(style='--x');
oil0d20k.MassOil.plot(style='--x');
oil0d20k.MDispersed.plot(style='--x');
oil0d20k.MBio.plot(style='--x')
massbeached20 = (oil0d20k.VolOilBeached*oil0d20k.Density/(1-oil0d20k.VWaterContent)
*(1-oil0d20k.MWaterContent))
massbeached10 = (oil0d10k.VolOilBeached*oil0d10k.Density/(1-oil0d10k.VWaterContent)
*(1-oil0d10k.MWaterContent))
massbeached5 = (oil0d5000.VolOilBeached*oil0d5000.Density/(1-oil0d5000.VWaterContent)
*(1-oil0d5000.MWaterContent))
massbeached20.plot(label="Beached", style='--x')
plt.plot(oil0d20k.MDissolved + oil0d20k.MEvaporated + oil0d20k.MassOil
+ massbeached20 + oil0d20k.MDispersed + oil0d20k.MBio);
plt.legend();
plt.grid();
(oil0d2000.Density/(1-oil0d2000.VWaterContent)
*(1-oil0d2000.MWaterContent)).plot();
(oil0d20k.Density/(1-oil0d20k.VWaterContent)
*(1-oil0d20k.MWaterContent)).plot();
oil0d2000.MDispersed.plot();
oil0d5000.MDispersed.plot();
oil0d10k.MDispersed.plot();
oil0d20k.MDispersed.plot();
fig, ax = plt.subplots(1, 1, figsize=(15, 3.5))
ax.plot(oil0d2000.MDissolved + oil0d2000.MEvaporated + oil0d2000.MassOil
+ massbeached2 + oil0d2000.MDispersed + oil0d2000.MBio);
ax.plot(oil0d5000.MDissolved + oil0d5000.MEvaporated + oil0d5000.MassOil
+ massbeached5 + oil0d5000.MDispersed + oil0d5000.MBio);
ax.plot(oil0d10k.MDissolved + oil0d10k.MEvaporated + oil0d10k.MassOil
+ massbeached10 + oil0d10k.MDispersed + oil0d10k.MBio);
ax.plot(oil0d20k.MDissolved + oil0d20k.MEvaporated + oil0d20k.MassOil
+ massbeached20 + oil0d20k.MDispersed + oil0d20k.MBio);
ax.grid();
massbeached2.plot(label="Beached");
massbeached5.plot(label="Beached");
massbeached10.plot(label="Beached");
massbeached20.plot(label="Beached");
plt.grid()
(oil0d2000.MDispersed/(oil0d2000.MDispersed + oil0d2000.MassOil))[:120].plot()
(oil0d20k.MDispersed/(oil0d20k.MDispersed + oil0d20k.MassOil)).plot()
plt.grid()
oil0d2000.VolumeOil.plot(style='+-');
oil0d20k.VolumeOil.plot();
plt.legend();
plt.grid();
oil0d2000.AnalyteMass1.plot()
oil0d2000.AnalyteMass2.plot()
oil0d2000.AnalyteMass3.plot()
oil0d2000.AnalyteMass4.plot()
oil0d2000.AnalyteMass5.plot();
oil0d20k.AnalyteMass1.plot()
oil0d20k.AnalyteMass2.plot()
oil0d20k.AnalyteMass3.plot()
oil0d20k.AnalyteMass4.plot()
oil0d20k.AnalyteMass5.plot();
oil0d2000.Thickness.plot();
oil0d5000.Thickness.plot();
oil0d10k.Thickness.plot();
oil0d20k.Thickness.plot();
oilLag2000 = xr.open_dataset('/data/sallen/results/MIDOSS/ParticleNoTests/SB_2000_bunkerc/Lagrangian_SB_2000_bunkerc_SB_2000_bunkerc.nc')
oilLag5000 = xr.open_dataset('/data/sallen/results/MIDOSS/ParticleNoTests/SB_5000_bunkerc/Lagrangian_SB_5000_bunkerc_SB_5000_bunkerc.nc')
oilLag10k = xr.open_dataset('/data/sallen/results/MIDOSS/ParticleNoTests/SB_10000_bunkerc/Lagrangian_SB_10000_bunkerc_SB_10000_bunkerc.nc')
oilLag20k = xr.open_dataset('/data/sallen/results/MIDOSS/ParticleNoTests/SB_20000_bunkerc/Lagrangian_SB_20000_bunkerc_SB_20000_bunkerc.nc')
imin, imax = 200, 350
jmin, jmax = 150, 280
fig, axs = plt.subplots(4, 2, figsize=(15, 20))
it = 20
field = oilLag2000.OilWaterColumnOilVol_3D[it]
(field[:, imin:imax , jmin:jmax].sum(axis=0)).plot(ax=axs[0, 0], cmap='copper')
print (oilLag2000.OilWaterColumnOilVol_3D[it, :, imin:imax, jmin:jmax].sum(axis=0).sum(axis=0).sum(axis=0))
axs[0, 1].plot(oilLag2000.time[0:72], oilLag2000.OilWaterColumnOilVol_3D[0:72].sum(axis=1).sum(axis=1).sum(axis=1)
)
field = oilLag5000.OilWaterColumnOilVol_3D[it]
(field[:, imin:imax , jmin:jmax].sum(axis=0)).plot(ax=axs[1, 0], cmap='copper')
print (oilLag5000.OilWaterColumnOilVol_3D[it, :, imin:imax, jmin:jmax].sum(axis=0).sum(axis=0).sum(axis=0))
axs[1, 1].plot(oilLag5000.time[0:72], oilLag5000.OilWaterColumnOilVol_3D[0:72].sum(axis=1).sum(axis=1).sum(axis=1)
)
field = oilLag10k.OilWaterColumnOilVol_3D[it]
(field[:, imin:imax , jmin:jmax].sum(axis=0)).plot(ax=axs[2, 0], cmap='copper')
print (oilLag10k.OilWaterColumnOilVol_3D[it, :, imin:imax, jmin:jmax].sum(axis=0).sum(axis=0).sum(axis=0))
axs[2, 1].plot(oilLag10k.time[0:72], oilLag10k.OilWaterColumnOilVol_3D[0:72].sum(axis=1).sum(axis=1).sum(axis=1)
)
field = oilLag20k.OilWaterColumnOilVol_3D[it]
(field[:, imin:imax , jmin:jmax].sum(axis=0)).plot(ax=axs[3, 0], cmap='copper')
print (oilLag20k.OilWaterColumnOilVol_3D[it, :, imin:imax, jmin:jmax].sum(axis=0).sum(axis=0).sum(axis=0))
axs[3, 1].plot(oilLag20k.time[0:72], oilLag20k.OilWaterColumnOilVol_3D[0:72].sum(axis=1).sum(axis=1).sum(axis=1)
)
<xarray.DataArray 'OilWaterColumnOilVol_3D' ()> array(10000.2349) Coordinates: time datetime64[ns] 2018-01-15T20:30:00 <xarray.DataArray 'OilWaterColumnOilVol_3D' ()> array(10000.2287) Coordinates: time datetime64[ns] 2018-01-15T20:30:00 <xarray.DataArray 'OilWaterColumnOilVol_3D' ()> array(9998.2285) Coordinates: time datetime64[ns] 2018-01-15T20:30:00 <xarray.DataArray 'OilWaterColumnOilVol_3D' ()> array(9998.7268) Coordinates: time datetime64[ns] 2018-01-15T20:30:00
[<matplotlib.lines.Line2D at 0x7f7558db50d0>]
fig, axs = plt.subplots(2, 2, figsize=(15, 15))
imin, imax = 250, 290
jmin, jmax = 230, 270
oilLag2000.OilWaterColumnOilVol_3D[:, 39, imin:imax, jmin:jmax].sum(axis=0).plot(ax=axs[0, 0], cmap='gist_ncar');
oilLag5000.OilWaterColumnOilVol_3D[:, 39, imin:imax, jmin:jmax].sum(axis=0).plot(ax=axs[0, 1], cmap='gist_ncar');
oilLag10k.OilWaterColumnOilVol_3D[:, 39, imin:imax, jmin:jmax].sum(axis=0).plot(ax=axs[1, 0], cmap='gist_ncar');
oilLag20k.OilWaterColumnOilVol_3D[:, 39, imin:imax, jmin:jmax].sum(axis=0).plot(ax=axs[1, 1], cmap='gist_ncar');
axs[0, 1].set_title('5000');
fig, axs = plt.subplots(2, 2, figsize=(15, 15))
imin, imax = 250, 290
jmin, jmax = 230, 270
(oilLag2000.OilWaterColumnOilVol_3D[:, 39, imin:imax, jmin:jmax].sum(axis=0)-
oilLag20k.OilWaterColumnOilVol_3D[:, 39, imin:imax, jmin:jmax].sum(axis=0)).plot(ax=axs[0, 0], cmap='bwr');
(oilLag5000.OilWaterColumnOilVol_3D[:, 39, imin:imax, jmin:jmax].sum(axis=0)-
oilLag20k.OilWaterColumnOilVol_3D[:, 39, imin:imax, jmin:jmax].sum(axis=0)).plot(ax=axs[0, 1], cmap='bwr');
(oilLag10k.OilWaterColumnOilVol_3D[:, 39, imin:imax, jmin:jmax].sum(axis=0)-
oilLag20k.OilWaterColumnOilVol_3D[:, 39, imin:imax, jmin:jmax].sum(axis=0)).plot(ax=axs[1, 0], cmap='bwr');
oilLag20k.OilWaterColumnOilVol_3D[:, 39, imin:imax, jmin:jmax].sum(axis=0).plot(ax=axs[1, 1], cmap='gist_ncar');
axs[0, 1].set_title('2000');
fig, axs = plt.subplots(2, 2, figsize=(15, 15))
imin, imax = 220, 350
jmin, jmax = 150, 280
oilLag2000.OilWaterColumnOilVol_3D[:, 39, imin:imax, jmin:jmax].sum(axis=0).plot(ax=axs[0, 0], cmap='gist_ncar');
oilLag5000.OilWaterColumnOilVol_3D[:, 39, imin:imax, jmin:jmax].sum(axis=0).plot(ax=axs[0, 1], cmap='gist_ncar');
oilLag10k.OilWaterColumnOilVol_3D[:, 39, imin:imax, jmin:jmax].sum(axis=0).plot(ax=axs[1, 0], cmap='gist_ncar');
oilLag20k.OilWaterColumnOilVol_3D[:, 39, imin:imax, jmin:jmax].sum(axis=0).plot(ax=axs[1, 1], cmap='gist_ncar');
axs[0, 1].set_title('5000');
fig, axs = plt.subplots(2, 2, figsize=(15, 15))
imin, imax = 250, 350
jmin, jmax = 150, 250
oilLag2000.Beaching_Volume[imin:imax , jmin:jmax].plot(ax=axs[0,0], cmap='copper', vmax=20)
oilLag5000.Beaching_Volume[imin:imax , jmin:jmax].plot(ax=axs[0,1], cmap='copper', vmax=20)
oilLag10k.Beaching_Volume[imin:imax , jmin:jmax].plot(ax=axs[1,0], cmap='copper', vmax=20)
oilLag20k.Beaching_Volume[imin:imax , jmin:jmax].plot(ax=axs[1,1], cmap='copper', vmax=20);
fig, axs = plt.subplots(2, 2, figsize=(15, 15))
imin, imax = 250, 350
jmin, jmax = 150, 250
(oilLag2000.Beaching_Volume[imin:imax , jmin:jmax]
-oilLag20k.Beaching_Volume[imin:imax , jmin:jmax]).plot(ax=axs[0,0], cmap='bwr')
(oilLag5000.Beaching_Volume[imin:imax , jmin:jmax]-
oilLag20k.Beaching_Volume[imin:imax , jmin:jmax]).plot(ax=axs[0,1], cmap='bwr')
(oilLag10k.Beaching_Volume[imin:imax , jmin:jmax]-
oilLag20k.Beaching_Volume[imin:imax , jmin:jmax]).plot(ax=axs[1,0], cmap='bwr')
oilLag20k.Beaching_Volume[imin:imax , jmin:jmax].plot(ax=axs[1,1], cmap='copper', vmax=20);
bt = np.array(oilLag2000.Beaching_Time[imin:imax, jmin:jmax] - oilLag2000.Beaching_Time[imin:imax, jmin:jmax].min())
plt.plot(bt/1e9/3600, 'ro');
btmax = np.array(oilLag20k.Beaching_Time[imin:imax, jmin:jmax] - oilLag20k.Beaching_Time[imin:imax, jmin:jmax].min())
plt.plot(np.arange(0, 100, 0.01), btmax.flatten()/1e9/3600, 'bx');
Time to Run: