Skip to content

Commit

Permalink
Merge pull request #419 from PrincetonUniversity/issue-411
Browse files Browse the repository at this point in the history
  • Loading branch information
lsawade authored Jan 22, 2025
2 parents e41d8df + c08ef4c commit 5fceec0
Show file tree
Hide file tree
Showing 916 changed files with 61 additions and 36 deletions.
9 changes: 7 additions & 2 deletions examples/anisotropic-crystal/CMakeFiles/Snakefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ rule run_solver:
config="specfem_config.yaml",
output:
seismograms=expand(
"OUTPUT_FILES/results/{station_name}.{network_name}.S2.{component}.semd",
"OUTPUT_FILES/results/{network_name}.{station_name}.S2.{component}.semd",
station_name=[
"S0010",
"S0020",
Expand Down Expand Up @@ -59,7 +59,7 @@ rule run_solver:
rule plot_seismogram:
input:
trace_files=expand(
"OUTPUT_FILES/results/{station_name}.{network_name}.S2.{component}.semd",
"OUTPUT_FILES/results/{network_name}.{station_name}.S2.{component}.semd",
station_name=[
"S0010",
"S0020",
Expand Down Expand Up @@ -91,16 +91,21 @@ rule plot_seismogram:
"S0040",
"S0050",
]

files = [glob.glob(directory + f"/{stationname}*.sem*")[0] for stationname in station_name]

## iterate over all seismograms
for filename in files:
station_id = os.path.splitext(filename)[0]
station_id = station_id.split("/")[-1]
# -------------------------
# FIX ME PLEASE!!!!!!!!!!!!
network = station_id[5:7]
station = station_id[0:5]
location = "00"
component = station_id[7:10]
# FIX ME PLEASE!!!!!!!!!!!!
# -------------------------
trace = np.loadtxt(filename, delimiter=" ")
starttime = trace[0, 0]
dt = trace[1, 0] - trace[0, 0]
Expand Down
12 changes: 8 additions & 4 deletions examples/fluid-solid-bathymetry/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ rule run_simulation:
specfem_config="specfem_config.yaml",
output:
pressure_seismograms=expand(
"OUTPUT_FILES/results/{station_name}.{network_name}.S2.{component}.semp",
"OUTPUT_FILES/results/{network_name}.{station_name}.S2.{component}.semp",
station_name=[
"S0001",
"S0002",
Expand All @@ -79,7 +79,7 @@ rule run_simulation:
rule plot_seismogram:
input:
pressure_seismograms=expand(
"OUTPUT_FILES/results/{station_name}.{network_name}.S2.{component}.semp",
"OUTPUT_FILES/results/{network_name}.{station_name}.S2.{component}.semp",
station_name=[
"S0001",
"S0002",
Expand All @@ -106,14 +106,18 @@ rule plot_seismogram:
## iterate over all seismograms
for filename in files:
station_name = os.path.splitext(filename)[0]
station_name = station_name.split("/")[-1]
network, station, location, channel = station_name.split("/")[-1].split(".")
trace = np.loadtxt(filename, delimiter=" ")
starttime = trace[0, 0]
dt = trace[1, 0] - trace[0, 0]
traces.append(
obspy.Trace(
trace[:, 1],
{"network": station_name, "starttime": starttime, "delta": dt},
{"network": network,
"station": station,
"location": location,
"channel": channel,
"starttime": starttime, "delta": dt},
)
)

Expand Down
12 changes: 8 additions & 4 deletions examples/fluid-solid-interface/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ rule run_solver:
config="specfem_config.yaml",
output:
seismograms=expand(
"OUTPUT_FILES/results/{station_name}.{network_name}.S2.{component}.semd",
"OUTPUT_FILES/results/{network_name}.{station_name}.S2.{component}.semd",
station_name=[
"S0001",
"S0002",
Expand Down Expand Up @@ -65,7 +65,7 @@ rule run_solver:
rule plot_seismogram:
input:
trace_files=expand(
"OUTPUT_FILES/results/{station_name}.{network_name}.S2.{component}.semd",
"OUTPUT_FILES/results/{network_name}.{station_name}.S2.{component}.semd",
station_name=[
"S0001",
"S0002",
Expand Down Expand Up @@ -102,14 +102,18 @@ rule plot_seismogram:
## iterate over all seismograms
for filename in files:
station_name = os.path.splitext(filename)[0]
station_name = station_name.split("/")[-1]
network, station, location, channel = station_name.split("/")[-1].split(".")
trace = np.loadtxt(filename, delimiter=" ")
starttime = trace[0, 0]
dt = trace[1, 0] - trace[0, 0]
traces.append(
obspy.Trace(
trace[:, 1],
{"network": station_name, "starttime": starttime, "delta": dt},
{"network": network,
"station": station,
"location": location,
"channel": channel,
"starttime": starttime, "delta": dt},
)
)

Expand Down
11 changes: 7 additions & 4 deletions examples/homogeneous-medium-flat-topography/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ rule run_solver:
config="specfem_config.yaml",
output:
siesmograms=expand(
"OUTPUT_FILES/results/{station_name}.{network_name}.S2.{component}.semv",
"OUTPUT_FILES/results/{network_name}.{station_name}.S2.{component}.semv",
station_name=["S0001", "S0002", "S0003", "S0004", "S0005", "S0006"],
network_name=["AA"],
component=["BXX", "BXZ"],
Expand All @@ -53,7 +53,7 @@ rule run_solver:
rule plot_seismogram:
input:
trace_files=expand(
"OUTPUT_FILES/results/{station_name}.{network_name}.S2.{component}.semv",
"OUTPUT_FILES/results/{network_name}.{station_name}.S2.{component}.semv",
station_name=["S0001", "S0002", "S0003", "S0004", "S0005", "S0006"],
network_name=["AA"],
component=["BXX", "BXZ"],
Expand All @@ -77,14 +77,17 @@ rule plot_seismogram:
## iterate over all seismograms
for filename in files:
station_name = os.path.splitext(filename)[0]
station_name = station_name.split("/")[-1]
network, station, location, channel = station_name.split("/")[-1].split(".")
trace = np.loadtxt(filename, delimiter=" ")
starttime = trace[0, 0]
dt = trace[1, 0] - trace[0, 0]
traces.append(
obspy.Trace(
trace[:, 1],
{"network": station_name, "starttime": starttime, "delta": dt},
{"network": network,
"station": station,
"location": location,
"channel": channel, "starttime": starttime, "delta": dt},
)
)

Expand Down
12 changes: 8 additions & 4 deletions examples/solid-solid-interface/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ rule run_solver:
config="specfem_config.yaml",
output:
seismograms=expand(
"OUTPUT_FILES/results/{station_name}.{network_name}.S2.{component}.semd",
"OUTPUT_FILES/results/{network_name}.{station_name}.S2.{component}.semd",
station_name=[
"S0001",
],
Expand All @@ -55,7 +55,7 @@ rule run_solver:
rule plot_seismogram:
input:
trace_files=expand(
"OUTPUT_FILES/results/{station_name}.{network_name}.S2.{component}.semd",
"OUTPUT_FILES/results/{network_name}.{station_name}.S2.{component}.semd",
station_name=[
"S0001",
],
Expand All @@ -82,14 +82,18 @@ rule plot_seismogram:
## iterate over all seismograms
for filename in files:
station_name = os.path.splitext(filename)[0]
station_name = station_name.split("/")[-1]
network, station, location, channel = station_name.split("/")[-1].split(".")
trace = np.loadtxt(filename, delimiter=" ")
starttime = trace[0, 0]
dt = trace[1, 0] - trace[0, 0]
traces.append(
obspy.Trace(
trace[:, 1],
{"network": station_name, "starttime": starttime, "delta": dt},
{"network": network,
"station": station,
"location": location,
"channel": channel,
"starttime": starttime, "delta": dt},
)
)

Expand Down
9 changes: 7 additions & 2 deletions src/IO/receivers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@ specfem::IO::read_receivers(const std::string stations_file,
}
// check if the read line meets the format
assert(current_station.size() == 6);
/* Get the network and station name
* Note that the station name is the second element in the vector
* and the network name is the first element. This is standard in
* the STATIONS file format.
*/
const std::string station_name = current_station[0];
const std::string network_name = current_station[1];
// get the x and z coordinates of the station;
const std::string network_name = current_station[0];
const std::string station_name = current_station[1];
const type_real x = static_cast<type_real>(std::stod(current_station[2]));
const type_real z = static_cast<type_real>(std::stod(current_station[3]));

Expand Down
32 changes: 16 additions & 16 deletions tests/unit-tests/displacement_tests/Newmark/newmark_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,34 +252,34 @@ TEST(DISPLACEMENT_TESTS, newmark_scheme_tests) {
std::vector<std::string> filename;
switch (seismogram_type) {
case specfem::wavefield::type::displacement:
filename.push_back(Test.database.traces + "/" + station_name + "." +
network_name + ".BXX.semd");
filename.push_back(Test.database.traces + "/" + station_name + "." +
network_name + ".BXZ.semd");
filename.push_back(Test.database.traces + "/" + network_name + "." +
station_name + ".S2.BXX.semd");
filename.push_back(Test.database.traces + "/" + network_name + "." +
station_name + ".S2.BXZ.semd");
break;
case specfem::wavefield::type::velocity:
filename.push_back(Test.database.traces + "/" + station_name + "." +
network_name + ".BXX.semv");
filename.push_back(Test.database.traces + "/" + station_name + "." +
network_name + ".BXZ.semv");
filename.push_back(Test.database.traces + "/" + network_name + "." +
station_name + ".S2.BXX.semv");
filename.push_back(Test.database.traces + "/" + network_name + "." +
station_name + ".S2.BXZ.semv");
break;
case specfem::wavefield::type::acceleration:
filename.push_back(Test.database.traces + "/" + station_name + "." +
network_name + ".BXX.sema");
filename.push_back(Test.database.traces + "/" + station_name + "." +
network_name + ".BXZ.sema");
filename.push_back(Test.database.traces + "/" + network_name + "." +
station_name + ".S2.BXX.sema");
filename.push_back(Test.database.traces + "/" + network_name + "." +
station_name + ".S2.BXZ.sema");
break;
case specfem::wavefield::type::pressure:
filename.push_back(Test.database.traces + "/" + station_name + "." +
network_name + ".PRE.semp");
filename.push_back(Test.database.traces + "/" + network_name + "." +
station_name + ".S2.PRE.semp");
break;
default:
FAIL() << "--------------------------------------------------\n"
<< "\033[0;31m[FAILED]\033[0m Test failed\n"
<< " - Test name: " << Test.name << "\n"
<< " - Error: Unknown seismogram type\n"
<< " - Station: " << station_name << "\n"
<< " - Network: " << network_name << "\n"
<< " - Station: " << station_name << "\n"
<< "--------------------------------------------------\n\n"
<< std::endl;
break;
Expand Down Expand Up @@ -311,8 +311,8 @@ TEST(DISPLACEMENT_TESTS, newmark_scheme_tests) {
<< "\033[0;31m[FAILED]\033[0m Test failed\n"
<< " - Test name: " << Test.name << "\n"
<< " - Error: Times do not match\n"
<< " - Station: " << station_name << "\n"
<< " - Network: " << network_name << "\n"
<< " - Station: " << station_name << "\n"
<< " - Component: " << icomp << "\n"
<< " - Expected: " << time << "\n"
<< " - Computed: " << computed_time << "\n"
Expand Down
Loading

0 comments on commit 5fceec0

Please sign in to comment.