#!/usr/bin/env python # coding: utf-8 # In[1]: import numpy as np from matplotlib import pyplot as plt import matplotlib as mpl import datetime as dt import pandas as pd mpl.rc('xtick', labelsize=14) mpl.rc('ytick', labelsize=14) mpl.rc('legend', fontsize=16) mpl.rc('axes', titlesize=16) mpl.rc('figure', titlesize=16) mpl.rc('axes', labelsize=16) mpl.rc('font', size=16) mpl.rc('legend', numpoints= 1) mpl.rc('lines', markersize= 8) get_ipython().run_line_magic('matplotlib', 'inline') # ## Mesozooplankton # REAL(wp), dimension (1:3) :: zz_rate_mesozoo_sumpeakval !uM N magnitude of mesozooplankton summer concentration peaks # REAL(wp), dimension (1:3) :: zz_rate_mesozoo_sumpeakpos ! year-day times of mesozooplankton summer concentration peaks # REAL(wp), dimension (1:3) :: zz_rate_mesozoo_sumpeakwid ! year-days widths of mesozooplankton summer concentration peaks # In[47]: #&nampismezo ! parameters for microzooplankton zz_rate_mesozoo_winterconc = 0.369 #uM N mesozooplankton background concentration zz_rate_mesozoo_summerconc = 1.0 # uM N mesozooplankton relative summer concentration zz_rate_mesozoo_sumpeakval = np.expand_dims(np.array((0.339, 0.0, 0.0)) ,0) #uM N magnitude of mesozooplankton summer concentration peaks zz_rate_mesozoo_sumpeakpos = np.expand_dims(np.array((217.000, 120.000, 300.000)),0) # year-day times of mesozooplankton summer concentration peaks zz_rate_mesozoo_sumpeakwid = np.expand_dims(np.array((114.0, 51.600, 40.000)),0) # year-days widths of mesozooplankton summer concentration peaks,0) #zz_rate_mesozoo_winterconc3 = 0.39 #uM N mesozooplankton background concentration #zz_rate_mesozoo_summerconc3 = 1.0 # uM N mesozooplankton relative summer concentration #zz_rate_mesozoo_sumpeakval3 = np.expand_dims(np.array((0.42, 0.0, 0.0)) ,0) #uM N magnitude of mesozooplankton summer concentration peaks #zz_rate_mesozoo_sumpeakpos3 = np.expand_dims(np.array((217.000, 120.000, 300.000)),0) # year-day times of mesozooplankton summer concentration peaks #zz_rate_mesozoo_sumpeakwid3 = np.expand_dims(np.array((100.0, 155.00, 218.000)),0) # year-days widths of mesozooplankton summer concentration peaks,0) #zz_rate_mesozoo_summerconc2 = 1.0 # uM N mesozooplankton relative summer concentration #zz_rate_mesozoo_winterconc2 = 0.41 #uM N mesozooplankton background concentration #zz_rate_mesozoo_sumpeakval2 = np.expand_dims(np.array((0.14, 0.18, .22)) ,0) #uM N magnitude of mesozooplankton summer concentration peaks ##zz_rate_mesozoo_sumpeakwid2 = np.expand_dims(np.array((50.0, 65.00, 80.00)),0) # year-days widths of mesozooplankton summer concentration peaks,0) #zz_rate_mesozoo_sumpeakwid2 = np.expand_dims(np.array((281.0, 155.00, 218.00)),0) # year-days widths of mesozooplankton summer concentration peaks,0) #zz_rate_mesozoo_sumpeakpos2 = np.expand_dims(np.array((281.000, 155.000, 218.00)),0) # year-day times of mesozooplankton summer concentration peaks zz_rate_mesozoo_summerconc2 = 1.0 # uM N mesozooplankton relative summer concentration zz_rate_mesozoo_winterconc2 = 0.3 #uM N mesozooplankton background concentration zz_rate_mesozoo_sumpeakval2 = np.expand_dims(np.array((0.60, 0.63, .42)) ,0) #uM N magnitude of mesozooplankton summer concentration peaks #zz_rate_mesozoo_sumpeakwid2 = np.expand_dims(np.array((50.0, 65.00, 80.00)),0) # year-days widths of mesozooplankton summer concentration peaks,0) zz_rate_mesozoo_sumpeakwid2 = np.expand_dims(np.array((40.0, 70.00, 43.00)),0) # year-days widths of mesozooplankton summer concentration peaks,0) zz_rate_mesozoo_sumpeakpos2 = np.expand_dims(np.array((130.000, 206.000, 290.00)),0) # year-day times of mesozooplankton summer concentration peaks zz_rate_mesozoo_summerconc4 = 1.0 # uM N mesozooplankton relative summer concentration zz_rate_mesozoo_winterconc4 = 0.41 #uM N mesozooplankton background concentration zz_rate_mesozoo_sumpeakval4 = np.expand_dims(np.array((0.18, 0.26, .22)) ,0) #uM N magnitude of mesozooplankton summer concentration peaks zz_rate_mesozoo_sumpeakwid4 = np.expand_dims(np.array((40.0, 65.00, 80.00)),0) # year-days widths of mesozooplankton summer concentration peaks,0) zz_rate_mesozoo_sumpeakpos4 = np.expand_dims(np.array((300.000, 185.000, 230.00)),0) # year-day times of mesozooplankton summer concentration peaks zz_rate_mesozoo_summerconc5 = 1.0 # uM N mesozooplankton relative summer concentration zz_rate_mesozoo_winterconc5 = 0.42 #uM N mesozooplankton background concentration zz_rate_mesozoo_sumpeakval5 = np.expand_dims(np.array((0.3, .4, 0.22)) ,0) #uM N magnitude of mesozooplankton summer concentration peaks zz_rate_mesozoo_sumpeakwid5 = np.expand_dims(np.array((55.00, 74.00, 38.0)),0) # year-days widths of mesozooplankton summer concentration peaks,0) zz_rate_mesozoo_sumpeakpos5 = np.expand_dims(np.array((160.000, 230.00, 300.000)),0) # year-day times of mesozooplankton summer concentration peaks zz_rate_mesozoo_summerconc6 = 1.0 # uM N mesozooplankton relative summer concentration zz_rate_mesozoo_winterconc6 = 0.42 #uM N mesozooplankton background concentration zz_rate_mesozoo_sumpeakval6 = np.expand_dims(np.array((0.42, .56, 0.31)) ,0) #uM N magnitude of mesozooplankton summer concentration peaks zz_rate_mesozoo_sumpeakwid6 = np.expand_dims(np.array((50.00, 66.00, 38.0)),0) # year-days widths of mesozooplankton summer concentration peaks,0) zz_rate_mesozoo_sumpeakpos6 = np.expand_dims(np.array((160.000, 230.00, 298.000)),0) # year-day times of mesozooplankton summer concentration peaks zz_rate_mesozoo_summerconc7 = 1.0 # uM N mesozooplankton relative summer concentration zz_rate_mesozoo_winterconc7 = 0.38 #uM N mesozooplankton background concentration zz_rate_mesozoo_sumpeakval7 = np.expand_dims(np.array((0.55, .56, 0.36)) ,0) #uM N magnitude of mesozooplankton summer concentration peaks zz_rate_mesozoo_sumpeakwid7 = np.expand_dims(np.array((40.00, 67.00, 43.0)),0) # year-days widths of mesozooplankton summer concentration peaks,0) zz_rate_mesozoo_sumpeakpos7 = np.expand_dims(np.array((130.000, 206.00, 290.000)),0) # year-day times of mesozooplankton summer concentration peaks zz_rate_mesozoo_summerconc8 = 1.0 # uM N mesozooplankton relative summer concentration zz_rate_mesozoo_winterconc8 = 0.41 #uM N mesozooplankton background concentration zz_rate_mesozoo_sumpeakval8 = np.expand_dims(np.array((0.53, .57, 0.35)) ,0) #uM N magnitude of mesozooplankton summer concentration peaks zz_rate_mesozoo_sumpeakwid8 = np.expand_dims(np.array((40.00, 65.00, 44.0)),0) # year-days widths of mesozooplankton summer concentration peaks,0) zz_rate_mesozoo_sumpeakpos8 = np.expand_dims(np.array((135.000, 208.00, 296.000)),0) # year-day times of mesozooplankton summer concentration peaks zz_rate_mesozoo_summerconc3 = 1.0 # uM N mesozooplankton relative summer concentration zz_rate_mesozoo_winterconc3 = 0.38 #uM N mesozooplankton background concentration zz_rate_mesozoo_sumpeakval3 = np.expand_dims(np.array((0.55, .55, 0.36)) ,0) #uM N magnitude of mesozooplankton summer concentration peaks zz_rate_mesozoo_sumpeakwid3 = np.expand_dims(np.array((40.00, 70.00, 43.0)),0) # year-days widths of mesozooplankton summer concentration peaks,0) zz_rate_mesozoo_sumpeakpos3 = np.expand_dims(np.array((130.000, 206.00, 290.000)),0) # year-day times of mesozooplankton summer concentration peaks # In[48]: zz_day=np.arange(1,366) # in model, nday_year starts at 1 on jan 1 dts=[dt.datetime(2014,12,31)+dt.timedelta(days=float(ii)) for ii in zz_day] zz_day=np.expand_dims(zz_day,1) zz_MesZoBar = zz_rate_mesozoo_winterconc + \ zz_rate_mesozoo_summerconc*(np.sum ( zz_rate_mesozoo_sumpeakval * \ np.exp(-(zz_day-zz_rate_mesozoo_sumpeakpos)**2/zz_rate_mesozoo_sumpeakwid**2),1) \ + np.sum ( zz_rate_mesozoo_sumpeakval * \ np.exp( -(zz_day-zz_rate_mesozoo_sumpeakpos-365.25)**2/zz_rate_mesozoo_sumpeakwid**2),1) \ + np.sum ( zz_rate_mesozoo_sumpeakval * \ np.exp( -(zz_day-zz_rate_mesozoo_sumpeakpos+365.25)**2/zz_rate_mesozoo_sumpeakwid**2),1) ) zz_MesZoBar2 = zz_rate_mesozoo_winterconc2 + \ zz_rate_mesozoo_summerconc2*(np.sum ( zz_rate_mesozoo_sumpeakval2 * \ np.exp(-(zz_day-zz_rate_mesozoo_sumpeakpos2)**2/zz_rate_mesozoo_sumpeakwid2**2),1) \ + np.sum ( zz_rate_mesozoo_sumpeakval2 * \ np.exp( -(zz_day-zz_rate_mesozoo_sumpeakpos2-365.25)**2/zz_rate_mesozoo_sumpeakwid2**2),1) \ + np.sum ( zz_rate_mesozoo_sumpeakval2 * \ np.exp( -(zz_day-zz_rate_mesozoo_sumpeakpos2+365.25)**2/zz_rate_mesozoo_sumpeakwid2**2),1) ) zz_MesZoBar4 = zz_rate_mesozoo_winterconc4 + \ zz_rate_mesozoo_summerconc4*(np.sum ( zz_rate_mesozoo_sumpeakval4 * \ np.exp(-(zz_day-zz_rate_mesozoo_sumpeakpos4)**2/zz_rate_mesozoo_sumpeakwid4**2),1) \ + np.sum ( zz_rate_mesozoo_sumpeakval4 * \ np.exp( -(zz_day-zz_rate_mesozoo_sumpeakpos4-365.25)**2/zz_rate_mesozoo_sumpeakwid4**2),1) \ + np.sum ( zz_rate_mesozoo_sumpeakval4 * \ np.exp( -(zz_day-zz_rate_mesozoo_sumpeakpos4+365.25)**2/zz_rate_mesozoo_sumpeakwid4**2),1) ) zz_MesZoBar5 = zz_rate_mesozoo_winterconc5 + \ zz_rate_mesozoo_summerconc5*(np.sum ( zz_rate_mesozoo_sumpeakval5 * \ np.exp(-(zz_day-zz_rate_mesozoo_sumpeakpos5)**2/zz_rate_mesozoo_sumpeakwid5**2),1) \ + np.sum ( zz_rate_mesozoo_sumpeakval5 * \ np.exp( -(zz_day-zz_rate_mesozoo_sumpeakpos5-365.25)**2/zz_rate_mesozoo_sumpeakwid5**2),1) \ + np.sum ( zz_rate_mesozoo_sumpeakval5 * \ np.exp( -(zz_day-zz_rate_mesozoo_sumpeakpos5+365.25)**2/zz_rate_mesozoo_sumpeakwid5**2),1) ) zz_MesZoBar6 = zz_rate_mesozoo_winterconc6 + \ zz_rate_mesozoo_summerconc6*(np.sum ( zz_rate_mesozoo_sumpeakval6 * \ np.exp(-(zz_day-zz_rate_mesozoo_sumpeakpos6)**2/zz_rate_mesozoo_sumpeakwid6**2),1) \ + np.sum ( zz_rate_mesozoo_sumpeakval6 * \ np.exp( -(zz_day-zz_rate_mesozoo_sumpeakpos6-365.25)**2/zz_rate_mesozoo_sumpeakwid6**2),1) \ + np.sum ( zz_rate_mesozoo_sumpeakval6 * \ np.exp( -(zz_day-zz_rate_mesozoo_sumpeakpos6+365.25)**2/zz_rate_mesozoo_sumpeakwid6**2),1) ) zz_MesZoBar7 = zz_rate_mesozoo_winterconc7 + \ zz_rate_mesozoo_summerconc7*(np.sum ( zz_rate_mesozoo_sumpeakval7 * \ np.exp(-(zz_day-zz_rate_mesozoo_sumpeakpos7)**2/zz_rate_mesozoo_sumpeakwid7**2),1) \ + np.sum ( zz_rate_mesozoo_sumpeakval7 * \ np.exp( -(zz_day-zz_rate_mesozoo_sumpeakpos7-365.25)**2/zz_rate_mesozoo_sumpeakwid7**2),1) \ + np.sum ( zz_rate_mesozoo_sumpeakval7 * \ np.exp( -(zz_day-zz_rate_mesozoo_sumpeakpos7+365.25)**2/zz_rate_mesozoo_sumpeakwid7**2),1) ) zz_MesZoBar8 = zz_rate_mesozoo_winterconc8 + \ zz_rate_mesozoo_summerconc8*(np.sum ( zz_rate_mesozoo_sumpeakval8 * \ np.exp(-(zz_day-zz_rate_mesozoo_sumpeakpos8)**2/zz_rate_mesozoo_sumpeakwid8**2),1) \ + np.sum ( zz_rate_mesozoo_sumpeakval8 * \ np.exp( -(zz_day-zz_rate_mesozoo_sumpeakpos8-365.25)**2/zz_rate_mesozoo_sumpeakwid8**2),1) \ + np.sum ( zz_rate_mesozoo_sumpeakval8 * \ np.exp( -(zz_day-zz_rate_mesozoo_sumpeakpos8+365.25)**2/zz_rate_mesozoo_sumpeakwid8**2),1) ) zz_MesZoBar3 = zz_rate_mesozoo_winterconc3 + \ zz_rate_mesozoo_summerconc3*(np.sum ( zz_rate_mesozoo_sumpeakval3 * \ np.exp(-(zz_day-zz_rate_mesozoo_sumpeakpos3)**2/zz_rate_mesozoo_sumpeakwid3**2),1) \ + np.sum ( zz_rate_mesozoo_sumpeakval3 * \ np.exp( -(zz_day-zz_rate_mesozoo_sumpeakpos3-365.25)**2/zz_rate_mesozoo_sumpeakwid3**2),1) \ + np.sum ( zz_rate_mesozoo_sumpeakval3 * \ np.exp( -(zz_day-zz_rate_mesozoo_sumpeakpos3+365.25)**2/zz_rate_mesozoo_sumpeakwid3**2),1) ) # In[50]: fig,ax=plt.subplots(1,1,figsize=(20,6)) ax.plot(dts,zz_MesZoBar8,'b-') #ax.plot(dts,zz_MesZoBar2,'r-') ax.plot(dts,zz_MesZoBar3,'c--') ax.plot([ii+dt.timedelta(days=365) for ii in dts],zz_MesZoBar3,'c--') ax.plot(dts,zz_MesZoBar2,'g--') ax.plot([ii+dt.timedelta(days=365) for ii in dts],zz_MesZoBar2,'g--') #ax.plot(dts,zz_MesZoBar4,'r--') ax.plot(dts,zz_MesZoBar5,'k--') ax.plot(dts,zz_MesZoBar6,'y--') ax.plot(dts,zz_MesZoBar7,'--',color='blueviolet') ax.set_ylim(0,1.3) ax.set_title('Mesozo') # In[ ]: # In[5]: df=pd.read_excel('/ocean/eolson/MEOPAR/obs/MackasZoop/1-s2.0-S007966111300061X-mmc2.xls',skiprows=1) df=df.dropna(0,how='any', subset=['Year','Month','Day']).dropna(1,how='any',thresh=200) # In[6]: df.keys() # In[7]: yd=[(dt.datetime(int(r.Year),int(r.Month),int(r.Day))-dt.datetime(int(r.Year)-1,12,31)).days for i,r in df.iterrows()] # In[8]: df=df.assign(yd=yd).sort_values(by='yd') # In[9]: dtsdf=[dt.datetime(2014,12,31)+dt.timedelta(days=int(ii)) for ii in df['yd'].values] # In[10]: fig,ax=plt.subplots(1,1,figsize=(18,6)) ax.plot(df['yd'],df['Total Biomass'],'k-') ax.plot(np.convolve(df['yd'], np.ones((30,))/30, mode='valid'),np.convolve(df['Total Biomass'].values, np.ones((30,))/30, mode='valid'),'k--') ax.plot(zz_day,zz_MesZoBar3*25,'--',color='blueviolet') #&nampismezo ! parameters for microzooplankton zz_rate_mesozoo_winterconc2 = 0.41 #uM N mesozooplankton background concentration zz_rate_mesozoo_sumpeakval2 = np.expand_dims(np.array((0.14, 0.18, .22)) ,0) #uM N magnitude of mesozooplankton summer concentration peaks zz_rate_mesozoo_sumpeakwid2 = np.expand_dims(np.array((50.0, 65.00, 80.00)),0) # year-days widths of mesozooplankton summer concentration peaks,0) zz_rate_mesozoo_sumpeakpos2 = np.expand_dims(np.array((281.000, 155.000, 218.00)),0) # year-day times of mesozooplankton summer concentration peaks zz_day=np.arange(1,367) # in model, nday_year starts at 1 on jan 1 dts=[dt.datetime(2014,12,31)+dt.timedelta(days=float(ii)) for ii in zz_day] zz_day=np.expand_dims(zz_day,1) zz_MesZoBar3 = zz_rate_mesozoo_winterconc2 + \ zz_rate_mesozoo_summerconc2*(np.sum ( zz_rate_mesozoo_sumpeakval2 * \ np.exp(-(zz_day-zz_rate_mesozoo_sumpeakpos2)**2/zz_rate_mesozoo_sumpeakwid2**2),1) \ + np.sum ( zz_rate_mesozoo_sumpeakval2 * \ np.exp( -(zz_day-zz_rate_mesozoo_sumpeakpos2-365.25)**2/zz_rate_mesozoo_sumpeakwid2**2),1) \ + np.sum ( zz_rate_mesozoo_sumpeakval2 * \ np.exp( -(zz_day-zz_rate_mesozoo_sumpeakpos2+365.25)**2/zz_rate_mesozoo_sumpeakwid2**2),1) ) # In[11]: fig,ax=plt.subplots(1,1,figsize=(18,6)) #ax.plot(df['yd'],df['Total Biomass'],'k-') ii=30 ax.plot(np.convolve(df['yd'], np.ones((ii,))/ii, mode='valid'),np.convolve(df['Total Biomass'].values, np.ones((ii,))/ii, mode='valid'),'k--') ax.plot(zz_day,zz_MesZoBar3*21,'c--') # In[12]: fig,ax=plt.subplots(1,1,figsize=(18,6)) ax.plot(df['yd'],df['Total Copepods'],'k-') ii=30 ax.plot(np.convolve(df['yd'], np.ones((ii,))/ii, mode='valid'),np.convolve(df['Total Copepods'].values, np.ones((ii,))/ii, mode='valid'),'k--') # In[13]: fig,ax=plt.subplots(1,1,figsize=(18,6)) #ax.plot(df['yd'],df['Total Copepods'],'k-') ii=30 tdf=df.dropna(axis=0,subset=['Calanoids<1mm']) ax.plot(np.convolve(tdf['yd'], np.ones((ii,))/ii, mode='valid'),np.convolve(tdf['Total Biomass'].values-tdf['Calanoids<1mm'].values, np.ones((ii,))/ii, mode='valid'),'k--') ax.plot(zz_day,zz_MesZoBar8*23,'c--') # In[ ]: # In[ ]: # In[ ]: # In[ ]: # In[ ]: # In[ ]: # In[ ]: