def _test2(): append=0 for fpart in ['dxc-op','dxc-cl']: g1 = vutils.opendss('anninputs.dss') g2 = vutils.opendss('annoutputs.dss') g1.filterBy(fpart) refs = g1[:] tw = vutils.timewindow('01oct1975 0000 - 01sep1991 0000') #tw = vutils.timewindow('01oct1975 0000 - 01oct1976 0000') inps = [] for i in range(len(refs)): inps.append(vutils.interpolate(DataReference.create(refs[i],tw).getData(),'1day')) inputs = [] for i in range(len(inps)): print 'Building inputs for ',inps[i] inputs=inputs+buildinput(inps[i],7,10,7) # weekly averages print 'Built inputs' outputs = [] ccc_ref = vutils.findpath(g2,'//ccc/ec///%s/'%fpart)[0] outputs.append(vutils.interpolate(DataReference.create(ccc_ref,tw).getData(),'1day')) print 'Built outputs' print 'Dumping patterns' if append: dump_patterns(inputs,outputs,'junk',0.75,365,1) else: dump_patterns(inputs,outputs,'junk',0.75,365,append) append = 1
def testspline(): from vutils import opendss, findpath, timewindow, tabulate infile='/delta/data/dss/dayflo.dss' inpath='/DELTA/OUT/FLOW//1day//' tw_str='01JAN1999 0000 - 30JUN1999 2400' g=opendss(infile) ref = findpath(g,inpath)[0] ref = DataReference.create(ref,timewindow(tw_str)) rts=interpolate(ref,outint='15min',offset=48) tabulate(rts)
def testlinear(): from vutils import opendss, findpath, timewindow, tabulate infile='h:/data/dss/IEP/hydro.dss' inpath='/RLTM\+CHAN/RSAC155/FLOW//1HOUR/CDEC/' tw_str='16JAN1999 1200 - 21JAN1999 1600' g=opendss(infile) ref = findpath(g,inpath)[0] ref = DataReference.create(ref,timewindow(tw_str)) rts=interplinear(ref) tabulate(rts,ref.getData())
def _test3(): from ANN import fnet_cccec fpart = 'dxc-op' g1 = vutils.opendss('anninputs.dss') g2 = vutils.opendss('annoutputs.dss') g1.filterBy(fpart) g2.filterBy(fpart) refs = g1[:] tw = vutils.timewindow('01oct1975 0000 - 01sep1991 0000') #tw = vutils.timewindow('01oct1975 0000 - 01oct1976 0000') inps = [] for i in range(len(refs)): inps.append(vutils.interpolate(DataReference.create(refs[i],tw).getData(),'1day')) inputs = [] for i in range(len(inps)): print 'Building inputs for ',inps[i] inputs=inputs+buildinput(inps[i],7,10,7) # weekly averages print 'Built inputs' outputs = [] ccc_ref = vutils.findpath(g2,'//ccc/ec///%s/'%fpart)[0] outputs.append(vutils.interpolate(DataReference.create(ccc_ref,tw).getData(),'1day')) mi = MultiIterator(inputs) import jarray ninps = len(inputs) input = jarray.zeros(ninps,'f') output = jarray.zeros(1,'f') ann = fnet_cccec() ndata = len(inputs[0]) for input_no in range(365): mi.advance() outdata = jarray.zeros(ndata,'f') while input_no < ndata: el = mi.getElement() i=0 while i < ninps: input[i] = el.getY(i) i=i+1 ann.engine(input,output,0) outdata[input_no] = output[0] mi.advance() input_no=input_no+1 # stime = inputs[0].getStartTime() ti = inputs[0].getTimeInterval() rtsout = vutils.RegularTimeSeries('/ann/ccc_out/ec///annutils/',str(stime),\ str(ti),outdata) vutils.plot(rtsout,outputs[0]) rtsout = (rtsout-0.140516)/0.000396563 vutils.writedss('annout.dss','/ann/ccc_out/ec///annutils/',rtsout)
def _test1(): g=vutils.opendss('/delta2/ann/hydrologies/sim809anndv.dss') refs = vutils.findpath(g,'//ndo/flow-ndo///') tw = vutils.timewindow('01jan1974 0000 - 01jan1992 0000') inps = [] for i in range(len(refs)): inps.append(vutils.interpolate(DataReference.create(refs[i],tw).getData(),'1day')) print 'Got data for ',tw scaling = 8.99649e-07 shift = 0.233677 crush(inps[0],scaling,shift) print 'Crushed data' inputs = buildinput(inps[0],8,10,7) print 'Built inputs' outputs = inps[:] print 'Dumping patterns' dump_patterns(inputs,outputs,'junk',0.75)
#!/usr/bin/env /site/scripts/vscript import sys, os, vutils def display_missing(ds): dsi = ds.getIterator() while not dsi.atEnd(): el = dsi.getElement() begin_date = None while not Constants.DEFAULT_FLAG_FILTER.isAcceptable(el) \ and not dsi.atEnd(): if begin_date == None: begin_date = el.getXString() end_date = el.getXString() dsi.advance() el = dsi.getElement() #print el if begin_date != None: print 'Missing for %s to %s'%(begin_date,end_date) if dsi.atEnd(): break dsi.advance() if len(sys.argv) !=3 : raise "Usage: showmissing dssfile pathname" dssfile = sys.argv[1] pathname = sys.argv[2] g=opendss(dssfile) refs = vutils.findpath(g,pathname) if refs == None or len(refs) == 0: raise "No data found for %s & %s"%(dssfile,pathname) for ref in refs: display_missing(ref.getData()) #