Skip to content

Commit 17aae47

Browse files
committed
Calculate parallel and master_node flags in RLparallelscript.py
1 parent 7a2f65c commit 17aae47

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

cosipy/image_deconvolution/RLparallelscript.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,15 @@ def main():
4848
parameter_filepath = DATA_DIR / 'imagedeconvolution_parfile_gal_511keV.yml'
4949
image_deconvolution.read_parameterfile(parameter_filepath)
5050

51+
parallel_computation = True
52+
if comm.Get_rank() == MASTER:
53+
master_node = True
54+
else:
55+
master_node = False
56+
5157
# Initialize model
52-
image_deconvolution.initialize(comm=comm)
58+
image_deconvolution.initialize(parallel_computation = parallel_computation,
59+
master_node = master_node)
5360

5461
# Execute deconvolution
5562
image_deconvolution.run_deconvolution()

cosipy/image_deconvolution/RichardsonLucy.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,9 @@ def finalization(self):
262262
for this_result in self.results:
263263
iteration_count = this_result["iteration"]
264264

265-
this_result["model"].write(f"{self.save_results_directory}/model_itr{iteration_count}_2.hdf5", overwrite = True)
266-
this_result["delta_model"].write(f"{self.save_results_directory}/delta_model_itr{iteration_count}_2.hdf5", overwrite = True)
267-
this_result["processed_delta_model"].write(f"{self.save_results_directory}/processed_delta_model_itr{iteration_count}_2.hdf5", overwrite = True)
265+
this_result["model"].write(f"{self.save_results_directory}/model_itr{iteration_count}.hdf5", overwrite = True)
266+
this_result["delta_model"].write(f"{self.save_results_directory}/delta_model_itr{iteration_count}.hdf5", overwrite = True)
267+
this_result["processed_delta_model"].write(f"{self.save_results_directory}/processed_delta_model_itr{iteration_count}.hdf5", overwrite = True)
268268

269269
#fits
270270
primary_hdu = fits.PrimaryHDU()

cosipy/image_deconvolution/image_deconvolution.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
from .RichardsonLucy import RichardsonLucy
1212
from .RichardsonLucySimple import RichardsonLucySimple
1313

14-
# MPI Master node
15-
MASTER = 0
16-
1714
class ImageDeconvolution:
1815
"""
1916
A class to reconstruct all-sky images from COSI data based on image deconvolution methods.
@@ -121,21 +118,14 @@ def results(self):
121118
"""
122119
return self._deconvolution.results
123120

124-
def initialize(self, comm = None): # comm is required if the user intends to use parallel features
121+
def initialize(self, parallel_computation = False, master_node = True):
125122
"""
126123
Initialize an initial model and an image deconvolution algorithm.
127124
It is mandatory to execute this method before running the image deconvolution.
128125
"""
129126

130-
if comm is None:
131-
self.parallel_computation = False
132-
self.master_node = True
133-
elif comm.Get_rank() == MASTER:
134-
self.parallel_computation = True
135-
self.master_node = True
136-
else:
137-
self.parallel_computation = True
138-
self.master_node = False
127+
self.parallel_computation = parallel_computation
128+
self.master_node = master_node
139129

140130
logger.info("#### Initialization Starts ####")
141131

0 commit comments

Comments
 (0)