Skip to content

Commit

Permalink
wbp
Browse files Browse the repository at this point in the history
  • Loading branch information
jbae11 committed Apr 24, 2020
1 parent dfaa25d commit eaea2ff
Show file tree
Hide file tree
Showing 14 changed files with 13 additions and 3,068 deletions.
877 changes: 0 additions & 877 deletions neams/cyclus.py

This file was deleted.

395 changes: 0 additions & 395 deletions neams/cyclus.sch

This file was deleted.

13 changes: 0 additions & 13 deletions neams/cyclus.wbg

This file was deleted.

95 changes: 0 additions & 95 deletions neams/cyclus.wbh

This file was deleted.

12 changes: 6 additions & 6 deletions neams/cyclus/cyclus.wbp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ filter_pattern = "CYCLUS"
processor("Material flow prototype to prototype") {
delimiter = ","

logic = """${AWK} -v new=${NEW_SHEET} -v begin="BEGIN" -v end="END" "/BEGIN trade_flow_prototype/,/END trade_flow_prototype/ { if(index($1,begin)==1 || index($NF,end)==1) {start=NR;next;} if(NR==start+1) {steps=$0; next;} print steps; print $0; print new }" ${CURRENT_FILE}"""
logic = """${AWK} -v new=${NEW_SHEET} -v begin="BEGIN" -v end="END" "/BEGIN trade_flow_prototype/,/END trade_flow_prototype/ { if(index($1,begin)==1 || index($1,end)==1) {start=NR;next;} if(NR==start+1) {steps=$0; next;} if(NR==start+2){next;} print steps; print $0; print new }" ${CURRENT_FILE}"""

graph("${a2}"){
% key axis (x-axis) label
Expand All @@ -39,7 +39,7 @@ processor("Material flow prototype to prototype") {
processor("Material flow agent to agent") {
delimiter = ","

logic = """${AWK} -v new=${NEW_SHEET} -v begin="BEGIN" -v end="END" "/BEGIN trade_flow_agent/,/END trade_flow_agent/ { if(index($1,begin)==1 || index($NF,end)==1) {start=NR;next;} if(NR==start+1) {steps=$0; next;} print steps; print $0; print new }" ${CURRENT_FILE}"""
logic = """${AWK} -v new=${NEW_SHEET} -v begin="BEGIN" -v end="END" "/BEGIN trade_flow_agent/,/END trade_flow_agent/ { if(index($1,begin)==1 || index($1,end)==1) {start=NR;next;} if(NR==start+1) {steps=$0; next;} if(NR==start+2){next;} print steps; print $0; print new }" ${CURRENT_FILE}"""

graph("${a2}"){
% key axis (x-axis) label
Expand Down Expand Up @@ -69,7 +69,7 @@ processor("Material flow agent to agent") {
processor("Material flow commodity") {
delimiter = ","

logic = """${AWK} -v new=${NEW_SHEET} -v begin="BEGIN" -v end="END" "/BEGIN commodity_flow/,/END commodity_flow/ { if(index($1,begin)==1 || index($NF,end)==1) {start=NR;next;} if(NR==start+1) {steps=$0; next;} print steps; print $0; print new }" ${CURRENT_FILE}"""
logic = """${AWK} -v new=${NEW_SHEET} -v begin="BEGIN" -v end="END" "/BEGIN commodity_flow/,/END commodity_flow/ { if(index($1,begin)==1 || index($1,end)==1) {start=NR;next;} if(NR==start+1) {steps=$0; next;} if(NR==start+2){next;} print steps; print $0; print new }" ${CURRENT_FILE}"""

graph("${a2}"){
% key axis (x-axis) label
Expand Down Expand Up @@ -97,7 +97,7 @@ processor("Material flow commodity") {
processor("Agents entered") {
delimiter = ","

logic = """${AWK} -v new=${NEW_SHEET} -v begin="BEGIN" -v end="END" "/BEGIN agent_flow_entered/,/END agent_flow_entered/ { if(index($1,begin)==1 || index($NF,end)==1) {start=NR;next;} if(NR==start+1) {steps=$0; next;} print steps; print $0; print new }" ${CURRENT_FILE}"""
logic = """${AWK} -v new=${NEW_SHEET} -v begin="BEGIN" -v end="END" "/BEGIN agent_flow_entered/,/END agent_flow_entered/ { if(index($1,begin)==1 || index($1,end)==1) {start=NR;next;} if(NR==start+1) {steps=$0; next;} if(NR==start+2){next;} print steps; print $0; print new }" ${CURRENT_FILE}"""

graph("${a2}"){
% key axis (x-axis) label
Expand Down Expand Up @@ -125,7 +125,7 @@ processor("Agents entered") {
processor("Agents exited") {
delimiter = ","

logic = """${AWK} -v new=${NEW_SHEET} -v begin="BEGIN" -v end="END" "/BEGIN agent_flow_exited/,/END agent_flow_exited/ { if(index($1,begin)==1 || index($NF,end)==1) {start=NR;next;} if(NR==start+1) {steps=$0; next;} print steps; print $0; print new }" ${CURRENT_FILE}"""
logic = """${AWK} -v new=${NEW_SHEET} -v begin="BEGIN" -v end="END" "/BEGIN agent_flow_exited/,/END agent_flow_exited/ { if(index($1,begin)==1 || index($1,end)==1) {start=NR;next;} if(NR==start+1) {steps=$0; next;} if(NR==start+2){next;} print steps; print $0; print new }" ${CURRENT_FILE}"""

graph("${a2}"){
% key axis (x-axis) label
Expand Down Expand Up @@ -155,7 +155,7 @@ processor("Agents exited") {
processor("Agents active") {
delimiter = ","

logic = """${AWK} -v new=${NEW_SHEET} -v begin="BEGIN" -v end="END" "/BEGIN agent_flow_deployed/,/END agent_flow_deployed/ { if(index($1,begin)==1 || index($NF,end)==1) {start=NR;next;} if(NR==start+1) {steps=$0; next;} print steps; print $0; print new }" ${CURRENT_FILE}"""
logic = """${AWK} -v new=${NEW_SHEET} -v begin="BEGIN" -v end="END" "/BEGIN agent_flow_deployed/,/END agent_flow_deployed/ { if(index($1,begin)==1 || index($1,end)==1) {start=NR;next;} if(NR==start+1) {steps=$0; next;} if(NR==start+2){next;} print steps; print $0; print new }" ${CURRENT_FILE}"""

graph("${a2}"){
% key axis (x-axis) label
Expand Down
65 changes: 6 additions & 59 deletions neams/cyclus/cyclus_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
from processor import load_environment, BinnedData, Sheet, Options, Processor


from cyclus_gui.gui.backend_window import BackendWindow
from tkinter import *



class CyclusPostrunner:
def __init__(self, sqlite_path):
#!
Expand Down Expand Up @@ -154,6 +149,10 @@ def generate_trade_flow(self, groupby):
raise ValueError('The x values are not the same!')
else:
self.csv_string += ','.join([str(q) for q in x]) + '\n'
if groupby == 'prototype':
self.csv_string += 'sender -> [commodity] -> receiver, trade_mass\n'
else:
self.csv_string += 'sender (senderid) -> [commodity] -> receiver (receiverid), trade_mass\n'

if groupby == 'prototype':
self.csv_string += '%s -> [%s] -> %s' %(s,c,r) + ',' + ','.join([str(q) for q in y]) + '\n'
Expand Down Expand Up @@ -181,6 +180,7 @@ def generate_commodity_flow(self):
raise ValueError('The x values are not the same')
else:
self.csv_string += ','.join([str(q) for q in x]) + '\n'
self.csv_string += 'commodity, trade_mass\n'

self.csv_string += commod + ',' + ','.join([str(q) for q in y])+'\n'
prev_x = x
Expand All @@ -200,6 +200,7 @@ def generate_agent_flow(self):
raise ValueError('The x values are not the same')
else:
self.csv_string += ','.join([str(q) for q in x]) + '\n'
self.csv_string += 'prototype, %s\n' %which

self.csv_string += proto + ',' + ','.join([str(q) for q in y]) + '\n'
prev_x = x
Expand Down Expand Up @@ -316,57 +317,3 @@ def get_timeseries_flow(self, timeseries):

def get_inventory_flow(self):
z=0


def read_csv(file, data_type):
filestr = file.read()
# lol research
alpha = filestr.find('BEGIN %s'%data_type) + len('BEGIN %s'%data_type)
omega = filestr.find('END %s' %data_type)
result = filestr[alpha+1:omega-1]
lines = result.split('\n')
lines = [q.split(',') for q in lines]
x = [float(q) for q in lines[0]]

# where's y?
y_indx = lines[1].index('y')
print(y_indx)

labels = ['_'.join(q[:y_indx]) for q in lines[2:]]
ys = [np.array(q[y_indx:], dtype=float) for q in lines[2:]]

for indx, val in enumerate(ys):
plt.plot(x, ys[indx], label=labels[indx])

plt.title(data_type.replace('_', ' ').capitalize())
plt.legend()
plt.show()



def main():
CyclusPostrunner('out.sqlite')
return
parser = ArgumentParser(description='', epilog='Jin Whan Bae')
#parser.add_argument('file', type=FileType('r'),
# help='Cyclus output csv file path')
parser.add_argument('file', type=str)
parser.add_argument('-data_type', type=str, default=None,
dest='data_type',
help='Type of data to be printed [trade_flow_agent/trade_flow_prototype/commodity_flow/agent_flow_entered/agent_flow_exited/agent_flow_deployed]'
)
args = parser.parse_args()
if '.csv' in args.file:
sqlite = args.file.replace('.csv', '.sqlite')
args.file = os.path.dirname(args.file)
root = Tk()
app = BackendWindow(root, args.file, sqlite)
root.mainloop()


#read_csv(args.file, args.data_type)
# cyclus_processor = CyclusProcessor('cyclus', args)


if __name__ == '__main__':
main()
6 changes: 1 addition & 5 deletions neams/cyclus_simple.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#!/usr/bin/python
"""Scale runtime environment"""

# standard imports
import os
import sys
import json
Expand All @@ -22,6 +19,7 @@ def __init__(self):
super(CyclusRuntimeEnvironment, self).__init__()
self.executable = 'cyclus'


def app_name(self):
"""returns the app's self-designated name"""
return "cyclus"
Expand Down Expand Up @@ -51,8 +49,6 @@ def run_args(self, options):
self.echo(1, '#!!!!! It simply adds a new SimId.')
self.echo(1, '#!!!!! So you will have one file with multiple simulation results.')
args.append(self.outpath)
#args.append('-v')
#args.append(self.verbosity)
return args


Expand Down
Loading

0 comments on commit eaea2ff

Please sign in to comment.