From e3b8918cb28b8a67a78ca249416ec25ed975a4f6 Mon Sep 17 00:00:00 2001 From: joeastro Date: Mon, 21 Oct 2024 14:18:26 -0400 Subject: [PATCH] gtorbsim profile interpolation fix --- src/read_ephem.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/read_ephem.cxx b/src/read_ephem.cxx index ab098e5..e895792 100644 --- a/src/read_ephem.cxx +++ b/src/read_ephem.cxx @@ -2612,7 +2612,8 @@ void doProfiled(double start, double end, double res, double *tms, for(jc=0; jc<=ncycles+1; jc++){ if(jc > 0){ - Lincr += difincr*(difincr/(fabs(difincr))); + //Lincr += difincr*(difincr/(fabs(difincr))); + Lincr += difincr; if((int)fabs(Lincr) >= (int)(res*secInDay)){ tms[16] = Ltime+(Lincr/fabs(Lincr))*(double)((int)(res*secInDay)); Lincr -= (Lincr/fabs(Lincr))*(double)((int)(res*secInDay)); @@ -2748,6 +2749,12 @@ double InterpProfile(double *tms, double *ofst, double res){ } else { Ltms[16] = tms[16]-(double)drem+(double)resS; difincr = -(double)drem+(double)resS; + // difincr should be negative if Ltms[16] > tms[16] + // i.e, if the interpolated profile is longer than the orginal profile, + // then the correction to the interpolated profile should shorten it + if(Ltms[16] > tms[16]){ + difincr *= -1; + } } if(Ltms[16] == Ltms[15]){