コード例 #1
0
 def _get_region_environment(self, sources):
     region_env = api.ARegionEnvironment()
     region_env.temperature = sources["temperature"]
     region_env.precipitation = sources["precipitation"]
     region_env.radiation = sources["radiation"]
     region_env.wind_speed = sources["wind_speed"]
     region_env.rel_hum = sources["relative_humidity"]
     return region_env
コード例 #2
0
 def create_dummy_region_environment(self, time_axis, mid_point):
     re = api.ARegionEnvironment()
     re.precipitation.append(self._create_constant_geo_ts(api.PrecipitationSource, mid_point, time_axis.total_period(), 5.0))
     re.temperature.append(self._create_constant_geo_ts(api.TemperatureSource, mid_point, time_axis.total_period(), 10.0))
     re.wind_speed.append(self._create_constant_geo_ts(api.WindSpeedSource, mid_point, time_axis.total_period(), 2.0))
     re.rel_hum.append(self._create_constant_geo_ts(api.RelHumSource, mid_point, time_axis.total_period(), 0.7))
     re.radiation = api.RadiationSourceVector()  # just for testing BW compat
     re.radiation.append(self._create_constant_geo_ts(api.RadiationSource, mid_point, time_axis.total_period(), 300.0))
     return re
コード例 #3
0
                                            float(rsvr), float(frst),
                                            float(unsp))

    rad_fx = 0.9
    # note, for now we need to make sure we cast some types to pure python, not numpy
    geo_cell_data = api.GeoCellData(gp, float(cell_area), int(cid), rad_fx,
                                    land_cover_frac)

    cell_data_vector.append(geo_cell_data)

# put it all together to initialize a model, we'll use PTGSK

params = api.pt_gs_k.PTGSKParameter()
model = api.pt_gs_k.PTGSKModel(cell_data_vector, params)

re = api.ARegionEnvironment()

# map the variable names in the netcdf file to source types
source_map = {
    'precipitation':
    ('precipitation.nc', api.PrecipitationSource, re.precipitation),
    'global_radiation': ('radiation.nc', api.RadiationSource, re.radiation),
    'temperature': ('temperature.nc', api.TemperatureSource, re.temperature),
    'wind_speed': ('wind_speed.nc', api.WindSpeedSource, re.wind_speed),
    'relative_humidity': ('relative_humidity.nc', api.RelHumSource, re.rel_hum)
}

for var, (file_name, source_type, source_vec) in source_map.items():
    nci = Dataset(
        os.path.join(shyftdata_dir,
                     'netcdf/orchestration-testdata/' + file_name))
コード例 #4
0
 def test_create_region_environment(self):
     region_env = api.ARegionEnvironment()
     temp_vector = api.TemperatureSourceVector()
     region_env.temperature = temp_vector
     self.assertTrue(region_env is not None)