Current Challenges in the Stella -> R Conversion

At this point, the script writes out all of its pieces, so that’s a landmark in this debugging process. Now, I’m catching problems where the R script crashes, and they’re becoming more cryptic as I go, which is to be expected.

I found a line in my original Stella model that has an essentially meaningless model, but it’s still assigned a rank even though it doesn’t have any inflows/outflows. This means that it’s written out as a blank assignment in the R code. So, I added an additional test in the models loop. I took out the automatic rank assignment and instead moved it down…

 if len(ltxt) > 0:

In part of this process, I decided that maybe it was a problem that in the body of the R script, there was a vector being created of array references before any array was created. For now, I’m writing out a blank array, and then the converter values in the body of the script.

convT = []
arrays = []

for conv in convlist:
 if ('[' in conv):
   ifsplit = re.split('\[',conv)[0]
   if (ifsplit not in arrays): 
     ff.writelines([ifsplit," <- c()\n"])

for conv in convlist:
 if (convertors[conv].value is not None): convs.append(conv)
convs = sorted(convs)
for i in range(0,len(convs)):
 convertors[convs[i]].value = '{0:g}'.format(convertors[convs[i]].value)
 ff.writelines([convs[i]," <- ",str(convertors[convs[i]].value),"\n"])

I’m also reformatting #s to get rid of superfluous trailing .0’s.

Leave a Reply

Your email address will not be published. Required fields are marked *