예제 #1
0
import scipy.interpolate as si

from adapt_utils.case_studies.tohoku.options.options import TohokuInversionOptions
from adapt_utils.io import readfile

# Parse arguments
parser = argparse.ArgumentParser()
parser.add_argument(
    'gauges',
    nargs='+',
    help="Gauge(s) to pre-process. Enter 'all' to pre-process all.")
parser.add_argument('-debug', help="Toggle debugging mode")
args = parser.parse_args()

# Create an Options class for convenience
op = TohokuInversionOptions(debug=bool(args.debug or False))

# Get gauge names
gauges = [gauge.upper() for gauge in args.gauges]
if 'ALL' in gauges:
    gauges = list(op.gauges.keys())

# Check data files exists
for gauge in gauges:
    if not os.path.exists(
            os.path.join(os.path.dirname(__file__), gauge + '.txt')):
        raise ValueError("Gauge data not found")

# Loop over gauges
for gauge in gauges:
예제 #2
0
from thetis import *

import argparse
import scipy.interpolate as si

from adapt_utils.case_studies.tohoku.options.options import TohokuInversionOptions
from adapt_utils.misc import gaussian, ellipse

# Parse arguments
parser = argparse.ArgumentParser()
parser.add_argument("level")
args = parser.parse_args()

# Set parameters
level = int(args.level)
op = TohokuInversionOptions(level=level)
gauges = list(op.gauges.keys())
for gauge in gauges:
    if gauge[:2] not in ('P0', '80'):
        op.gauges.pop(gauge)
gauges = list(op.gauges.keys())
op.end_time = 60 * 30

# Create function spaces
mesh = op.default_mesh
P2_vec = VectorFunctionSpace(mesh, "CG", 2)
P1 = FunctionSpace(mesh, "CG", 1)
P0 = FunctionSpace(mesh, "DG", 0)
V = P2_vec * P1

# Setup forward problem
예제 #3
0
from adapt_utils.optimisation import GradientConverged

# Parse arguments
parser = argparse.ArgumentParser()
parser.add_argument("level")
parser.add_argument("-gtol")
parser.add_argument("-family")
parser.add_argument("-taylor_test")
args = parser.parse_args()

# Set parameters
level = int(args.level)
gtol = float(args.gtol or 1.0e-08)
family = args.family or 'cg-cg'
assert family in ('dg-dg', 'dg-cg', 'cg-cg')
op = TohokuInversionOptions(level=level)
gauges = list(op.gauges.keys())
for gauge in gauges:
    if gauge[:2] not in ('P0', '80'):
        op.gauges.pop(gauge)
gauges = list(op.gauges.keys())
op.end_time = 60 * 30

# Create function spaces
mesh = op.default_mesh
P1 = FunctionSpace(mesh, "CG", 1)
if family == 'dg-dg':
    V = VectorFunctionSpace(mesh, "DG", 1) * FunctionSpace(mesh, "DG", 1)
elif family == 'dg-cg':
    V = VectorFunctionSpace(mesh, "DG", 1) * FunctionSpace(mesh, "CG", 2)
elif family == 'cg-cg':
예제 #4
0
import matplotlib.pyplot as plt
import numpy as np
import os

from adapt_utils.io import create_directory
from adapt_utils.case_studies.tohoku.options.options import TohokuInversionOptions
from adapt_utils.plotting import *  # NOQA

di = create_directory(os.path.join(os.path.dirname(__file__), 'plots'))

# Instantiate TohokuOptions object and setup interpolator
op = TohokuInversionOptions()
gauges = list(op.gauges)
num_gauges = len(gauges)
for smoothed in (True, False):
    for gauge in gauges:
        sample = 60 if smoothed and (gauge[0] == 'P' or 'PG' in gauge) else 1
        op.sample_timeseries(gauge, sample=sample)
        op.gauges[gauge]["data"] = []

    # Interpolate timeseries data from file
    t = 0.0
    t_epsilon = 1.0e-05
    time_seconds = []
    while t < op.end_time - t_epsilon:
        time_seconds.append(t)
        for gauge in gauges:
            op.gauges[gauge]["data"].append(
                float(op.gauges[gauge]["interpolator"](t)))
        t += op.dt