def rename(file,oldf,newfile,newf): g=vutils.opendss(file) g.filterBy(PathPartPredicate(oldf,Pathname.F_PART),1) if len(g) == 0: raise SystemExit,'No FPART: %s in DSS FILE: %s'%(oldf,file) for ref in g: path = ref.getPathname() ds = ref.getData() path.setPart(Pathname.F_PART,newf) print 'OLD: %s -> NEW: %s'%(str(ref.getPathname()),str(path)) vutils.writedss(newfile,str(path),ds) g.removeDataReference(ref)
def rename(file, oldf, newfile, newf): g = vutils.opendss(file) g.filterBy(PathPartPredicate(oldf, Pathname.F_PART), 1) if len(g) == 0: raise SystemExit, 'No FPART: %s in DSS FILE: %s' % (oldf, file) for ref in g: path = ref.getPathname() ds = ref.getData() path.setPart(Pathname.F_PART, newf) print 'OLD: %s -> NEW: %s' % (str(ref.getPathname()), str(path)) vutils.writedss(newfile, str(path), ds) g.removeDataReference(ref)
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 writewdl(filename, result): for key in result: its = result[key].toITS() writedss(filename, its.name, its)