Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop/2.2.2 #55

Merged
merged 3 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/VERSION.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.1
2.2.2
2 changes: 1 addition & 1 deletion infra/scripts/version_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Check current version based on active develop branch name

CURRENTVERSION="2.2.1"
CURRENTVERSION="2.2.2"

VERSIONDOC=$(cat docs/VERSION.md)

Expand Down
2 changes: 1 addition & 1 deletion test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# License: GPL-3.0 <https://www.gnu.org/licenses/gpl-3.0.txt>.

# List default tests here
TESTS=libraries bug optimization
TESTS=libraries bug optimization test_parameters

# Default is to run all tests
all: $(addsuffix .test, $(TESTS))
Expand Down
22 changes: 22 additions & 0 deletions test/test_parameters/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Makefile
#
# Purpose: Run default parameters tests.
#
# Site: https://www.geofisicando.com
#
# Programmer: Rodolfo A C Neves (Dirack) 25/02/2024
#
# Email: rodolfo_profissional@hotmail.com
#
# License: GPL-3.0 <https://www.gnu.org/licenses/gpl-3.0.txt>.

TESTS=rnip_beta_plane_interface

# Default is to run the test
all: $(addsuffix .test,$(TESTS))

%.test: %
make -C $<

help:
@echo "Run 'make' to run default parameres tests"
5 changes: 5 additions & 0 deletions test/test_parameters/rnip_beta_plane_interface/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
test_beta_interface1.txt
test_beta_interface2.txt
test_rnip_interface1.txt
test_rnip_interface2.txt

50 changes: 50 additions & 0 deletions test/test_parameters/rnip_beta_plane_interface/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Makefile
#
# Purpose: Parameters test. Obtain RNIP and BETA correct values.
#
# Site: https://www.geofisicando.com
#
# Programer: Rodolfo A. C. Neves (Dirack) 25/02/2024
#
# Email: rodolfo_profissional@hotmail.com
#
# License: GPL-3.0 <https://www.gnu.org/licenses/gpl-3.0.txt>.

all: generate_data view test clean

generate_data: SConstruct
@scons; \
<crsParameters1.rsf sfwindow n3=1 f3=1 | sfdisfil col=1 number=n format="%f |" > test_rnip_interface1.txt; \
<crsParameters2.rsf sfwindow n3=1 f3=1 | sfdisfil col=1 number=n format="%f" > test_rnip_interface2.txt; \
<crsParameters1.rsf sfwindow n3=1 f3=2 | sfdisfil col=1 number=n format="%f |" > test_beta_interface1.txt; \
<crsParameters2.rsf sfwindow n3=1 f3=2 | sfdisfil col=1 number=n format="%f" > test_beta_interface2.txt;

view: header_result view_rnip view_beta

header_result:
@echo
@echo "Result of this test - Start report"
@echo

view_rnip: test_rnip_interface1.txt test_rnip_interface2.txt
@echo "--- RNIPs for each interface ---"
@echo " First | Second"
@paste $^ -d" | "
@echo "--- Correct value ---"
@echo "1.000000 | 1.950000"
@echo

view_beta: test_beta_interface1.txt test_beta_interface2.txt
@echo "--- BETAs for each interface ---"
@echo " First | Second"
@paste $^ -d" | "
@echo "--- Correct value ---"
@echo "0.000000 | 0.000000"
@echo

test: ./Test_parameter_values.sh
./$<
@echo

clean:
scons -c; rm test_rnip_interface*.txt test_beta_interface*.txt
15 changes: 15 additions & 0 deletions test/test_parameters/rnip_beta_plane_interface/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Test obtain correct RNIP and BETA parameters for a plane interface velocity model

This test is used to assure that vfsa is obtaining correct values for RNIP and BETA parameters.
The parameters values are calculated for a simple plane interfaces model using Hubral's transmission law.
The paramters values should be as follows:

- For the first interface RNIP should be close to 1
- For the second interface RNIP should be close to 1.95
- For both interfaces BETA should be close to 0

Run this test with make:

```
make
```
108 changes: 108 additions & 0 deletions test/test_parameters/rnip_beta_plane_interface/SConstruct
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# SConstruct (Madagascar Script)
#
# Purpose: Obtain correct value for RNIP parameter for a plane interface model.
# Obtain zero-offset CRS parameters using VFSA for a set of (t0,m0) pairs.
#
# Site: https://www.geofisicando.com
#
# Programmer: Rodolfo A. C. Neves (Dirack) 25/02/2024
#
# Email: rodolfo_profissional@hotmail.com
#
# License: GPL-3.0 <https://www.gnu.org/licenses/gpl-3.0.txt>.

# Madagascar library
from rsf.proj import *
from model import *

# Python math library
import math

__author__="Rodolfo Dirack <rodolfo_profissional@hotmail.com>"
__site__="https://www.geofisicando.com"

Help('''
Obtain zero offset CRS parameters using VFSA for a set of (t0,m0) pairs
=======================================================================

Obtain RN, RNIP and BETA parameters using Very Fast Simulated Annealing (VFSA)
global optimization

Author: %s
Site: %s
''' % (__author__,__site__))

Help('''
### Kirchhoff modeling ###

Use Kirchhoff modeling in a Gaussian reflector linear velocity model
velocity increases with depth with a 0.5 velocity gradient
''')

# Velocity model parameters
xmax = 6.0
zmax = 4.0
layers = ((1.00,1.00,1.00,1.00),(1.85,1.85,1.85,1.85))
velocities = (1.508,1.690,2.0)

# Generate velocity model and seismic data cube
nt=1001
dt=0.004
nm=241
dm=0.025
nh=161
dh=0.025

trueModel = 'velocity'
dataCube = 'dataCube'

modeling(trueModel,
dataCube,
xmax,
zmax,
layers,
velocities,
nt,
dt,
nm,
dm,
nh,
dh)

Result(trueModel,velplot("Velocity Model"))

om0=2
dm0=0.5
nm0=6
ot0=1.1
dt0=0.1
nt0=1
ot0=1.33
v0=1.508
repeat=8

Help('''
### Very Fast Simulated Annealing (VFSA) ###

Obtain RN, RNIP and BETA parameters for nm0=%g om0=%g dm0=%g nt0=%g ot0=%g dt0=%g v0=%g
using non-hyperbolic CRS aproximation and VFSA repeated %d times
''' % (nm0,om0,dm0,nt0,ot0,dt0,v0,repeat))

# Very Fast Simulated Annealling Global Optimization (VFSA) - First interface
Flow('crsParameters1',dataCube,
'''
vfsacrsnh om0=%g dm0=%g nm0=%d ot0=%g dt0=%g nt0=%d v0=%g verb=y repeat=%d
''' % (om0,dm0,nm0,ot0,dt0,nt0,v0,repeat))

ot0=2.33

# Very Fast Simulated Annealling Global Optimization (VFSA) - Second interface
Flow('crsParameters2',dataCube,
'''
vfsacrsnh om0=%g dm0=%g nm0=%d ot0=%g dt0=%g nt0=%d v0=%g verb=y repeat=%d
''' % (om0,dm0,nm0,ot0,dt0,nt0,v0,repeat))

End()
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash
#
# Test_parameter_values.sh (Shell Script)
#
# Purpose: Calculate the average of parameters values and test if it is close to the correct values
#
# Site: https://www.geofisicando.com
#
# Programmer: Rodolfo A C Neves (Dirack) 25/02/2024
#
# Email: rodolfo_profissional@hotmail.com
#
# License: GPL-3.0 <https://www.gnu.org/licenses/gpl-3.0.txt>.


TESTSTR="Test_paramter_values.sh: Get correct RNIP and BETA values"

check_value(){

file="$1"
expected="$2"
delta="$3"
average="0"
nvalues="0"

while read v
do
fv=$(echo "$v" | cut -d" " -f1)
average=$(echo "$fv+$average" | bc -l)
nvalues=$(echo "$nvalues+1" | bc -l)
done < "$file"

average=$(echo "$average/$nvalues" | bc -l)

min=$(echo "$expected-$delta" | bc -l)
max=$(echo "$expected+$delta" | bc -l)
res=$(echo "$average < $min || $average > $max" | bc -l)

if [ "$res" -eq "1" ]
then
echo -e "${TESTSTR}:\033[31mFAIL\033[m: Average of values for parameter is far from expected: Average=$average Expected=$min<$expected<$max\033[m"
echo -e "${TESTSTR}:\033[31mFAILED while checking parameters from file $file\033[m"
exit 1
fi
}

check_value test_rnip_interface1.txt "1.0" "0.1"
check_value test_rnip_interface2.txt "1.95" "0.1"
check_value test_beta_interface1.txt "0.00" "0.1"
check_value test_beta_interface2.txt "0.00" "0.1"

echo -e "${TESTSTR}:\033[32mPASS\033[m"
Loading