From 7186f31391cdf0b573517a27e85c7f877548bc92 Mon Sep 17 00:00:00 2001 From: ivar <amvdw95@gmail.com> Date: Fri, 25 Sep 2015 10:17:33 +0000 Subject: [PATCH] error occurs when an observation is taken exactly at midnight UTC (00:00). This causes a problem to calculate the n value because hr and mi variables are empty. I made a quick fix by setting n value to 24 if an observation is taken at midnight. --- da/stilt/stilt.co2.simu.2015.Sep.bc.r | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/da/stilt/stilt.co2.simu.2015.Sep.bc.r b/da/stilt/stilt.co2.simu.2015.Sep.bc.r index c985d1c..ea7a6d8 100755 --- a/da/stilt/stilt.co2.simu.2015.Sep.bc.r +++ b/da/stilt/stilt.co2.simu.2015.Sep.bc.r @@ -556,12 +556,21 @@ flog.info('eventids: %s',eventids[mm], name='logger.b') #June 23 hr=substring(dd,12,13) mi=substring(dd,15,16) + flog.info('dd: %s, length dd: %s,hr: %s, mi: %s',dd,length(dd),hr,mi,name='logger.b') + n = 24-floor(as.numeric(hr) + as.numeric(mi)/60) + if (nchar(dd,type='width') ==10) + { + n=24 + flog.info('No hr and mi, set n to 24',name='logger.b') + } + print("XXXn") print(n) datevalid=dateall[1]+0.5*3600-(0:(ntimes-1))*3600 #ixflux=(1:ntimes)[(datevalid<=xx)][1:endtime] #time backward #ixflux=(1:ntimes)[(datevalid<=xx)][1:(endtime+n)] + flog.info('n: %s, endtime: %s',n,endtime,name='logger.b') ixflux <-array(n:(endtime+n-1),dim=c(240)) flog.info('ixflux endtime: %s,%s,%s',endtime,n,as.numeric(hr)+(as.numeric(hr)/60),name='logger.b') -- GitLab