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 4 forks source link

How to set survey metadata values for v0.1.0 data #220

Closed kkappler closed 2 months ago

kkappler commented 3 months ago

I added a test to tests/version_1/test_mth5.py

    def test_set_survey_metadata(self):
        """ Test that we can change a value in the survey metadata and this is written to mth5"""
        survey_metadata = self.mth5_obj.survey_group.metadata
        assert survey_metadata.id is None
        new_survey_id = "MT Survey"
        survey_metadata.id = new_survey_id
        assert survey_metadata.id == new_survey_id
        self.mth5_obj.survey_group.metadata = survey_metadata
        assert self.mth5_obj.survey_group.metadata.id == new_survey_id

The last line fails and I'm not sure why. This sort of setting seems to work in v0.2.0, but the syntax is different.

Actually, the solution was to use

self.mth5_obj.survey_group.update_metadata(survey_metadata.to_dict())
assert self.mth5_obj.survey_group.metadata.id == new_survey_id

as the last two lines. I'll commit this test for future reference

kkappler commented 3 months ago

test is on branch fix_issue_219. When that is merged into main this can be closed.