-
Notifications
You must be signed in to change notification settings - Fork 6
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
Refactoring #95
Refactoring #95
Conversation
…s-from-pandas-=2.0#79 Update requirements and fix tests from pandas =2.0#79
* removed parse scaffolding to the extent where we only initialize a parser, in the initialization of the parser we set parser.data class parameter, and then assign format class data class parameter * we always parse file now * minimize offset code to what is necessary * enforce that input file (in parsers) is not none
* reduce spacing and removing unused imports * may lead to lint errors
* ignore no gridpoint belongs to any region since we want this behavior to occur
for more information, see https://pre-commit.ci
* remove offset functionality in regions2d
* remove offset from r2d test * remove offset from api * remove offset from region_mask
for more information, see https://pre-commit.ci
* refactored main classes into lines and regions2d directories
* removed get points from region (unused) * separate utils into time based and io based functions * turn plot and mask into functions for both lines and regions2d
* refactored regions2d_mask * added lines_mask functionality
* add class sonar for nc data storage * sonar does parsing of nc files and checks inside dataset * does value setting checking * implement sonar for lines_mask and regions2d_mask * update lines_mask and regions2d_mask tests
for more information, see https://pre-commit.ci
Codecov Report
@@ Coverage Diff @@
## main #95 +/- ##
==========================================
- Coverage 80.72% 76.22% -4.50%
==========================================
Files 15 13 -2
Lines 555 408 -147
==========================================
- Hits 448 311 -137
+ Misses 107 97 -10
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
* for further sonar data tests
for more information, see https://pre-commit.ci
* add option for method and limit area for lines mask
* needed to parse with xr.open_dataset and xr.open_zarr and these are user needed functions
* refactor read_nc to read_sonar * add ability to read zarr files in read_sonar * in reading zarr files manipulate echo range and water level to get depth values and append these values to Sv (this may be non-functional, must test on more examples)
for more information, see https://pre-commit.ci
…into refactoring
* make processing for zarr and nc files cleaner and more in sync with each other by removing unnecessary variables and coordinates for masking
for more information, see https://pre-commit.ci
* expect input data arrays to be of "good" masking quality so there will be no functionality checking for "good" quality of data * slight change in r2d masking where we fillnas with max depth both before and after interpolation
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.
Hey @ctuguinay : Thanks for the refactoring work! I am done with this round of review. All comments are either in my overall comment last night or inline with the code.
One last thing is the location of read_evr
and read_evl
. Could you move them out of utils
and put them into core.py
at root level? (echoregions/echoregions/core.py
) This way we can easily find them, and init is easy. We may decide to move them later to another module, but for now let's keep it simple.
* send read_evl and read_evr to core.py from utils.py for easier reading
* simplified lines and regions2d init files to only include main class
* simplified echoregions main init to just read_evl and read_evr (we work with the lines and regions2d objects for every functionality)
* remove nan_depth_value property and setter * create appropriate lambda function to replace replace_depth * place lines mask in lines class as a class function * remove checking for ._data type (it is hidden and is set by code so we know it is dataframe) * separate start time and end time checking * revise the usage of lines_mask in tests so that we have just lines.mask(...)
* move regions2d mask to regions2d class as a class method * revise tests accordingly to have that r2d.mask(...) when we want to use a mask * remove depth * remove property and setter functions for max_depth and min_depth * remove checking for .data type
* catch invalid method and limit area values prior to interpolation * interpolation try except block is for errors that may not arise from the explicit value of method and limit area
for more information, see https://pre-commit.ci
@leewujung Sorry for how long this comment is. I mostly just wanted to keep all these replies to your comments in one place, for easier access later on. 1
I addressed both of these in the latest push. 2
True, no reason keeping
True, I think I initially wrote this prior to making it a private attribute. I removed it in latest push. 3
Yup, removed them in latest push. Initially moved them here since they were inherited by a Geometry class that I deleted. 4
Just separated them, can be found in latest push. 5
Since I am placing both masking functions as class methods, I don't think they need to be here. So the only functions needed are read_evl and read_evr. I made this change and it can be found in the latest push. 6
I addressed both of these in the latest push. For the reason listed above, I removed both mask functions too. 7
Just removed 8
Just removed this. Can be found in latest push. 9
I will put this in a new issue and will reference it in a bit. I don't see it used anywhere, but it was created for a reason. It is related to #53, and as such may be used there. 10
I'll place this in a separate issue to investigate further and mention this PR when I’ve created it. But yes, I think you're right in the sense that nothing should be returned if true, but in this case, if true it will return something instead of changing it inplace. 11
I address this in #97, so I'll leave it in there as it's more relevant for that PR. 12
Just changed this. Can be found in latest push. 13
Just made them class functions. Can check the latest push. 14
Due to how large this PR is, I'll place this in a separate issue and mention this PR when I’ve created it. 15
Not sure why, but reindexing directly to 16
Just changed this code. Can be found in latest push. 17
Just made a note! 18
I will place this in a separate issue and mention this PR when I’ve created it. 19
Just moved them. Can be found in latest push. |
Could you put in a TODO comment in the code to say what you have here, and we can potentially investigate later? It runs through fine so no reason for this to be a blocker. Thanks! |
echoregions/lines/lines.py
Outdated
Arguments: | ||
sonar - Sonar object containing DataArray of shape (ping_time, depth). | ||
method - String containing interpolation method. | ||
limit_area - String for determining filling restriction for NA values. | ||
|
||
Returns: | ||
bottom_mask - xarray with dimensions: (ping_time, depth) with bottom: False, otherwise: True |
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.
Let's also change this to numpy docstring format to be consistent.
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.
@ctuguinay : Thanks for making the changes and adding issues for the various pieces.
I only have a minor comment about docstring in one of the mask functions, but other than that, feel free to merge this PR!
* revised lines mask docstring to match numpy docstring format * add todo to investigate reindex/loc error
Refactoring
This PR addresses the following issues: #91, #88, #83, #43.
The main folders are now:
As opposed to before:
Refactoring notes:
r2d.plot()
andlines.plot()
.regions2d_mask(r2d,....)
andlines_mask(lines,.....)
.parse_regions_file(input_file)
andparse_lines_file(input_file)
.Other Changes Include:
All tests currently pass.
@leewujung @valentina-s Feel free to review this when you are free.