创建一个post进程,从XML文件中获取数据,并结合编写.gnu-fi的代码

2024-09-19 23:31:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我是一个相对较新的程序员,真的需要一些帮助。如果我不能很好地描述我的问题,我很抱歉。我正在尝试编写一个post-process/get-data-from-XML文件,它将与我的代码一起编写.gnu文件。最终目标是使用这个customfunctions脚本生成一个png文件,其中包含来自XML文件的数据的图形。我的代码如下所示。你知道吗

我不能使用:plot“MDNBR_数据.dat“行,因为我无法在系统中拥有该文件,必须有一个自定义代码来解析xml。所有的帮助和建议将不胜感激。你知道吗

def MDNBR(self):
    '''
    '''
    self.filename = "MDNBR_data.gnu"
    self.figurename = "MDNBR_data.png"

    #-- post process / get data from XML file

    #-- write code to write .gnu file

    self.output = textwrap.dedent('''\
    set terminal png size 800,600 
    set output "MDNBR_data.png" 
    set grid 
    set xlabel "Cycle" 
    set title "MDNBR-CEA Ejection" 
    set xtics (25,26,27)
    set yrange[1.1:1.4]
    plot "MDNBR_data.dat" using 1:2 title 'MDNBR' w linespoints lt 3 lw 3 pt 7 ps 1.5, "MDNBR_data.dat" u 1:3 t 'Limit' w linespoints lt 1 lw 3 pt 7 ps 1.5
    ''')
    pass


class RunGnuPlot (object):
'''
'''
def __init__ (self, gnu_filename):
    self.status = 0

Tags: 文件数据代码fromgnuselfdataget