diff --git a/include/database.h b/include/database.h index b3f2297cc..4f2503e62 100644 --- a/include/database.h +++ b/include/database.h @@ -1,5 +1,5 @@ /* Number of entries in PSR database */ -#define NP 2000 +#define NP 3000 #define NBP 200 /* This is a structure that contains the "normal" information in the database */ diff --git a/lib/python/parfile.py b/lib/python/parfile.py index 76e27f403..f071a5b27 100644 --- a/lib/python/parfile.py +++ b/lib/python/parfile.py @@ -132,17 +132,14 @@ def __init__(self, parfilenm): f, fd, = pu.p_to_f(self.P0, self.P1) setattr(self, 'F0_ERR', self.P0_ERR/(self.P0*self.P0)) setattr(self, 'F1', fd) - if hasattr(self, 'F0_ERR'): - if hasattr(self, 'F1_ERR'): - p, perr, pd, pderr = pu.pferrs(self.F0, self.F0_ERR, - self.F1, self.F1_ERR) - setattr(self, 'P0_ERR', perr) - setattr(self, 'P1', pd) - setattr(self, 'P1_ERR', pderr) - else: - p, pd, = pu.p_to_f(self.F0, self.F1) - setattr(self, 'P0_ERR', self.F0_ERR/(self.F0*self.F0)) - setattr(self, 'P1', pd) + if (hasattr(self, 'F0_ERR') and hasattr(self, 'F1_ERR')): + p, perr, pd, pderr = pu.pferrs(self.F0, self.F0_ERR, + self.F1, self.F1_ERR) + setattr(self, 'P0_ERR', perr) + setattr(self, 'P1', pd) + setattr(self, 'P1_ERR', pderr) + elif (hasattr(self, 'F0') and hasattr(self, 'F0_ERR')): + setattr(self, 'P0_ERR', self.F0_ERR/(self.F0*self.F0)) if hasattr(self, 'EPS1') and hasattr(self, 'EPS2'): ecc = math.sqrt(self.EPS1 * self.EPS1 + self.EPS2 * self.EPS2) omega = math.atan2(self.EPS1, self.EPS2) diff --git a/src/database.c b/src/database.c index 3152ec89d..ee921081a 100644 --- a/src/database.c +++ b/src/database.c @@ -27,6 +27,11 @@ int read_database(void) database = chkfopen(databasenm, "rb"); while (chkfread(&pdata, sizeof(psrdata), 1, database)) { + if (np >= NP) { + printf("NP value set to small (%d) in $PRESTO/include/database.h\n", NP); + printf("Please increase it and recompile\n"); + exit(-1); + } strncpy(pulsardata[np].jname, pdata.jname, 13); strncpy(pulsardata[np].bname, pdata.bname, 9); strncpy(pulsardata[np].alias, pdata.alias, 10);