示例#1
0
#! /usr/bin/python3

# This script demonstrates the current state of the pyslat library.

# Import the pyslat library, and other libraries needed to plot
# the results:
import os
import pyslat
import matplotlib.pyplot as plt
import numpy as np
import math

# Create a non-linear hyperbolic function, as used in example 1, and use it as
# the base function for an IM-Rate relationship:
im = pyslat.factory(pyslat.FUNCTION_TYPE.NLH, [1221, 29.8, 62.2])
im_rate = pyslat.MakeIM(im)

old_slat_path = os.path.expanduser(
    "~") + "/Downloads/SLATv1.15_Public/example1_output_gcc/"
old_slat_path = "paleo-SLAT-data/"
if True:
    im_rate_GCC = np.loadtxt(old_slat_path + "example1_IM-rate-1",
                             skiprows=3,
                             unpack=True)
    old_slat_line, = plt.loglog(im_rate_GCC[0], im_rate_GCC[1])
    old_slat_line.set_label("Old SLAT")
    old_slat_line.set_linewidth(1)

    # Use the numpy and matplotlib libraries to reproduce the IM-Rate
    # diagram from example 1:
    t = np.arange(0.0, 1.001, 0.001)
示例#2
0
# Import the pyslat library, and other libraries needed to plot 
# the results:
import os
import pyslat
import matplotlib.pyplot as plt
import numpy as np
import math

# Create a an interpolated function from the data generated by the original SLAT
# code, and use it as the base function for an IM-Rate relationship:


old_slat_path = os.path.expanduser("~") + "/Downloads/SLATv1.15_Public/example1_output_gcc/"
im_rate_GCC = np.loadtxt(old_slat_path + "example1_IM-rate-1", skiprows=3, unpack=True)
im = pyslat.factory(pyslat.FUNCTION_TYPE.LOGLOG, [list(im_rate_GCC[0]), list(im_rate_GCC[1])])
im_rate = pyslat.MakeSimpleRelationship(im)

old_slat_line, = plt.loglog(im_rate_GCC[0], im_rate_GCC[1])
old_slat_line.set_label("Old SLAT")
old_slat_line.set_linewidth(1)

# Use the numpy and matplotlib libraries to reproduce the IM-Rate
# diagram from example 1:
t = np.arange(0.0, 1.001, 0.001)
s = list(map(im_rate.getlambda, t))
pyslat_line, = plt.loglog(t, s)
pyslat_line.set_label("pyslat")
pyslat_line.set_linewidth(6)
pyslat_line.set_linestyle(":")
plt.xlabel('IM (PGA)')
示例#3
0
import os
import pyslat
import matplotlib.pyplot as plt
import numpy as np
import math

# Create a an interpolated function from the data generated by the original SLAT
# code, and use it as the base function for an IM-Rate relationship:

old_slat_path = os.path.expanduser(
    "~") + "/Downloads/SLATv1.15_Public/example1_output_gcc/"
im_rate_GCC = np.loadtxt(old_slat_path + "example1_IM-rate-1",
                         skiprows=3,
                         unpack=True)
im = pyslat.factory(
    pyslat.FUNCTION_TYPE.LOGLOG,
    [list(im_rate_GCC[0]), list(im_rate_GCC[1])])
im_rate = pyslat.MakeSimpleRelationship(im)

old_slat_line, = plt.loglog(im_rate_GCC[0], im_rate_GCC[1])
old_slat_line.set_label("Old SLAT")
old_slat_line.set_linewidth(1)

# Use the numpy and matplotlib libraries to reproduce the IM-Rate
# diagram from example 1:
t = np.arange(0.0, 1.001, 0.001)
s = list(map(im_rate.getlambda, t))
pyslat_line, = plt.loglog(t, s)
pyslat_line.set_label("pyslat")
pyslat_line.set_linewidth(6)
pyslat_line.set_linestyle(":")
示例#4
0
                        'NLH': pyslat.FUNCTION_TYPE.NLH,
                        'PLC': pyslat.FUNCTION_TYPE.PLC,
                        #'LIN': pyslat.FUNCTION_TYPE.LIN,
                        #'LOGLOG': pyslat.FUNCTION_TYPE.LOGLOG
                    }

                    id = command[1]
                    flavour = command[2]
                    params = list(map(lambda s: float(s), command[3:]))

                    if func_in_use(id):
                        raise ValueError("Function {0} already in use.".format(id))

                    flavour = flavours.get(flavour, False)
                    if type:
                        deter_funcs[id] = pyslat.factory(flavour, params)
                    else:
                        line_error(line)
                        print("Error creating function")
                        usage("FUNC")
                else:
                    line_error(line)
                    print("Too few arguments")
                    usage("FUNC")
            elif cmd=='PFUNC':
                if len(command) == 5:
                    id = command[1]
                    flavour = command[2]
                    mu_func = command[3]
                    sigma_func = command[4]
示例#5
0
                        'PLC': pyslat.FUNCTION_TYPE.PLC,
                        #'LIN': pyslat.FUNCTION_TYPE.LIN,
                        #'LOGLOG': pyslat.FUNCTION_TYPE.LOGLOG
                    }

                    id = command[1]
                    flavour = command[2]
                    params = list(map(lambda s: float(s), command[3:]))

                    if func_in_use(id):
                        raise ValueError(
                            "Function {0} already in use.".format(id))

                    flavour = flavours.get(flavour, False)
                    if type:
                        deter_funcs[id] = pyslat.factory(flavour, params)
                    else:
                        line_error(line)
                        print("Error creating function")
                        usage("FUNC")
                else:
                    line_error(line)
                    print("Too few arguments")
                    usage("FUNC")
            elif cmd == 'PFUNC':
                if len(command) == 5:
                    id = command[1]
                    flavour = command[2]
                    mu_func = command[3]
                    sigma_func = command[4]
示例#6
0
#! /usr/bin/python3

# This script demonstrates the current state of the pyslat library.

# Import the pyslat library, and other libraries needed to plot 
# the results:
import os
import pyslat
import matplotlib.pyplot as plt
import numpy as np
import math

# Create a non-linear hyperbolic function, as used in example 1, and use it as
# the base function for an IM-Rate relationship:
im = pyslat.factory(pyslat.FUNCTION_TYPE.NLH, [1221, 29.8, 62.2])
im_rate = pyslat.MakeIM(im)

old_slat_path = os.path.expanduser("~") + "/Downloads/SLATv1.15_Public/example1_output_gcc/"
old_slat_path = "paleo-SLAT-data/"
if True:
    im_rate_GCC = np.loadtxt(old_slat_path + "example1_IM-rate-1", skiprows=3, unpack=True)
    old_slat_line, = plt.loglog(im_rate_GCC[0], im_rate_GCC[1])
    old_slat_line.set_label("Old SLAT")
    old_slat_line.set_linewidth(1)

    # Use the numpy and matplotlib libraries to reproduce the IM-Rate
    # diagram from example 1:
    t = np.arange(0.0, 1.001, 0.001)
    s = list(map(im_rate.getlambda, t))
    pyslat_line, = plt.loglog(t, s)
    pyslat_line.set_label("pyslat")