Skip to content

Commit cc278a9

Browse files
authored
Merge pull request #43 from elmbeech/master
pcdl v4.1.2
2 parents 51e9f9c + fd9a250 commit cc278a9

16 files changed

Lines changed: 199 additions & 42 deletions

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,15 @@ Developers, please make pull requests to the https://github.com/elmbeech/physice
129129

130130

131131
## Release Notes:
132+
+ version 4.1.2 (2026-03-06): elmbeech/physicelldataloader
133+
+ new **custom_data_astype** TimeStep class and TimeSeries class function to set the dtype of custom\_data variables even after the timestep or timeseries is loaded.
134+
+ TimeSeries \_\_init\_\_ function can now handle a list of TimeStep objects as input instead of a path.
135+
132136
+ version 4.1.1 (2026-02-28): elmbeech/physicelldataloader
133-
+ reduce memory footprint.
137+
+ reduced memory footprint.
134138

135139
+ version 4.1.0 (2025-12-31): elmbeech/physicelldataloader
136-
+ new TimeStep class and TimeSeris class function **get_spatialdata** and command line command **pcdl_get_spatialdata**.
140+
+ new **get_spatialdata** TimeStep class and TimeSeris class function and **pcdl_get_spatialdata** command line command.
137141

138142
+ version 4.0.5 (2025-10-22): elmbeech/physicelldataloader
139143
+ **settingxml** default is now set to False, because the cell\_type id label mapping can, in recent PhysiCell output, be retrieved from output\*.xml too.

man/REFERENCE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Basically, there are four types of functions:
3939

4040
### TimeStep initialize
4141
+ [help(pcdl.TimeStep.\_\_init\_\_)](https://github.com/elmbeech/physicelldataloader/tree/master/man/docstring/mcds.__init__.md) #! workhorse function
42+
+ [help(mcds.custom_data_astype)](https://github.com/elmbeech/physicelldataloader/tree/master/man/docstring/mcds.custom_data_astype.md) #! workhorse function
4243
+ [help(mcds.set_verbose_false)](https://github.com/elmbeech/physicelldataloader/tree/master/man/docstring/mcds.set_verbose_false.md) #! workhorse function
4344
+ [help(mcds.set_verbose_true)](https://github.com/elmbeech/physicelldataloader/tree/master/man/docstring/mcds.set_verbose_true.md) #! workhorse function
4445

@@ -124,6 +125,7 @@ Basically, there are four types of functions:
124125
+ [help(mcdsts.read_mcds)](https://github.com/elmbeech/physicelldataloader/tree/master/man/docstring/mcdsts.read_mcds.md)
125126
+ [help(mcdsts.get_mcds_list)](https://github.com/elmbeech/physicelldataloader/tree/master/man/docstring/mcdsts.get_mcds_list.md) #! workhose function
126127
+ [help(mcdsts.get_annmcds_list)](https://github.com/elmbeech/physicelldataloader/tree/master/man/docstring/mcdsts.get_annmcds_list.md) #! workhose function
128+
+ [help(mcdsts.custom_data_astype)](https://github.com/elmbeech/physicelldataloader/tree/master/man/docstring/mcdsts.custom_data_astype.md) #! workhorse function
127129
+ [help(mcdsts.set_verbose_false)](https://github.com/elmbeech/physicelldataloader/tree/master/man/docstring/mcdsts.set_verbose_false.md) #! workhorse function
128130
+ [help(mcdsts.set_verbose_true)](https://github.com/elmbeech/physicelldataloader/tree/master/man/docstring/mcdsts.set_verbose_true.md) #! workhorse function
129131

man/TUTORIAL_python3_timestep.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ python3 -c"import pathlib, pcdl, shutil; pcdl.install_data(); s_ipath=str(pathli
3333
By default, all data related to the snapshot is loaded.
3434
For speed and less memory usage, it is however possible to only load the essential (output xml and cell mat data),
3535
and exclude microenvironment, graph data, PhysiBoss data, and the PhysiCell\_settings.xml cell type ID label mapping. \
36-
For custom\_data variables it is possible to specify data types, apart from the generic float type, namely: int, bool, and str. \
36+
For custom\_data variables it is possible to specify data types, apart from the generic float type, namely: int, bool, and str.
37+
This can be done too, after the data is loaded, using the mcds.custom\_data\_astype function. \
3738
For paths, in general, unix (slash) and windows (backslash) notation will work.
3839

3940
The basic way to load a mcds time step object:

man/docstring/mcds.__init__.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
relative or absolute path to the directory where
1212
the PhysiCell output files are stored.
1313
14-
custom_dtype: dictionary; default is {}
14+
custom_data_type: dictionary; default is {}
1515
variable to specify custom_data variable types other than
1616
floats (namely: int, bool, str) like this: {var: dtype, ...}.
1717
downstream float and int will be handled as numeric,
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# mcds.custom_data_astype()
2+
3+
4+
## input:
5+
```
6+
custom_data_type: dictionary; default is {}
7+
variable to specify custom_data variable types other than
8+
floats (namely: int, bool, str) like this: {var: dtype, ...}.
9+
downstream float and int will be handled as numeric,
10+
bool as Boolean, and str as categorical data.
11+
12+
```
13+
14+
## output:
15+
```
16+
self.data['cell']['df_cell']:
17+
the dtype of columns as specified in the custom_data_type dictionary.
18+
19+
```
20+
21+
## description:
22+
```
23+
function to set the dtype of custom_data variables,
24+
even after the data is loaded.
25+
26+
```

man/docstring/mcdsts.__init__.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33

44
## input:
55
```
6-
output_path: string, default '.'
6+
output_path: string or list of mcds objects, default '.'
77
relative or absolute path to the directory where
8-
the PhysiCell output files are stored.
8+
the PhysiCell output files are stored or
9+
a list of mcds timestep objects.
910
1011
custom_data_type: dictionary; default is {}
1112
variable to specify custom_data variable types
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# mcdsts.custom_data_astype()
2+
3+
4+
## input:
5+
```
6+
custom_data_type: dictionary; default is {}
7+
variable to specify custom_data variable types other than
8+
floats (namely: int, bool, str) like this: {var: dtype, ...}.
9+
downstream float and int will be handled as numeric,
10+
bool as Boolean, and str as categorical data.
11+
12+
```
13+
14+
## output:
15+
```
16+
self.data['cell']['df_cell']:
17+
the dtype of columns as specified in the custom_data_type dictionary.
18+
19+
```
20+
21+
## description:
22+
```
23+
function to set the dtype of custom_data variables,
24+
even after the data is loaded.
25+
26+
```

man/scarab.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ def docstring_md(s_function, ls_doc, s_header=None, s_opath='man/docstring/'):
127127
ls_doc = pcdl.TimeStep.__init__.__doc__.split('\n'),
128128
s_header = "mcds = pcdl.TimeStep('path/to/outputnnnnnnnn.xml')"
129129
)
130+
docstring_md(
131+
s_function = 'mcds.custom_data_astype',
132+
ls_doc = pcdl.TimeStep.custom_data_astype.__doc__.split('\n'),
133+
)
130134
docstring_md(
131135
s_function = 'mcds.set_verbose_false',
132136
ls_doc = pcdl.TimeStep.set_verbose_false.__doc__.split('\n'),
@@ -332,6 +336,10 @@ def docstring_md(s_function, ls_doc, s_header=None, s_opath='man/docstring/'):
332336
ls_doc = pcdl.TimeSeries.__init__.__doc__.split('\n'),
333337
s_header = "mcdsts = pcdl.TimeSeries('path/to/output')"
334338
)
339+
docstring_md(
340+
s_function = 'mcdsts.custom_data_astype',
341+
ls_doc = pcdl.TimeSeries.custom_data_astype.__doc__.split('\n'),
342+
)
335343
docstring_md(
336344
s_function = 'mcdsts.get_xmlfile_list',
337345
ls_doc = pcdl.TimeSeries.get_xmlfile_list.__doc__.split('\n'),

pcdl/VERSION.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '4.1.1'
1+
__version__ = '4.1.2'

pcdl/timeseries.py

Lines changed: 60 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,10 @@ class TimeSeries:
164164
def __init__(self, output_path='.', custom_data_type={}, load=True, microenv=True, graph=True, physiboss=True, settingxml=False, verbose=True):
165165
"""
166166
input:
167-
output_path: string, default '.'
167+
output_path: string or list of mcds objects, default '.'
168168
relative or absolute path to the directory where
169-
the PhysiCell output files are stored.
169+
the PhysiCell output files are stored or
170+
a list of mcds timestep objects.
170171
171172
custom_data_type: dictionary; default is {}
172173
variable to specify custom_data variable types
@@ -208,31 +209,67 @@ def __init__(self, output_path='.', custom_data_type={}, load=True, microenv=Tru
208209
TimeSeries.__init__ generates a class instance the instance offers
209210
functions to process all time steps in the output_path directory.
210211
"""
211-
output_path = output_path.replace('\\','/')
212-
while (output_path.find('//') > -1):
213-
output_path = output_path.replace('//','/')
214-
if (output_path.endswith('/')) and (len(output_path) > 1):
215-
output_path = output_path[:-1]
216-
if not os.path.isdir(output_path):
217-
sys.exit(f'Error @ TimeSeries.__init__ : this is not a path! could not load {output_path}.')
218-
self.path = output_path
219-
# bue 2022-10-22: is output*.xml always the correct pattern? i could add initial or final step.
220-
self.ls_xmlfile = [s_pathfile.replace('\\','/').split('/')[-1] for s_pathfile in sorted(glob.glob(self.path + f'/output*.xml'))]
221-
if (len(self.ls_xmlfile) == 0):
222-
sys.exit(f'Error @ TimeSeries.__init__ : could not detect any output*.xml! is the given output_path correct? {output_path}')
223-
self.custom_data_type = custom_data_type
224-
self.microenv = microenv
225-
self.graph = graph
226-
self.physiboss = physiboss
227-
self.settingxml = settingxml
212+
# set generic variables
228213
self.verbose = verbose
229-
if load:
230-
self.read_mcds()
231-
else:
232-
self.l_mcds = None
233214
self.l_annmcds = None
234215
self.l_sdmcds = None
235216

217+
# load mcds timeseries from list if mcds timesteps
218+
if (type(output_path) is list):
219+
self.ls_xmlfile = None
220+
self.l_mcds = output_path
221+
self.custom_data_type = None
222+
self.microenv = None
223+
self.graph = None
224+
self.physiboss = None
225+
self.settingxml = None
226+
227+
# load mcds timrseries from physicell output directory
228+
else:
229+
output_path = output_path.replace('\\','/')
230+
while (output_path.find('//') > -1):
231+
output_path = output_path.replace('//','/')
232+
if (output_path.endswith('/')) and (len(output_path) > 1):
233+
output_path = output_path[:-1]
234+
if not os.path.isdir(output_path):
235+
sys.exit(f'Error @ TimeSeries.__init__ : this is not a path! could not load {output_path}.')
236+
self.path = output_path
237+
# bue 2022-10-22: is output*.xml always the correct pattern? i could add initial or final step.
238+
self.ls_xmlfile = [s_pathfile.replace('\\','/').split('/')[-1] for s_pathfile in sorted(glob.glob(self.path + f'/output*.xml'))]
239+
if (len(self.ls_xmlfile) == 0):
240+
sys.exit(f'Error @ TimeSeries.__init__ : could not detect any output*.xml! is the given output_path correct? {output_path}')
241+
self.custom_data_type = custom_data_type
242+
self.microenv = microenv
243+
self.graph = graph
244+
self.physiboss = physiboss
245+
self.settingxml = settingxml
246+
if load:
247+
self.read_mcds()
248+
else:
249+
self.l_mcds = None
250+
251+
252+
def custom_data_astype(self, custom_data_type={}):
253+
"""
254+
input:
255+
custom_data_type: dictionary; default is {}
256+
variable to specify custom_data variable types other than
257+
floats (namely: int, bool, str) like this: {var: dtype, ...}.
258+
downstream float and int will be handled as numeric,
259+
bool as Boolean, and str as categorical data.
260+
261+
output:
262+
self.data['cell']['df_cell']:
263+
the dtype of columns as specified in the custom_data_type dictionary.
264+
265+
description:
266+
function to set the dtype of custom_data variables,
267+
even after the data is loaded.
268+
"""
269+
# variable typing
270+
for mcds in self.get_mcds_list():
271+
mcds.custom_data_astype(custom_data_type=custom_data_type)
272+
236273

237274
def set_verbose_false(self):
238275
"""
@@ -1826,4 +1863,3 @@ def get_sdmcds_list(self):
18261863
function returns a binding to the self.l_sdmcds list of spdata mcds objects.
18271864
"""
18281865
return self.l_sdmcds
1829-

0 commit comments

Comments
 (0)