コード例 #1
0
ファイル: get_TOAs.py プロジェクト: mahmoud-lsw/swiftmonitor
                    if not ii and not jj:
                        sys.stderr.write("WARNING!: Lengths of template (%d) and data (%d) are incompatible!  Skipping '%s'!\n" % (len(template), fold_pfd.proflen, fold_pfd.filenm))
                    continue
                # Interpolate the data
                if (len(template) > fold_pfd.proflen):
                    prof = psr_utils.linear_interpolate(prof, len(template)/fold_pfd.proflen)
                    if not ii and not jj:
                        sys.stderr.write("Note: Interpolating the data for '%s'\n"%fold_pfd.filenm)
                # Interpolate the template
                elif (1):
                    template = psr_utils.linear_interpolate(template, fold_pfd.proflen/len(template))
                    if not ii and not jj:
                        sys.stderr.write("Note: Interpolating the template for '%s'\n"%fold_pfd.filenm)
                # Downsample the data (Probably not a good idea)
                else:
                    prof = psr_utils.downsample(prof, fold_pfd.proflen/len(template))
                    if not ii and not jj:
                        sys.stderr.write("Note:  Downsampling the data for '%s'\n"%fold_pfd.filenm)

            try:
                # Try using FFTFIT first
                shift,eshift,snr,esnr,b,errb,ngood = measure_phase(prof, template, rotate_prof)
                # tau and tau_err are the predicted phase of the pulse arrival
                tau, tau_err = shift/len(prof), eshift/len(prof)
                # Note: "error" flags are shift = 0.0 and eshift = 999.0

                # If that failed, use a time-domain correlation
                if (Num.fabs(shift) < 1e-7 and
                    Num.fabs(eshift-999.0) < 1e-7):
                    sys.stderr.write('Warning!  Bad return from FFTFIT.  Using PRESTO correlation...\n')
                    # Not enough structure in the template profile for FFTFIT
コード例 #2
0
                        len(template) / fold_pfd.proflen)
                    if not ii and not jj:
                        sys.stderr.write(
                            "Note: Interpolating the data for '%s'\n" %
                            fold_pfd.filenm)
                # Interpolate the template
                elif (1):
                    template = psr_utils.linear_interpolate(
                        template, fold_pfd.proflen / len(template))
                    if not ii and not jj:
                        sys.stderr.write(
                            "Note: Interpolating the template for '%s'\n" %
                            fold_pfd.filenm)
                # Downsample the data (Probably not a good idea)
                else:
                    prof = psr_utils.downsample(
                        prof, fold_pfd.proflen / len(template))
                    if not ii and not jj:
                        sys.stderr.write(
                            "Note:  Downsampling the data for '%s'\n" %
                            fold_pfd.filenm)

            try:
                tau = None
                if len(prof) & 2 * len(prof):
                    sys.stderr.write(
                        "Profile length %d is not a power of two; unable to use FFTFIT.\n"
                        % len(prof))
                elif len(template) & 2 * len(template):
                    sys.stderr.write(
                        "Template length %d is not a power of two; unable to use FFTFIT.\n"
                        % len(template))