libplanarradpy/planrad.py
def generate_directories(self, overwrite=False):
        """For all possible combinations of 'batchable' parameters. create a unique directory to story outputs

        Each directory name is unique and contains the run parameters in the directory name

        :param overwrite: If set to True will over write all files default = False
        """
        if not os.path.exists(self.batch_output):
            try:
                lg.info('Creating batch project directory')
                if self.batch_output == self.run_params.output_path + 'batch':
                    lg.warning('Using default project name.  Consider renaming!')
                os.makedirs(self.batch_output)
            except OSError:
                lg.exception('Could not create project directory')

        elif os.path.exists(self.batch_output) and overwrite == True:
            try:
                lg.info('Creating batch project directory')
                lg.warning('Overwriting existing directories')
                if self.batch_output == self.run_params.output_path + 'batch':
                    lg.warning('Using default project name.  Consider renaming!')
                os.makedirs(self.batch_output)
            except OSError:
                lg.exception('Could not create project directory')



        # --------------------------------------------------#
        # GENERATE ALL THE IOPS FROM BIOP
        # --------------------------------------------------#

        #--------------------------------------------------#
        # WRITE EACH BIOP TO CSV FILE INTO THE INPUT
        # DIRECTORY IF IT DOESNT EXIST
        #--------------------------------------------------#

        #--------------------------------------------------#
        # GENERATE A LIST OF ALL COMBINATIONS OF BIOPS
        #--------------------------------------------------#

        #--------------------------------------------------#
        # WRITE THE DIRECTORIES FOR EACH BIOP AND NAME APPROPRIATELY
        # DON'T OVERWRITE IF THEY EXIST ALREADY
        #--------------------------------------------------#

        self.bio_params.read_pure_water_absorption_from_file(
            self.run_params.pure_water_absorption_file)
        self.bio_params.read_pure_water_scattering_from_file(
            self.run_params.pure_water_scattering_file)
        self.bio_params.read_aphi_from_file(self.run_params.phytoplankton_absorption_file)

        for saa in self.saa_list:
            # update the saa in the run file & the todo filename!
            self.run_params.sky_aziumth = saa
            self.run_params.sky_file = os.path.abspath(
                os.path.join(os.path.join(self.run_params.input_path, 'sky_files'),
                             'sky_' + self.run_params.sky_state + '_z' + str(self.run_params.sky_zenith) + '_a' + str(
                                 self.run_params.sky_azimuth) + '_' + str(
                                 self.run_params.num_bands) + '_' + self.run_params.ds_code))

            for sza in self.sza_list:
                # update the saz in the run file
                self.run_params.sky_zenith = sza
                self.run_params.sky_file = os.path.abspath(
                    os.path.join(os.path.join(self.run_params.input_path, 'sky_files'),
                                 'sky_' + self.run_params.sky_state + '_z' + str(
                                     self.run_params.sky_zenith) + '_a' + str(self.run_params.sky_azimuth) + '_' + str(
                                     self.run_params.num_bands) + '_' + self.run_params.ds_code))
                for p in self.p_list:
                    for x in self.x_list:
                        for y in self.y_list:
                            for g in self.g_list:
                                for s in self.s_list:
                                    for z in self.z_list:
                                        file_name = 'SAA' + str(saa) + '_SZA' + str(sza) + '_P' + str(p) + '_X' + str(
                                            x) + '_Y' + str(y) + '_G' + str(g) + '_S' + str(s) + '_Z' + str(z)
                                        dir_name = os.path.join(self.batch_output, file_name)
                                        self.run_params.output_path = dir_name
                                        #--------------------------------------------------#
                                        # UPDATE THE IOP PARAMETERS FOR THE RUN FILE
                                        #--------------------------------------------------#
                                        self.run_params.sky_azimuth = saa
                                        self.run_params.sky_zenith = sza
                                        self.run_params.depth = z
                                        self.bio_params.build_bbp(x, y)  # todo add wave const as a kwarg
                                        self.bio_params.build_a_cdom(g, s)
                                        # Need to re-read the file as it was scaled in a the other run!
                                        self.bio_params.read_aphi_from_file(
                                            self.run_params.phytoplankton_absorption_file)
                                        self.bio_params.scale_aphi(p)

                                        self.bio_params.build_all_iop()
                                        self.run_params.scattering_file = os.path.join(
                                            os.path.join(self.run_params.input_path, 'iop_files'), 'b_' + file_name)
                                        self.bio_params.write_b_to_file(self.run_params.scattering_file)

                                        self.run_params.attenuation_file = os.path.join(
                                            os.path.join(self.run_params.input_path, 'iop_files'), 'c_' + file_name)
                                        self.bio_params.write_c_to_file(self.run_params.attenuation_file)

                                        self.run_params.project_file = os.path.join(dir_name, 'batch.txt')
                                        self.run_params.report_file = os.path.join(dir_name, 'report.txt')

                                        self.run_params.write_sky_params_to_file()
                                        self.run_params.write_surf_params_to_file()
                                        self.run_params.write_phase_params_to_file()

                                        if not os.path.exists(dir_name):
                                            try:
                                                lg.info('Creating run directory')
                                                os.makedirs(dir_name)
                                                self.run_params.write_run_parameters_to_file()
                                            except OSError:
                                                lg.exception('Could not create run directory')

                                        elif os.path.exists(dir_name) and overwrite == True:
                                            try:
                                                lg.info('Creating run directory')
                                                lg.warning('Overwriting existing directories')
                                                os.makedirs(dir_name)
                                                self.run_params.write_run_parameters_to_file()
                                            except OSError:
                                                lg.exception('Could not create run directory')
def generate_directories(self, overwrite=False):
        """For all possible combinations of 'batchable' parameters. create a unique directory to story outputs

        Each directory name is unique and contains the run parameters in the directory name

        :param overwrite: If set to True will over write all files default = False
        """
        if not os.path.exists(self.batch_output):
            try:
                lg.info('Creating batch project directory')
                if self.batch_output == self.run_params.output_path + 'batch':
                    lg.warning('Using default project name.  Consider renaming!')
                os.makedirs(self.batch_output)
            except OSError:
                lg.exception('Could not create project directory')

        elif os.path.exists(self.batch_output) and overwrite == True:
            try:
                lg.info('Creating batch project directory')
                lg.warning('Overwriting existing directories')
                if self.batch_output == self.run_params.output_path + 'batch':
                    lg.warning('Using default project name.  Consider renaming!')
                os.makedirs(self.batch_output)
            except OSError:
                lg.exception('Could not create project directory')



        # --------------------------------------------------#
        # GENERATE ALL THE IOPS FROM BIOP
        # --------------------------------------------------#

        #--------------------------------------------------#
        # WRITE EACH BIOP TO CSV FILE INTO THE INPUT
        # DIRECTORY IF IT DOESNT EXIST
        #--------------------------------------------------#

        #--------------------------------------------------#
        # GENERATE A LIST OF ALL COMBINATIONS OF BIOPS
        #--------------------------------------------------#

        #--------------------------------------------------#
        # WRITE THE DIRECTORIES FOR EACH BIOP AND NAME APPROPRIATELY
        # DON'T OVERWRITE IF THEY EXIST ALREADY
        #--------------------------------------------------#

        self.bio_params.read_pure_water_absorption_from_file(
            self.run_params.pure_water_absorption_file)
        self.bio_params.read_pure_water_scattering_from_file(
            self.run_params.pure_water_scattering_file)
        self.bio_params.read_aphi_from_file(self.run_params.phytoplankton_absorption_file)

        for saa in self.saa_list:
            # update the saa in the run file & the todo filename!
            self.run_params.sky_aziumth = saa
            self.run_params.sky_file = os.path.abspath(
                os.path.join(os.path.join(self.run_params.input_path, 'sky_files'),
                             'sky_' + self.run_params.sky_state + '_z' + str(self.run_params.sky_zenith) + '_a' + str(
                                 self.run_params.sky_azimuth) + '_' + str(
                                 self.run_params.num_bands) + '_' + self.run_params.ds_code))

            for sza in self.sza_list:
                # update the saz in the run file
                self.run_params.sky_zenith = sza
                self.run_params.sky_file = os.path.abspath(
                    os.path.join(os.path.join(self.run_params.input_path, 'sky_files'),
                                 'sky_' + self.run_params.sky_state + '_z' + str(
                                     self.run_params.sky_zenith) + '_a' + str(self.run_params.sky_azimuth) + '_' + str(
                                     self.run_params.num_bands) + '_' + self.run_params.ds_code))
                for p in self.p_list:
                    for x in self.x_list:
                        for y in self.y_list:
                            for g in self.g_list:
                                for s in self.s_list:
                                    for z in self.z_list:
                                        file_name = 'SAA' + str(saa) + '_SZA' + str(sza) + '_P' + str(p) + '_X' + str(
                                            x) + '_Y' + str(y) + '_G' + str(g) + '_S' + str(s) + '_Z' + str(z)
                                        dir_name = os.path.join(self.batch_output, file_name)
                                        self.run_params.output_path = dir_name
                                        #--------------------------------------------------#
                                        # UPDATE THE IOP PARAMETERS FOR THE RUN FILE
                                        #--------------------------------------------------#
                                        self.run_params.sky_azimuth = saa
                                        self.run_params.sky_zenith = sza
                                        self.run_params.depth = z
                                        self.bio_params.build_bbp(x, y)  # todo add wave const as a kwarg
                                        self.bio_params.build_a_cdom(g, s)
                                        # Need to re-read the file as it was scaled in a the other run!
                                        self.bio_params.read_aphi_from_file(
                                            self.run_params.phytoplankton_absorption_file)
                                        self.bio_params.scale_aphi(p)

                                        self.bio_params.build_all_iop()
                                        self.run_params.scattering_file = os.path.join(
                                            os.path.join(self.run_params.input_path, 'iop_files'), 'b_' + file_name)
                                        self.bio_params.write_b_to_file(self.run_params.scattering_file)

                                        self.run_params.attenuation_file = os.path.join(
                                            os.path.join(self.run_params.input_path, 'iop_files'), 'c_' + file_name)
                                        self.bio_params.write_c_to_file(self.run_params.attenuation_file)

                                        self.run_params.project_file = os.path.join(dir_name, 'batch.txt')
                                        self.run_params.report_file = os.path.join(dir_name, 'report.txt')

                                        self.run_params.write_sky_params_to_file()
                                        self.run_params.write_surf_params_to_file()
                                        self.run_params.write_phase_params_to_file()

                                        if not os.path.exists(dir_name):
                                            try:
                                                lg.info('Creating run directory')
                                                os.makedirs(dir_name)
                                                self.run_params.write_run_parameters_to_file()
                                            except OSError:
                                                lg.exception('Could not create run directory')

                                        elif os.path.exists(dir_name) and overwrite == True:
                                            try:
                                                lg.info('Creating run directory')
                                                lg.warning('Overwriting existing directories')
                                                os.makedirs(dir_name)
                                                self.run_params.write_run_parameters_to_file()
                                            except OSError:
                                                lg.exception('Could not create run directory')
For all possible combinations of 'batchable' parameters. create a unique directory to story outputs

        Each directory name is unique and contains the run parameters in the directory name

        :param overwrite: If set to True will over write all files default = False