Skip to content
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

Fix: testDataMgr doesn't compute grid extents correctly #2957

Merged
merged 7 commits into from
Jan 6, 2022

Conversation

sgpearse
Copy link
Collaborator

@sgpearse sgpearse commented Jan 6, 2022

Fixes #2944 by reducing the maximum extents after offsetting them by the minimum value. Removes the reduction to the minimum extents which are not needed.

I'm not sure why clang-format is modifying lines 115 through 117.

@clyne Since this fixes an issue that doesn't present itself on main, this PR is targeting your ROMS PR fix, #2943.

@sgpearse sgpearse requested a review from clyne January 6, 2022 02:14
@sgpearse sgpearse changed the title Issue2944v2 Fix: testDataMgr doesn't compute grid extents correctly Jan 6, 2022
minExt[i] /= 32.0;
maxExt[i] /= 32.0;
}
for (int i = 0; i < minExt.size(); i++) maxExt[i] = minExt[i] + maxExt[i] / 32.0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the goal here is to reduce the data size to 1/32 of its original, keeping the original coordinate origin, then what I believe you want is:

maxExt[i] = minExt[i] + (maxExt[i]-minExt[i]) / 32.0

Consider what would happen with the code as implemented if the extents were, for example, -1000 .. 0. (the volume size is unchanged). Or if the original extents were 1,000,000..1,000,010 (the domain grows!).

To center the reduced domain you could do something like;

center = (maxExt + minExt) / 2.0;
width = (maxExt - minExt) / 32.0
minExt = center - (width / 2.0)
maxExt = center + (width / 2.0);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, that didn't occur to me. Updated with comment that the origin must be maintained.

@clyne clyne merged commit 38bece4 into issue_2853 Jan 6, 2022
@clyne clyne deleted the issue2944v2 branch January 6, 2022 16:28
clyne added a commit that referenced this pull request Jan 6, 2022
* Replace use of std::vector with std::array in DataMgr for compability with
Grid class.

WIP

* WIP

* Incremental

* clang-format pre-push hook

* Merged with main

* clang-format pre-push hook

* Port to centos

* Fixed edge case - grids with dimesions of 1

* clang-format pre-push hook

* Fix: testDataMgr doesn't compute grid extents correctly (#2957)

* fix 2944 by adding offset to resampled extents

* test

* Only reduce maximum extents

* clang format

* update extents with comment

* remove old code

* Update dataMgrTools.cpp

Co-authored-by: clyne <clyne@ucar.edu>

Co-authored-by: sgpearse <pearse@ucar.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants