kujaku11 / mt_metadata

Tools for standardizing metadata, geared towards magnetotelluric (MT) data but is general enough to accommodate "any" type of metadata.
https://mt-metadata.readthedocs.io/en/latest/
MIT License
19 stars 5 forks source link

Example of how to manually assign coordinates to run_group #85

Closed kkappler closed 1 year ago

kkappler commented 2 years ago
    from mth5.mth5 import MTH5
    from mt_metadata.timeseries.location import Location

    m = MTH5(file_version="0.1.0")
    m.open_mth5("test.h5", mode="w")
    station_group = m.add_station("test1")

    location = Location()
    location.latitude = 17.996

    station_group.metadata.location = location    
    run_group = station_group.add_run('001')
    run_group.station_group.metadata.location = location

Setting latitude in the location object has the expected result:

In[12]: location
Out[12]: 
{
    "location": {
        "declination.model": "WMM",
        "declination.value": 0.0,
        "elevation": 0.0,
        "latitude": 17.996,
        "longitude": 0.0
    }
}

And the information does propagate to the station_group

In[16]: station_group.metadata.location
Out[16]: 
{
    "location": {
        "declination.model": "WMM",
        "declination.value": 0.0,
        "elevation": 0.0,
        "latitude": 17.996,
        "longitude": 0.0
    }
}

But it does not propagate to the run_group

In[20]: run_group.station_group.metadata.location
Out[20]: 
{
    "location": {
        "declination.model": "WMM",
        "declination.value": 0.0,
        "elevation": 0.0,
        "latitude": 0.0,
        "longitude": 0.0
    }
}

@kujaku11 Is this expected behaviour? Or should the run_group inherit the location info from it's station group?

kkappler commented 2 years ago

Once this is sorted out, the comments and reference to this issue can be deleted from

aurora/aurora/test_utils/synthetic/make_mth5_from_asc.py

kkappler commented 2 years ago

I wound up factoring this mini test out, it is now in its own file in aurora aurora/sandbox/debug_mt_metadata_issue_85.py

Currently it is on the aurora fix_issue_80 branch

kujaku11 commented 2 years ago

@kkappler After you change the metadata, you'll have to run the method write_metadata to be sure that it is written the HDF5, then when you call run_group.station_metadata it will pull the newly written metadata from the station metadata.