Hi

I change a little bit the script, i don't really need all the
variables of my model, so i can pass now the variables that i need
like this:

 ./script.py SandBox_res.plt time p.y p.theta p.T p.omega ekf.y
ekf.theta ekf.T ekf.omega > Modelo_Completo_20081210_res.csv

and i note something weird, a least in this particular simulation, the
file has 180505 lines, but only 90501 are uniques, openmodelica is
generating the result file with a lot of duplicated data, that is like
200MB extra.


#!/usr/bin/python

from sys import argv

FILENAME = argv[1]
VBLES = argv[2:]

fd = open(FILENAME,"r")

buffer = [[]]
c = -1
vble = ""

for d in fd:

    if d[0] == "#":
        continue

    if ":" in d:
        res = d.split(":")
        if (res[0] =="DataSet"):
            #Start a new vble.
            vble = res[1].strip()
            if vble in VBLES:
                buffer[0].append(vble)
                c += 1
                i = 0
                continue

    if vble not in VBLES:
        continue

    res = d.split(",")
    if len(res) == 2:
        i+=1
        if c == 0:
            #First Vble.
            buffer.append([])

        buffer[i].append(res[1].strip())

fd.close()
print "\n".join(map(" , ".join,buffer))



2008/12/10 Adrian Pop <ad...@ida.liu.se>:
>
>
> Hi Jorge,
>
> Nice script.
> You could actually change the build/bin/doPlot
> script to do the conversion instead/or together
> with plotting.
>
> Cheers,
> Adrian Pop/
>
> Jorge Cardona wrote:
>>
>> Well, i already got the first one:
>>
>> #!/usr/bin/python
>>
>> from sys import argv
>>
>> FILENAME = argv[1]
>>
>> fd = open(FILENAME)
>> data = fd.read().split("\n")[:-1]
>> fd.close()
>>
>>
>> buffer = [[]]
>> c = -1
>>
>> for d in data:
>>
>>    if len(d) < 1:
>>        continue
>>
>>    if d[0] == "#":
>>        continue
>>
>>    res = d.split(":")
>>    if (len(res) == 2) and (res[0] =="DataSet"):
>>        #Start a new vble.
>>        buffer[0].append(res[1])
>>        c += 1
>>        i = 0
>>        continue
>>
>>    res = d.split(",")
>>    if len(res) == 2:
>>        i+=1
>>        if c == 0:
>>            #First Vble.
>>            buffer.append([])
>>            buffer[i].append(res[1])
>>        else:
>>            buffer[i].append(res[1])
>>
>> print "\n".join(map(" , ".join,buffer))
>>
>> you just have to pass the name of the result with ptplot format, and
>> it print the csv file, at debian use it like this:
>>
>> $ ./script.py /home/jcardona/SandBox_res.plt > file.csv
>>
>> i will check the code that generate the ptplot file.
>>
>> Thanks.
>>
>> 2008/12/9 Adrian Pop <ad...@ida.liu.se>:
>>>
>>> Hi Jorge,
>>>
>>> Well, the file returned is text in ptplot format
>>> and you could probably build your own tool to
>>> transform it into .csv in no time.
>>>
>>> Alternatively, you could change the file:
>>> c_runtime/simulation_result.cpp function
>>> deinitializeResult to dump directly .cvs
>>> or to dump also .cvs together with .plt
>>>
>>> Cheers,
>>> Adrian Pop/
>>>
>>> Jorge Cardona wrote:
>>>>
>>>> Greetings.
>>>>
>>>> Is there any way that openmodelica  returns the results in csv format???
>>>>
>>>> Thanks.
>>>>
>>
>>
>>
>



-- 
Jorge Eduardo Cardona
jorgeecard...@gmail.com
jorgeecardona.blogspot.com
------------------------------------------------
Linux registered user  #391186
Registered machine    #291871
------------------------------------------------

Reply via email to