jpvantassel / hvsrpy

A Python package for Horizontal-to-Vertical (H/V, HVSR) Spectral Ratio Processing.
https://pypi.org/project/hvsrpy/
Other
71 stars 29 forks source link

Output final results #26

Closed mcardenass closed 1 month ago

mcardenass commented 1 month ago

In the previous version it was possible to save the final results by hv. to_file (file_name_out, distribution_f0, distribution_mc, data_format= "hvsrpy"). Is there a way to do the same in this new version? Thank you

jpvantassel commented 1 month ago

@mcardenass,

Yes, this is now supported through the hvsrpy.object_io module. An example of how to use the two key functions hvsrpy.object_io.write_hvsr_object_to_file and hvsrpy.object_io.read_hvsr_object_from_file are provided here. The change was necessary to support writing and reading text-based summaries of all HVSR objects in one unified interface.

All the best, Joe

mcardenass commented 1 month ago

Joe, thanks for the information. One more request, how extracts the statistical information to a txt file, especially the peak of the average curve and the amplitude. Thanks in advance. Martin

jpvantassel commented 1 month ago

Hi @mcardenass,

This is not currently in the output file, although it probably should be. The solution for now is to access the statistics from the methods of the associated HVSR object. For example: mean_fn_amplitude, mean_fn_frequency, std_fn_frequency, std_fn_amplitude, and mean_curve_peak. If you have the output files already you can use hvsrpy.object_io.read_hvsr_object_from_file to read them back into an object then call the method, without having to reprocess your data.

All the best, Joe

mcardenass commented 1 month ago

Thanks Joe!!

hvsr_from_disk = hvsrpy.object_io.read_hvsr_object_from_file(f"{fname_prefix}.csv") (fre,amp)=hvsr_from_disk.mean_curve_peak()

Martín

jpvantassel commented 1 month ago

That's it!