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

Problems reading .miniseed files #27

Open
DavidMvD opened this issue Aug 1, 2024 · 4 comments
Open

Problems reading .miniseed files #27

DavidMvD opened this issue Aug 1, 2024 · 4 comments

Comments

@DavidMvD
Copy link

DavidMvD commented Aug 1, 2024

Hello!

My name is David. First of all, thank you very much for this code, it looks really great and very useful!

Well, lets go to the issue. I'm having some problems when I use my own .miniseed files with your codes. For example, i'm struggling with the code named "Gallery of mHVSR Examples Automatically Checked with SESAME (2004) Reliability and Clarity Criteria". When I use my .miniseed file (or even yours), I obtain the same problem message:

ValueError: Must provide 3 peer files (one per trace) as list or tuple, not <class 'str'>

I thought that maybe the problem is because I merged the three components (E, N, Z) into 1 .miniseed file, but if I use it in Geopsy there's no problem, I can see each component and the obtain the HV curve. Even if I try to use the three .miniseed components I have problems.

I have to say that I'm still a beginner playing with python and I believe that I'm missing something.

Could you help me? Thank you in advance! ;)

@jpvantassel
Copy link
Owner

Hi @DavidMvD,

I just took at a look at gallery_sesame.ipynb and everything is running as expected on my laptop and the test server, so I need to better understand exactly how to reproduce the error. From your message it appears that you tried running the notebook as-is (i.e., with the provided data) and are seeing an error, is that correct? If so, can you share the exact error message, your current version of Python, and your current version of hvsrpy. With that I should hopefully be able to reproduce the error and we can go from there.

If you are only getting an error using one of your own .miniseed files it is most-likely an issue with the formatting of the file itself, but I cannot say for sure without looking at the file. The most-likely possibility is that the components are not labeled correctly and the code is not able to understand which trace belongs to the NS, EW, and VT components. You can fix this in Python (using obspy) or in Geopsy and export a correct miniSEED file with the three components labeled correctly. You can supply either a merged three-component file or three one-component files to hvsrpy.read() (see docs).

All the best,
Joe

@masamasace
Copy link

I'm not sure if this is helpful for you, @DavidMvD but I've come across a similar issue and found a potential solution.
According to line 39, hvsrpy.data_wrangler.py, it seems that the channel name of each trace should end with any character of E, N, or Z.

data_wrangler.py attempts to read the file in alternative formats if it encounters difficulties in the current format. It follows the sequence of mseed, saf, minishark, sac, gcf, and finally peer. It appears that when reading the last peer files, they should be made up of three individual files, rather than a single merged file. This may be the reason why the ValueError is being raised.

ValueError: Must provide 3 peer files (one per trace) as list or tuple, not <class 'str'>

@jpvantassel would it be possible to modify the code to raise a warning or error to point out the incorrect channel name?

@masamasace
Copy link

It would appear from Line 618 in data_wrangler.py that the exception can only be raised when the peer file processes. I'm not sure what the intention behind this conditional sentence is, but perhaps deleting the line would be a temporary solution?

for ftype, read_function in READ_FUNCTION_DICT.items():
    try:
        srecording_3c = read_function(fnames,
                                      obspy_read_kwargs=obspy_read_kwargs,
                                      degrees_from_north=degrees_from_north)
    except Exception as e:
        logger.info(f"Tried reading as {ftype}, got exception |  {e}")

        if ftype == "peer": # here
            raise e

        pass
    else:
        logger.info(f"File type identified as {ftype}.")
        break

@jpvantassel
Copy link
Owner

Hi @masamasace,
Thank you for the suggestion. I could raise a warning if I could know for certain the file is a minSEED file. The error that gets raised either explains the file is a miniSEED file that is incorrectly formatted or that it is not a miniSEED file at all and should be read by something else. Once I understand @DavidMvD problem better I can provide better guidance.
All the best,
Joe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants