def TestUtcTimeVector(): """ Just to verify that 64bits int array are convertible to utctime in enki. """ llv=np.ones(10, np.int64) v=Enp.UtcTimeVector.FromNdArray(llv) print "Size of long long alias UtcTime vector is ", v.size() utc = enki.Calendar() Tnow= utc.trim(enki.utctimeNow(), enki.deltahours(1)); v.push_back(Tnow) print "Size after adding Tnow to the list is ", v.size() Xnow=v[10] print "Original timestamp is ", utc.toString(Tnow), " and roundtrip tstamp is ", utc.toString(Xnow) return
def IncrementalTesting(): utc = enki.Calendar() Tnow = utc.trim(enki.utctimeNow(), enki.deltahours(1)); timeAxis = enki.FixedIntervalTimeAxis(Tnow, enki.deltahours(1), 24) FxSinus = enki.FxSinus(10.0, -5.0, 15.0, 10.0, Tnow, enki.deltahours(24)) ts1 = enki.FxSinusTs(FxSinus, 'ts1', 1, enki.InputTs, timeAxis); print ts1.getValue(timeAxis.getTime(2)) #print("Size of container is %s"%tscontainer.size()) enkiService=enki.EnkiApiService() enkiService.setRootPath(enkiModelPath) runCfg=enki.RunConfiguration() runCfg.calculationModelName='enki' # Testing vector tv= enki.UtcTimeVector() tv.push_back(Tnow) qv= enki.IntVector() qv.push_back(0);qv.push_back(0);qv.push_back(0); pvv= np.array([1.0, 2.0, 3.0, 4.0], np.float32) #print "Now it works..:", Ex.rms(pvv) #xvv=enki.MakeFloatVectorFromNp(pvv) #print xvv.size(), " xvv " , xvv[0] vv= enki.FloatVector() vv.push_back(1.0) vv.push_back(2.0) vv.push_back(3.0) vv.push_back(4.0) npvv=np.fromiter(vv, np.float32) print "Ok, got np array:", npvv #xvv=Ex.MakeFloatVector(npvv) xxv=Enp.FloatVector.FromNdArray(pvv) print "Ok, now a float vector,", xxv.size() #-- now check float64 FloatVector dv= np.ones(3, dtype=np.float64); fdv= Enp.FloatVector.FromNdArrayDouble(dv); print "Ok, now a float vector from np.float64", fdv.size() for i in range(fdv.size()): print i, "=", fdv[i] #-- xx rst1=enki.RasterFloat(2, 2, xxv); print "Raster from flat float array ", rst1.nRows(), " x ", rst1.nCols(), "=", rst1.nCells() #xnpvv=enki.MakeFloatVectorFromNp(ct.c_void_p(npvv.ctypes.data),ct.c_int(3)) #print "Round trip ",xnpvv.size() qv= enki.IntVector() qv.push_back(0);qv.push_back(0);qv.push_back(0); factory= enki.TsFactory(); metaInfo=enki.MetaInfo(1, "InstantRunoff", "InstantRunoff", 0, enki.InputTs) pts= factory.CreatePointTs(metaInfo, 3, Tnow, enki.deltahours(1), vv, qv); print "tv size=", tv.size(), " vv.size", vv.size(), " pts.Count()=", pts.nPoints() for i in range(pts.nPoints()): ti=pts.getTime(i) print i, utc.toString(ti), pts.getValue(i) runCfg.regionName='SentralReg' runCfg.Tstart = utc.time(enki.YMDhms(2012, 01, 01, 00, 00, 00)) runCfg.deltaT=enki.deltahours(1) runCfg.nSteps=24 runCfg.runType=enki.UpdateRun