예제 #1
0
파일: coverage-test.py 프로젝트: bje-/NEMO
 def test_003(self):
     c = nem.Context()
     # Add 25 DR generators so that the abbreviated legend is used.
     for i in range(25):
         dr = nem.generators.DemandResponse(polygons.wildcard, 100, 0)
         c.generators += [dr]
     print len(c.generators)
     nem.run(c)
     nem.plot(c, filename='foo.png')
     os.unlink('foo.png')
예제 #2
0
파일: coverage-test.py 프로젝트: bje-/NEMO
 def test_002(self):
     c = nem.Context()
     # Make sure there is unserved energy by setting 2nd and
     # subsequent generator capacity to 0.
     for g in c.generators[1:]:
         g.set_capacity(0)
     nem.run(c)
     nem.plot(c, filename='foo.png')
     os.unlink('foo.png')
     nem.plot(c, filename='foo.png', spills=True)
     os.unlink('foo.png')
예제 #3
0
assert context.nsp_limit >= 0 and context.nsp_limit <= 1, \
    "NSP limit must be in the interval [0,1]"

# Apply each demand modifier in the order given on the command line.
if args.demand_modifier is not None:
    for arg in args.demand_modifier:
        scenarios.demand_switch(arg)(context)

capacities = []
replayfile = open(args.f)
for line in replayfile:
    if re.search(r'^\s*$', line):
        continue
    if re.search(r'^\s*#', line):
        print line,
        continue
    if not re.search(r'^\s*\w+:\s*\[.*\]\s*.?$', line):
        print 'skipping malformed input:', line
        continue
    m = re.match(r'^\s*(\w+):\s*\[(.*)\]\s*.?$', line)
    scenario = m.group(1)
    print 'scenario', scenario
    capacities = m.group(2).split(',')
    scenarios.supply_switch(scenario)(context)
    capacities = [float(elt) for elt in capacities]  # str -> float
    run_one(capacities)
    print

    if args.x:  # pragma: no cover
        nem.plot(context, spills=args.spills)
예제 #4
0
파일: replay.py 프로젝트: bje-/NEMO
assert context.nsp_limit >= 0 and context.nsp_limit <= 1, \
    "NSP limit must be in the interval [0,1]"

# Apply each demand modifier in the order given on the command line.
if args.demand_modifier is not None:
    for arg in args.demand_modifier:
        scenarios.demand_switch(arg)(context)

capacities = []
replayfile = open(args.f)
for line in replayfile:
    if re.search(r'^\s*$', line):
        continue
    if re.search(r'^\s*#', line):
        print line,
        continue
    if not re.search(r'^\s*[\w\-\+]+:\s*\[.*\]\s*.?$', line):
        print 'skipping malformed input:', line
        continue
    m = re.match(r'^\s*([\w\-\+]+):\s*\[(.*)\]\s*.?$', line)
    scenario = m.group(1)
    print 'scenario', scenario
    capacities = m.group(2).split(',')
    scenarios.supply_switch(scenario)(context)
    capacities = [float(elt) for elt in capacities]  # str -> float
    run_one(capacities)
    print

    if args.x:  # pragma: no cover
        nem.plot(context, spills=args.spills, showlegend=args.no_legend)