Skip to content

Address bug in NORM operators#6535

Merged
PaulWessel merged 2 commits intomasterfrom
math-norm-fix
Apr 8, 2022
Merged

Address bug in NORM operators#6535
PaulWessel merged 2 commits intomasterfrom
math-norm-fix

Conversation

@PaulWessel
Copy link
Member

The NORM operator in grdmath* and gmtmath says it will convert A so that max(A)-min(A) = 1. This it does, but not it a good way. For instance, if your data set generally goes from 3.0 to 3.5 and you call NORM, you get a result that goes from 6-7 instead - hardly a useful transformation. What is needed of course is to say that NORM converts A so that min(A) = 0 and max(A) = 1. This bug (and bad documentation) has now been fixed for both grdmath and gmtmath with this PR.

No tests were affected. Here is what it used to look like:

gmt math -T0/1/0.1 T 0.5 MUL 3 ADD =
0	3
0.1	3.05
0.2	3.1
0.3	3.15
0.4	3.2
0.5	3.25
0.6	3.3
0.7	3.35
0.8	3.4
0.9	3.45
1	3.5

gmt math -T0/1/0.1 T 0.5 MUL 3 ADD NORM =
0	6
0.1	6.1
0.2	6.2
0.3	6.3
0.4	6.4
0.5	6.5
0.6	6.6
0.7	6.7
0.8	6.8
0.9	6.9
1	7

and this is after the fix

gmt math -T0/1/0.1 T 0.5 MUL 3 ADD NORM =
0	0
0.1	0.1
0.2	0.2
0.3	0.3
0.4	0.4
0.5	0.5
0.6	0.6
0.7	0.7
0.8	0.8
0.9	0.9
1	1

The NORM operator in g??math says it will convert A so that max(A)-min(A) = 1.  This it does, but not it a good way.  For instance, if your data set generally goes from 3.0 to 3.5 and you call NORM, you get a result that goes from 6-7 instead - hardly a useful transformation.  What is needed of course is to say that NORM converts A so that min(A) = 0 and max(A) = 1.  This bug (and bad documentation) has now been fixed for both grdmath and gmtmath with this PR.
@PaulWessel PaulWessel added the bug Something isn't working label Apr 8, 2022
@PaulWessel PaulWessel added this to the 6.4.0 milestone Apr 8, 2022
@PaulWessel PaulWessel requested review from joa-quim and maxrjones April 8, 2022 09:04
@PaulWessel PaulWessel self-assigned this Apr 8, 2022
@PaulWessel PaulWessel merged commit db71468 into master Apr 8, 2022
@PaulWessel PaulWessel deleted the math-norm-fix branch April 8, 2022 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants