R code for making nice plots of HVSR geopsy results

This forum is dedicated to discuss all problems and suggestions related to the use of geopsy database and its plugins (array processing, H/V,...).
Post Reply
andrea_V
Posts: 6
Joined: Thu Jan 11, 2024 5:01 pm

R code for making nice plots of HVSR geopsy results

Post by andrea_V »

Good morning,

I would like to share with you the R code I wrote that takes .hv, .grid, .spec files to make a (hopefully) meaningful view of an H/V survey processed with geopsy.

What it does: (see also the two images attached)
- plots the H/V ratio with standard deviation
- plots the Z N E components
- plots the rotation spectrum
- saves the rotation spectrum in polar coordinates together with a world text file for fast visualization in QGIS
- a separate script plots multiple h/v measurements as a 2D profile, taking a separate DEM for adding topography.


Use cases:
According to my perspective, it is very convenient in cases of surveys with many measurements, in which I can process manually an acquisition with geopsy, save its parameters, apply the same parameters to all the dataset and then plot them with this R script.
I generally use the windows command line and type similar commands to batch process:

for %f in (*.SAF) do (geopsy-hv.exe -hv -param params.param %f & rename .hv %f.hv & rename .log %f.log & geopsy-hv.exe -rotate -param params.param %f & rename .hv %f.grid)

for %f in (*.txt) do (geopsy-hv.exe -rotate -param params.param %f & rename %f.hv %f.grid & geopsy-hv.exe -hv -param params.param %f)

to do the amplitude spectrum of each component: (for some reasons saf files require their output to be renamed...

for %f in (*.txt) do (geopsy-hv.exe -spectrum -param params.param %f)
for %f in (*.SAF) do (geopsy-hv.exe -spectrum -param params.param %f & rename _E.spec %f_E.spec & rename _N.spec %f_N.spec & rename _Z.spec %f_Z.spec & rename _E.log %f_E.log & rename _N.log %f_N.log & rename _Z.log %f_Z.log )


then, with all the output files of geopsy (.hv,.grid,.spec...) in the same folder, I run my R script to produce the images.

Where to download it - and modify according to your needs, and improve it if you want <3
https://github.com/Andrea-Vergnano/geophysics-utils
under the folders HV-geopsy-niceplot and HV-geopsy-profileplot. You should find a readme file and comments along the code to help you use it, or feel free to contact me for any questions :)


Example study that used this tool
:
Francesco Seitone, Andrea Vergnano, Cesare Comina, Mauro Bonasera, Giandomenico Fubelli, Comparative analysis of geological and seismic microtremors models of a large translational landslide: The case of San Vito Romano (Central Italy), Engineering Geology, Volume 347, 2025, https://doi.org/10.1016/j.enggeo.2025.107934
Attachments
profile_plot2025-02-20 19-09-02.677861.jpg
(65.02 KiB) Not downloaded yet
L3_03conv.SAF.png
(263.44 KiB) Not downloaded yet
Post Reply