Esempio n. 1
0
from __future__ import print_function
import pygplates
import numpy as np
import sys
import xarray as xr
import inpaint
import scipy.interpolate as spi


bug_fix_arc_dir = -1.0 if pygplates.Version.get_imported_version() < pygplates.Version(14) else 1.0


# function that takes a netcdf grid, fills dummy values, then creates 
# an interpolator object that can be evaluated later at specified points
def make_age_interpolator(grdfile,interp='Spherical'):
 
    ds_disk = xr.open_dataset(grdfile)
    
    data_array = ds_disk['z']

    coord_keys = data_array.coords.keys()
    gridX = data_array.coords['lon'].data
    gridY = data_array.coords['lat'].data
    gridZ = data_array.data

    # handle grids that are in range 0_360 instead of -180_180
    if gridX.max()>180.:
        index1 = np.where(gridX>180.)[0]
        index2 = np.where(gridX<=180.)[0]
        gridX = np.hstack((gridX[index1]-360.,gridX[index2[1:]]))
        gridZ = np.hstack((gridZ[:,index1],gridZ[:,index2[1:]]))
Esempio n. 2
0
    def itervalues(d):
        return d.itervalues()

    def iteritems(d):
        return d.iteritems()

    def listvalues(d):
        return d.values()

    def listitems(d):
        return d.items()


# Required pygplates version.
# Need ability to query topological sections.
PYGPLATES_VERSION_REQUIRED = pygplates.Version(21)


def remove_features_not_referenced_by_topologies(
        feature_collections,
        restrict_referenced_feature_time_periods=False,
        removed_features_collections=None):
    # Docstring in numpydoc format...
    """Remove any regular features not referenced by topological features.
    
    The results are returned as a list of pygplates.FeatureCollection (one per input feature collection).
    
    The input feature collections should contain the topological and regular features that make up the topological model.
    Ensure you at least specify all topological features in the topological model, otherwise regular features
    referenced by the missing topologies will get removed.
    
    with this program; if not, write to Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
"""

from __future__ import print_function
import argparse
import math
from . import separate_ridge_transform_segments
import sys
import os.path
import pygplates

# PyGPlates version 26 supports default anchor plate ID in pygplates.RotationModel.__init__().
USING_PYGPLATES_VERSION_GREATER_EQUAL_26 = (
    hasattr(pygplates, 'Version')
    and pygplates.Version.get_imported_version() >= pygplates.Version(26))

DEFAULT_OUTPUT_FILENAME_PREFIX = 'topology_'
DEFAULT_OUTPUT_FILENAME_EXTENSION = 'shp'


def resolve_topologies(
    rotation_features_or_model,
    topology_features,
    time,
    output_filename_prefix,
    output_filename_extension,
    transform_segment_deviation_in_radians=separate_ridge_transform_segments.
    DEFAULT_TRANSFORM_SEGMENT_DEVIATION_RADIANS):
    """
    Resolves topologies at specified time and saves (to separate files) the resolved topologies, and their boundary sections as subduction zones,
Esempio n. 4
0
# Recieves a rotation files of a plate kinematic model, features to be reconstructed and a specified timestep.
# The function produces a geometry file rotated in accordance to the time step and rotation files.
def reconstruct_features(rotation_model, topological_features,
                         reconstruction_time, output_filename_prefix,
                         output_filename_extension):

    export_filename = 'reconstructed_{0!s}_{1}Ma.{2!s}'.format(
        output_filename_prefix, reconstruction_time, output_filename_extension)
    pygplates.reconstruct(topological_features, rotation_model,
                          export_filename, reconstruction_time)


if __name__ == "__main__":

    # Check the imported pygplates version.
    required_version = pygplates.Version(12)
    if not hasattr(
            pygplates, 'Version'
    ) or pygplates.Version.get_imported_version() < required_version:
        print(
            '{0}: Error - imported pygplates version {1} but version {2} or greater is required'
            .format(os.path.basename(__file__),
                    pygplates.Version.get_imported_version(),
                    required_version),
            file=sys.stderr)
        sys.exit(1)


    __description__ = \
    """Reconstruct features to a time step in accordance to given rotation files.
##################################################

from __future__ import print_function
import argparse
import math
import sys
import pygplates
import warnings


def _runtime_warning(message_string):
    warnings.warn(message_string, RuntimeWarning)


# Required pygplates version.
PYGPLATES_VERSION_REQUIRED = pygplates.Version(12)

# If we have pyGPlates version 22 or above then we can handle topological lines (can get their sub-sub-segment plate IDs).
CAN_HANDLE_TOPOLOGICAL_LINES = (
    hasattr(pygplates, 'Version')
    and pygplates.Version.get_imported_version() >= pygplates.Version(22))

# The default threshold sampling distance along subduction zones.
DEFAULT_THRESHOLD_SAMPLING_DISTANCE_DEGREES = 0.5
DEFAULT_THRESHOLD_SAMPLING_DISTANCE_KMS = math.radians(
    DEFAULT_THRESHOLD_SAMPLING_DISTANCE_DEGREES
) * pygplates.Earth.equatorial_radius_in_kms

DEFAULT_TIME_RANGE_YOUNG_TIME = 0
DEFAULT_TIME_RANGE_OLD_TIME = 200
DEFAULT_TIME_INCREMENT = 1