pygplates专栏——Sample code——Query feature types

Query feature types

这个例子展示了如何查询各种类型的特性。

查询coastline feature

示例代码

import pygplates

# 加载全球海岸线特征
coastline_features = pygplates.FeatureCollection("Global_EarthByte_GPlates_PresentDay_Coastlines.gpmlz")
# 遍历海岸线特征
for feature in coastline_features:
    # 输出特征类型和海岸线名称
    print("%s: %s" % (feature.get_feature_type().get_name(), feature.get_name()))
    # 输出海岸线的描述
    print("description: %s" % feature.get_description())
    # 输出海岸线的板块ID
    print("plate ID: %d" % feature.get_reconstruction_plate_id())
    # 输出海岸线几何要素的长度,每个feature可能不止一个几何要素
    for geometry in feature.get_geometries():
        print("length: %f Kms" % (geometry.get_arc_length() * pygplates.Earth.mean_radius_in_kms))
    # 输出海岸线的有效时段
    print("valid teim period: %f -> %f" % feature.get_valid_time())

查询isochron feature

示例代码

import pygplates

# 加载等时线数据
isochron_features = pygplates.FeatureCollection("Seton_etal_2020_Isochrons.gpmlz")
# 遍历等时线特征
for feature in isochron_features:
    # 输出特征类型和名称
    print("%s : %s " % (feature.get_feature_type().get_name(), feature.get_name()))
    # 输出描述
    print("description %s" % feature.get_description())
    # 输出板块ID
    print("plate ID: %d" % feature.get_reconstruction_plate_id())
    # 输出共轭板块ID
    print("conjugate plate ID: %d "% feature.get_conjugate_plate_id())
    # 输出等时线的长度,每个feature可能不止一个几何要素
    for geometry in feature.get_geometries():
        print(" length: %f Kms" % (geometry.get_arc_length() * pygplates.Earth.mean_radius_in_kms))
    # 输出等时线的有效时段
    print("valid time period: %f -> %f" % feature.get_valid_time())

查询大洋中脊feature

示例代码

import pygplates

# 加载全球大洋中脊features
ridge_features = pygplates.FeatureCollection("Muller_etal_2019_GeeK07_Ridges.gpmlz")
# 遍历大洋中脊特征
for feature in ridge_features:
    # 输出特征类型和大洋中脊名称
    print("%s:%s" % (feature.get_feature_type().get_name(), feature.get_name()))
    # 输出大洋中脊的描述
    print("  description: %s" % feature.get_description())
    # 大洋中脊既可以通过板块ID或半个板块运动来重建
    if feature.get_reconstruction_method() == "ByPlateId":
        # 输出大洋中脊的板块ID
        print("  plate ID: %d" % feature.get_reconstruction_plate_id())
        # 输出共轭板块ID
        conjugate_plate_id = feature.get_conjugate_plate_id(None)
        if conjugate_plate_id is not None:
            print("  conjugate plate ID: %d" % conjugate_plate_id)
    else:
        # 输出左边的板块ID
        print("  left plate ID: %d" % feature.get_left_plate())
        # 输出右边的板块ID
        print("  right plate ID: %d" % feature.get_right_plate())
    # 输出大洋中脊几何要素的长度
    for geometry in feature.get_geometries():
        print("  length: %f Kms" % (geometry.get_arc_length() * pygplates.Earth.mean_radius_in_kms))
    # 大洋中脊的有效时段
    print("  valid time period: %f -> %f" % feature.get_valid_time())

查询俯冲带特征

实例代码

import pygplates

# 加载俯冲带特征
subduction_zone_features = pygplates.FeatureCollection("subduction_zones.gpml")
# 遍历俯冲带区域
for feature in subduction_zone_features:
    # 输出特征类型和名称
    print("%s : %s" % (feature.get_feature_type().get_name(), feature.get_name()))
    # 输出特征描述
    print("  description: %s" % feature.get_description())
    # 输出板块ID
    print("  plate ID: %d" % feature.get_reconstruction_plate_id())
    # 输出共轭板块ID
    conjugate_plate_id = feature.get_conjugate_plate_id(None)
    if conjugate_plate_id is not None:
        print("  conjugate plate ID: %d" % conjugate_plate_id)
    # 输出俯冲带的极性
    polarity = feature.get_enumeration(
        pygplates.PropertyName.gpml_subduction_polarity,
        "Unknown"
    )
    print("  polarity: %s" % polarity)
    # 输出几何要素的长度
    for geometry in feature.get_geometries():
        print("  length: %f Kms" % (geometry.get_arc_length() * pygplates.Earth.mean_radius_in_kms))
    # 输出有效时段
    print("  valid time period: %f -> %f" % feature.get_valid_time())

查询虚拟地磁极性特征

示例代码

import pygplates

# 加载虚拟地磁极性特征
vgp_feature = pygplates.FeatureCollection("4-output_virtual_geomagnetic_pole.gpml")
# 遍历虚拟地磁极性特征
for feature in vgp_feature:
    # 输出类型和名称
    print("%s: %s" % (feature.get_feature_type().get_name(), feature.get_name()))
    #输出特征描述
    print("  description: %s"% feature.get_description())
    # 输出板块ID
    print("  plate ID: %d"%feature.get_reconstruction_plate_id())
    # 输出特征的平均倾角
    average_inclination = feature.get_double(pygplates.PropertyName.gpml_average_inclination, None)
    if average_inclination is None:
        print("  average inclination: %f" % average_inclination)
    # 输出特征的平均偏差
    average_declination = feature.get_double(pygplates.PropertyName.gpml_average_declination, None)
    if average_declination is None:
        print("  average declination: %f" % average_declination)
    # 输出极位不确定性
    pole_position_uncertainty = feature.get_double(pygplates.PropertyName.gpml_pole_a95, None)
    if pole_position_uncertainty is not None:
        print("  pole position uncertainty: %f" % pole_position_uncertainty)
    # 输出平均年龄
    average_age = feature.get_double(pygplates.PropertyName.gpml_average_age, None)
    if average_age is not None:
        print("  average age: %f"% average_age)
    # 输出虚拟地磁极点
    pole_lat, pole_lon = feature.get_geometry().to_lat_lon()
    print("  pole lat: %f, pole lon: %f" % (pole_lat, pole_lon))
    # 输出平均取样点
    average_sample_site_lat, average_sample_site_lon = feature.get_geometry(
        pygplates.PropertyName.gpml_average_sample_site_position
    ).to_lat_lon()
    print("  average sample site lat: %f, average sample site lon: %f" % (average_sample_site_lat, average_sample_site_lon))

查询移动轨迹特征

示例代码

import pygplates

# 加载移动轨迹特征
motion_path_feature = pygplates.FeatureCollection("4-output_motion_path.gpml")
# 遍历移动轨迹特征
for feature in motion_path_feature:
    # 输出特征类型和名称
    print("%s:%s"% (feature.get_feature_type().get_name(), feature.get_name()))
    # 输出描述
    print("  description: %s" % feature.get_description())
    # 输出板块ID
    print("  plate ID: %d" % feature.get_reconstruction_plate_id())
    # 输出相关的板块ID
    print("  relative plate ID: %d" % feature.get_relative_plate())
    # 输出运动轨迹的时间
    print("  times: %s" % feature.get_times())
    # 输出运动轨迹的起始点
    for seed_point in feature.get_geometry().get_points():
        print("  seed point lat: %f, seed point lon: %f" % seed_point.to_lat_lon())
    # 输出有效时段
    print("  valid time period: %f -> %f" % feature.get_valid_time())

查询flowline feature

示例代码

import pygplates

# 加载流水线特征
flowline_features = pygplates.FeatureCollection("4-output_flowline.gpml")
# 遍历流水线特征
for feature in flowline_features:
    # 输出类型和名称
    print("%s : %s" % (feature.get_feature_type().get_name(), feature.get_name()))
    # 输出流水线的描述
    print("  description: %s" % feature.get_description())
    # 输出左边的板块ID
    print("  left plate ID: %d" % feature.get_left_plate())
    # 输出右边的板块ID
    print("  right plate ID: %d" % feature.get_right_plate())
    # 输出时间
    print("  times: %s" % feature.get_times())
    # 输出点坐标
    for seed_point in feature.get_geometry().get_points():
        print("  seed point lat: %f, seed point lon: %f" % seed_point.to_lat_lon())
    # 输出有效时段
    print("  valid time period: %f -> %f" % feature.get_valid_time())

查询完整重建序列特征

示例代码

import pygplates

# 加载板块运动模型
rotation_features = pygplates.FeatureCollection("4-output_rotation_feature_550_rel_801.gpml")
# 遍历特征
for feature in rotation_features:
    fixed_plate_id, moving_plate_id, total_reconstruction_pole = feature.get_total_reconstruction_pole()
    if moving_plate_id == 999:
        continue
    # 输出特征类型和名称
    print("%s : %s" % (feature.get_feature_type().get_name(), feature.get_name()))
    # 输出特征的描述
    print("  description: %s" % feature.get_description())
    # 输出移动板块的ID
    print("  moving plate ID: %d" % moving_plate_id)
    # 输出修正板块的ID
    print("  fixed plate ID: %d" % fixed_plate_id)
    # 输出时段
    enabled_time_samples = total_reconstruction_pole.get_enabled_time_samples()
    if enabled_time_samples:
        print("  enabled time period: %f -> %f" % (enabled_time_samples[0].get_time(), enabled_time_samples[-1].get_time()))
    # 根据时间取样序列输出运动极点
    print("  time samples: ")
    for time_sample in enabled_time_samples:
        finite_rotation = time_sample.get_value().get_finite_rotation()
        pole_lat, pole_lon, pole_angle = finite_rotation.get_lat_lon_euler_pole_and_angle_degrees()
        time = time_sample.get_time()
        description = time_sample.get_description()
        print("  %f %f %f %f %s" % (time, pole_lat, pole_lon, pole_angle, description))

猜你喜欢

转载自blog.csdn.net/whitedrogen/article/details/131703721