kujaku11 / mth5

Exchangeable and archivable format for magnetotelluric time series to better serve the community through FAIR principles.
https://mth5.readthedocs.io/en/latest/index.html
MIT License
16 stars 6 forks source link

mt_code nomenclature definitions #38

Open kkappler opened 3 years ago

kkappler commented 3 years ago

ex, ey, hx, hy vs e1, e2, h1, h2

Inside mth5/mth5/utils/fdsn_tools.py there are rules for assigning an "mt_code" to channels. This is called when we make channels from obspy in mth5/mth5/timeseries/channel_ts.py in the from_obspy_trace() method.

Specifically the mt_code = fdsn_tools.make_mt_channel( fdsn_tools.read_channel_code(obspy_trace.stats.channel) ) is changing ex to e1.

This comes from fdsn tools.

Let's review these conventions. I had thought that ex, ey had to do more with local strike than cardinal direction.

def make_mt_channel(code_dict, angle_tol=15): """

:param code_dict: DESCRIPTION
:type code_dict: TYPE
:return: DESCRIPTION
:rtype: TYPE

"""

mt_comp = mt_code_dict[code_dict["component"]]

if not code_dict["vertical"]:
    if (
        code_dict["orientation"]["min"] >= 0
        and code_dict["orientation"]["max"] <= angle_tol
    ):
        mt_dir = "x"
    elif (
        code_dict["orientation"]["min"] >= angle_tol
        and code_dict["orientation"]["max"] <= 45
    ):
        mt_dir = "1"
    if (
        code_dict["orientation"]["min"] >= (90 - angle_tol)
        and code_dict["orientation"]["max"] <= 90
    ):
        mt_dir = "y"
    elif code_dict["orientation"]["min"] >= 45 and code_dict["orientation"][
        "max"
    ] <= (90 - angle_tol):
        mt_dir = "2"
kkappler commented 3 years ago

I have applied the following (uncommitted) workaround: in mth5/timeseries/run_ts.py I added at line 413:

            if channel_ts.channel_metadata.component=="e1":
                channel_ts.channel_metadata.component="ex"
            if channel_ts.channel_metadata.component=="e2":
                channel_ts.channel_metadata.component="ey"
            if channel_ts.channel_metadata.component=="h1":
                channel_ts.channel_metadata.component="hx"
            if channel_ts.channel_metadata.component=="h2":
                channel_ts.channel_metadata.component="hy"
            if channel_ts.channel_metadata.component=="h3":
                channel_ts.channel_metadata.component="hz"

@kujaku11 Any problem with me committing this to see if it makes the aurora tests pass?

kujaku11 commented 3 years ago

Maybe just make a new branch on mth5, and I think you can set aurora to download that version. If thats too much just commit to master.

On Sun, Sep 5, 2021, 4:09 PM kkappler @.***> wrote:

I have applied the following (uncommitted) workaround: in mth5/timeseries/run_ts.py I added at line 413:

        if channel_ts.channel_metadata.component=="e1":
            channel_ts.channel_metadata.component="ex"
        if channel_ts.channel_metadata.component=="e2":
            channel_ts.channel_metadata.component="ey"
        if channel_ts.channel_metadata.component=="h1":
            channel_ts.channel_metadata.component="hx"
        if channel_ts.channel_metadata.component=="h2":
            channel_ts.channel_metadata.component="hy"
        if channel_ts.channel_metadata.component=="h3":
            channel_ts.channel_metadata.component="hz"

@kujaku11 https://github.com/kujaku11 Any problem with me committing this to see if it makes the aurora tests pass?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kujaku11/mth5/issues/38#issuecomment-896135769, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQA5BXSYBMDOCIHPZ4Y6I3UAP2DHANCNFSM5AQMJVNA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

kkappler commented 3 years ago

@kujaku11 I pulled latest mth5 and created branch channel_nomenclature_38 on mth5 as follows:

-git checkout -b channel_nomenclature_38  #create branch
-git commit mth5/timeseries/run_ts.py -m"force 'xyz' channel names to override '123', plus some flake8 stuffs"
-git push --set-upstream origin channel_nomenclature_38

I then modified aurora/.github/workflows/tests.yaml from

pip install git+https://github.com/kujaku11/mth5.git

TO

pip install git+https://github.com/kujaku11/mth5.git@channel_nomenclature_38

My latest push is showing the sample_rate error (relates to issue #41 ) is no longer showing. Now I have new errors but they are downstream from the previous one.

I will make a pull request to merge channel_nomenclature_38 branch into master.

kkappler commented 3 years ago

@timronan This is the issue that we discussed Friday that relates to issue #54 that you are encountering.

Let's discuss this workaround with relabeling with @kujaku11 on Friday 08 October.

We need to identify exactly what is breaking in the code when the workaround is applied and when it is not applied. I think the issue may have been in aurora, and if so, then the workaround should be in aurora, not mth5.

Maybe try commenting out the workaround and see if your make mth5 runs.

The workaround I refer to is this block in mth5/timeseries/run_ts.py :

if channel_ts.channel_metadata.component=="e1":
    channel_ts.channel_metadata.component="ex"
if channel_ts.channel_metadata.component=="e2":
    channel_ts.channel_metadata.component="ey"
if channel_ts.channel_metadata.component=="h1":
    channel_ts.channel_metadata.component="hx"
if channel_ts.channel_metadata.component=="h2":
    channel_ts.channel_metadata.component="hy"
if channel_ts.channel_metadata.component=="h3":
    channel_ts.channel_metadata.component="hz"