-
Notifications
You must be signed in to change notification settings - Fork 77
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
Add update_platform method to EchoData #434
Conversation
Great to see this PR, @imranmaj! What's the reason that for |
Ah that's right, I should add AZFP too; I took most of this from the pre-class-redesign code which didn't consider AZFP. |
echopype/echodata/echodata.py
Outdated
# only take data during ping times | ||
start_time, end_time = min(self.beam["ping_time"]), max(self.beam["ping_time"]) | ||
|
||
# saildrone specific workaround |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This customization to the one instance of saildrone data that we have may be fragile. While that file follows a community convention for "trajectory" data, there are details that could change w/o breaking the convention. For example, I believe the coordinate variable doesn't have to be named trajectory
. Also, a future netcdf file could contain more than one trajectory (deployment), in which case extra_platform_data["trajectory"][0]
would no longer be correct.
I'll take a crack at generalizing this block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've pushed into your PR the code that generalizes the handling of "trajectory" data encoded using the convention used by the Saildrone sample file
Codecov Report
@@ Coverage Diff @@
## dev #434 +/- ##
==========================================
+ Coverage 76.41% 76.64% +0.22%
==========================================
Files 37 5 -32
Lines 3227 334 -2893
==========================================
- Hits 2466 256 -2210
+ Misses 761 78 -683
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
@emiliom : seems like this operation is something we should record in the Provenance group also? |
Great suggestion!! I totally agree. |
@emiliom I was running into issues with trajectory in the saildrone data before so I added that small section to fix it, I can investigate whether it's necessary at all |
0432f70
to
e62c1ad
Compare
I think it is necessary. I'm finally getting around to adding the generalized code (done). Now I just need to run the tests. |
@imranmaj I'm running into an error with the
I think the glitch is different from what I experienced earlier, a couple of weeks ago, but I don't remember the details of that instance. For now, I just need to build a conda env to run the echopype tests, so I changed |
Hmm... I did not run into the ~= problem while creating a new environment with just python=3.8 and echopype. I used conda-forge as usual. @emiliom is the env you are working with a brand new one? |
Yeah. I'm creating a new env |
echopype/echodata/echodata.py
Outdated
- `"longitude"` | ||
- `"water_level"` | ||
|
||
Only `sonar_model`s of `"EK60"`, `"EK80"`, `"EA640"`, and `"AZFP"` are currently supported. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thinks that's for you and @imranmaj to answer. I don't remember being in a conversation about it, and wouldn't know if there's anything specific about AD2CP files that creates a special issue. I assume there isn't, and that its absence was just inertia.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inertia! 😅
@imranmaj : do you see problems with adding AD2CP support in this? The potential "problem" I can see is that AD2CP files comes with pitch
, roll
and heading
but not lat
lon
, so it is a partially filled dataset. So suppose users then want to add lat
lon
, the operations would become reading in the existing Platform group and add the new variables. Is this accurate?
Perhaps more generally the approach would be to:
- check if there is duplications in variables in
extra_platform_data
with the existinged.platform
dataset, warn user of overwritting if that's what they select - add an option to allow user to specify if they want to overwrite or use existing variables
- if allow overwriting then replace everything
- add new variables not already exist in
ed.platform
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For what it's worth, the need you've outlined is more or less identical to the situation for the OOI AZFP data. The platform group is created with some variables, but empty lat & lon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed!
External data is being indexed by a dimension named
|
# Handle data stored as a CF Trajectory Discrete Sampling Geometry | ||
# http://cfconventions.org/Data/cf-conventions/cf-conventions-1.8/cf-conventions.html#trajectory-data | ||
# The Saildrone sample data file follows this convention |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emiliom: reading this section you pointed out makes me wonder whether or not it is worthwhile to point out that the lat/lon data in the SONAR-netCDF4 ver.1 is consistent with the H.4.2. Single trajectory specification. Not that this necessitates any actual changes, but there seems to be values to make this explicit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I think once we get around to put this function into the documentation, we should link this explicitly!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emiliom: reading this section you pointed out makes me wonder whether or not it is worthwhile to point out that the lat/lon data in the SONAR-netCDF4 ver.1 is consistent with the H.4.2. Single trajectory specification. Not that this necessitates any actual changes, but there seems to be values to make this explicit.
Late reply ... Interesting observation. I agree, the structure is consistent. Maybe the right place to add this observation is the SONAR-netCDF4 version 2 draft text. From what Gavin said, it doesn't look like there are changes in the Platform group in v.2.
Also, I think once we get around to put this function into the documentation, we should link this explicitly!
Definitely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The consistency with the CF single trajectory specification was deliberate :) We tried to use CF conventions whenever it was sensible (and did attempt to meet CF-1.7, although it wasn't feasible for all of sonar-netcdf4 v1).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gavinmacaulay thanks for taking the time to chime in! I've gone ahead and created a new issue in the SONAR-netCDF4 repo. I'll try to handle it myself, hopefully next week.
Thanks for the changes @imranmaj ! We can now merge this 🙂 |
* re-attach sonar_model to combined echodata object (#437) * Correct duplicate ping_times during EK60 conversion (fixes #235) (#433) * Add fix for duplicate ping_time * Remove dead code * Increment by 1ns instead of 1ms * Add duplicate ping time warning and store in provenance * Autoformatter * Add test for duplicate ping times file * Add qc method to remove duplicate pings * Drop entire pings with duplicate values * Store entire original ping_time and add attribute when there are duplicate ping_times * Remove duplicate ping_time qc method, it will be added back in future PR * Change EchoData combine ping_time reversal attribute to netCDF encodable value * Remove unused import * Update tests * Clarify duplicate ping_time removal and drop warnings * Add removal note to deprecation warnings (#443) * Add removal note to deprecation warnings * Say removal will be specifically in next release * AD2CP conversion bug fixes (#438) * Allow strings in AD2CP config string data record * Add ping_time dimension to ahrs variables * Default AHRS to empty list instead of None * Change AHRS dims when it does not exist * Add update_platform method to EchoData (#434) * Add update_platform method to EchoData * Add test for update_platform * Use drop_vars instead of drop * Use .data on variables * Generalize extra_platform_data time dimension name * Add AZFP support * Generalized update_platform handling of CF trajectory-encoded datasets * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Default water_level to zeros instead of ones * Add warning for overwritten variables * Index incoming data by time2 * Add long_name for time2 * Show dropped variable warning when nans do not exist * Reword dropped variable warning * Rename mapping_get_multiple to mapping_search_variable Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * Add summary statistics (#444) * initial add of echo metrics functions * update echo metrics to use range as data variable * small readability edit * added test functions to echopype.tests * Modified syntax for consistency * lint corrections on metrics * added docstrings * changed summary_statistics.py docstrings to numpy format * Clean up tabs in code * Clean up tabs in test code * add metrics to run-test.py * renamed test_metrics_summary_statistics * small debug edits * pre commit black edits * moved test_metrics_summary_statistics.py to /tests/metrics/ * docstring update, add typing, change inertia to dispersion * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: stuara <stuara@uw.edu> Co-authored-by: Landung "Don" Setiawan <landung.setiawan@gmail.com> Co-authored-by: stuara <83487347+stuara@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * Prepare workflows for master -> main (#445) * Add PathNotFoundError in _load_convert for open_converted (#447) * add PathNotFoundError in _load_convert for open_converted Co-authored-by: imranmaj <49664304+imranmaj@users.noreply.github.com> Co-authored-by: Emilio Mayorga <emiliomayorga@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: stuara <stuara@uw.edu> Co-authored-by: Landung "Don" Setiawan <landung.setiawan@gmail.com> Co-authored-by: stuara <83487347+stuara@users.noreply.github.com> Co-authored-by: Landung "Don" Setiawan <landungs@uw.edu>
Part of #201
Adds an
EchoData.update_platform
method which can be used to update theEchoData.platform
group with additional external platform data.Partially adapted from ngkavin#2, ngkavin#3