Ejemplo n.º 1
0
 def _create_fractional_file_and_set_parameters(self, parameters, run_model):
     """
     Create a land cover fractional ASCII file on the job runner and set the appropriate parameter
     in the parameter list
     :param parameters: List of parameters for model run
     :param run_model: Model run
     :return: JSON land cover object (empty)
     """
     # Save the fractional file
     self.start_new_file(run_model.id, constants.FRACTIONAL_FILENAME)
     self.append_to_file(run_model.id, constants.FRACTIONAL_FILENAME, run_model.land_cover_frac)
     self.close_file(run_model.id, constants.FRACTIONAL_FILENAME)
     utils.set_parameter_value_in_parameter_list(
         parameters, constants.JULES_PARAM_FRAC_FILE, constants.FRACTIONAL_FILENAME)
     return {}
Ejemplo n.º 2
0
 def alter_driving_data_start(self, parameters):
     """
     Moves the driving data start to be closer to the main run start
     Due to a bug in JULES if the driving data start is too far before the main run start,
     an integer overflows and causes an error. We therefore need to move the driving data
     start close to the model run
     :param parameters: List of parameters
     :return:
     """
     driving_start = utils.get_first_parameter_value_from_parameter_list(parameters,
                                                                         constants.JULES_PARAM_DRIVE_DATA_START)
     spinup_start = utils.get_first_parameter_value_from_parameter_list(parameters,
                                                                        constants.JULES_PARAM_SPINUP_START)
     time_gap = relativedelta(years=10)
     new_driving_start = max(spinup_start - time_gap, driving_start)
     utils.set_parameter_value_in_parameter_list(
         parameters, constants.JULES_PARAM_DRIVE_DATA_START, new_driving_start)
     return parameters
Ejemplo n.º 3
0
    def _create_json_land_cover(self, parameters):
        """
        Create a JSON land cover object with the land cover base filename, variable key and empty
        actions and single point edits
        :param parameters: Parameters for model run
        :return: JSON land cover object
        """
        json_land_cover = {}

        fractional_base_filename = utils.get_first_parameter_value_from_parameter_list(
            parameters, constants.JULES_PARAM_FRAC_FILE)
        utils.set_parameter_value_in_parameter_list(
            parameters, constants.JULES_PARAM_FRAC_FILE, constants.USER_EDITED_FRACTIONAL_FILENAME)
        fractional_base_variable_key = utils.get_first_parameter_value_from_parameter_list(
            parameters, constants.JULES_PARAM_FRAC_NAME)

        # Create the land cover JSON object
        json_land_cover[constants.JSON_LAND_COVER_BASE_FILE] = fractional_base_filename
        json_land_cover[constants.JSON_LAND_COVER_BASE_KEY] = fractional_base_variable_key
        json_land_cover[constants.JSON_LAND_COVER_ACTIONS] = []
        json_land_cover[constants.JSON_LAND_COVER_POINT_EDIT] = {}
        return json_land_cover