当前位置: 首页>>代码示例>>Python>>正文


Python World.set_temperature方法代码示例

本文整理汇总了Python中worldengine.world.World.set_temperature方法的典型用法代码示例。如果您正苦于以下问题:Python World.set_temperature方法的具体用法?Python World.set_temperature怎么用?Python World.set_temperature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在worldengine.world.World的用法示例。


在下文中一共展示了World.set_temperature方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_world_to_hdf5

# 需要导入模块: from worldengine.world import World [as 别名]
# 或者: from worldengine.world.World import set_temperature [as 别名]
def load_world_to_hdf5(filename):
    f = h5py.File(filename, libver='latest', mode='r')

    w = World(f['general/name'].value,
              f['general/width'].value,
              f['general/height'].value,
              f['generation_params/seed'].value,
              f['generation_params/n_plates'].value,
              f['generation_params/ocean_level'].value,
              Step.get_by_name(f['generation_params/step'].value))

    # Elevation
    e = numpy.array(f['elevation/data'])
    e_th = [('sea', f['elevation/thresholds/sea'].value),
            ('plain', f['elevation/thresholds/plain'].value),
            ('hill', f['elevation/thresholds/hill'].value),
            ('mountain', None)]
    w.set_elevation(e, e_th)

    # Plates
    w.set_plates(numpy.array(f['plates']))

    # Ocean
    w.set_ocean(numpy.array(f['ocean']))
    w.sea_depth = numpy.array(f['sea_depth'])

    # Biome
    if 'biome' in f.keys():
        biome_data = []
        for y in range(w.height):
            row = []
            for x in range(w.width):
                value = f['biome'][y, x]
                row.append(biome_index_to_name(value))
            biome_data.append(row)
        biome = numpy.array(biome_data, dtype=object)
        w.set_biome(biome)

    # Humidity
    # FIXME: use setters
    if 'humidity' in f.keys():
        w.humidity = _from_hdf5_matrix_with_quantiles(f['humidity'])
        w.humidity['data'] = numpy.array(w.humidity['data']) # numpy conversion

    if 'irrigation' in f.keys():
        w.irrigation = numpy.array(f['irrigation'])

    if 'permeability' in f.keys():
        p = numpy.array(f['permeability/data'])
        p_th = [
            ('low', f['permeability/thresholds/low'].value),
            ('med', f['permeability/thresholds/med'].value),
            ('hig', None)
        ]
        w.set_permeability(p, p_th)

    if 'watermap' in f.keys():
        w.watermap = dict()
        w.watermap['data'] = numpy.array(f['watermap/data'])
        w.watermap['thresholds'] = {}
        w.watermap['thresholds']['creek'] = f['watermap/thresholds/creek'].value
        w.watermap['thresholds']['river'] =  f['watermap/thresholds/river'].value
        w.watermap['thresholds']['main river'] =  f['watermap/thresholds/mainriver'].value

    if 'precipitation' in f.keys():
        p = numpy.array(f['precipitation/data'])
        p_th = [
            ('low', f['precipitation/thresholds/low'].value),
            ('med', f['precipitation/thresholds/med'].value),
            ('hig', None)
        ]
        w.set_precipitation(p, p_th)

    if 'temperature' in f.keys():
        t = numpy.array(f['temperature/data'])
        t_th = [
            ('polar', f['temperature/thresholds/polar'].value),
            ('alpine', f['temperature/thresholds/alpine'].value),
            ('boreal', f['temperature/thresholds/boreal'].value),
            ('cool', f['temperature/thresholds/cool'].value),
            ('warm', f['temperature/thresholds/warm'].value),
            ('subtropical', f['temperature/thresholds/subtropical'].value),
            ('tropical', None)
        ]
        w.set_temperature(t, t_th)

    if 'icecap' in f.keys():
        w.icecap = numpy.array(f['icecap'])

    if 'lake_map' in f.keys():
        m = numpy.array(f['lake_map'])
        w.set_lakemap(m)

    if 'river_map' in f.keys():
        m = numpy.array(f['river_map'])
        w.set_rivermap(m)

    f.close()

    return w
开发者ID:theomission,项目名称:worldengine,代码行数:102,代码来源:hdf5_serialization.py


注:本文中的worldengine.world.World.set_temperature方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。