In [1]:
%run basics
%matplotlib
In [4]:
ncname = "C:/OzFlux/Sites/CUP/Processed/CumberlandPlain_2012_to_2015_L6.nc"
In [5]:
print ncname
type(ncname)
Out[5]:
In [6]:
ds=qcio.nc_read_series(ncname)
In [7]:
type(ds)
Out[7]:
In [8]:
ds.series.keys()
Out[8]:
In [37]:
dt=ds.series["DateTime"]["Data"]
Fsd,flag,attr=qcutils.GetSeriesasMA(ds,"Fsd")
Fc,flag,attr=qcutils.GetSeriesasMA(ds,"Fc")
VPD,flag,attr=qcutils.GetSeriesasMA(ds,"VPD")
Ta,flag,attr=qcutils.GetSeriesasMA(ds,"Ta")
Sws,flag,attr=qcutils.GetSeriesasMA(ds,"Sws")
Ts,flag,attr=qcutils.GetSeriesasMA(ds,"Ts")
ustar,flag,attr=qcutils.GetSeriesasMA(ds,"ustar")
In [10]:
fig = plt.figure()
ax1=plt.subplot(511)
plt.plot(dt,Fsd)
ax2=plt.subplot(512,sharex=ax1)
plt.plot(dt,VPD)
ax3=plt.subplot(513,sharex=ax1)
plt.plot(dt,Ta)
ax4=plt.subplot(514,sharex=ax1)
plt.plot(dt,Fc)
ax5=plt.subplot(515,sharex=ax1)
plt.plot(dt,Sws)
plt.show()
In [27]:
#here we have Fc day vs Fsd by VPD to see if intercept of Fsd=0 varies by VPD and season
#could do a bit more work setting the colorbar to a particular scale and labelling it
Fc_day=numpy.ma.masked_where(Fsd<10,Fc)
VPD_day=numpy.ma.masked_where(Fsd<10,VPD)
Fsd_day=numpy.ma.masked_where(Fsd<10,Fsd)
start_date = dt[0]
end_date = dt[-1]
this_date = start_date+dateutil.relativedelta.relativedelta(months=2)
while start_date<end_date:
si = qcutils.GetDateIndex(dt,str(start_date))
ei = qcutils.GetDateIndex(dt,str(this_date))
Fsd_sub=Fsd_day[si:ei+1]
Fc_sub=Fc_day[si:ei+1]
VPD_sub=VPD_day[si:ei+1]
fig=plt.figure()
plt.title(str(start_date)+" to "+str(this_date)+" by VPD")
cm=plt.cm.get_cmap('rainbow')
sc=plt.scatter(Fsd_sub,Fc_sub,c=VPD_sub,cmap=cm)
plt.xlabel("Fsd (W/m2)")
plt.xlim([0,1200])
plt.ylabel("Fc (umol/m2/s)")
plt.ylim([-20,20])
plt.colorbar(sc)
plt.show()
start_date = this_date
this_date = start_date+dateutil.relativedelta.relativedelta(months=2)
In [22]:
#here we have Fc during daytime vs VPD by Fsd to evaluate if a VPD threshold exists, and by season
Fc_day=numpy.ma.masked_where(Fsd<10,Fc)
VPD_day=numpy.ma.masked_where(Fsd<10,VPD)
Fsd_day=numpy.ma.masked_where(Fsd<10,Fsd)
start_date = dt[0]
end_date = dt[-1]
this_date = start_date+dateutil.relativedelta.relativedelta(months=2)
while start_date<end_date:
si = qcutils.GetDateIndex(dt,str(start_date))
ei = qcutils.GetDateIndex(dt,str(this_date))
Fsd_sub=Fsd_day[si:ei+1]
Fc_sub=Fc_day[si:ei+1]
VPD_sub=VPD_day[si:ei+1]
fig=plt.figure()
plt.title(str(start_date)+" to "+str(this_date)+" by Fsd")
cm=plt.cm.get_cmap('rainbow')
sc=plt.scatter(VPD_sub,Fc_sub,c=Fsd_sub,cmap=cm)
plt.xlabel("VPD (kPa)")
plt.xlim([-0.2,6])
plt.ylabel("Fc (umol m-2 s-1)")
plt.ylim([-20,20])
plt.colorbar(sc)
plt.show()
start_date = this_date
this_date = start_date+dateutil.relativedelta.relativedelta(months=2)
In [35]:
#here we have Fc during nighttime vs Ts by soil moisture, and by season
Fc_night=numpy.ma.masked_where((Fsd>1)|(ustar<0.26),Fc)
Ts_night=numpy.ma.masked_where(Fsd>1,Ts)
Sws_night=numpy.ma.masked_where(Fsd>1,Sws)
start_date = dt[0]
end_date = dt[-1]
this_date = start_date+dateutil.relativedelta.relativedelta(months=2)
while start_date<end_date:
si = qcutils.GetDateIndex(dt,str(start_date))
ei = qcutils.GetDateIndex(dt,str(this_date))
Ts_sub=Ts_night[si:ei+1]
Fc_sub=Fc_night[si:ei+1]
Sws_sub=Sws_night[si:ei+1]
fig=plt.figure()
plt.title(str(start_date)+" to "+str(this_date)+" by Sws")
cm=plt.cm.get_cmap('rainbow')
sc=plt.scatter(Ts_sub,Fc_sub,c=Sws_sub,cmap=cm)
plt.xlabel("Ts (C)")
plt.xlim([10,30])
plt.ylabel("Fc (umol m-2 s-1)")
plt.ylim([-20,20])
plt.colorbar(sc)
plt.show()
start_date = this_date
this_date = start_date+dateutil.relativedelta.relativedelta(months=2)
In [39]:
#here we have Fc during nighttime vs Ts by soil moisture, full record
#element-wise comparisons in "or" use | "and" use &
#consider defining the thresholds above in order to do sensitvity testing
#Fc_night=numpy.ma.masked_where(Fsd>1,Fc)
Fc_night=numpy.ma.masked_where((Fsd>1)|(ustar<0.26),Fc)
Ts_night=numpy.ma.masked_where(Fsd>1,Ts)
Sws_night=numpy.ma.masked_where(Fsd>1,Sws)
fig=plt.figure()
plt.title(str(start_date)+" to "+str(this_date)+" by Sws")
cm=plt.cm.get_cmap('rainbow')
sc=plt.scatter(Ts_night,Fc_night,c=Sws_night,cmap=cm)
plt.xlabel("Ts (C)")
plt.xlim([10,30])
plt.ylabel("Fc (umol m-2 s-1)")
plt.ylim([-20,20])
plt.colorbar(sc)
plt.show()
In [ ]:
def ER_LloydTaylor(T,rb,E0):
# return rb*numpy.exp(E0*(1/(c.Tref-c.T0)-1/(T-c.T0)))
return rb*numpy.exp(E0*(1/(288.13-227.13)-1/((T+273.15)-227.13)))
In [28]:
#consider using Awesome_lasslop instead of this stuff
GPP,flag,attr=qcutils.GetSeriesasMA(ds,"GPP_LT",si=si,ei=ei)
fig=plt.figure()
plt.plot(Fsd,GPP,"b.")
plt.xlabel("Fsd")
plt.ylabel("GPP(units)")
plt.show()
In [33]:
GPP,flag,attr=qcutils.GetSeriesasMA(ds,"GPP_LT",si=si,ei=ei)
VPD,flag,attr=qcutils.GetSeriesasMA(ds,"VPD",si=si,ei=ei)
fig=plt.figure()
plt.scatter(Fsd,GPP,c=VPD)
plt.xlabel("Fsd")
plt.ylabel("GPP(units)")
plt.show()
In [30]:
def GPP_Lasslop(Fsd,D,alpha,beta0,k,D0):
beta = beta0*SHD_func_Lasslop(D,k,D0)
GPP = alpha*beta*Fsd/(alpha*Fsd+beta)
return GPP
def SHD_func_Lasslop(D,k,D0):
SHD_func = numpy.ones(len(D))
idx = numpy.where(D>D0)[0]
SHD_func[idx] = numpy.exp(-k*(D[idx]-D0))
return SHD_func
In [ ]: