예제 #1
0
    def create_two_driving_datasets(self):
        """
        Creates two driving datasets with datasets, parameter values etc set up
        :return: nothing
        """

        with session_scope(Session) as session:
            self.create_driving_dataset(session)

            model_run_service = ModelRunService()

            driving2 = DrivingDataset()
            driving2.name = "driving2"
            driving2.description = "driving 2 description"
            driving2.geographic_region = 'Global'
            driving2.spatial_resolution = 'Half degree'
            driving2.temporal_resolution = '3 Hours'
            driving2.boundary_lat_north = 85
            driving2.boundary_lat_south = -90
            driving2.boundary_lon_west = -180
            driving2.boundary_lon_east = 180
            driving2.time_start = datetime.datetime(1901, 1, 1, 0, 0, 0)
            driving2.time_end = datetime.datetime(2001, 1, 1, 0, 0, 0)
            driving2.view_order_index = 200
            driving2.usage_order_index = 2
            driving2.is_restricted_to_admins = False

            location3 = DrivingDatasetLocation()
            location3.base_url = "base_url3"
            location3.driving_dataset = driving2

            val = f90_helper.python_to_f90_str(8 * ["i"])
            pv1 = DrivingDatasetParameterValue(model_run_service, driving2,
                                               constants.JULES_PARAM_DRIVE_INTERP, val)
            val = f90_helper.python_to_f90_str(3600)
            pv2 = DrivingDatasetParameterValue(model_run_service, driving2,
                                               constants.JULES_PARAM_DRIVE_DATA_PERIOD, val)
            val = f90_helper.python_to_f90_str("data/driving2/frac.nc")
            pv3 = DrivingDatasetParameterValue(model_run_service, driving2,
                                               constants.JULES_PARAM_FRAC_FILE, val)
            val = f90_helper.python_to_f90_str("frac2")
            pv4 = DrivingDatasetParameterValue(model_run_service, driving2,
                                               constants.JULES_PARAM_FRAC_NAME, val)
            val = f90_helper.python_to_f90_str(['b', 'sathh', 'satcon', 'sm_sat', 'sm_crit',
                                                'sm_wilt', 'hcap', 'hcon', 'albsoil'])
            pv5 = DrivingDatasetParameterValue(model_run_service, driving2,
                                               constants.JULES_PARAM_SOIL_PROPS_VAR, val)
            val = f90_helper.python_to_f90_str(['bexp', 'sathh', 'satcon', 'vsat', 'vcrit',
                                                'vwilt', 'hcap', 'hcon', 'albsoil'])
            pv6 = DrivingDatasetParameterValue(model_run_service, driving2,
                                               constants.JULES_PARAM_SOIL_PROPS_VAR_NAME, val)
            val = f90_helper.python_to_f90_str(9)
            pv7 = DrivingDatasetParameterValue(model_run_service, driving2,
                                               constants.JULES_PARAM_SOIL_PROPS_NVARS, val)
            val = f90_helper.python_to_f90_str("data/WATCH_2D/ancils/soil_igbp_bc_watch_0p5deg_capUM6.6_2D.nc")
            pv7 = DrivingDatasetParameterValue(model_run_service, driving2,
                                               constants.JULES_PARAM_SOIL_PROPS_FILE, val)
            session.add(driving2)
            session.commit()
def _create_watch_driving_data_basic(conf):
    watch_driving_dataset = DrivingDataset()
    watch_driving_dataset.name = "WATCH Forcing Data 20th Century"
    watch_driving_dataset.description = \
        "A sub-diurnal meteorological forcing dataset: based on ERA-40 for the sub-monthly variability, " \
        "tuned to CRU monthly observations. " \
        "See Weedon et al, 2011, Journal of Hydrometeorology, doi: 10.1175/2011JHM1369.1"
    watch_driving_dataset.geographic_region = 'Global'
    watch_driving_dataset.temporal_resolution = '3 Hours'
    watch_driving_dataset.spatial_resolution = '0.5 Degrees'
    watch_driving_dataset.boundary_lat_north = 84
    watch_driving_dataset.boundary_lat_south = -56
    watch_driving_dataset.boundary_lon_west = -180
    watch_driving_dataset.boundary_lon_east = 180
    watch_driving_dataset.time_start = datetime.datetime(1901, 1, 1, 0, 0, 0)
    if conf['full_data_range'].lower() == "true":
        watch_driving_dataset.time_end = datetime.datetime(2001, 12, 31, 21, 0, 0)
    else:
        watch_driving_dataset.time_end = datetime.datetime(1901, 1, 31, 21, 0, 0)
    watch_driving_dataset.view_order_index = 100
    watch_driving_dataset.usage_order_index = 2
    watch_driving_dataset.is_restricted_to_admins = False
    return watch_driving_dataset
def _create_chess_data_basic(conf):
    chess_driving_dataset = DrivingDataset()
    chess_driving_dataset.name = "UK CHESS Forcing Data"
    chess_driving_dataset.description = \
        "A daily meteorological forcing dataset: based on MORECS at 40km and downscaled to 1km using sub-grid scale " \
        "topography. See Robinson et al, 2014. manuscript in prep."
    chess_driving_dataset.geographic_region = 'UK'
    chess_driving_dataset.temporal_resolution = '24 Hours'
    chess_driving_dataset.spatial_resolution = '1 km'
    chess_driving_dataset.boundary_lat_north = 59
    chess_driving_dataset.boundary_lat_south = 50
    chess_driving_dataset.boundary_lon_west = -7.5
    chess_driving_dataset.boundary_lon_east = 1.5
    chess_driving_dataset.time_start = datetime.datetime(1961, 1, 1, 0, 0, 0)
    if conf['full_data_range'].lower() == "true":
        chess_driving_dataset.time_end = datetime.datetime(1999, 1, 1, 0, 0, 0)
    else:
        chess_driving_dataset.time_end = datetime.datetime(1961, 1, 31, 0, 0, 0)
    chess_driving_dataset.view_order_index = 200
    chess_driving_dataset.usage_order_index = 1
    chess_driving_dataset.is_restricted_to_admins = True

    return chess_driving_dataset
예제 #4
0
    def create_driving_dataset(
            self,
            session,
            jules_params=DrivingDatasetJulesParams(dataperiod=3600, var_interps=8 * ["i"]),
            is_restricted_to_admins=False,
            data_range_from = 10,
            data_range_to = 5):
        """
        Create a driving dataset
        :param session: session to use
        :param jules_params: set of jules parameters
        :return: dataset
        """
        model_run_service = ModelRunService()

        driving1 = DrivingDataset()
        driving1.name = "driving1"
        driving1.description = "driving 1 description"
        driving1.geographic_region = 'European'
        driving1.spatial_resolution = '1km'
        driving1.temporal_resolution = '24 hours'
        driving1.boundary_lat_north = 50
        driving1.boundary_lat_south = -10
        driving1.boundary_lon_west = -15
        driving1.boundary_lon_east = 30
        driving1.time_start = datetime.datetime(1979, 1, 1, 0, 0, 0)
        driving1.time_end = datetime.datetime(2010, 1, 1, 0, 0, 0)
        driving1.view_order_index = 100
        driving1.is_restricted_to_admins = is_restricted_to_admins
        location1 = DrivingDatasetLocation()
        location1.base_url = "base_url"
        location1.dataset_type_id = 1
        location1.driving_dataset = driving1
        location2 = DrivingDatasetLocation()
        location2.base_url = "base_url2"
        location2.driving_dataset = driving1
        location2.dataset_type_id = 1
        jules_params.add_to_driving_dataset(model_run_service, driving1, session)

        val = f90_helper.python_to_f90_str(8 * ["i"])
        pv1 = DrivingDatasetParameterValue(model_run_service, driving1,
                                           constants.JULES_PARAM_DRIVE_INTERP, val)
        val = f90_helper.python_to_f90_str(3600)
        pv2 = DrivingDatasetParameterValue(model_run_service, driving1,
                                           constants.JULES_PARAM_DRIVE_DATA_PERIOD, val)
        val = f90_helper.python_to_f90_str("data/driving1/frac.nc")
        pv3 = DrivingDatasetParameterValue(model_run_service, driving1,
                                           constants.JULES_PARAM_FRAC_FILE, val)
        val = f90_helper.python_to_f90_str("frac")
        pv4 = DrivingDatasetParameterValue(model_run_service, driving1,
                                           constants.JULES_PARAM_FRAC_NAME, val)

        session.add(driving1)
        session.commit()

        driving_data_filename_param_val = DrivingDatasetParameterValue(
            model_run_service,
            driving1,
            constants.JULES_PARAM_DRIVE_FILE,
            "'testFileName'")
        session.add(driving_data_filename_param_val)
        session.commit()

        return driving1