Пример #1
0
def compare_dss_files(file1, file2, showPlot=False, outputFile=None, outputPathFile=None):
    """
    Simply compares the files and outputs differences if any of those that differ and lists mismatching pathnames in either
    """
    g1 = vutils.opendss(file1)
    g2 = vutils.opendss(file2)
    print 'Comparing %s to %s' % (file1, file2)
    print '%12s\t%32s' % ('DIFFERENCE', 'PATHNAME')
    if outputPathFile:
        opf_handle=open(outputPathFile, 'wb')
        opf = csv.writer(opf_handle, delimiter=",", quotechar='"', quoting=csv.QUOTE_MINIMAL)
        opf.writerow([file1,file2])
    no_diff=True
    for ref1 in g1:
        p1 = ref1.pathname
        found = False
        for ref2 in g2:
            p2 = ref2.pathname
            if matches(p1, p2):
                found = True
                diff = ref2.data - ref1.data
                absdiff = diff.createSlice(diff.getTimeWindow())
                vtimeseries.apply(absdiff, math.fabs)
                diff_total = vtimeseries.total(absdiff)
                if (diff_total > 1e-06) :
                    no_diff=False
                    if showPlot: plot(ref1.data, ref2.data)
                    print '%10.2f\t%32s' % (diff_total, p1)
                    if outputFile:
                        diffp = set_part(p1, 'DIFF-%s-%s' % (os.path.basename(file1), os.path.basename(file2)), Pathname.A_PART)
                        writedss(outputFile, str(diffp), diff)
                    if outputPathFile:
                        opf.writerow([p1, p1, diff_total])
                break
        if (not found):
            no_diff=False
            print 'No matching path: %s in file %s NOT found in file %s' % (p1, file1, file2)
            if outputPathFile: opf.writerow([p1, "", "M"])
    for ref2 in g2:
        p2 = ref2.pathname
        found = False
        for ref1 in g1:
            p1 = ref1.pathname
            if matches(p1, p2):
                found = True
                break
        if (not found):
            no_diff=False
            print 'No matching path: %s in file %s NOT found in file %s' % (p2, file2, file1)
            if outputPathFile: opf.writerow(["", p2, "M"])
    if no_diff:
        print 'NO DIFFERENCE ACROSS ENTIRE FILEs %s and %s'%(file1,file2)
    if outputPathFile: opf_handle.close()
Пример #2
0
def plot_vol_calcs(tidefile,chan,tw,run_name):
    volume = get_volume_data(tidefile, chan, tw)
    upflow = get_upstream_flow_data(tidefile, chan, tw)
    downflow = get_downstream_flow_data(tidefile, chan, tw)
    #import vdisplay
    #vdisplay.plot(volume)
    initial_volume = volume[0].y
    final_volume = volume[len(volume) - 1].y
    ndata = len(upflow)
    vol = [initial_volume]
    for i in range(0, ndata):
        vol.append(vol[i] + (upflow[i].y - downflow[i].y) * time_step)
    print 'Initial Volume: %f -> Final Volume: %f' % (initial_volume, final_volume)
    print 'Initial Volume: %f -> Final Volume: %f' % (initial_volume, vol[ndata - 1])
    print 'Difference in Volume %f' % (final_volume-vol[ndata-1])
    from vista.set import RegularTimeSeries, DataSetAttr
    attr = volume.getAttributes().createClone()
    attr.setTypeName("VOLCALC")
    volcalc = RegularTimeSeries("/VOL/%s/VOLCALC//1HOUR/%s/"%(chan,run_name),"01OCT1974 0000","1HOUR",vol[1:])
    volcalc.setAttributes(attr)
    import vdisplay
    vdisplay.plot(volcalc,volume)
    vdisplay.plot(volcalc-volume)
Пример #3
0
def plot_vol_calcs(tidefile,chan,tw,run_name):
    volume = get_volume_data(tidefile, chan, tw)
    upflow = get_upstream_flow_data(tidefile, chan, tw)
    downflow = get_downstream_flow_data(tidefile, chan, tw)
    #import vdisplay
    #vdisplay.plot(volume)
    initial_volume = volume[0].y
    final_volume = volume[len(volume) - 1].y
    ndata = len(upflow)
    vol = [initial_volume]
    for i in range(0, ndata):
        vol.append(vol[i] + (upflow[i].y - downflow[i].y) * time_step)
    print 'Initial Volume: %f -> Final Volume: %f' % (initial_volume, final_volume)
    print 'Initial Volume: %f -> Final Volume: %f' % (initial_volume, vol[ndata - 1])
    print 'Difference in Volume %f' % (final_volume-vol[ndata-1])
    from vista.set import RegularTimeSeries, DataSetAttr
    attr = volume.getAttributes().createClone()
    attr.setTypeName("VOLCALC")
    volcalc = RegularTimeSeries("/VOL/%s/VOLCALC//1HOUR/%s/"%(chan,run_name),"01OCT1974 0000","1HOUR",vol[1:])
    volcalc.setAttributes(attr)
    import vdisplay
    vdisplay.plot(volcalc,volume)
    vdisplay.plot(volcalc-volume)
Пример #4
0
import cdec
import vdisplay
from vutils import *
if __name__=='__main__':
    station_name='MRZ'
    sensor_number=1811
    start_date="04/01/2013"
    end_date="07/01/2014"
    rts=cdec.retrieve(station_name,sensor_number,start_date,end_date,verbose=1)
    if rts: vdisplay.plot(rts)
    writedss('z:/temp/cdec.dss',rts.name,rts)
Пример #5
0
import cdec
import vdisplay
if __name__=='__main__':
    station_name='GGS'
    sensor_number=1902
    start_date="10/01/2000"
    end_date="05/01/2001"
    rts=cdec.retrieve(station_name,sensor_number,start_date,end_date,verbose=1)
    if rts: vdisplay.plot(rts)
Пример #6
0
import cdec
import vdisplay

if __name__ == "__main__":
    station_name = "GGS"
    sensor_number = 1902
    start_date = "10/01/2000"
    end_date = "05/01/2001"
    rts = cdec.retrieve(station_name, sensor_number, start_date, end_date, verbose=1)
    if rts:
        vdisplay.plot(rts)
Пример #7
0
def compare_dss_files(file1,
                      file2,
                      showPlot=False,
                      outputFile=None,
                      outputPathFile=None):
    """
    Simply compares the files and outputs differences if any of those that differ and lists mismatching pathnames in either
    """
    g1 = vutils.opendss(file1)
    g2 = vutils.opendss(file2)
    print 'Comparing %s to %s' % (file1, file2)
    print '%12s\t%32s' % ('DIFFERENCE', 'PATHNAME')
    if outputPathFile:
        opf_handle = open(outputPathFile, 'wb')
        opf = csv.writer(opf_handle,
                         delimiter=",",
                         quotechar='"',
                         quoting=csv.QUOTE_MINIMAL)
        opf.writerow([file1, file2])
    no_diff = True
    for ref1 in g1:
        p1 = ref1.pathname
        found = False
        for ref2 in g2:
            p2 = ref2.pathname
            if matches(p1, p2):
                found = True
                diff = ref2.data - ref1.data
                absdiff = diff.createSlice(diff.getTimeWindow())
                vtimeseries.apply(absdiff, math.fabs)
                diff_total = vtimeseries.total(absdiff)
                if (diff_total > 1e-06):
                    no_diff = False
                    if showPlot: plot(ref1.data, ref2.data)
                    print '%10.2f\t%32s' % (diff_total, p1)
                    if outputFile:
                        diffp = set_part(
                            p1, 'DIFF-%s-%s' %
                            (os.path.basename(file1), os.path.basename(file2)),
                            Pathname.A_PART)
                        writedss(outputFile, str(diffp), diff)
                    if outputPathFile:
                        opf.writerow([p1, p1, diff_total])
                break
        if (not found):
            no_diff = False
            print 'No matching path: %s in file %s NOT found in file %s' % (
                p1, file1, file2)
            if outputPathFile: opf.writerow([p1, "", "M"])
    for ref2 in g2:
        p2 = ref2.pathname
        found = False
        for ref1 in g1:
            p1 = ref1.pathname
            if matches(p1, p2):
                found = True
                break
        if (not found):
            no_diff = False
            print 'No matching path: %s in file %s NOT found in file %s' % (
                p2, file2, file1)
            if outputPathFile: opf.writerow(["", p2, "M"])
    if no_diff:
        print 'NO DIFFERENCE ACROSS ENTIRE FILEs %s and %s' % (file1, file2)
    if outputPathFile: opf_handle.close()