Mosaik-Odysseus Connection

sergewarde
Posts: 8
Joined: Tue Apr 05, 2016 10:48 am

Mosaik-Odysseus Connection

Post by sergewarde » Fri Apr 15, 2016 12:49 pm

Hello all,
I want to connect Odysseus to Mosaik for data visualization.
Following the online tutorial (http://mosaik.readthedocs.org/en/latest ... sseus.html and http://mosaik.readthedocs.org/en/latest ... seus2.html), I first ran the Odysseus script then the mosaik scenario (after adequate modification).

However, there's no additional source appearing in the source-view in Odysseus, even when the mosaik simulation is finished.
Is this normal?

Curiously enough, when I add the sender operator to store the simulated data in CSV, a csv is succesfully created (but still no additional source in Odysseus).

Regarding the csv, do you know how I could add the adequate columns names (since there seems to be none appearing, just the raw data)?
My sender operator is:
send = SENDER({
SINK='writeCSV',
transport='File',
wrapper='GenericPush',
protocol='CSV',
dataHandler='Tuple',
options=[
['filename','${WORKSPACEPROJECT}\output3.csv'],
['csv.writeMetadata', 'true']
]}, aggregatedTuples)


Thanks in advance, have a great day!
Serge Wardé

User avatar
Marco Grawunder
Posts: 272
Joined: Tue Jul 29, 2014 10:29 am
Location: Oldenburg, Germany
Contact:

Re: Mosaik-Odysseus Connection

Post by Marco Grawunder » Mon Apr 18, 2016 8:27 am

Hi,

when I look at the example on the page, I see that the source is defined with "=". In this case, no sources appear in the source view of Odysseus, because the source definition is only query local. If you want to see the source in the view, you will have to use ":=" for the sources definition instead. In this case, the following query must be defined with another #ADDQUERY comannd.

Greetings,

Marco

P.S. If there are further problems, could you please post your script?

sergewarde
Posts: 8
Joined: Tue Apr 05, 2016 10:48 am

Re: Mosaik-Odysseus Connection

Post by sergewarde » Mon Apr 18, 2016 1:58 pm

Hi Marco, thanks for your answer.
I've managed to view the results of the simulations in odysseus by adding a dashboard part and by looking at the query view (and not the source view). Sorry about that, I'm starting to find my way around Odysseus and Mosaik.

However, I'm still having trouble with the csv export using the sender operator.
The operation works ok but I want to add the names of the columns to the data in the output csv.

I still get the raw data (without the column names) using this sender operator at the end of the query:

send = SENDER({
SINK='writeCSV',
transport='File',
wrapper='GenericPush',
protocol='CSV',
dataHandler='Tuple',
options=[
['filename','${WORKSPACEPROJECT}\output3.csv'],
['csv.writeMetadata', 'true']
]}, Power)


I want to avoid having to manually fill the columns' names using excel after the export from Odysseus.
Could you help me with that?

Thanks

sergewarde
Posts: 8
Joined: Tue Apr 05, 2016 10:48 am

Re: Mosaik-Odysseus Connection

Post by sergewarde » Mon Apr 18, 2016 1:59 pm

Here's my full script:

#PARSER PQL
#METADATA TimeInterval
#RUNQUERY
mosaikCon = MOSAIK({SOURCE = 'mosaik', type='simapi'})

tuples = KEYVALUETOTUPLE({
SCHEMA = [
['odysseus_0.P_out.HouseholdSim-0.House_5', 'Double'],
['odysseus_0.P.CSV-0.PV_2', 'Double'],
['odysseus_0.P.PyPower-0.0-node_b3', 'Double'],
['timestamp', 'STARTTIMESTAMP']
],
KEEPINPUT = false,
TYPE = 'mosaik'},
mosaikCon)

renamedTuples = RENAME({aliases =
['House_5','PV_2','node_b3', 'timestamp']
}, tuples)

Power = MAP({EXPRESSIONS = [
['Abs(House_5)', 'House_5'],
['Abs(PV_2)', 'PV_2']
]}, tuples)

send = SENDER({
SINK='writeCSV',
transport='File',
wrapper='GenericPush',
protocol='CSV',
dataHandler='Tuple',
options=[
['filename','${WORKSPACEPROJECT}\output3.csv'],
['csv.writeMetadata', 'true']
]}, Power)

User avatar
Marco Grawunder
Posts: 272
Joined: Tue Jul 29, 2014 10:29 am
Location: Oldenburg, Germany
Contact:

Re: Mosaik-Odysseus Connection

Post by Marco Grawunder » Mon Apr 18, 2016 2:54 pm

Hi,

in the current version, this is not possible ... but the next nightly will contain the new option

csv.writeheading

If this is set to 'true' the headings will be printed:

Code: Select all

out = CSVFILESINK({
          sink = 'sink',
          filename = "${PROJECTPATH}/testout",
          options=[
          	['csv.writeheading','true']
          ]        
        },
        in
      )
This is not tested very well ;-) So, if you find an error, please report.

Greetings,

Marco

sergewarde
Posts: 8
Joined: Tue Apr 05, 2016 10:48 am

Re: Mosaik-Odysseus Connection

Post by sergewarde » Mon Apr 18, 2016 3:05 pm

Hi Marco,

thanks for the feedback
Will try the new option when available :)

Thanks again

sergewarde
Posts: 8
Joined: Tue Apr 05, 2016 10:48 am

Re: Mosaik-Odysseus Connection

Post by sergewarde » Tue Apr 19, 2016 12:54 pm

Hi Marco,

The csv.writeheading option works :)
All the columns names are added at the first line (even though they all start by 'mosaik:')

Thanks a lot!
Have a great day!

User avatar
Marco Grawunder
Posts: 272
Joined: Tue Jul 29, 2014 10:29 am
Location: Oldenburg, Germany
Contact:

Re: Mosaik-Odysseus Connection

Post by Marco Grawunder » Wed Apr 20, 2016 9:31 am

Hi,

if you want to remove the

Code: Select all

mosaik.
prefix, just add type='' in the RENAME statement:

Code: Select all

renamedTuples = RENAME({type='', aliases =
 ['House_5','PV_2','node_b3', 'timestamp']
 }, tuples)
Greetings,

Marco

sergewarde
Posts: 8
Joined: Tue Apr 05, 2016 10:48 am

Re: Mosaik-Odysseus Connection

Post by sergewarde » Wed Apr 20, 2016 12:13 pm

Hey marco,

I added the type option in the RENAME statement, as you said:

renamedTuples = RENAME({type='', aliases =
['House_5','PV_2','node_b3', 'timestamp']
}, tuples)


However it doesn't remove the 'mosaik:' prefix from the csv output's column names.
I'll try to find a way to remove this prefix using a python script

In any case, thanks for your help and quick responses! :) :)

User avatar
Marco Grawunder
Posts: 272
Joined: Tue Jul 29, 2014 10:29 am
Location: Oldenburg, Germany
Contact:

Re: Mosaik-Odysseus Connection

Post by Marco Grawunder » Wed Apr 20, 2016 12:58 pm

Hmm. Then you could try to add another RENAME directly in front of the sink with only the type parameter. Could be that the MAP operator sets the type again.

Greetings,

Marco

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest