diff --git a/python/lsst/ts/imsim/imsim_cmpt.py b/python/lsst/ts/imsim/imsim_cmpt.py index cf935a1..2c13376 100644 --- a/python/lsst/ts/imsim/imsim_cmpt.py +++ b/python/lsst/ts/imsim/imsim_cmpt.py @@ -22,6 +22,7 @@ __all__ = ["ImsimCmpt"] import os +import sys from typing import Any import numpy as np @@ -327,13 +328,20 @@ def run_imsim(self, config_file_path: str, imsim_log_file: str = "") -> None: # this variable gets set when sklearn is imported, which happens inside # of ts_wep before ever getting to this method, so we can't just unset # it in the environment ahead of time. - with ModifiedEnvironment(KMP_INIT_AT_FORK=None): - if imsim_log_file == "": - runProgram(f"galsim {config_file_path}") - else: - runProgram( - f"galsim {config_file_path} -l {os.path.join(self.output_dir, imsim_log_file)} -v 2" - ) + if imsim_log_file == "": + cmd = f"galsim {config_file_path}" + else: + cmd = f"galsim {config_file_path} -l {os.path.join(self.output_dir, imsim_log_file)} -v 2" + # Disabling the KMP_INIT_AT_FORK env variable only for OSX. + # This line checks whether the platform identifies itself as OSX. + # For all other environments (eg. linux) this is not needed; + # and indeed was found to cause issues for mag=12 and brighter + # source on USDF. + if sys.platform.startswith("darwin"): + with ModifiedEnvironment(KMP_INIT_AT_FORK=None): + runProgram(cmd) + else: + runProgram(cmd) def write_yaml_and_run_imsim( self,