issue on outputs recording

38 views
Skip to first unread message

Joséphine

unread,
Jul 30, 2020, 5:47:24 AM7/30/20
to GAMA
Hello everyone,

I am a begginer on GAMA, I made a model on carbon as part of my master 1 internship and I have an issue regarding the recording of my outputs. My purpose is to recording 2 variables: a map and a float, in 2 different csv files. For this, I have an action "setHeader" which sets up header for the two files and which is call in the init of my model :

action setHeader {
        string myfile <- getFileName ("file_flux_plot");
        save ["plotName", "year", "cycle", "origin", "destination", "quantity_kgC"] to: myfile type: csv header:false rewrite:true;
        string myfile2 <- getFileName ("file_stock_plot");
        save ["plotName", "year", "cycle", "stockValue"] to: myfile2 type: csv header:false rewrite:true;
    }

and two actions saveFlux (map) and saveStock (float) which are call in a monthly reflex :

action saveFlux {
        string myfile;
        ask world{
            myfile <- getFileName ("file_flux_plot");
            }
        loop i over: flux.keys {
            save [self, year, cycle, i.key, i.value, flux[i]] to: myfile type: csv header:false rewrite:false;
        }
        flux <- ([]);
    }

action saveStock {
        string myfile2;
        ask world {
            myfile2 <- getFileName ("file_stock_plot");   
        }
        save [self, year, cycle, stableCsoilStock_kgC] to: myfile2 type: csv header:false rewrite:false;
    }

GetFileName is just an action to have the correct file name :

action getFileName (string myname) {
        string filename <- "" + path_outputs + myname + "_" + scenario + ".csv";       
        return (filename);
    }

The problem is that the recording of my map of flux (myfile) works perfectly well but it is not the same for the recording of my float stableCsoilStock_kgC...
First, my headers are not setting well: there is a line with "plotName", "year", "cycle" and "stockValue" but under a first line "Column 1", "Column 2"... and so, it is registred in my outputs folder as "no header" while the other file is registred as "with header".
And secondly, 6 values are registred in my first column like that: 0;agriculturalPlot0;83.32855271422689;81.81375662289858;0.0;agriculturalPlot0, I think the first one corresponds to the "cycle", the seconds, and thus the last one, to the "plotName" (it is not even the sequence I asked for) and I don't even know what the rest of the values are, they not correspond to my stock at all.
I have to admit that I am completly lost because I feel like I am doing exactly the same things for the two files and I tried several tricks without success...

I hope I managed to state my problem clearly although my english is not fluent yet and I have no experience in this kind of forum. Please let me know if you have questions and if you have any idea to help me or if you have been in this situation before and have tip, I will be very, very glad to hear it ! 
Thank you in advance,
Joséphine Hazera

ledoyen...@gmail.com

unread,
Jul 30, 2020, 8:05:08 AM7/30/20
to GAMA
Hi Josephine,

The recorded values 0;agriculturalPlot0;83.32855271422689;81.81375662289858;0.0;agriculturalPlot0 are data about the simulation running (cycle,  simulation name, ...) and refers to variable self  that you are recording in the first position of save statement. Data recorded into the first file are the right ones ?

0;agriculturalPlot0;83.32855271422689;81.81375662289858;0.0; is displayed in the first column (in GAMA IDE) because the default delimiter for csv file is is ",".

Cheers,
François L.

josephi...@hotmail.fr

unread,
Jul 30, 2020, 9:26:01 AM7/30/20
to GAMA
Hi François,

Thank you for answering.

I forgot to precise that my two saving functions (saveFlux and saveStock) are part of my species "agriculturalPlot", so self should refer only to the name of the plot (just agriculturalPlot0 or agriculturalPlot125 for instance), at least that is what it corresponds to in my first file. In my first file, I have my first column with the plot name, my second with the year, my third with the cycle... and the last column with the correct value of the considered flux, and that is what I would like to have in my second file. I even tried to register my stock value in this file this morning by adding my variable stableCsoilStock after my variable flux[i] in my save statement and it worked ! So I don't understand why it is impossible to do the same thing but in an other file...

Concerning the default delimiter for csv file ",", this is a problem when I open the file with Excel what I don't want to do. Normally if I open the file on GAMA interface, it managed to open it correctly column by column, as it does for the first file. 

Maybe it is just because it doesn't managed to write two files in the same time, is that can be an explanation ?

Thank you again for answering,
Joséphine

Srirama Bhamidipati

unread,
Jul 30, 2020, 11:15:41 AM7/30/20
to GAMA
Hi

Welcome to GAMA.

1. What you are getting are default values of self, these include: cycle, agent_name, location x,y,z, agent_name. Yes, agent_name is twice. Note, the default values depend (also) on the skills attached (if any) to a species. see bullet 3 below.
2. If you see column1 column2, switch your view to text view (see at the bottom of the window)
3. You perhaps want to try 'name' in place of 'self'

Srirama

Joséphine Hazera

unread,
Jul 31, 2020, 11:20:54 AM7/31/20
to gama-p...@googlegroups.com

Hi Srirama,

 

Thank you for answering.

 

I just tried with « name » instead of « self » and it works !! I still don’t understand why in one case it works with « self » and in the other case it works only with « name » but it works, I now have the right data in the right column and without « Column1 », « Column2 » above.

 

Thank you very much for your help !

 

Joséphine

 

Provenance : Courrier pour Windows 10

 

De : Srirama Bhamidipati
Envoyé le :jeudi 30 juillet 2020 17:15
À : GAMA
Objet :[gama (9440)] Re: issue on outputs recording

--
You received this message because you are subscribed to a topic in the Google Groups "GAMA" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gama-platform/1Dvbv7dDctU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gama-platfor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gama-platform/db5c744e-d02c-4aa5-ad33-91b5ed254b4bn%40googlegroups.com.

 

Reply all
Reply to author
Forward
0 new messages