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