<jupyter_start><jupyter_text>PSRJ2022+3842 Data from ATNF1. Right Ascension (J2000): 20:22:21.689 or in degree: 305.590372. Declination (J2000): +38:42:14.82 or in degree:38.7041173. Galactic Longitude/Latitude: 76.888/0.9604. Period (P): 0.048578779636 5. Period Derivative: 8.61E-14 6. Frequency: 20.5851198307. Frequency Derivative: -3.648E-118. Epoch of timing solution (PEPOCH): 55666.23789. Dispersion Measure (DM): 429.110. DM distance: 13.15411. Characteristic Age: 8.94e+0312. Spin-down power: 3.0e+3713. Surface Magnetic Field: 2.07e+12<jupyter_code>import numpy as np
events=np.loadtxt('/content/PNsspec_500assy2.dat')
print(events.size)
t0= 4877
print("Event index assigned phase 0: {}".format(t0))
#Frequency: 20.585119830
#Frequency Derivative: -3.648E-11
#Trial Frequencies
f0=20.585119830
f1=-3.648E-11
#We would assign phase of events[t0]=0.0
#Add f1 value for better accuracy of taylor series expansion
def trial_phase(events,f0):
    middle= events[t0]
    phi0=0.0
    phi= np.empty_like(events)
    for i in range(events.size):
        phi[i]= phi0 + f0*(events[i]-middle)+0.5*f1*(events[i]-middle)**2
    return phi
phase= trial_phase(events,f0)
print(phase.size)
#Deriving fractional phases 
def frac_phase(phaseArr):
    fracphase= np.empty_like(phaseArr)
    for j in range(phaseArr.size):
        if (phaseArr[j]>0):
            fracphase[j]= phaseArr[j]-int(phaseArr[j])
        elif(phaseArr[j]<0):
            fracphase[j]= phaseArr[j]- int(phaseArr[j]-1)
        else:
            fracphase[j]=phaseArr[j]
    return fracphase
phaseNorm= frac_phase(phase)
print(phaseNorm[phaseNorm==0])
#Z_test for derived phase values
def Z_test(phasefraction, n):
    N = len(phasefraction)
    z2=0
    for k in range(1,n+1):
        term1=0
        term2=0
        for j in range(1, (N+1)):
            term1 += np.cos(k*phasefraction[j-1])
            term2 += np.sin(k*phasefraction[j-1])
        z2 += np.square(term1)+ np.square(term2)
    Z= z2*2/N
    return Z
Z2= Z_test(phaseNorm,2)
Z1= Z_test(phaseNorm, 1)
print(Z1, Z2)
def freq (v,r,step,n,events):
    start= v-r
    end= v+r
    vRange= np.arange(start,end, step)
    zArr = np.empty_like(vRange)
    print("size of vrange ={}".format(vRange.size))
    for v in range(vRange.size):
        p= trial_phase(events,vRange[v])
        pFrac= frac_phase(p)
        Zstat = Z_test(pFrac, n)
        zArr[v]= Zstat
    return vRange, zArr    
freqArr1, zArray1= freq(f0,0.01,1e-5,1,events)
freqArr2, zArray2= freq(f0,0.01,1e-5,2,events)
print(np.argmax(zArray1),np.argmax(zArray2))
print(zArray1[292], freqArr1[292])
print(zArray2[292], freqArr2[292])
freqArr11, zArray11= freq(freqArr1[292],0.00001,1e-8,1,events)
print(np.argmax(zArray11))
print(zArray11[np.argmax(zArray11)], freqArr11[np.argmax(zArray11)])
import matplotlib.pyplot as plt
plt.figure(figsize=(20,8))
plt.plot(freqArr1,zArray1, scaley=True)
plt.yscale('log')
plt.show()
plt.figure(figsize=(8,8))
plt.errorbar(freqArr11,zArray11,yerr = 0.0001)
plt.show()
freqArr111, zArray111= freq(f0,0.00001,1e-8,1,events)
freqArr10, zArray10= freq(f0,0.0001,1e-8,1,events)
print(np.argmax(zArray111))
print(np.argmax(zArray10))
print(zArray111[np.argmax(zArray111)], freqArr111[np.argmax(zArray111)])
print(zArray10[np.argmax(zArray10)], freqArr10[np.argmax(zArray10)])
plt.figure(figsize=(8,8))
plt.errorbar(freqArr111,zArray111,yerr = 0.0001)
plt.show()
plt.figure(figsize=(8,8))
plt.errorbar(freqArr10,zArray10)
#plt.errorbar(freqArr111,zArray111)
#plt.errorbar(freqArr1,zArray1)
plt.show()
phaseActual=trial_phase(events,20.585141460010064)
phaseActualNorm= frac_phase(phaseActual)
print(phaseActualNorm.size)
arr=np.arange(0,9755)
arr
plt.hist(phaseActualNorm,100)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15396995708154507, 'fraction_numerical': 0.11239270386266094, 'mean_word_length': 4.844827586206897, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '411559', 'license': 'MIT', 'n_tokens_mistral': 1786, 'n_tokens_neox': 1533, 'n_words': 270, 'path': 'XRay_Emission_Profiles_Pulsars.ipynb', 'repo_name': 'supremeKAI40/PulsarDataPlotting', 'size': '3728'}