### Disappearing cells

73
views
0
4 weeks ago by

I loose the record of some cells at the end of my simulation, what could be the cause for it?

An example file extraction:

cell_no,time_mcs,x_position_(px),y_position_(px)
...
428,966,22.6896551724,14.8965517241
429,966,22.56,36.12
428,967,22.6153846154,15.1923076923
429,967,22.7083333333,35.9166666667
428,968,22.7037037037,14.851851

STOPS?? :)

There should be 999 entries? What to do/how to fix?

Best regards,
Pauli
:)
Community: CompuCell3D

2
4 weeks ago by
Try self.File.flush() and self.File2.flush() after the write statements. I tried a version of your code and it works for me
I see that these code lines, yours and James', should solve the issue. I test tomorrow and report if still any related problems.
written 4 weeks ago by Pauli Tikka
2
4 weeks ago by
Instead of the the flush commands you might just need to explicitly close your output files. Closing will flush the write buffer.  I believe this will do it;

def finish(self):
    # Finish Function gets called after the last MCS
    self.File.close()
    self.File2.close()
thank you for the code, should be ok
written 4 weeks ago by Pauli Tikka
2
4 weeks ago by
Another way to flush the writes is to open your output file(s) with a zero size buffer;
self.File=open(FileName,"w",0)
The zero is the output buffer size. This flushes the output after every write command.

If you don't write to the file too often then the zero size output buffer wont slow things down.
0
4 weeks ago by
Could you post the part of your code that is printing to the file? A possible reason could be if you are not `flushing' after printing (eg print>>some_fileHandle, results ; some_fileHandle.flush() ) but this is just a guess.
0
4 weeks ago by
Are you sure the missing lines aren't actually in the file somewhere other than at the end? Depending on your data structure Python might not be printing things in the order you expect. Dictionaries in particular can print with odd ordering.
0
4 weeks ago by
Hi,

Here is the steppables.py file almost as it is:

from PySteppables import *
import CompuCell
import sys
import random
from math import *
from XMLUtils import dictionaryToMapStrStr as d2mss
from PySteppablesExamples import MitosisSteppableBase

class ConstraintInitializerSteppable(SteppableBasePy):
def __init__(self,_simulator,_frequency=1):
SteppableBasePy.__init__(self,_simulator,_frequency)
def start(self):
for cell in self.cellList:
cell.targetVolume=30
cell.lambdaVolume=1.0

class peittoSteppable(SteppableBasePy):

def __init__(self,_simulator,_frequency=1):
SteppableBasePy.__init__(self,_simulator,_frequency)
self.cellA=None
self.cellB=None
def start(self):

_yAxisTitle='Variables', _xScaleType='linear', _yScaleType='linear')

for cell in self.cellListByType(self.NPCELLS):
c = random.choice(['green','yellow','red','blue']) #,'yellow','red','blue'

for cell in self.cellListByType(self.ACELLS):
c = random.choice(['green','yellow','red','blue']) #,'yellow','red','blue'

FileName = "C:/CompuCell3D-64bit/pauli/movements/m16/okok/heihou99.txt"
FileName2 = "C:/CompuCell3D-64bit/pauli/movements/m16/okok/tt2.txt"

self.File = open(FileName,"w")
self.File2 = open(FileName2,"w")

self.File.write("cell_no, time_mcs,x_position_(px),y_position_(px)\n")
self.File2.write("cell_no, distances, time_mcs,x_position_(px),y_position_(px)\n")

def step(self,mcs):
for cell in self.cellList:
self.File2.write(str(cell.id)+","+str(mcs)+","+str(self.distanceBetweenCells(self.attemptFetchingCellById(15),self.attemptFetchingCellById(cell.id)))+","+str(cell.xCOM)+","+str(cell.yCOM)+"\n")

for cell in self.cellListByType(self.NPCELLS):
self.File.write(str(cell.id)+","+str(mcs)+","+str(cell.xCOM)+","+str(cell.yCOM)+"\n")
for cell in self.cellListByType(self.ACELLS):
self.File.write(str(cell.id)+","+str(mcs)+","+str(cell.xCOM)+","+str(cell.yCOM)+"\n")

def finish(self):
# Finish Function gets called after the last MCS
pass

-Pauli
:)
0
4 weeks ago by