Commit befcf3de authored by Vlad Kondratiev's avatar Vlad Kondratiev

checking parfiles now if they have PEPOCH keyword (many of new pulsars in the...

checking parfiles now if they have PEPOCH keyword (many of new pulsars in the ATNF now do not have it, which causes both prepfold and dspsr to crash). If parfile does not have it, this pulsar is excluded from folding
parent ca7daf19
......@@ -563,12 +563,20 @@ class PipeUnit:
tmpdir = tempfile.mkdtemp()
# Now we check the par-files if they have non-appropriate flags that can cause prepfold to crash
toremove_psrs=[] # list of pulsars to remove from folding in case there is a problem with the parfile (e.g. PEPOCH is absent)
for psr in self.psrs:
psr2=re.sub(r'^[BJ]', '', psr)
parfile="%s/%s.par" % (self.outdir, psr2)
cmd="rsync -a %s %s" % (parfile, tmpdir)
parf="%s/%s" % (tmpdir, parfile.split("/")[-1])
# check first that PEPOCH is in the parfile
cmd="grep 'PEPOCH' %s" % (parf,)
if np.size(status)>0:
self.log.warning("WARNING: Par-file %s has no PEPOCH keyword, so this pulsar will be excluded from folding." % (parfile,))
# check first for PSRB name. It should be changed to PSRJ
cmd="grep 'PSRB' %s" % (parf,)
......@@ -595,10 +603,17 @@ UNITS line will be removed from the parfile!" % (parfile,))
self.execute(cmd, self.log, is_os=True)
cmd="rsync -a %s %s" % (parf, self.outdir)
# removing pulsars from folding if their parfile is bad (e.g. no PEPOCH)
if len(toremove_psrs) > 0:
for psr in np.unique(toremove_psrs):
for ii in xrange(len(self.psrs)):
if psr == self.psrs[ii]: indices_to_remove.add(ii)
indices_to_remove = sorted(indices_to_remove, reverse=True)
for ind in indices_to_remove: del(self.psrs[ind])
# return tmpdir
return tmpdir
def execute(self, cmd, workdir=None, shell=False, is_os=False):
Execute the command 'cmd' after logging the command
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment