libplanarradpy/planrad.py
def _run(self, run_dir):
        """Distributed process"""

        # Check to see if the required run_params files exist, if they dont use the tools to generate them

        # --------------------------------------------------#
        # HERE WE RECREATE OUR RUN_PARAMS OBJECT FROM
        # THE RUN FILE WE WROTE TO DISK EARLIER
        # --------------------------------------------------#
        file_tools = FileTools()
        run_dict = file_tools.read_param_file_to_dict(os.path.join(run_dir, 'batch.txt'))
        #print(run_dict['band_centres_data'])

        #self.run_params.wavelengths = run_dict['wavelengths']
        #run_params = RunParameters()
        #run_params = file_tools.dict_to_object(run_params, run_dict)
        #------------------------------------------------#
        # Sky inputs
        #------------------------------------------------#
        #lg.debug(run_dict.keys())
        #self.run_params.update_filenames()
        #lg.debug('!!!!!!!!!' + run_dict['sky_fp'])
        if os.path.isfile(run_dict['sky_fp']):
            sky_file_exists = True
            lg.info('Found sky_tool generated file' + run_dict['sky_fp'])
        else:
            lg.info('No sky_tool generated file, generating one')
            #try:
            inp_file = run_dict['sky_fp'] + '_params.txt'
            #self.run_params.sky_file = inp_file
            self.run_params.write_sky_params_to_file()
            #if not os.path.isfile(inp_file):
            #    lg.error(inp_file + ' : is not a valid parameter file')
            lg.debug('Runing skytool' + os.path.join(self.run_params.exec_path, 'skytool_free') + '#')
            lg.debug(os.path.join(self.run_params.exec_path, 'skytool_free') + ' params=' + inp_file)
            os.system(os.path.join(self.run_params.exec_path, 'skytool_free') + ' params=' + inp_file)
            #except OSError:
            #    lg.exception('Cannot execute PlannarRad, cannot find executable file to skytool_free')

        #------------------------------------------------#
        # Water surface inputs
        #------------------------------------------------#
        if os.path.isfile(run_dict['water_surface_fp']):
            surface_file_exists = True
            lg.info('Found surf_tool generated file' + run_dict['water_surface_fp'])
        else:
            lg.info('No surf_tool generated file, generating one')
            try:
                inp_file = run_dict['water_surface_fp'] + '_params.txt'
                self.run_params.write_surf_params_to_file()
                if not os.path.isfile(inp_file):
                    lg.error(inp_file + ' : is not a valid parameter file')
                os.system(os.path.join(self.run_params.exec_path, 'surftool_free') + ' params=' + inp_file)
            except OSError:
                lg.exception('Cannot execute PlannarRad, cannot find executable file to surftool_free')

        #------------------------------------------------#
        # Phase functions inputs
        #------------------------------------------------#
        if os.path.isfile(run_dict['pf_fp']):
            phase_file_exists = True
            lg.info('Found phase_tool generated file' + run_dict['pf_fp'])
        else:
            lg.info('No sky_tool generated file, generating one')
            try:
                inp_file = run_dict['pf_fp'] + '_params.txt'
                self.run_params.write_phase_params_to_file()
                if not os.path.isfile(inp_file):
                    lg.error(inp_file + ' : is not a valid parameter file')
                os.system(os.path.join(self.run_params.exec_path, 'phasetool_free') + ' params=' + inp_file)
            except OSError:
                lg.exception('Cannot execute PlannarRad, cannot find executable file to phasetool_free')

        #------------------------------------------------#
        # slabtool inputs [Run planarrad]
        #------------------------------------------------#

        inp_file = run_dict['name']

        if not os.path.isfile(inp_file):
            lg.error(inp_file + ' : is not a valid batch file')

        try:
            os.system(os.path.join(self.run_params.exec_path, 'slabtool_free') + ' params=' + inp_file)
        except OSError:
            lg.exception('Cannot execute PlannarRad, cannot find executable file to slabtool_free')
def _run(self, run_dir):
        """Distributed process"""

        # Check to see if the required run_params files exist, if they dont use the tools to generate them

        # --------------------------------------------------#
        # HERE WE RECREATE OUR RUN_PARAMS OBJECT FROM
        # THE RUN FILE WE WROTE TO DISK EARLIER
        # --------------------------------------------------#
        file_tools = FileTools()
        run_dict = file_tools.read_param_file_to_dict(os.path.join(run_dir, 'batch.txt'))
        #print(run_dict['band_centres_data'])

        #self.run_params.wavelengths = run_dict['wavelengths']
        #run_params = RunParameters()
        #run_params = file_tools.dict_to_object(run_params, run_dict)
        #------------------------------------------------#
        # Sky inputs
        #------------------------------------------------#
        #lg.debug(run_dict.keys())
        #self.run_params.update_filenames()
        #lg.debug('!!!!!!!!!' + run_dict['sky_fp'])
        if os.path.isfile(run_dict['sky_fp']):
            sky_file_exists = True
            lg.info('Found sky_tool generated file' + run_dict['sky_fp'])
        else:
            lg.info('No sky_tool generated file, generating one')
            #try:
            inp_file = run_dict['sky_fp'] + '_params.txt'
            #self.run_params.sky_file = inp_file
            self.run_params.write_sky_params_to_file()
            #if not os.path.isfile(inp_file):
            #    lg.error(inp_file + ' : is not a valid parameter file')
            lg.debug('Runing skytool' + os.path.join(self.run_params.exec_path, 'skytool_free') + '#')
            lg.debug(os.path.join(self.run_params.exec_path, 'skytool_free') + ' params=' + inp_file)
            os.system(os.path.join(self.run_params.exec_path, 'skytool_free') + ' params=' + inp_file)
            #except OSError:
            #    lg.exception('Cannot execute PlannarRad, cannot find executable file to skytool_free')

        #------------------------------------------------#
        # Water surface inputs
        #------------------------------------------------#
        if os.path.isfile(run_dict['water_surface_fp']):
            surface_file_exists = True
            lg.info('Found surf_tool generated file' + run_dict['water_surface_fp'])
        else:
            lg.info('No surf_tool generated file, generating one')
            try:
                inp_file = run_dict['water_surface_fp'] + '_params.txt'
                self.run_params.write_surf_params_to_file()
                if not os.path.isfile(inp_file):
                    lg.error(inp_file + ' : is not a valid parameter file')
                os.system(os.path.join(self.run_params.exec_path, 'surftool_free') + ' params=' + inp_file)
            except OSError:
                lg.exception('Cannot execute PlannarRad, cannot find executable file to surftool_free')

        #------------------------------------------------#
        # Phase functions inputs
        #------------------------------------------------#
        if os.path.isfile(run_dict['pf_fp']):
            phase_file_exists = True
            lg.info('Found phase_tool generated file' + run_dict['pf_fp'])
        else:
            lg.info('No sky_tool generated file, generating one')
            try:
                inp_file = run_dict['pf_fp'] + '_params.txt'
                self.run_params.write_phase_params_to_file()
                if not os.path.isfile(inp_file):
                    lg.error(inp_file + ' : is not a valid parameter file')
                os.system(os.path.join(self.run_params.exec_path, 'phasetool_free') + ' params=' + inp_file)
            except OSError:
                lg.exception('Cannot execute PlannarRad, cannot find executable file to phasetool_free')

        #------------------------------------------------#
        # slabtool inputs [Run planarrad]
        #------------------------------------------------#

        inp_file = run_dict['name']

        if not os.path.isfile(inp_file):
            lg.error(inp_file + ' : is not a valid batch file')

        try:
            os.system(os.path.join(self.run_params.exec_path, 'slabtool_free') + ' params=' + inp_file)
        except OSError:
            lg.exception('Cannot execute PlannarRad, cannot find executable file to slabtool_free')
Distributed process