tests/testthat/test_LightResponseCurveFitter.R

#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#+++ Unit tests for fConvertTimeToPosix functions +++
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Author: TW
#require(testthat)
context("LightResponseCurveFitter")

#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

# 8 first days of June from IT-MBo.2005.txt
# 10 days from June from Example_DETha98.txt shipped with REddyProc
.tmp.f <- function(){
	#save(dsNEE, file="tmp/dsNEE_Tharandt.RData")
	load("tmp/dsNEE_Tharandt.RData") # dsNEE
	dsNEE$Temp <- dsNEE$Tair_f
	dsNEE$Rg_f <- dsNEE$Rg
	dsNEE$isNight <- (dsNEE$Rg_f <= 4 & dsNEE$PotRad_NEW == 0)
	dsNEE$isDay=(dsNEE$Rg_f > 4 & dsNEE$PotRad_NEW != 0)
}

.tmp.f2 <- function(){
	# else stop in partitionNEEGL, and grap ds:
	attr(ds$sDateTime, "tzone") <- "UTC"
	dsJune <- ds
	dsNEE <- dsJune[ dsJune$sDateTime >= as.POSIXct("1998-06-01", tz="UTC") & dsJune$sDateTime < as.POSIXct("1998-06-10", tz="UTC")
		, c("sDateTime","NEE_f","NEE_fqc","NEE_fsd","Tair_f","Tair_fqc","VPD_f","VPD_fqc","Rg_f","PotRad_NEW")]
	save(dsNEE, file="tmp/dsNEE_Tharandt.RData")
	dput(dsNEE)
}

dsNEE <- structure(list(sDateTime = structure(c(896660100, 896661900,
								896663700, 896665500, 896667300, 896669100, 896670900, 896672700,
								896674500, 896676300, 896678100, 896679900, 896681700, 896683500,
								896685300, 896687100, 896688900, 896690700, 896692500, 896694300,
								896696100, 896697900, 896699700, 896701500, 896703300, 896705100,
								896706900, 896708700, 896710500, 896712300, 896714100, 896715900,
								896717700, 896719500, 896721300, 896723100, 896724900, 896726700,
								896728500, 896730300, 896732100, 896733900, 896735700, 896737500,
								896739300, 896741100, 896742900, 896744700, 896746500, 896748300,
								896750100, 896751900, 896753700, 896755500, 896757300, 896759100,
								896760900, 896762700, 896764500, 896766300, 896768100, 896769900,
								896771700, 896773500, 896775300, 896777100, 896778900, 896780700,
								896782500, 896784300, 896786100, 896787900, 896789700, 896791500,
								896793300, 896795100, 896796900, 896798700, 896800500, 896802300,
								896804100, 896805900, 896807700, 896809500, 896811300, 896813100,
								896814900, 896816700, 896818500, 896820300, 896822100, 896823900,
								896825700, 896827500, 896829300, 896831100, 896832900, 896834700,
								896836500, 896838300, 896840100, 896841900, 896843700, 896845500,
								896847300, 896849100, 896850900, 896852700, 896854500, 896856300,
								896858100, 896859900, 896861700, 896863500, 896865300, 896867100,
								896868900, 896870700, 896872500, 896874300, 896876100, 896877900,
								896879700, 896881500, 896883300, 896885100, 896886900, 896888700,
								896890500, 896892300, 896894100, 896895900, 896897700, 896899500,
								896901300, 896903100, 896904900, 896906700, 896908500, 896910300,
								896912100, 896913900, 896915700, 896917500, 896919300, 896921100,
								896922900, 896924700, 896926500, 896928300, 896930100, 896931900,
								896933700, 896935500, 896937300, 896939100, 896940900, 896942700,
								896944500, 896946300, 896948100, 896949900, 896951700, 896953500,
								896955300, 896957100, 896958900, 896960700, 896962500, 896964300,
								896966100, 896967900, 896969700, 896971500, 896973300, 896975100,
								896976900, 896978700, 896980500, 896982300, 896984100, 896985900,
								896987700, 896989500, 896991300, 896993100, 896994900, 896996700,
								896998500, 897000300, 897002100, 897003900, 897005700, 897007500,
								897009300, 897011100, 897012900, 897014700, 897016500, 897018300,
								897020100, 897021900, 897023700, 897025500, 897027300, 897029100,
								897030900, 897032700, 897034500, 897036300, 897038100, 897039900,
								897041700, 897043500, 897045300, 897047100, 897048900, 897050700,
								897052500, 897054300, 897056100, 897057900, 897059700, 897061500,
								897063300, 897065100, 897066900, 897068700, 897070500, 897072300,
								897074100, 897075900, 897077700, 897079500, 897081300, 897083100,
								897084900, 897086700, 897088500, 897090300, 897092100, 897093900,
								897095700, 897097500, 897099300, 897101100, 897102900, 897104700,
								897106500, 897108300, 897110100, 897111900, 897113700, 897115500,
								897117300, 897119100, 897120900, 897122700, 897124500, 897126300,
								897128100, 897129900, 897131700, 897133500, 897135300, 897137100,
								897138900, 897140700, 897142500, 897144300, 897146100, 897147900,
								897149700, 897151500, 897153300, 897155100, 897156900, 897158700,
								897160500, 897162300, 897164100, 897165900, 897167700, 897169500,
								897171300, 897173100, 897174900, 897176700, 897178500, 897180300,
								897182100, 897183900, 897185700, 897187500, 897189300, 897191100,
								897192900, 897194700, 897196500, 897198300, 897200100, 897201900,
								897203700, 897205500, 897207300, 897209100, 897210900, 897212700,
								897214500, 897216300, 897218100, 897219900, 897221700, 897223500,
								897225300, 897227100, 897228900, 897230700, 897232500, 897234300,
								897236100, 897237900, 897239700, 897241500, 897243300, 897245100,
								897246900, 897248700, 897250500, 897252300, 897254100, 897255900,
								897257700, 897259500, 897261300, 897263100, 897264900, 897266700,
								897268500, 897270300, 897272100, 897273900, 897275700, 897277500,
								897279300, 897281100, 897282900, 897284700, 897286500, 897288300,
								897290100, 897291900, 897293700, 897295500, 897297300, 897299100,
								897300900, 897302700, 897304500, 897306300, 897308100, 897309900,
								897311700, 897313500, 897315300, 897317100, 897318900, 897320700,
								897322500, 897324300, 897326100, 897327900, 897329700, 897331500,
								897333300, 897335100, 897336900, 897338700, 897340500, 897342300,
								897344100, 897345900, 897347700, 897349500, 897351300, 897353100,
								897354900, 897356700, 897358500, 897360300, 897362100, 897363900,
								897365700, 897367500, 897369300, 897371100, 897372900, 897374700,
								897376500, 897378300, 897380100, 897381900, 897383700, 897385500,
								897387300, 897389100, 897390900, 897392700, 897394500, 897396300,
								897398100, 897399900, 897401700, 897403500, 897405300, 897407100,
								897408900, 897410700, 897412500, 897414300, 897416100, 897417900,
								897419700, 897421500, 897423300, 897425100, 897426900, 897428700
						), class = c("POSIXct", "POSIXt"), tzone = "UTC"), NEE_f = c(4.1960303030303,
						4.10934375, 4.43365789473684, 4.14159459459459, 4.738, 4.59211904761905,
						4.76740909090909, 14.68, 0.41, -3.51, -4.66, -1.31, -2.65, -4.37,
						-7.36, -4.9, -15.41, -17.37, -23.71, -24.74, -18.22, -31.37,
						-19.82, -18.58, -17.39, -17.43, -16.2, -28.04, -10.63, -12.34,
						-8.65, -12.73, 0.87, -8.58, -8.29, -3.08, -3.24, -0.68, 3.49,
						2.7, 3.04, 4.59, 3.886625, 2.933, 3.98753333333333, 3.98753333333333,
						3.61592857142857, 3.61592857142857, 3.61592857142857, 3.61592857142857,
						3.61592857142857, 3.61592857142857, 3.61592857142857, 3.61592857142857,
						3.61592857142857, 3.61592857142857, 3.1120625, 1.93, -1.79, -4.55428571428571,
						-13.8055555555556, -17.5555555555556, -18.0776923076923, -18.1815384615385,
						-24.2675, -21.928, -17.89, -12.07, -12.9583333333333, -17.75,
						-13.575, -13.25, -15.65, -10.02, -13.8971428571429, -14.95, -10.015,
						-7.71, -10.76, -11.59, -4.57, -6.8, -0.46, -3.11, -0.44, -2.7,
						5.61, 2.78, 3.509, 4.61, 3.64, 5.31, 1.39, 4.86878947368421,
						4.84617948717949, 4.730775, 4.62386363636364, 9.16, 4.67611904761905,
						4.730775, 5.07, 9.44, 3.68, 4.89, 11.06, 4.49726315789474, 4.36317647058824,
						0.6, 0.526923076923077, -0.35, 1.66, -4.7, -6.78, -21.3314285714286,
						-9.21647058823529, -11.38, -8.93, -14.24, -13.39, -19.02, -11.78,
						-17.81, -23.5, -15.1927272727273, -13.899, -22.15, -15.83, -11.59,
						-9.94, -6.92, -2.74, -4.12, -2.65, -1.58, 3.663, 3.646, 3.616,
						4.66109523809524, 4.55721276595745, 4.37677777777778, 4.57465384615385,
						4.60647169811321, 4.39544230769231, 3.349, 5.82, 4.40038775510204,
						4.38164, 4.27934615384615, 4.31362962962963, 4.27934615384615,
						4.31362962962963, 4.32357692307692, 4.18546428571429, 0.52, -3.33,
						-0.98, -2.05, -21.11, -7.6, -6.77, -10.44, -19.08, -18.66, -11.43,
						-16.83, -12.04, -14.82, -15.5, -16.96, -13.57, -19.4, -20.82,
						-14.31, -16.85, -12.54, -10.68, -8.36, -5.24, -3.4, -5.57, -1.53,
						-1.03, 3.783, 3.765, 3.734, 4.86866666666667, 4.85652631578947,
						4.74207692307692, 4.4281875, 4.72565909090909, 4.75571428571429,
						4.85897619047619, 4.797425, 4.65044736842105, 4.40288888888889,
						4.43685714285714, 4.461, 4.46514285714286, 4.57367741935484,
						4.57367741935484, 2.25, -0.272093023255814, 9.94, -0.43, -10.9475,
						4.34, -8.45, -19.061, -16.065, -17.33125, -20.55, -7.83, -3.9,
						-10.85, -10.73, -7.1, -9.25, -9.6, -5.9, -3.77, -1.46, 1.18,
						-1.94, 1.18, -2.73, -1.38, -0.78, -1.09, -0.33, 2.16, 5.02, 6.32,
						9.7, 6.68, 5.56, 4.92, 2.82, 6.52, 5.5, 2.56, 7.86, 4.82, 4.363,
						5.56, 6.81, 4.36, 4.06, 4.25, 3.58, 1.06, -1.78, -6.89, -5.09,
						-10.46, -13.23, -8.185, -3.31333333333333, -14.0544444444444,
						-10.9146153846154, -11.9492857142857, -11.4726315789474, -0.8475,
						-4.85, 0.37, -1.04, 3.96, -1.32, -1.18, -1.52, -1.19, -2.05,
						0.31, -0.01, -1.03, -0.51, 3.26, 2.75, 5.42, 9.87, 3.42, 5.702,
						16.81, 2.97, 5.7997619047619, 5.69886363636364, 5.87725, 5.73119047619048,
						5.66713636363636, 5.3855625, 4.85285714285714, 4.94438461538462,
						4.90064285714286, 5.3855625, 5.3855625, 4.94438461538462, 4.90064285714286,
						4.94438461538462, 2.32, -2.02, -2.945, -7.55, -9.6425, -12.895,
						-10.25, -13.4526666666667, -7.905, -9.165, -6.32, 0.17, -14.3533333333333,
						-9.02666666666667, -9.425, -12.8025, -9.035, -8.57478260869565,
						-10.991, -12.9656097560976, 2.32, 1.97023255813954, 5.94, -1.27,
						-7.04333333333333, -16.135, -10.3363829787234, -0.114848484848485,
						2.8140625, 6.35733333333333, 4.924, 4.30169230769231, 4.772,
						4.57369230769231, 4.881625, 4.236625, 4.72334615384615, 4.35,
						11.94, 7.76, 3.44, 4.1, 4.98, 6.23, 3.74, 7.03, 3.85, 3.72, 2.5275,
						0.95, -1.41133333333333, 0.14, -1.08, -1.99, -3.05, -3.51, -6.54,
						-6.61, -11.96, 3.63, -14.7, -10.26, -11.12, -16.49, -11.48, -19.2,
						-24.25, -13.08, -18.81, -20.05, -18.78, -15.83, -11.4, -9.51333333333333,
						-7.12, -3, 0.22, 4.006, 4.006, 3.987, 3.954, 4.96, 3.875, 4.68322916666667,
						4.86950980392157, 4.81164150943396, 5.22405357142857, 5.35267857142857,
						5.2169649122807, 5.19295081967213, 5.17129032258064, 5.20190476190476,
						5.19875, 5.19230769230769, 5.16388059701493, 4.78684931506849,
						1.38, -1.75, -5.73, -8.91, -10.17, -12.44, -12.57, -12.67, -13.96,
						-15.57, -11.84, -8.88, -14.33, -13.98, -14.51, -8.34, -10.54,
						-12.17, -12.98, -11.8, -12.45, -8.35, -6.82, -5.88, -2.43, -3.14,
						-3.41, -1.43, 0.34, 4.332, 4.322, 4.302, 4.18992, 4.81429166666667,
						4.53585714285714), NEE_fqc = c(1, 1, 1, 1, 1, 1, 1, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1,
						1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0,
						0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
						1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1,
						0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
						1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 1, 1, 1, 1,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
						1, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1,
						1, 1, 2, 2, 2, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
						0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
						1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1), NEE_fsd = c(4.16363460125922,
						4.16366125027679, 4.12220247661117, 3.94271517033813, 4.00575817859314,
						4.002254883964, 3.92991287741872, 4.18288071775, 4.0549961194074,
						4.34479453867882, 4.57699387529336, 4.41395424347512, 4.27220954357771,
						4.65706293941524, 5.81847623237104, 6.71601304534889, 8.55494162750395,
						7.86318469383823, 8.01804188778568, 5.82650797975041, 6.0054554410923,
						6.05339098557515, 5.74739212599941, 6.54369745355303, 6.05749944971796,
						8.0832915878828, 7.67271038062693, 7.76157238466233, 6.7987212817701,
						5.58789539987999, 5.80256510720576, 4.96952916865398, 5.52680865962573,
						6.07015880534257, 6.04032509660923, 4.43893221741099, 3.70478100199287,
						2.13824694551401, 1.74315873299624, 1.75991590708193, 1.77391661013304,
						1.78377793367523, 1.78377793367523, 1.79849456358314, 1.79849456358314,
						1.79849456358314, 1.11924551952064, 1.11924551952064, 1.11924551952064,
						1.11924551952064, 1.11924551952064, 1.11924551952064, 1.11924551952064,
						1.11924551952064, 1.11924551952064, 1.11924551952064, 1.72936136454087,
						1.88485947436281, 3.54208036799468, 4.25451468890345, 3.64393026521883,
						6.51596522226583, 5.39678322992218, 6.20970053780621, 5.04828931421328,
						6.81764035425748, 3.36243215544939, 2.98267776782318, 3.70473435844821,
						3.10416195269696, 3.14969839825974, 2.91701004781396, 3.14736715366987,
						3.14094652214027, 4.12950648498387, 3.78150029015528, 3.58001629419011,
						3.72552792679552, 2.9519180205419, 3.04495103174325, 5.09231272496975,
						2.86888421980858, 3.23822470536315, 3.29718061379719, 2.87662666197422,
						1.57762455686524, 1.6698462509746, 2.16415463213581, 2.36168732084128,
						2.40557102748058, 2.47383969164624, 2.43741633874957, 2.47237506599767,
						2.47290192981461, 2.44422865748982, 2.52067363287307, 2.41685461158313,
						2.38646156757794, 2.47163180226542, 2.52067363287307, 2.52067363287307,
						2.44455269989155, 2.50326483767918, 2.43230985464137, 2.35090377141409,
						3.7602974988992, 4.24122387618414, 4.11676174592692, 3.9502961589721,
						3.70722959423446, 7.40196573431856, 6.84207667209402, 6.5944930233714,
						5.03330384728039, 8.605555575598, 6.80319959738833, 9.60502776327759,
						7.18519917152635, 7.22989142380437, 3.56979457859039, 5.03360264180195,
						3.13168218906921, 4.49621136810389, 3.13491655681325, 4.5351379986354,
						4.5760297780294, 5.06870294294403, 6.11324287604692, 4.87971913367249,
						4.84723069953819, 4.03745942040642, 3.41323242038329, 4.22108291228459,
						2.63472508053497, 2.11425548217391, 2.23444389081926, 2.43899145350213,
						2.50056800190914, 2.38777318433588, 2.52603402669885, 3.64643070114053,
						3.63964132110555, 3.61072086884112, 3.45780190782027, 3.45663486709972,
						3.49231281302429, 3.45903449876891, 3.44234425301413, 3.42469026995775,
						3.44234425301413, 3.42469026995775, 3.40385510593534, 3.43882268946952,
						3.94616822730113, 3.39167269004007, 4.22483529689827, 6.03234435046385,
						7.20854206370543, 6.86468202764406, 8.20188903908873, 5.6166003952569,
						3.19714959855737, 2.54630102087104, 3.01151480630121, 4.18509358716544,
						3.55672960098817, 2.86594204573711, 2.82444730241202, 4.10689953730595,
						3.76090119223808, 4.10828757339531, 5.41467714378508, 4.84345729530349,
						4.20860937331357, 5.29002023649854, 4.89150546501644, 4.821268159589,
						2.80832269578059, 4.84501197373557, 4.72444776314298, 4.18855614912574,
						1.75609597599991, 2.19674726240497, 2.20396999838353, 2.35730731851035,
						2.38682908273203, 2.4176478823585, 2.57836003962347, 2.3332387284836,
						2.67292616366915, 2.93326792939967, 3.06431519814226, 3.12888917691411,
						2.89884091186291, 2.43121164122839, 2.45802293990704, 2.49077197477068,
						2.46217091133793, 2.5778643148557, 2.5778643148557, 2.56683257596125,
						3.35663561588197, 5.63827102837332, 4.90313868863609, 6.4335542276412,
						7.29954911760044, 5.58169535866327, 4.59440589799765, 4.99656181789038,
						4.47602322699195, 2.66699402752559, 4.50849885269608, 3.82397569965019,
						3.42545748395145, 2.85519458375627, 1.90264289870695, 2.80025643666988,
						2.80025643666988, 2.84931395251559, 1.91139347074327, 1.63341666454092,
						2.20617315730203, 2.20617315730203, 2.82842712474619, 1.40714249456123,
						0.0707106781186548, 0.0424264068711929, 0.55075705472861, 1.01707095786544,
						0.643467170879758, 3.65570980405018, 3.3479788217933, 3.04069064366571,
						2.89786863925236, 1.67699820166256, 3.03889587875346, 3.31266845076683,
						3.09079375386766, 3.21917033977244, 3.09079375386766, 2.94982814599581,
						1.67699820166256, 1.67699820166256, 1.65921006003861, 1.61974482352417,
						1.60501953108263, 1.56824446648686, 1.58190228311781, 1.22326755267798,
						1.7819090885901, 1.55468324748162, 3.87755492833077, 2.77991846403211,
						3.52586159682992, 6.04086362479185, 7.13470742217226, 1.3494196283341,
						7.79967663147361, 7.61071132832385, 8.17655604037046, 6.73882766107088,
						3.6270224243402, 3.18222092256336, 3.18222092256336, 3.18222092256336,
						3.18222092256336, 3.18222092256336, 6.7009130743065, 7.62127961150007,
						0.608111831820431, 0.608111831820431, 7.61611406536263, 7.06477388173181,
						5.53408230569201, 5.17188558303145, 4.24898502312118, 1.88797510576808,
						4.48252382391134, 5.38784435558415, 4.82046427323383, 4.82046427323383,
						3.65570980405018, 3.3479788217933, 3.04069064366571, 3.0049115714024,
						3.09833692019648, 3.07519562985914, 3.01608478937678, 1.64706296049463,
						1.03178007921656, 1.01302957660521, 0.98695238815432, 1.64706296049463,
						1.64706296049463, 1.01302957660521, 0.98695238815432, 1.01302957660521,
						1.7819090885901, 0.597327380922723, 2.63221706298448, 1.76783766223033,
						3.06317237516925, 1.74655374953077, 4.21435641587182, 6.58997124063383,
						1.53442171517481, 4.64569155239562, 3.68243126208759, 7.43876333808248,
						2.97005611619264, 1.8252762348021, 0.247487373415291, 3.93715104273805,
						4.60326514552442, 6.16977520554489, 7.01041248129486, 6.85125282294431,
						1.7819090885901, 4.0230014194404, 4.96773590280321, 4.30774883204673,
						0.857807282163851, 5.47451367703105, 5.10480695267233, 3.46515900064729,
						4.18391378694792, 4.07262879886362, 3.18156020426038, 2.37310718906021,
						2.88529489227438, 2.90210734882474, 2.89235894210936, 0.802841727419368,
						3.07934791723583, 3.22706658714067, 3.72210297717934, 3.807294815112,
						3.72719248907547, 3.72719248907547, 3.72719248907547, 3.72719248907547,
						4.0624133433895, 4.12392287664901, 4.11012932550768, 4.11036396082158,
						4.73110410502999, 3.35570046030969, 4.32390207976572, 4.32600086312311,
						2.54726039863645, 3.01835864152835, 2.47954178655339, 4.67279318652358,
						6.07491061662639, 5.61328557976521, 5.0274856493105, 6.25376260076017,
						5.25621884132848, 5.95941667101936, 5.65430990199832, 6.92195566118699,
						6.65924333082449, 4.61124330687124, 6.31325730330847, 5.83373979536283,
						6.14265795756411, 5.90027753584524, 6.41018163326349, 5.69066887300801,
						4.27102509441736, 4.33806984729384, 3.87781872903287, 2.48733550452847,
						4.53969242049803, 2.70489704055441, 2.70489704055441, 2.90406102475204,
						3.10237005870664, 3.09932635889867, 3.04302739708817, 3.49735520278544,
						3.54167186155098, 3.62365070959756, 3.99663493645088, 4.07130920246521,
						3.96115150540179, 3.95636005871655, 3.92750186061709, 3.8624987679893,
						3.83180451087002, 3.8021054608067, 3.75941689757459, 3.85027416293392,
						3.64193141676837, 5.44886930652376, 5.18292931169238, 4.92241433817458,
						5.53613265392953, 5.59836493987307, 5.44778334126214, 6.34172908423072,
						3.92941085187807, 4.4883766553176, 4.91881664049974, 3.2988026447317,
						3.39577662529338, 3.11364256137406, 2.76580006508063, 2.94348247674572,
						2.98912696284383, 4.00252420354956, 2.32103425222464, 3.49989999857139,
						5.06243024643303, 2.70114790413261, 3.52139177030901, 3.81943713130613,
						4.35367316182554, 5.94429979055565, 4.59833574966712, 1.10699292379551,
						1.53744376590929, 1.6930251160211, 1.31667420218904, 0.960701018849802,
						0.954500825911988, 2.18561372296536, 2.48553083436344), Tair_f = c(14.9,
						14.8, 15.2, 14.9, 15.5, 15.3, 15.5, 14.1, 13.9, 13.9, 14, 14.1,
						13.6, 13.7, 14, 14.1, 14.5, 14.6, 14.8, 15.4, 15, 15.2, 15.4,
						15.5, 14.9, 15.1, 14.6, 14.3, 13.9, 13.7, 12.9, 12.9, 12.4, 12,
						12, 11.4, 11.3, 11, 11, 11.1, 11.2, 11.1, 10.6, 10.5, 10.2, 10.2,
						10, 10, 10.2, 10, 10.1, 10.3, 10.3, 10.4, 10.4, 10.1, 10, 9.6,
						9.7, 10, 11.3, 12.4, 13.6, 14.6, 15.1, 15.7, 16.4, 17.1, 18.4,
						18.5, 19, 19.7, 20.1, 20.6, 21.3, 21.2, 21.6, 21.4, 21.4, 22.1,
						22.6, 22.4, 22.3, 22, 22, 21.4, 20.7, 19.7, 19, 18.7, 18.4, 18.4,
						18.1, 18.1, 18.1, 17.9, 17.6, 17.6, 17.9, 18.1, 18.1, 17.7, 18.1,
						17.9, 17.6, 14.7, 13.8, 14, 14.5, 14.8, 15.2, 15.9, 15.9, 16.1,
						15.9, 15.3, 15.9, 16.8, 17.6, 18.5, 18.4, 19.1, 19.3, 19.5, 19.9,
						20, 20.4, 20.2, 20.8, 21.3, 21.5, 21.4, 21.2, 20.6, 20, 19.4,
						18.8, 18, 17.6, 17, 16, 15.4, 15.2, 15.1, 15.1, 14.5, 14.6, 14.8,
						14.9, 14.8, 15.1, 14.7, 14.8, 15.3, 15.9, 16.1, 16.2, 17, 17.1,
						16.9, 17.8, 18.5, 19, 19, 19.6, 19.7, 20.2, 20.7, 20.5, 21.1,
						20.6, 21.1, 21.1, 21.3, 21.5, 21.4, 21.4, 20.8, 20.3, 20.2, 20.1,
						19.9, 19.5, 19.6, 19.2, 19, 19, 18.3, 17.2, 16.6, 16.5, 16.2,
						16.1, 16.3, 16.4, 16.4, 16.3, 16.7, 16.9, 16.9, 16.8, 14.1, 13.9,
						14.4, 15.4, 16.5, 17, 17.9, 18.6, 19.5, 20.3, 20.7, 21.8, 22.5,
						23.8, 24.4, 25.2, 25.8, 26.2, 26.7, 27.1, 27.2, 27.8, 27.6, 27.5,
						27.5, 27.3, 27.1, 26.7, 26.1, 25.5, 24.7, 24, 23.2, 23, 23.5,
						23.8, 23.5, 23.9, 23.7, 23.4, 23, 22.5, 22, 21.9, 21.7, 21.7,
						21.6, 21.5, 21.7, 22, 22.5, 23.3, 24.3, 25.4, 26.1, 27.3, 27.5,
						28.4, 28.4, 29.6, 29.9, 30.3, 30.6, 30.3, 30.4, 30.8, 30.9, 31.5,
						31.7, 31.8, 31.5, 30.4, 29.9, 29.4, 28.9, 28.5, 27.9, 27.5, 26.9,
						26.6, 25.5, 24.8, 24, 23.9, 24.1, 23.9, 23.4, 23, 22.4, 22.6,
						23, 23.1, 23.1, 22.8, 22.8, 22.5, 22.5, 22.6, 22.5, 21.4, 22.5,
						23.4, 24.8, 25.3, 25.8, 25.5, 25, 24.8, 25, 25.8, 26.9, 25.7,
						23.2, 23, 24.3, 24.2, 23, 20.5, 18.5, 18.8, 19, 20.4, 21.7, 21.1,
						20.6, 19.9, 19.4, 18.8, 18.3, 18.3, 18.3, 17.3, 16, 15, 14.6,
						14.4, 14.2, 14.1, 14.1, 14, 13.9, 13.8, 13.8, 13.8, 13.6, 14,
						14.2, 14.5, 14.6, 14.1, 14.1, 14.2, 14.6, 14.4, 13.4, 14, 14.2,
						14.1, 14.2, 14.5, 14.9, 15.7, 16.1, 16.3, 16.6, 17.1, 18.1, 18.6,
						18.7, 18.9, 18.6, 18.3, 18, 18, 18, 16.4, 15.5, 15.3, 15.2, 14.7,
						14.4, 14, 13.9, 13.8, 13.9, 13.6, 13.5, 13.4, 13.4, 13.4, 13.1,
						13.1, 13.3, 13.9, 14.9, 15.9, 16.8, 17.6, 18, 18.3, 18.9, 19.5,
						19.9, 20.8, 21.1, 21.7, 22.2, 22, 22.5, 22.5, 23, 23.2, 23.1,
						23.8, 23.6, 23.8, 23.8, 23.8, 23.7, 23.5, 22.9, 22.1, 21.3, 20.9,
						20.2, 19.5, 18.9), Tair_fqc = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), VPD_f = c(3.8,
						4, 4.8, 4.6, 5.5, 5.3, 5.2, 3.2, 3, 3.2, 3.4, 3.4, 2.7, 2.9,
						3.3, 3.3, 4, 4.2, 4.4, 5.1, 4.8, 5, 5.2, 5.3, 4.4, 4.4, 3.7,
						3.6, 3.5, 3.1, 2.2, 2.3, 2.1, 1.9, 2.2, 1.7, 1.8, 1.6, 1.6, 1.6,
						1.7, 1.7, 1.3, 1.2, 1.2, 1.4, 1.4, 1.4, 1.4, 1.3, 1.5, 1.8, 2,
						2, 2, 2, 1.9, 1.7, 1.8, 1.9, 2.6, 3.4, 4.6, 5.9, 7.2, 7.8, 8.8,
						10.3, 11.9, 12, 13.2, 14.4, 15.4, 15.6, 17, 16.4, 16.8, 16, 15.8,
						16.7, 16.9, 16.5, 16.3, 15.6, 15.5, 14.4, 13.5, 12.3, 11.4, 11.3,
						11.1, 11, 10.5, 10.2, 10, 9.7, 9.1, 9, 9.3, 9.7, 9.6, 9.1, 9.6,
						9.1, 8.3, 2.2, 1.2, 1.4, 1.5, 1.7, 1.8, 2.1, 2, 2.3, 2.4, 2.7,
						2.8, 4, 5.4, 7.4, 8, 9.2, 10.1, 11.1, 11.1, 11.3, 11.9, 11.5,
						12.8, 15, 15.5, 15.1, 14.6, 13.1, 12.1, 11.2, 10.2, 9, 8.7, 7.9,
						6.6, 5.6, 5.5, 5.6, 5.5, 4.9, 4.8, 4.7, 4.9, 4.8, 5, 4.6, 4.4,
						4.7, 4.9, 5, 5, 6, 7.1, 7.3, 9.4, 10.5, 10.7, 10.9, 11.6, 12.2,
						12.6, 13.5, 13.8, 15, 14.3, 15, 15, 15.2, 15.3, 14.7, 14.5, 13.2,
						12.5, 12, 12, 11.5, 10.9, 11.5, 11.2, 11, 10.8, 9.8, 7.9, 7.4,
						7.5, 7.3, 7.4, 8.1, 8.5, 8.5, 8.4, 9, 9.4, 9.4, 9.2, 5.9, 5.4,
						5.6, 6.4, 8, 8.3, 8.9, 9.6, 10.9, 11.5, 11.8, 13.4, 13.9, 15.6,
						16.4, 17.7, 20, 21.4, 22.8, 23.8, 24.2, 25.7, 25.1, 24.5, 24.4,
						23.7, 22.6, 21.4, 20, 18.3, 16.6, 15, 13.7, 13.8, 15.7, 16.6,
						16, 16.4, 16, 15.1, 14.3, 13.1, 12.1, 11.5, 11.1, 10.9, 10.7,
						10.4, 10.5, 10.8, 11.4, 12.5, 14, 15.9, 16.7, 19.5, 18.7, 20.7,
						19.4, 25.1, 27.1, 29.9, 31.6, 30.3, 30.2, 31.1, 31.5, 33.4, 34.2,
						33.8, 32.2, 28.7, 27, 25.8, 24.6, 23.2, 21.2, 19.3, 17.5, 16.7,
						15.3, 15.6, 13.9, 13.7, 14.1, 13.2, 11.8, 10.4, 9.4, 9.4, 10,
						10.2, 10.2, 9.8, 10, 9.5, 9.6, 9.7, 9.3, 7.1, 8.3, 9.5, 11.7,
						13.8, 15.5, 14.6, 13.6, 12.8, 12.6, 14, 16.2, 12.9, 8.2, 7.1,
						8.5, 8.2, 5.9, 3.2, 3.4, 3.6, 2.9, 4.4, 4.9, 3.2, 4.4, 3.6, 2.4,
						2.3, 2, 1.6, 2.2, 2.4, 1.9, 1.8, 1.7, 1.6, 1.5, 1.5, 1.6, 1.6,
						1.6, 1.6, 1.7, 1.7, 1.5, 1.9, 2, 2, 1.9, 1.2, 1.1, 1, 1.2, 1.4,
						1.2, 1.4, 2, 2.1, 2.2, 2.9, 4, 5.6, 6.1, 6.3, 6.6, 7.3, 8.4,
						9.1, 9.5, 9.6, 9.4, 8.9, 8.4, 8.1, 8.5, 5.1, 4.3, 4.1, 4, 3.6,
						3.2, 2.8, 2.9, 3, 3.3, 3.5, 3.6, 3.6, 3.9, 4, 3.7, 4, 4.3, 4.9,
						5.8, 6.7, 7.5, 8.3, 8.7, 10.4, 11.9, 13.1, 13.6, 14.6, 15, 16.3,
						17.4, 16.7, 17.4, 17.1, 17.4, 17.9, 17.9, 19.4, 19.5, 19.4, 19.2,
						19.3, 18.4, 18, 16.6, 14.9, 13.8, 13, 11.4, 10.1, 9.5), VPD_fqc = c(0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0), Rg_f = c(0, 0, 0, 0, 0, 0, 0, 0, 7.6, 28.21,
						72.65, 58.6, 64.96, 88.09, 129.71, 181.79, 249.7, 275.14, 334.38,
						436.75, 446.38, 485.57, 436.23, 465.6, 397.78, 373.51, 264.65,
						335.03, 279.05, 186.92, 157.86, 195.08, 109.75, 157.09, 148.44,
						68.99, 62.2, 23.19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0.65, 18.18, 63.46, 102.18, 144.81, 259.45, 341.64,
						445.58, 477.72, 516.94, 518.02, 649.17, 788.36, 807.12, 820.66,
						861.57, 883.71, 934.16, 866.49, 734.32, 488.3, 461.36, 387.41,
						304.3, 548.53, 497.1, 282.8, 217.01, 219.53, 177.14, 104.46,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.25, 1.81,
						1.75, 11.23, 20.21, 22.18, 44.11, 179.91, 344.17, 326.2, 439.67,
						247.61, 165.58, 587.41, 338.38, 702.08, 877.56, 516.66, 544.75,
						626.47, 552.62, 525.21, 468.4, 509.77, 397.1, 472.03, 500.15,
						405.04, 307.41, 217.25, 136.11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0.92, 10.4, 30.54, 54.78, 70.5, 150.72,
						336.81, 252.93, 378.43, 598.36, 664.71, 711.15, 796.05, 853.26,
						864.03, 925.24, 891.71, 743.14, 732.38, 628.13, 630.96, 579.5,
						589.56, 510.88, 477.17, 442.26, 285.11, 232.36, 226.17, 181.08,
						113.69, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.46,
						16.67, 52.51, 116.79, 175.91, 237.03, 340.2, 429, 504.94, 579.23,
						644.62, 707.77, 761.29, 808.66, 841.88, 866.18, 887.1, 890.79,
						897.56, 892.63, 843.73, 802.51, 711.15, 684.7, 607.13, 502.21,
						420.85, 344.01, 268.47, 201.75, 109.72, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11.63, 44.51, 100.55, 169.79,
						247.24, 324.14, 418.02, 393.32, 574.58, 627.06, 690.55, 741.3,
						792.67, 840.65, 875.1, 891.71, 897.86, 886.79, 867.41, 813.58,
						756.37, 675.23, 698.54, 463.33, 348.72, 271.36, 159.39, 104.06,
						47.86, 22.05, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 13.72, 39.16, 96.58, 149.74, 260.72, 316.05, 404.52, 441.36,
						563.94, 670.77, 577.23, 277.63, 222.33, 801.43, 900.32, 878.79,
						785.28, 341.46, 863.41, 817.58, 362.5, 25.35, 27.65, 34.36, 64.53,
						159.09, 318.33, 273.7, 60.1, 20.36, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0.46, 8.7, 21.81, 63.67, 71.58, 78.25,
						45.52, 66.16, 57.06, 98.03, 152.54, 136.17, 112.92, 245.27, 116.82,
						215.28, 241.09, 292.34, 286.89, 438.17, 497.75, 330.11, 382.09,
						515.13, 632.53, 516.57, 448.41, 281.14, 221.16, 97.54, 48.45,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.28, 16.7,
						61.49, 125.96, 202.52, 284.03, 365.73, 447.76, 534.32, 614.45,
						683.78, 748.68, 805.59, 862.18, 825.27, 897.2475, 996.6, 904.94,
						941.23, 801.59, 943.39, 688.45, 582.24, 780.67, 640.44, 556.04,
						465.7, 384.61, 301.13, 205.9, 140.66, 0, 0, 0, 0, 0, 0), PotRad_NEW = c(0,
						0, 0, 0, 0, 0, 0, 0, 31.0113596762252, 124.182306379573, 221.793025863617,
						322.173371655182, 423.605808207084, 524.354798407536, 622.69649910131,
						716.948256524067, 805.497396974778, 886.828820109871, 959.550922730176,
						1022.41940949748, 1074.35858317276, 1114.47975009418, 1142.09642597201,
						1156.7360818252, 1158.14822908322, 1146.30870551496, 1121.42008865122,
						1083.90822962696, 1034.41496675034, 973.787143471304, 903.06211865536,
						823.450017085794, 736.313023893104, 643.142077189756, 545.531357705712,
						445.151011914147, 343.718575362245, 242.969585161793, 144.627884468018,
						50.3761270452619, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 33.3160607059766, 126.340357520714, 223.806357769276, 324.046391164729,
						425.345322943889, 525.969900298644, 624.198408812053, 718.350131469362,
						806.814106192115, 888.076689845959, 960.747457094333, 1023.58299096147,
						1075.50815804161, 1115.63450432963, 1143.27545691542, 1157.95807143671,
						1159.43112428826, 1147.66941112736, 1122.87417812717, 1085.46967859886,
						1036.09591389984, 975.597682833102, 905.010126905481, 825.541018769464,
						738.550096898259, 645.525800083521, 548.059799834959, 447.819766439507,
						346.520834660347, 245.896257305591, 147.667748792183, 53.5160261348739,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 35.4800203141296,
						128.361131872284, 225.68639289217, 325.790541174076, 426.960766986786,
						527.466019716958, 625.58662662506, 719.643716922721, 808.027947717396,
						889.227040315451, 961.85165572989, 1024.65916665563, 1076.57491916719,
						1116.71062034534, 1144.37953721519, 1159.10824693785, 1160.64473720637,
						1148.96271824627, 1124.26207264082, 1086.96543528465, 1037.7109619835,
						977.341410431478, 906.889720393235, 827.561339818226, 740.713599292071,
						647.832487733916, 550.507226714031, 450.403078432125, 349.232852619415,
						248.727599889242, 150.606992981141, 56.54990268348, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37.50330822859, 130.244848608224,
						227.433490397721, 327.406308990282, 428.452741742085, 528.843856173385,
						626.861932482585, 720.829854208291, 809.139804156946, 890.280774600784,
						962.864421038985, 1025.648817157, 1077.55970453013, 1117.70887348301,
						1145.40936060339, 1160.18720287662, 1161.78954732421, 1150.18897738841,
						1125.58398203712, 1088.39555956257, 1039.2600141839, 979.018068705475,
						908.700479516654, 829.510400064178, 742.802794563117, 650.061254183484,
						552.872612393986, 452.899793801425, 351.853361049622, 251.462246618322,
						153.444170309122, 59.4762485834158, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 39.3860430813494, 131.991771951647, 229.048050264278,
						328.894218188229, 429.821880107735, 530.104135744918, 628.025127902332,
						721.909401255335, 810.15056985722, 891.238802848134, 963.786658079697,
						1026.55282163483, 1078.46334705304, 1118.63003085211, 1146.36560993591,
						1161.19552085658, 1162.86601972663, 1151.34852384725, 1126.84010076618,
						1089.76009639736, 1040.74295989607, 980.627388057947, 910.441974984339,
						831.387612552004, 744.81694282017, 652.211213949873, 555.154935637242,
						455.30876771329, 354.381105793784, 254.098850156601, 156.177857999188,
						62.2935846461844, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 41.1283916918298, 133.602210320652, 230.530512301075, 330.254827512609,
						431.068845273181, 531.247609787983, 629.077034621365, 722.883231190987,
						811.061149465552, 892.102040815844, 964.61927312208, 1027.37205643393,
						1079.28667323055, 1119.47485002513, 1147.24895597042, 1162.13376841328,
						1163.87460408594, 1152.44167680741, 1128.03060713322, 1091.05907523354,
						1042.15967426959, 982.169086549364, 912.113767661276, 833.192383534508,
						746.75530093261, 654.281482303787, 557.353180323365, 457.628865111831,
						356.814847351258, 256.636082836456, 158.806658003074, 65.0004614334521,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42.7305683761548,
						135.076515506527, 231.88135520456, 331.488729823647, 432.194329567674,
						532.275053704155, 630.018493295495, 723.752230990684, 811.872456549858,
						892.871408482155, 965.363172262862, 1028.10739371518, 1080.03050181407,
						1120.24407778415, 1148.06005619128, 1163.00249793286, 1164.81573368785,
						1153.46873848977, 1129.15566257245, 1092.29250940568, 1043.51001776054,
						983.642869594147, 913.715408409934, 834.924112456318, 748.61712265214,
						656.271175521768, 559.466335823736, 459.858961204648, 359.153361460621,
						259.07263732414, 161.329197732801, 67.5954600376106, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 44.1928342826379, 136.415081884726,
						233.101095653588, 332.59655108721, 433.199053357771, 533.18726575914,
						630.85036225516, 724.517300187456, 812.585412278626, 893.547828713698,
						966.019260100444, 1028.75970015496, 1080.69564255298, 1120.9384489207,
						1148.79955368377, 1163.80224561512, 1165.68982449629, 1154.42999332927,
						1130.21541094715, 1093.46039556805, 1044.7938356955, 985.048429661859,
						915.246437928906, 836.582191927964, 750.401658717958, 658.17941111587,
						561.493397347008, 461.997941913386, 361.395439642824, 261.407227241455,
						163.744130745436, 70.0771928131399, 0, 0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 45.5154967535342, 137.618345658769, 234.190287443711,
						333.578949409619, 434.083763994513, 533.985065955646, 631.573516318591,
						725.179349641006, 813.200944162306, 894.132225996035, 966.588438471626,
						1029.32983570497, 1081.28289499419, 1121.55868509075, 1149.46807605954,
						1164.53353048313, 1166.4972742594, 1155.32570718789, 1131.20997787854,
						1094.56271314598, 1046.01095785031, 986.385445985734, 916.706386591575,
						838.16600769275, 752.108156947724, 660.005308042489, 563.433366257547,
						464.044704291639, 363.539889706746, 263.638587745612, 166.050137382668,
						72.4443040602518, 0, 0, 0, 0)), .Names = c("sDateTime", "NEE_f",
				"NEE_fqc", "NEE_fsd", "Tair_f", "Tair_fqc", "VPD_f", "VPD_fqc",
				"Rg_f", "PotRad_NEW"), row.names = 7249:7676, class = "data.frame")
dsNEE$Temp <- dsNEE$Tair_f
dsNEE$isNight <- (dsNEE$Rg_f <= 4 & dsNEE$PotRad_NEW == 0)
dsNEE$isDay=(dsNEE$Rg_f > 4 & dsNEE$PotRad_NEW != 0)


RectangularLRCFitter$methods()
lrcFitter <- RectangularLRCFitter()

test_predictLRC <- function(lrcFitter){
			theta0 <- structure(c(0, 27.3333395589509, 0.162207578338878, 2.59392002410639, 185, 1.1
					), .Names = c("k", "beta", "alpha", "RRef","E0","logitconv"))
			nRow <- 5L
			iRowK <- 4L
			theta0M <- do.call(rbind, lapply(1:nRow, function(i){theta0}))
			theta0M[iRowK,"k"] <- 0.05
			dss <- subset(dsNEE, as.POSIXlt(dsNEE$sDateTime)$mday %in% 1:8 )
			dssDay <- do.call( rbind, lapply(1:nRow, function(i){ subset(dss, isDay==TRUE)[1,] }))
			dsDay <- data.frame( NEE=dssDay$NEE_f, sdNEE=dssDay$NEE_fsd, Rg=dssDay$Rg_f, Temp=dssDay$Temp, VPD=dssDay$VPD_f)
			#
			# lrcFitter$trace("predictLRC", browser)   # lrcFitter$untrace("predictLRC")
			gpp <- gpp0 <- lrcFitter$predictLRC(theta0M, Rg=dsDay$Rg, VPD=dsDay$VPD, Temp=dsDay$Temp, VPD0=0)$GPP
			expect_equal( length(gpp), nRow )
			expect_true( all(gpp[-iRowK] == gpp[1]) )
			expect_true( all(gpp[iRowK] != gpp[1]) )
			#
			gpp <- lrcFitter$predictLRC(theta0M, Rg=dsDay$Rg, VPD=dsDay$VPD, Temp=dsDay$Temp, VPD0=0, fixVPD=FALSE)$GPP
			expect_equal( length(gpp), nRow )
			expect_true( all(gpp[-iRowK] == gpp[1]) )	# the only row with k!=0
			expect_true( all(gpp[iRowK] != gpp[1]) )
			#
			gpp <- lrcFitter$predictLRC(theta0M, Rg=dsDay$Rg, VPD=rep(NA_real_,nRow), Temp=dsDay$Temp, VPD0=0, fixVPD=FALSE)$GPP
			expect_equal( length(gpp), nRow )
			expect_true( all(is.na(gpp)) )	# VPD in computation
			#
			gpp <- lrcFitter$predictLRC(theta0M, Rg=dsDay$Rg, VPD=rep(NA_real_,nRow), Temp=dsDay$Temp, VPD0=0, fixVPD=TRUE)$GPP
			expect_equal( length(gpp), nRow )
			expect_true( all(gpp == gpp[1]) )	# same value not regarding different k
			expect_true( is.finite(gpp[1]) )	# finite despite NA VPD
			#
			gpp <- lrcFitter$predictLRC(theta0M, Rg=dsDay$Rg, VPD=rep(NA_real_,nRow), Temp=dsDay$Temp, VPD0=0)$GPP
			expect_equal( length(gpp), nRow )
			expect_true( all(gpp[-iRowK] == gpp[1]) )	# the only row with k!=0
			expect_true( is.na(gpp[iRowK]) )
		}

test_that("RectangularLRCFitter$predictLRC vector form",{
			lrcFitter <- RectangularLRCFitter()
			test_predictLRC(lrcFitter)
			#lrcFitter <- LogisticSigmoidLRCFitter()
		})

test_that("NonrectangularLRCFitter$predictLRC vector form",{
			lrcFitter <- NonrectangularLRCFitter()
			test_predictLRC(lrcFitter)
		})

test_LRCGRadient_vectorForm <- function(lrcFitter){
	theta0 <- structure(c(0, 27.3333395589509, 0.162207578338878, 2.59392002410639, 185, 1.1
			), .Names = c("k", "beta", "alpha", "RRef","E0","logitconv"))
	nRow <- 5L
	iRowK <- 4L
	theta0M <- do.call(rbind, lapply(1:nRow, function(i){theta0}))
	theta0M[iRowK,"k"] <- 0.05
	dss <- subset(dsNEE, as.POSIXlt(dsNEE$sDateTime)$mday %in% 1:8 )
	dssDay <- do.call( rbind, lapply(1:nRow, function(i){ subset(dss, isDay==TRUE)[1,] }))
	dsDay <- data.frame( NEE=dssDay$NEE_f, sdNEE=dssDay$NEE_fsd, Rg=dssDay$Rg_f, Temp=dssDay$Temp, VPD=dssDay$VPD_f)
	#
	gpp <- gpp0 <- lrcFitter$computeLRCGradient(theta0M, Rg=dsDay$Rg, VPD=dsDay$VPD, Temp=dsDay$Temp, VPD0=0)$GPP
	expect_equal( nrow(gpp), nRow )
	expect_true( all(gpp[-iRowK,][2,] == gpp[1,]) )
	expect_true( all(gpp[iRowK,"k"] != gpp[1,"k"]) )
	#
	gpp <- lrcFitter$computeLRCGradient(theta0M, Rg=dsDay$Rg, VPD=dsDay$VPD, Temp=dsDay$Temp, VPD0=0, fixVPD=FALSE)$GPP
	expect_equal( nrow(gpp), nRow )
	expect_true( all(gpp[-iRowK,][2,] == gpp[1,]) )
	expect_true( all(gpp[iRowK,"k"] != gpp[1,"k"]) )
	#
	gpp <- lrcFitter$computeLRCGradient(theta0M, Rg=dsDay$Rg, VPD=rep(NA_real_,nRow), Temp=dsDay$Temp, VPD0=0, fixVPD=FALSE)$GPP
	expect_equal( nrow(gpp), nRow )
	expect_true( all(is.na(gpp)) )	# VPD in computation
	#
	gpp <- lrcFitter$computeLRCGradient(theta0M, Rg=dsDay$Rg, VPD=rep(NA_real_,nRow), Temp=dsDay$Temp, VPD0=0, fixVPD=TRUE)$GPP
	expect_equal( nrow(gpp), nRow )
	expect_true( all(gpp[,"alpha"] == gpp[1,"alpha"]) )	# same value not regarding different k
	expect_true( is.finite(gpp[1,"alpha"]) )	# finite despite NA VPD
	#
	gpp <- lrcFitter$computeLRCGradient(theta0M, Rg=dsDay$Rg, VPD=rep(NA_real_,nRow), Temp=dsDay$Temp, VPD0=0)$GPP
	expect_equal( nrow(gpp), nRow )
	expect_true( all(gpp[-iRowK,"alpha"] == gpp[1,"alpha"]) )	# same value not regarding different k
	expect_true( is.finite(gpp[1,"alpha"]) )	# finite despite NA VPD
	expect_true( is.na(gpp[iRowK,"alpha"]) )
}

test_that("RectangularLRCFitter$predictLRC vector form",{
			lrcFitter <- RectangularLRCFitter()
			test_LRCGRadient_vectorForm(lrcFitter)
			#lrcFitter <- LogisticSigmoidLRCFitter()
		})

test_that("NonrectangularLRCFitter$predictLRC vector form",{
			lrcFitter <- NonrectangularLRCFitter()
			test_LRCGRadient_vectorForm(lrcFitter)
		})

test_LRCGradient <- function(lrcFitter){
	#str(ds)
	ds <- dsNEE
	theta0 <- structure(c(0.05, 27.3333395589509, 0.162207578338878, 2.59392002410639, 185, 1.1
			), .Names = c("k", "beta", "alpha", "RRef","E0","logitconv"))
	res <- lrcFitter$computeLRCGradient(theta0, Rg=ds$Rg_f, VPD=ds$VPD_f, Temp=ds$Temp)
	.numDerivLRC <- function(theta, eps=0.0001, ..., varName="NEP"){
		ans <- matrix( NA, nrow=length(list(...)[[1]]), ncol=length(theta), dimnames=list(NULL,names(theta)))
		i <- 1L
		for( i in seq_along(theta)){
			thetaMinus <- theta; thetaMinus[i] <- theta[i]-eps
			thetaPlus <- theta; thetaPlus[i] <- theta[i]+eps
			fMinus <- lrcFitter$predictLRC(thetaMinus, ...)[[varName]]
			fPlus <- lrcFitter$predictLRC(thetaPlus, ...)[[varName]]
			ans[,i] <- derivI <- (fPlus - fMinus)/(2*eps)
		}
		ans
	}
	varName <- "NEP"
	#varName <- "Reco"
	#varName <- "GPP"
	res20 <- .numDerivLRC(varName=varName, theta=theta0, Rg=ds$Rg_f, VPD=ds$VPD_f, Temp=ds$Temp)
	res2 <- res20[, colnames(res[[varName]])]
	expect_true( all(na.omit(abs(res[[varName]] - res2) < 1e-2)))
	#plot( res[[varName]][,2L] ~ res2[,2L])
	#plot( res$NEP[,4L] ~ res2[,4L])
	#plot( resRectGrad$NEP[,3L] ~ res$NEP[,3L])
}

test_that("RectangularLRCFitter$computeLRCGradient matches numerical estimates",{
			lrcFitter <- RectangularLRCFitter()
			test_LRCGradient(lrcFitter)
			#lrcFitter <- LogisticSigmoidLRCFitter()
			#lrcFitter <- NonrectangularLRCFitter()
		})


test_that("RHLightResponseCostC",{
			.tmp.reloadDll <- function(){
				library.dynam.unload("REddyProc", file.path(.libPaths()[1],"REddyProc") )
				installPkg()
				library.dynam("REddyProc","REddyProc", .libPaths()[1] )
			}
			#
			dss <- subset(dsNEE, as.POSIXlt(dsNEE$sDateTime)$mday %in% 1:8 )
			dssDay <- subset(dss, isDay==TRUE)
			theta <- c(k=0, beta=28.6, alpha=0.18,  RRef=2.87, E0=185)
			flux <- dssDay$NEE_f
			sdFlux <- dssDay$NEE_fsd
			betaPrior <- 26
			sdBetaPrior <- 0.3*betaPrior / sqrt(length(flux))
			parameterPrior <- c(0,betaPrior,8,15, 185)
			sdParameterPrior <- c(NA,sdBetaPrior,NA,NA, NA)
			predR <- lrcFitter$predictLRC(theta
				,dssDay$Rg_f, dssDay$VPD_f, dssDay$Temp, 10.0, FALSE)
			RSSR <- lrcFitter$computeCost( theta, theta, seq_along(theta), flux, sdFlux, parameterPrior, sdParameterPrior
					,Rg=dssDay$Rg_f, VPD=dssDay$VPD_f, Temp=dssDay$Temp)
			LRC_CVersion <- RectangularLRCFitterCVersion()
			tmp <- LRC_CVersion$computeCost( theta, theta, seq_along(theta), flux, sdFlux, parameterPrior, sdParameterPrior
					,Rg=dssDay$Rg_f, VPD=dssDay$VPD_f, Temp=dssDay$Temp)
			#(predR$NEP - tmp)
			expect_true(tmp - RSSR < 1e-8)
		})

.benchmark_RHLightResponseCostC <- function(){
	#require(rbenchmark)
	tmp <- benchmark(
			lrcFitter$computeCost( theta[1:4], theta, 1:4, flux, sdFlux, parameterPrior, sdParameterPrior
				 ,dssDay$Rg_f, dssDay$VPD_f, dssDay$Temp)
			,LRC_CVersion$computeCost( theta[1:4], theta, 1:4, flux, sdFlux, parameterPrior, sdParameterPrior
				,dssDay$Rg_f, dssDay$VPD_f, dssDay$Temp)
		,replications = 10000
					)
	tmp			#speedup of only 2 :(
}

test_that("fitLRC",{
			dss <- subset(dsNEE, as.POSIXlt(dsNEE$sDateTime)$mday %in% 1:8 )
			dssDay <- subset(dss, isDay==TRUE)
			dssNight <- subset(dss, isNight==TRUE)
			dsDay <- data.frame( NEE=dssDay$NEE_f, sdNEE=dssDay$NEE_fsd, Rg=dssDay$Rg_f, Temp=dssDay$Temp, VPD=dssDay$VPD_f)
			#lrcFitter <- RectangularLRCFitter()
			res <- resRect <- lrcFitter$fitLRC(dsDay, E0=185, sdE0=.05*185,RRefNight=mean(dssNight$NEE_f, na.rm=TRUE), lastGoodParameters=NA_real_
					,controlGLPart=partGLControl(nBootUncertainty=10L)
			)
			parNames <- as.vector(lrcFitter$getParameterNames())
			expect_equal( names(res$thetaOpt), parNames )
			expect_equal( names(res$thetaInitialGuess), parNames )
			expect_equal( colnames(res$covParms), parNames )
			expect_true( !all(res$covParms["E0",1:4]==0) )
			#testing Lasslop compliency: different priors, covariance from fit
			res <- lrcFitter$fitLRC(dsDay, E0=185, sdE0=.05*185,RRefNight=mean(dssNight$NEE_f, na.rm=TRUE), lastGoodParameters=NA_real_
				,controlGLPart=partGLControl(nBootUncertainty=0L, isLasslopPriorsApplied=TRUE)
			)
			expect_true( all(res$covParms["E0",1:4]==0) ) # without bootstrap no covariance wiht other parameters
			#dput(res$opt.parms.V)
			.tmp.plot <- function(){
				dsDay <- dsDay[ order(dsDay$Rg), ]
				plot( -NEE ~ Rg, dsDay)		# NEE negative?
				p <- res$thetaOpt
				pred <- lrcFitter$predictLRC(p, Rg=dsDay$Rg, VPD=dsDay$VPD, Temp=dsDay$Temp)
				lines(pred$NEP  ~ dsDay$Rg)
			}
			# testing increasing number of bootstrap samples
			.tmp.f <- function(){
				(res60 <- lrcFitter$fitLRC(dsDay, E0=185, sdE0=.05*185, RRefNight=mean(dssNight$NEE_f, na.rm=TRUE)
						,controlGLPart=partGLControl(nBootUncertainty=100L)
				))
			}
		})

#----------------------------- Logistic Sigmoid
test_that("LogisticSigmoidLRCFitter$computeLRCGradient matches numerical estimates",{
			#lrcFitter <- RectangularLRCFitter()
			lrcFitter <- LogisticSigmoidLRCFitter()
			#lrcFitter <- NonrectangularLRCFitter()
			test_LRCGradient(lrcFitter)
		})

test_that("fitLRC_LogisticSigmoid",{
			dss <- subset(dsNEE, as.POSIXlt(dsNEE$sDateTime)$mday %in% 1:8 )
			dssDay <- subset(dss, isDay==TRUE)
			dssNight <- subset(dss, isNight==TRUE)
			dsDay <- data.frame( NEE=dssDay$NEE_f, sdNEE=dssDay$NEE_fsd, Rg=dssDay$Rg_f, Temp=dssDay$Temp, VPD=dssDay$VPD_f)
			LRCl <- LogisticSigmoidLRCFitter()
			res <- resSig <- LRCl$fitLRC(dsDay, E0=185, sdE0=.05*185,RRefNight=mean(dssNight$NEE_f, na.rm=TRUE), lastGoodParameters=NA_real_
					,controlGLPart=partGLControl(nBootUncertainty=10L)
			)
			expect_true( !all(res$covParms["E0",1:4]==0) )
			#testing Lasslop compliency: different priors, covariance from fit
			res <- LRCl$fitLRC(dsDay, E0=185, sdE0=.05*185,RRefNight=mean(dssNight$NEE_f, na.rm=TRUE), lastGoodParameters=NA_real_
					,controlGLPart=partGLControl(nBootUncertainty=0L, isLasslopPriorsApplied=TRUE)
			)
			expect_true( all(res$covParms["E0",1:4]==0) ) # without bootstrap no covariance wiht other parameters
			#dput(res$opt.parms.V)
			.tmp.plot <- function(){
				# dsDay <- list(...)$dsDay
				dsDay <- dsDay[ order(dsDay$Rg), ]
				plot( -NEE ~ Rg, dsDay)		# NEE negative?
				p <- res$thetaOpt
				#p <- resOpt$theta
				#LRCn$trace(predictLRC, recover); #LRCn$trace(predictLRC)
				pred <- LRCl$predictLRC(p, Rg=dsDay$Rg, VPD=dsDay$VPD, Temp=dsDay$Temp)
				lines(pred$NEP  ~ dsDay$Rg)
				plot( I(pred$NEP+dsDay$NEE) ~ dsDay$Rg); abline(0,0)	# inspect residuals
			}
			# testing increasing number of bootstrap samples
			.tmp.f <- function(){
				(res60 <- LRCl$fitLRC(dsDay, E0=185, sdE0=.05*185, RRefNight=mean(dssNight$NEE_f, na.rm=TRUE), lastGoodParameters=NA_real_
									,controlGLPart=partGLControl(nBootUncertainty=100L)
							))
			}
		})


#----------------------------- Nonrectangular
test_that("NonrectangularLRCFitter$computeGPPGradient matches numerical estimates",{
			#str(ds)
			ds <- dsNEE
			theta0 <- structure(c(0, 27.3333395589509, 0.162207578338878, 2.59392002410639, 185, 1.1
					), .Names = c("k", "beta", "alpha", "RRef","E0","logitconv"))
			lrcFitter <- NonrectangularLRCFitter()
			res <- lrcFitter$computeGPPGradient(Rg=ds$Rg_f, Amax=theta0["beta"], alpha=theta0["alpha"], logitconv=theta0["logitconv"] )
			.numDerivGPP <- function(theta, eps=0.00001, Rg, ...){
				GPPParNames <- c("beta","alpha","logitconv")
				ans <- matrix( NA, nrow=length(list(...)[[1]]), ncol=length(GPPParNames), dimnames=list(NULL,GPPParNames))
				i <- "beta"
				for( i in GPPParNames){
					thetaMinus <- theta; thetaMinus[i] <- theta[i]-eps
					thetaPlus <- theta; thetaPlus[i] <- theta[i]+eps
					fMinus <- lrcFitter$predictGPP(Rg=Rg, Amax=thetaMinus["beta"], alpha=thetaMinus["alpha"], conv = invlogit(thetaMinus["logitconv"]))
					fPlus <- lrcFitter$predictGPP(Rg=Rg, Amax=thetaPlus["beta"], alpha=thetaPlus["alpha"], conv = invlogit(thetaPlus["logitconv"]))
					ans[,i] <- derivI <- (fPlus - fMinus)/(2*eps)
				}
				ans
			}
			res2 <- .numDerivGPP(theta=theta0, Rg=ds$Rg_f, VPD=ds$VPD_f, Temp=ds$Temp)
			expect_true( all(na.omit(abs(res - res2) < 1e-2)))
			#plot( res[,2L] ~ res2[,2L])
		})

test_that("NonrectangularLRCFitter$computeLRCGradient matches numerical estimates",{
			#lrcFitter <- RectangularLRCFitter()
			#lrcFitter <- LogisticSigmoidLRCFitter()
			lrcFitter <- NonrectangularLRCFitter()
			test_LRCGradient(lrcFitter)
		})


test_that("fitLRC_Nonrectangular",{
			dss <- subset(dsNEE, as.POSIXlt(dsNEE$sDateTime)$mday %in% 1:8 )
			dssDay <- subset(dss, isDay==TRUE)
			dssNight <- subset(dss, isNight==TRUE)
			dsDay <- data.frame( NEE=dssDay$NEE_f, sdNEE=dssDay$NEE_fsd, Rg=dssDay$Rg_f, Temp=dssDay$Temp, VPD=dssDay$VPD_f)
			#loadPkg()
			LRCn <- NonrectangularLRCFitter()
			res <- resNonrect <- LRCn$fitLRC(dsDay, E0=185, sdE0=.05*185,RRefNight=mean(dssNight$NEE_f, na.rm=TRUE), lastGoodParameters=NA_real_
					,controlGLPart=partGLControl(nBootUncertainty=10L)
			)
			expect_true( !all(res$covParms["E0",1:4]==0) )
			#testing Lasslop compliency: different priors, covariance from fit
			res <- LRCn$fitLRC(dsDay, E0=185, sdE0=.05*185,RRefNight=mean(dssNight$NEE_f, na.rm=TRUE), lastGoodParameters=NA_real_
					,controlGLPart=partGLControl(nBootUncertainty=0L, isLasslopPriorsApplied=TRUE)
			)
			expect_true( all(res$covParms["E0",1:4]==0) ) # without bootstrap no covariance wiht other parameters
			#dput(res$opt.parms.V)
			.tmp.plot <- function(){
				# dsDay <- list(...)$dsDay
				dsDay <- dsDay[ order(dsDay$Rg), ]
				plot( -NEE ~ Rg, dsDay)		# NEE negative?
				p <- res$thetaOpt
				#p <- resOpt$theta
				#p <- theta0Adj
				#p <- theta0
				#LRCn$trace(predictLRC, recover); #LRCn$trace(predictLRC)
				pred <- LRCn$predictLRC(p, Rg=dsDay$Rg, VPD=dsDay$VPD, Temp=dsDay$Temp)
				lines(pred$NEP  ~ dsDay$Rg)
				plot( I(pred$NEP+dsDay$NEE) ~ dsDay$Rg); abline(0,0)	# inspect residuals
			}
			# testing increasing number of bootstrap samples
			.tmp.f <- function(){
				(res60 <- LRCn$fitLRC(dsDay, E0=185, sdE0=.05*185, RRefNight=mean(dssNight$NEE_f, na.rm=TRUE)
									,controlGLPart=partGLControl(nBootUncertainty=100L)
							))
				sqrt(diag(res60$covParms))/res60$thetaOpt
			}
		})

###------------------------------ error on inverting hessian ------
args <- list(
dsDay = structure(list(sDateTime = structure(
  c(987401700, 987403500, 
    987405300, 987407100, 987408900, 987410700, 987412500, 987414300, 
    987416100, 987417900, 987419700, 987421500, 987423300, 987425100, 
    987426900, 987428700, 987430500, 987432300, 987434100, 987435900, 
    987437700, 987488100, 987489900, 987491700, 987493500, 987495300, 
    987497100, 987498900, 987511500, 987513300, 987515100, 987516900, 
    987518700, 987520500, 987522300, 987524100, 987572700, 987574500, 
    987576300, 987578100, 987579900, 987581700, 987583500, 987585300, 
    987587100, 987588900, 987590700, 987592500, 987594300, 987596100, 
    987597900, 987599700, 987601500, 987603300, 987605100, 987606900, 
    987608700, 987610500, 987659100, 987662700, 987664500, 987666300, 
    987668100, 987669900, 987671700, 987673500, 987675300, 987677100, 
    987678900, 987680700, 987682500, 987684300, 987686100, 987687900, 
    987689700, 987691500, 987693300, 987695100, 987696900), 
  class = c("POSIXct", "POSIXt"), tzone = "UTC"), 
  NEE = c(
    0.35400003194809, 0.532000005245209, 
    0.452000021934509, 0.887999951839447, 0.284999996423721, 0.696999967098236, 
    0.50900000333786, 0.435000032186508, 0.32600000500679, 0.445999979972839, 
    0.397000014781952, 1.02100002765656, 0.50299996137619, 0.234999999403954, 
    0.340000003576279, 0.472000002861023, 0.395000010728836, 0.155000001192093, 
    0.21299996972084, 0.679999947547913, 0.42399999499321, 0.471999943256378, 
    0.187000036239624, -0.318000018596649, 0.64599996805191, 0.204000011086464, 
    0.367000013589859, -1.28100001811981, 0.0670000314712524, 1.12699997425079, 
    0.709000051021576, 1.16599988937378, 3.26600003242493, 0.282000005245209, 
    1.04100000858307, 1.20700001716614, 0.533999979496002, -0.175999999046326, 
    -0.256999999284744, -1.32000005245209, 0.188999950885773, 1.66199994087219, 
    0.196999996900558, 0.566999971866608, 0.039000004529953, 0.725000023841858, 
    -0.650000035762787, -0.583000004291534, 0.441000014543533, 1.19400000572205, 
    1.04999995231628, 0.671000003814697, 0.187000006437302, -0.412999987602234, 
    -0.306999981403351, 0.785999953746796, 0.638999998569489, 0.738000094890594, 
    -0.340000003576279, 1.52699995040894, 0.712999999523163, 0.130999982357025, 
    -0.101999998092651, -0.199999988079071, 0.453000009059906, -0.0219999849796295, 
    1.14800000190735, -0.293000012636185, 0.880000054836273, 0.678999960422516, 
    0.795000016689301, -0.0259999930858612, 0.787999987602234, 1.27799999713898, 
    -0.248999997973442, -0.462000012397766, 0.874999940395355, 0.51800000667572, 
    0.36300003528595), 
  sdNEE = c(
    0.809749957666536, 0.628224972940061, 
    0.659803884323685, 0.662579436599356, 0.650053791385915, 0.660612423407973, 
    0.610460777640826, 0.542368468171728, 0.594734288978246, 0.579223376405118, 
    0.630268911933181, 0.607940657100616, 0.659803884323685, 0.575262505769259, 
    0.475729669132864, 0.648430658832156, 0.682795725496793, 0.577201698568239, 
    0.698479742960692, 0.71378981486918, 0.606161513437173, 0.786607636006147, 
    0.806993072704408, 0.684570302164522, 0.723004813652185, 0.623127617572988, 
    0.718289427337163, 0.732915617698706, 0.718289427337163, 0.58019133449497, 
    0.685697693495996, 0.668489300649783, 1.07041296286867, 0.398845289016157, 
    0.470392568692144, 0.697977377661453, 0.787856461757981, 1.03571321161812, 
    0.938838173853171, 0.697215779779815, 0.453336654077684, 0.882031438984157, 
    1.16052219915433, 0.555610054123532, 0.401003326590866, 0.578448314947156, 
    0.597527646859134, 0.599727434290068, 0.579782790464044, 0.5773945573756, 
    0.599727434290068, 0.536770541502652, 0.573246404355542, 1.08054803991486, 
    0.733622677330087, 0.655104966509601, 0.752326787415782, 0.529818303846866, 
    0.806993072704408, 0.806695090744094, 0.737711291476921, 0.576470661150769, 
    0.72864610563661, 0.677348267331516, 0.653979307248866, 0.48473545601523, 
    1.01680853513454, 0.981286911668651, 0.466287618250474, 0.331923568560297, 
    1.04350607959198, 0.48138096273862, 0.563125213132485, 1.01610379909119, 
    0.727864584639489, 0.604706926370824, 0.618848471216863, 0.691699568925105, 
    0.461768677852474), 
  Temp = c(
    1.20500004291534, 1.60399997234344, 
    2.35199999809265, 1.41700005531311, 1.60300004482269, 1.82299995422363, 
    1.86800003051758, 2.2409999370575, 2.17499995231628, 2.28500008583069, 
    2.125, 2.25399994850159, 2.41599988937378, 2.33800005912781, 
    2.21099996566772, 1.99300003051758, 2.09400010108948, 1.99899995326996, 
    2.05100011825562, 2.09999990463257, 2.17000007629395, 2.04200005531311, 
    1.39800000190735, 1.40199995040894, 1.68700003623962, 1.88300001621246, 
    1.87999999523163, 1.52900004386902, 1.86699998378754, 2.59100008010864, 
    2.64100003242493, 2.75200009346008, 4.47800016403198, 4.32499980926514, 
    4.64300012588501, 3.9210000038147, -1.807000041008, -1.78199994564056, 
    -0.637000024318695, 1.91299998760223, 3.66100001335144, 4.02299976348877, 
    4.33199977874756, 4.75299978256226, 5.06799983978271, 4.91200017929077, 
    6.28700017929077, 6.38600015640259, 6.65299987792969, 6.44199991226196, 
    6.57200002670288, 6.60300016403198, 7.10500001907349, 6.75799989700317, 
    7.23000001907349, 7.92500019073486, 7.97499990463257, 6.31699991226196, 
    1.37300002574921, 1.57200002670288, 1.83299994468689, 2.93600010871887, 
    2.7590000629425, 2.99399995803833, 4.08699989318848, 5.32800006866455, 
    5.83099985122681, 5.95300006866455, 5.80900001525879, 5.70599985122681, 
    5.93200016021729, 6.03800010681152, 7.23099994659424, 6.81300020217896, 
    7.46600008010864, 7.76999998092651, 8.625, 8.92500019073486, 
    9.10000038146973), 
  VPD = c(
    0.200011223554611, 0.205833956599236, 
    0.231631278991699, 0.223395854234695, 0.219540312886238, 0.216062813997269, 
    0.202776655554771, 0.19389633834362, 0.178689301013947, 0.165691033005714, 
    0.15668548643589, 0.158136337995529, 0.15270359814167, 0.144625097513199, 
    0.13615371286869, 0.12699282169342, 0.12080705165863, 0.112930752336979, 
    0.106267288327217, 0.0995310693979263, 0.0928854197263718, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0252391025424004, 0.307956606149673, 
    1.0468270778656, 1.16496980190277, 0.834864974021912, 1.00261807441711, 
    1.2131587266922, 1.90804219245911, 2.35116386413574, 2.20005965232849, 
    2.20672249794006, 2.39285826683044, 2.51623201370239, 2.50632429122925, 
    3.08190584182739, 3.11264896392822, 3.08240079879761, 2.98003649711609, 
    3.3766405582428, 4.0762357711792, 4.41115427017212, 4.14953422546387, 
    4.072425365448, 4.51607370376587, 4.21010255813599, 3.14566493034363, 
    0.573594272136688, 0.568167388439178, 0.453360319137573, 0.430106312036514, 
    0.476890712976456, 0.545533657073975, 0.818514168262482, 1.62483441829681, 
    1.95072364807129, 2.30293464660645, 2.07698583602905, 2.13552165031433, 
    2.14131665229797, 2.20398330688477, 2.91198372840881, 2.90875840187073, 
    3.2385835647583, 3.56008434295654, 4.03070735931396, 4.26191759109497, 
    4.86756706237793), 
  Rg = c(
    19.71875, 105.892852783203, 131.607131958008, 
    37.4553565979004, 59.8214302062988, 53.035717010498, 88.5714263916016, 
    141.741073608398, 131.473220825195, 157.857147216797, 75.2678604125977, 
    89.7767868041992, 129.866073608398, 115.044647216797, 115.044647216797, 
    58.0803604125977, 47.7232131958008, 21.1339282989502, 38.4375, 
    36.9196395874023, 25.9285717010498, 9.4776782989502, 10.6741065979004, 
    39.8660736083984, 83.5714263916016, 111.116065979004, 101.071426391602, 
    91.6071395874023, 99.6428527832031, 170.982147216797, 185.178558349609, 
    215.982131958008, 418.75, 299.821411132812, 216.607147216797, 
    190.267868041992, 14.8169631958008, 37.3660697937012, 110.223213195801, 
    225.178573608398, 313.392852783203, 365.178558349609, 436.160705566406, 
    508.482147216797, 532.589294433594, 507.589294433594, 588.392883300781, 
    655.803588867188, 626.785705566406, 622.321411132812, 654.464294433594, 
    644.642883300781, 646.875, 450.892852783203, 477.678558349609, 
    463.839294433594, 408.035705566406, 252.991073608398, 14.5982141494751, 
    11.9821424484253, 96.7410659790039, 173.4375, 134.866073608398, 
    145, 239.732147216797, 318.75, 402.232147216797, 403.571441650391, 
    324.107147216797, 303.258911132812, 379.017852783203, 353.571441650391, 
    575.446411132812, 376.339294433594, 445.089294433594, 496.428558349609, 
    463.839294433594, 402.678558349609, 337.5), 
  isDay = c(
    TRUE, TRUE, 
    TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, 
    TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, 
    TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, 
    TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, 
    TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, 
    TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, 
    TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE
  ), 
  isNight = c(
    FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, 
    FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, 
    FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, 
    FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, 
    FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, 
    FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, 
    FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, 
    FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, 
    FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE
  )), 
  row.names = c(
    92749L, 92750L, 92751L, 92752L, 92753L, 92754L, 
    92755L, 92756L, 92757L, 92758L, 92759L, 92760L, 92761L, 92762L, 
    92763L, 92764L, 92765L, 92766L, 92767L, 92768L, 92769L, 92797L, 
    92798L, 92799L, 92800L, 92801L, 92802L, 92803L, 92810L, 92811L, 
    92812L, 92813L, 92814L, 92815L, 92816L, 92817L, 92844L, 92845L, 
    92846L, 92847L, 92848L, 92849L, 92850L, 92851L, 92852L, 92853L, 
    92854L, 92855L, 92856L, 92857L, 92858L, 92859L, 92860L, 92861L, 
    92862L, 92863L, 92864L, 92865L, 92892L, 92894L, 92895L, 92896L, 
    92897L, 92898L, 92899L, 92900L, 92901L, 92902L, 92903L, 92904L, 
    92905L, 92906L, 92907L, 92908L, 92909L, 92910L, 92911L, 92912L, 
    92913L), class = "data.frame"),
E0 = 255.598188786627,
sdE0 =63.36264,
RRefNight = 3.47679878519779,
controlGLPart = list(
  LRCFitConvergenceTolerance = 0.001, nLRCFitConvergenceTolerance = 0.001, 
  nBootUncertainty = 0L, minNRecInDayWindow = 10L, isAssociateParmsToMeanOfValids = TRUE, 
  isLasslopPriorsApplied = TRUE, isUsingLasslopQualityConstraints = FALSE, 
  isSdPredComputed = FALSE, isFilterMeteoQualityFlag = FALSE, 
  isBoundLowerNEEUncertainty = TRUE, fixedTRefAtNightTime = NA, 
  isExtendTRefWindow = TRUE, smoothTempSensEstimateAcrossTime = TRUE, 
  isNeglectPotRadForNight = FALSE, isNeglectVPDEffect = FALSE, 
  isRefitMissingVPDWithNeglectVPDEffect = FALSE, fixedTempSens = structure(list(
    E0 = NA_real_, sdE0 = NA_real_, RRef = NA_real_), 
    class = "data.frame", row.names = c(NA, -1L)), 
  replaceMissingSdNEEParms = c(perc = 0.2, minSd = 0.7), 
  neglectNEEUncertaintyOnMissing = FALSE, minPropSaturation = NA, 
  useNightimeBasalRespiration = FALSE),
lastGoodParameters = c(
  k = 0.939127165902557, beta = 3.71354808845461, alpha = 0.0382004665603087, 
                       RRef = 1.05034157955867, E0 = 41.1118669819426)
)

test_that("error on inverting hessian",{
  lrcFitter <- RectangularLRCFitter$new()
  #lrcFitter$trace(fitLRC, browser)
  #lrcFitter$trace(optimLRCBounds, browser)
  ans <- do.call(lrcFitter$fitLRC, args)
  expect_true(all(is.na(ans$thetaOpt)))
  #expect_equal(ans$convergence, 1006) # now with this data isFixedVPD is used
})

Try the REddyProc package in your browser

Any scripts or data that you put into this service are public.

REddyProc documentation built on March 18, 2022, 5:41 p.m.