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

updating how a TF is initiated, initialize xarray is expensive #188

Closed kujaku11 closed 9 months ago

kujaku11 commented 9 months ago

There was a double initialization of the transfer function xarray.Dataset. Once when TF is initiated then then again with period is set. Update such that TF(period=periods) that way it only initiates once.

There is a slow down in building the xarray.Dataset, which I think comes from we are combining a couple different xarray.DataArrays that have slightly different coordinates and when you combine then each DataArray needs to be aligned and this seems to be where the slow down is. Not sure how to get around that. This PR at least alleviates the double initialization and reduces the initialization time by 1/3.

codecov-commenter commented 9 months ago

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (02d27e9) 83.99% compared to head (7017e0e) 84.00%. Report is 1 commits behind head on main.

Files Patch % Lines
mt_metadata/transfer_functions/core.py 89.47% 2 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #188 +/- ## ======================================= Coverage 83.99% 84.00% ======================================= Files 269 269 Lines 20130 20161 +31 ======================================= + Hits 16909 16937 +28 - Misses 3221 3224 +3 ``` | [Flag](https://app.codecov.io/gh/kujaku11/mt_metadata/pull/188/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JP) | Coverage Δ | | |---|---|---| | [tests](https://app.codecov.io/gh/kujaku11/mt_metadata/pull/188/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JP) | `84.00% <94.59%> (+<0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JP#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.