From 645445534d12f81990b1d1d3aa2e02530a985a34 Mon Sep 17 00:00:00 2001 From: "N. Brouard" Date: Wed, 22 May 2019 17:56:10 +0000 Subject: [PATCH] Summary: Fix bug by moving date2dmy and nhstepm which gaefin=-1 --- src/imach.c | 48 +++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/src/imach.c b/src/imach.c index 5538037..1420ae3 100644 --- a/src/imach.c +++ b/src/imach.c @@ -1,6 +1,20 @@ /* $Id$ $State$ $Log$ + Revision 1.296 2019/05/20 13:03:18 brouard + Summary: Projection syntax simplified + + + We can now start projections, forward or backward, from the mean date + of inteviews up to or down to a number of years of projection: + prevforecast=1 yearsfproj=15.3 mobil_average=0 + or + prevforecast=1 starting-proj-date=1/1/2007 final-proj-date=12/31/2017 mobil_average=0 + or + prevbackcast=1 yearsbproj=12.3 mobil_average=1 + or + prevbackcast=1 starting-back-date=1/10/1999 final-back-date=1/1/1985 mobil_average=1 + Revision 1.295 2019/05/18 09:52:50 brouard Summary: doxygen tex bug @@ -3032,7 +3046,7 @@ double **pmij(double **ps, double *cov, int ncovmodel, double *x, int nlstate ) sumnew=0.; /*for (ii=1;ii<=nlstate+ndeath;ii++){*/ for (ii=1;ii<=nlstate;ii++){ /* Only on live states */ - /* printf(" agefin=%d, ii=%d, ij=%d, prev=%f\n",(int)agefin,ii, ij, prevacurrent[(int)agefin][ii][ij]); */ + /* printf(" agefin=%d, ii=%d, ij=%d, prev=%f\n",(int)agefin,ii, ij, prevacurrent[(int)agefin][ii][ij]); */ sumnew+=prevacurrent[(int)agefin][ii][ij]; } if(sumnew >0.01){ /* At least some value in the prevalence */ @@ -4407,6 +4421,20 @@ void pstamp(FILE *fichier) fprintf(fichier,"# %s.%s\n#IMaCh version %s, %s\n#%s\n# %s", optionfilefiname,optionfilext,version,copyright, fullversion, strstart); } +void date2dmy(double date,double *day, double *month, double *year){ + double yp=0., yp1=0., yp2=0.; + + yp1=modf(date,&yp);/* extracts integral of date in yp and + fractional in yp1 */ + *year=yp; + yp2=modf((yp1*12),&yp); + *month=yp; + yp1=modf((yp2*30.5),&yp); + *day=yp; + if(*day==0) *day=1; + if(*month==0) *month=1; +} + /************ Frequencies ********************/ @@ -8307,20 +8335,6 @@ set ter svg size 640, 480\nunset log y\nplot [%.f:%.f] ", ageminpar, agemaxpar) }/* End movingaverage */ - int date2dmy(double date,double *day, double *month, double *year){ - double yp=0., yp1=0., yp2=0.; - - yp1=modf(date,&yp);/* extracts integral of date in yp and - fractional in yp1 */ - *year=yp; - yp2=modf((yp1*12),&yp); - *month=yp; - yp1=modf((yp2*30.5),&yp); - *day=yp; - if(*day==0) *day=1; - if(*month==0) *month=1; - return; - } /************** Forecasting ******************/ /* void prevforecast(char fileres[], double dateintmean, double anprojd, double mprojd, double jprojd, double ageminpar, double agemax, double dateprev1, double dateprev2, int mobilav, double ***prev, double bage, double fage, int firstpass, int lastpass, double anprojf, double p[], int cptcoveff)*/ @@ -10734,8 +10748,8 @@ int hPijx(double *p, int bage, int fage){ /* for (agedeb=fage; agedeb>=bage; agedeb--){ /\* If stepm=6 months *\/ */ for (agedeb=bage; agedeb<=fage; agedeb++){ /* If stepm=6 months and estepm=24 (2 years) */ /* nhstepm=(int) rint((agelim-agedeb)*YEARM/stepm); /\* Typically 20 years = 20*12/6=40 *\/ */ - nhstepm=(int) rint((agedeb-ageminl)*YEARM/stepm); /* Typically 20 years = 20*12/6=40 */ - nhstepm = nhstepm/hstepm; /* Typically 40/4=10, because estepm=24 stepm=6 => hstepm=24/6=4 */ + nhstepm=(int) rint((agedeb-ageminl)*YEARM/stepm+0.1)-1; /* Typically 20 years = 20*12/6=40 or 55*12/24=27.5-1.1=>27 */ + nhstepm = nhstepm/hstepm; /* Typically 40/4=10, because estepm=24 stepm=6 => hstepm=24/6=4 or 28*/ /* nhstepm=nhstepm*YEARM; aff par mois*/ -- 2.43.0