diff --git a/eda-frontend/src/components/SchematicEditor/SimulationProperties.js b/eda-frontend/src/components/SchematicEditor/SimulationProperties.js index 8b3556cd..434de544 100644 --- a/eda-frontend/src/components/SchematicEditor/SimulationProperties.js +++ b/eda-frontend/src/components/SchematicEditor/SimulationProperties.js @@ -775,7 +775,7 @@ export default function SimulationProperties (props) { if (typeSimulation !== 'noiseAnalysis') { controlBlock = `\n.control \nrun \nprint ${cblockline} > data.txt \n.endc \n.end` } else { - controlBlock = `\n.control \nrun \n${noiseMode} \nprint ${cblockline} > data.txt \n.endc \n.end` + controlBlock = `\n.control \nrun \n${noiseMode}\nprint all > data.txt \n.endc \n.end` } // console.log(controlLine) diff --git a/esim-cloud-backend/simulationAPI/helpers/parse.py b/esim-cloud-backend/simulationAPI/helpers/parse.py index 08bd8953..5e16945c 100644 --- a/esim-cloud-backend/simulationAPI/helpers/parse.py +++ b/esim-cloud-backend/simulationAPI/helpers/parse.py @@ -1,39 +1,43 @@ import re import sys +NGSPICE_INTERNAL_VARS = { + 'false', 'true', 'boltz', 'c', 'pi', 'kelvin', 'e', + 'echarge', 'i', 'infinity', 'nan', 'no', 'yes', 'planck' +} def extract_data_from_ngspice_output(pathToFile): """ Parses the output file generated by ngspice and returns a json containing points to plot graph. """ - try: with open(pathToFile, 'r') as f: f_contents = f.readlines() graph = False - curernt_headers = [] total_number_of_tables = 0 if(len(f_contents) > 3): if('---' in f_contents[2]): graph = True - if(not graph): json_data = {"data": [], "graph": "false"} for line in f_contents: contents_of_line = line.split() + if len(contents_of_line) >= 1: + var_name = contents_of_line[0].lower().rstrip('=').split('(')[-1].rstrip(')') + if var_name in NGSPICE_INTERNAL_VARS: + continue json_data["data"].append(contents_of_line) - else: json_data = {"data": [], "graph": "true"} for line in f_contents: contents_of_line = line.split() - + if len(contents_of_line) >= 1: + var_name = contents_of_line[0].lower().rstrip('=').split('(')[-1].rstrip(')') + if var_name in NGSPICE_INTERNAL_VARS: + continue if('Index' in contents_of_line): - # line_set = remove_duplicate_items_from_list( - # contents_of_line) line_set = contents_of_line - if(line_set != curernt_headers): curernt_headers = line_set json_data["data"].append( @@ -41,40 +45,25 @@ def extract_data_from_ngspice_output(pathToFile): index = len(json_data["data"]) - 1 for x in range(2, len(curernt_headers)): json_data["data"][index]["y"].append([]) - for x in range(1, len(curernt_headers)): json_data["data"][index]["labels"].append( curernt_headers[x]) total_number_of_tables += 1 - else: m = re.match('[0-9]+', line) if(m): index = len(json_data["data"]) - 1 data = json_data["data"][index] data["x"].append(contents_of_line[1]) - for x in range(len(data["y"])): data["y"][x].append(contents_of_line[x+2]) json_data["total_number_of_tables"] = total_number_of_tables -\ len(json_data["data"]) return json_data - except IOError as e: print('Cannot Open File') raise e - -# def remove_duplicate_items_from_list(line_list): -# res = [] -# for i in line_list: -# if i not in res: -# res.append(i) -# return res - - -# for testing provide the filepath as command line argument if __name__ == "__main__": - filePath = sys.argv[1] print(extract_data_from_ngspice_output(filePath))