NOAA-PMEL/PyFerret

@DIN transformation gives incorrect results if the lo:hi limits lie within one grid cell

Closed this issue · 1 comments

@ryofurue reports this issue: https://www.pmel.noaa.gov/maillists/tmap/ferret_users/fu_2019/msg00974.html

Here's an even simpler example, using a unitless axis and asking for the definite integral with at every half grid cell for a few steps. The first two results should be 0.0 and 0.5. If the limits extend beyond one cell, then the result is correct, even if they include a partial cell on one or both ends of the interval.

yes? define axis/y=0:30:1 yaxis
yes? let ones =  1 + 0*y[gy=yaxis]
yes? repeat/range=0:6/name=yy (let val = ones[y=0:`yy/2`@din]; say `val`)
!-> REPEAT: YY:0
 !-> DEFINE VARIABLE val = ones[y=0:0@DIN]
 !-> MESSAGE/CONTINUE 1
1
!-> REPEAT: YY:1
 !-> DEFINE VARIABLE val = ones[y=0:0.5@DIN]
 !-> MESSAGE/CONTINUE 1
1
!-> REPEAT: YY:2
 !-> DEFINE VARIABLE val = ones[y=0:1@DIN]
 !-> MESSAGE/CONTINUE 1
1
!-> REPEAT: YY:3
 !-> DEFINE VARIABLE val = ones[y=0:1.5@DIN]
 !-> MESSAGE/CONTINUE 1.5
1.5
!-> REPEAT: YY:4
 !-> DEFINE VARIABLE val = ones[y=0:2@DIN]
 !-> MESSAGE/CONTINUE 2
2
!-> REPEAT: YY:5
 !-> DEFINE VARIABLE val = ones[y=0:2.5@DIN]
 !-> MESSAGE/CONTINUE 2.5
2.5
!-> REPEAT: YY:6
 !-> DEFINE VARIABLE val = ones[y=0:3@DIN]
 !-> MESSAGE/CONTINUE 3
3

This can be fixed with an update

fer/doo/do_ave_int.F

which is currently in my fork at https://github.com/ACManke/PyFerret.