Added depth-slice visualization of CVM-S4.26.M01 for the La Habra model region.

parent 64ffd1da
Visualization of the Velocity Model
===================================
The scripts in this directory visualize vp, vs and rho of the velocity model CVM-S4.26.M01 (cvmsi) at a set of depths.
The colors scales are dynamic.
Used commands
.. code-block:: bash
./generate.sh 2>&1 | tee generate.sh.log
#!/usr/bin/env bash
##
# @file This file is part of EDGE.
#
# @author Alexander Breuer (breuer AT mytum.de)
# @section LICENSE
# Copyright (c) 2020, Alexander Breuer
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# @section DESCRIPTION
# Plots the velocity model at the given depths.
##
depths=( 0 10 25 50 100 250 500 750 1000 1500 2500 5000 7500 10000 )
min_vs=( 500 500 500 500 500 500 500 500 500 500 500 500 500 500 )
max_vs=( 2500 2500 2500 2500 2500 2500 2500 2500 3000 5000 7500 10000 10000 10000 )
min_vp=( 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 1500 )
max_vp=( 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 7500 10000 10000 10000 )
min_rho=( 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 )
max_rho=( 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 )
rm -r plots
mkdir plots
for (( de=0; de < ${#depths[@]}; de++ ))
do
date
echo "working on depth ${depths[de]}"
tmp_dir=$(mktemp -d)
bash query.sh -z ${depths[de]} -o ${tmp_dir}/vel_data
python vis.py --in_data ${tmp_dir}/vel_data --quantity vs --color_scale ${min_vs[de]} ${max_vs[de]} --out_file plots/vs_${depths[de]}.png
python vis.py --in_data ${tmp_dir}/vel_data --quantity vp --color_scale ${min_vp[de]} ${max_vp[de]} --out_file plots/vp_${depths[de]}.png
python vis.py --in_data ${tmp_dir}/vel_data --quantity rho --color_scale ${min_rho[de]} ${max_rho[de]} --out_file plots/rho_${depths[de]}.png
rm -r ${tmp_dir}
date
done
This source diff could not be displayed because it is stored in LFS. You can view the blob instead.
.. image:: http://i.creativecommons.org/p/zero/1.0/88x31.png
:alt: CC0
:target: http://creativecommons.org/publicdomain/zero/1.0/
To the extent possible under law, `Alexander Nikolas Breuer <https://dial3343.org/>`_ has waived all copyright and related or neighboring rights to the following work:
* `rho_0.png`
* `rho_10.png`
* `rho_25.png`
* `rho_50.png`
* `rho_100.png`
* `rho_250.png`
* `rho_500.png`
* `rho_750.png`
* `rho_1000.png`
* `rho_1500.png`
* `rho_2500.png`
* `rho_5000.png`
* `rho_7500.png`
* `rho_10000.png`
* `vp_0.png`
* `vp_10.png`
* `vp_25.png`
* `vp_50.png`
* `vp_100.png`
* `vp_250.png`
* `vp_500.png`
* `vp_750.png`
* `vp_1000.png`
* `vp_1500.png`
* `vp_2500.png`
* `vp_5000.png`
* `vp_7500.png`
* `vp_10000.png`
* `vs_0.png`
* `vs_10.png`
* `vs_25.png`
* `vs_50.png`
* `vs_100.png`
* `vs_250.png`
* `vs_500.png`
* `vs_750.png`
* `vs_1000.png`
* `vs_1500.png`
* `vs_2500.png`
* `vs_5000.png`
* `vs_7500.png`
* `vs_10000.png`
This work is published from: Germany.
#!/usr/bin/env bash
##
# @file This file is part of EDGE.
#
# @author Alexander Breuer (breuer AT mytum.de)
# @section LICENSE
# Copyright (c) 2020, Alexander Breuer
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# @section DESCRIPTION
# Queries UCVM's cmvsi at the given depths.
##
help() {
cat << EOF
Usage: ${0##*/} [-h] [-z DEPTH -o OUT_FILE]
Queries UCVM for the given depth-slice.
-h This help message.
-z DEPTH depth of the slice.
-o OUT_FILE file to which the output is written.
EOF
}
while getopts "hz:o:" opt; do
case "$opt" in
h)
help
exit 0
;;
z)
DEPTH=$OPTARG
;;
o)
OUT_FILE=$OPTARG
;;
'?')
help >&2
exit 1
;;
esac
done
shift "$((OPTIND-1))"
TMP_DIR=$(mktemp -d)
cd ${TMP_DIR}
xmin=-50000
xmax=50000
dx=125
ymin=-50000
ymax=50000
dy=125
z=${DEPTH}
echo "creating xyz grid"
for y in $(seq $ymax -$dy $ymin)
do
for x in $(seq $xmin $dx $xmax)
do
echo "$x $y $z" >> coords.xyz
done
done
echo "converting coords to lat/lon"
cat coords.xyz | cs2cs +proj=tmerc +units=m +axis=enu +no_defs +datum=WGS84 +k=0.9996 +lon_0=-117.916 +lat_0=33.933 +to +proj=latlong +datum=WGS84 -f %.12f > coords.latlon
echo "querying ucvm and writing ${OUT_FILE}"
cat coords.latlon | ${UCVM_INSTALL_PATH}/bin/ucvm_query -c gd -f ${UCVM_INSTALL_PATH}/conf/ucvm.conf -m cvmsi > ${OUT_FILE}
rm -r ${TMP_DIR}
#!/usr/bin/env bash
##
# @file This file is part of EDGE.
#
# @author Alexander Breuer (breuer AT mytum.de)
# @section LICENSE
# Copyright (c) 2020, Alexander Breuer
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# @section DESCRIPTION
# Visualizes the given depth-slice.
##
import matplotlib.pyplot as plt
import pandas
import numpy
import math
import argparse
# command line arguments
l_parser = argparse.ArgumentParser( description='Plots a depth-slice.' )
l_parser.add_argument( '--in_data',
dest = 'in_data',
required = True,
type = str,
help = 'Path to the input data.' )
l_parser.add_argument( '--quantity',
dest = 'quantity',
required = True,
type = str,
help = 'Quantity which is visualized.' )
l_parser.add_argument( '--color_scale',
dest = 'color_scale',
required = True,
type = float,
nargs = 2,
help = 'Color scale (min / max).' )
l_parser.add_argument( '--out_file',
dest = 'out_file',
required = True,
type = str,
help = 'Path to the output file.' )
l_args = vars(l_parser.parse_args())
l_ucvm = pandas.read_csv( l_args['in_data'],
skiprows=0,
delim_whitespace=True,
names=[ 'lon', 'lat', 'Z', 'elevation', 'vs30_from_Map',
'cvm_name', 'cvm_vp', 'cvm_vs', 'cvm_rho',
'gtl_name', 'gtl_vp', 'gtl_vs', 'gtl_rho',
'combining_algorithm_name', 'combined_vp', 'combined_vs', 'combined_rho' ] )
l_dataNumpy = numpy.array( l_ucvm['combined_' + l_args['quantity']] )
l_min = float(l_args['color_scale'][0])
l_max = float(l_args['color_scale'][1])
l_dataNumpy = numpy.clip( l_dataNumpy, l_min, l_max )
l_shapeSqrt = int( math.sqrt( l_dataNumpy.shape[0] ) )
l_dataNumpy = l_dataNumpy.reshape( [l_shapeSqrt, l_shapeSqrt] )
l_fig = plt.figure( figsize=(15, 15) )
plt.imshow( l_dataNumpy, cmap=plt.get_cmap('gray') )
plt.colorbar()
l_fig.savefig( l_args['out_file'],
bbox_inches='tight' )
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment