├── 19BeamHeaderUpdate ├── combine_fits.py ├── fitslist.txt ├── readme.txt ├── stt_offs_check.py ├── update_Header-OFFSSUB.py ├── update_Header-TBIN-OFFSSUB.py └── usage.txt ├── Combinefits ├── combine_fits.py ├── fitslist.txt └── readme.txt ├── Cutfits ├── cut.sh └── cut_FASTpsrfits_freq_time_splitpol.py ├── FASTFitsMerge ├── FASTFitsMerge.pro ├── FASTFitsMerge.pro.user ├── FASTFitsMerge.pro.user.a6a3201 ├── README.md ├── fileextractor.cpp ├── fileextractor.h ├── filefilter.h ├── filemerger.cpp ├── filemerger.h ├── filenamesystem.cpp ├── filenamesystem.h ├── fileprovider.cpp ├── fileprovider.h ├── fitsutility.cpp ├── fitsutility.h ├── main.cpp ├── maintask.cpp ├── maintask.h ├── setting.h └── utility.h ├── FAST_source_arrival_time ├── .DS_Store ├── PSR_time.py ├── shao │ ├── .DS_Store │ ├── Jname_input.list │ ├── PSR_transit_time_FAST.list │ └── SHAO_source_arrival_time.sh ├── shao_input_radec │ ├── .DS_Store │ ├── Tianma_source_arrival_time_v2.sh │ └── radec_input.list ├── ver1_input_Jname │ ├── .DS_Store │ ├── FAST_source_arrival_time_v1.sh │ ├── Jname_input.list │ └── PSR_transit_time_FAST.txt ├── ver2_input_radec │ ├── .DS_Store │ ├── FAST_source_arrival_time_v2.sh │ └── radec_input.list └── ver3_input_radec_J2017 │ ├── .DS_Store │ ├── FAST_source_arrival_time_v3.sh │ └── radec_input.list ├── FastFitsTools ├── .DS_Store ├── BeamWeight.py ├── CutByTF.py ├── FitsTools │ ├── .FitsCut.py.swp │ ├── Fits.py │ ├── Fits.pyc │ ├── FitsCut.py │ ├── FitsCut.pyc │ ├── FitsMerge.py │ ├── FitsOutput.py │ ├── FitsOutput.pyc │ ├── FitsWeighting.py │ ├── MergrPolo.py │ ├── MergrPolo.pyc │ ├── TimeCal.py │ ├── TimeCal.pyc │ ├── __init__.py │ ├── __init__.pyc │ └── beamweighting.py ├── MassFilePreTreated.py ├── MergeByF.py ├── MergeByT.py ├── __init__.py └── __init__.pyc ├── Gal_plot ├── .GCs-FASTsky_40.txt.swp ├── .GCs_Npsr-obser.py.swp ├── GCs-FASTsky_40.txt └── GCs_Npsr-obser.py ├── M31-gridding-survey ├── M31_grid.py └── grid.txt ├── MJD_extract ├── 20170822_Filename.list ├── 20170822_RaDec.list ├── 20170825_Filename.list ├── 20170825_RaDec.list ├── 20170827_Filename.list ├── 20170827_RaDec.list ├── MJD2pointing.sh ├── filename2pointing.sh └── readfile_MJD.sh ├── P-Pdot ├── .DS_Store ├── BINARY.txt ├── MAGNETAR.txt ├── MSP.txt ├── NORMAL.txt ├── RRAT.txt ├── XDINS.txt ├── fast.xlsx └── p-pdot.py ├── PSRCAT_matching ├── .DS_Store ├── DataList ├── Matching_PSRCAT_auto.sh ├── Matching_PSRCAT_v1.1.sh ├── Matching_PSRCAT_v2.1.sh ├── P0_fitting.sh ├── PSR_15.11.2.list ├── PSR_17.08.27.list └── matching.list ├── README.md ├── Timing ├── .DS_Store ├── .FTp_stt_mod_19beams.sh.swp ├── FTp_SMJD_OFFS_mod.sh ├── FTp_stt_mod_19beams.sh ├── FTplist.txt ├── George_timing_pipeline.png ├── stt_offs_check.py └── 脉冲星计时流程wangpei.txt ├── beamWeighting └── Beam_weighting.py ├── coordination ├── .DS_Store ├── J20002deg.py ├── J20002deg_batch.py ├── deg2J2000_batch.py ├── radec_deg_input.list └── radec_dms_input.list ├── downSampleCode ├── Downsamp_FASTpsrfits_freq_time_splitpol.py ├── cut_downsamping.sh └── 频率通道重采样程序示例.pdf ├── fits_plot ├── plotfits.py ├── plotfits2png.py └── usage.txt ├── pointing ├── FAST_source_RaJ_DecJ.py └── FAST_source_RaJ_manual.py ├── scintillation └── heatmap-plot.py └── update_fitsheader ├── test_result.png ├── update_Header-STT_offs.py └── update_pos.py /19BeamHeaderUpdate/fitslist.txt: -------------------------------------------------------------------------------- 1 | C34_tracking-M01_0001.fits 2 | C34_tracking-M01_0002.fits 3 | C34_tracking-M01_0003.fits 4 | C34_tracking-M01_0004.fits 5 | C34_tracking-M01_0005.fits 6 | C34_tracking-M01_0006.fits 7 | C34_tracking-M01_0007.fits 8 | C34_tracking-M01_0008.fits 9 | C34_tracking-M01_0009.fits 10 | C34_tracking-M01_0010.fits 11 | C34_tracking-M01_0011.fits 12 | C34_tracking-M01_0012.fits 13 | C34_tracking-M01_0013.fits 14 | C34_tracking-M01_0014.fits 15 | C34_tracking-M01_0015.fits 16 | C34_tracking-M01_0016.fits 17 | C34_tracking-M01_0017.fits 18 | C34_tracking-M01_0018.fits 19 | C34_tracking-M01_0019.fits 20 | C34_tracking-M01_0020.fits 21 | C34_tracking-M01_0021.fits 22 | C34_tracking-M01_0022.fits 23 | C34_tracking-M01_0023.fits 24 | C34_tracking-M01_0024.fits 25 | C34_tracking-M01_0025.fits 26 | C34_tracking-M01_0026.fits 27 | C34_tracking-M01_0027.fits 28 | C34_tracking-M01_0028.fits 29 | C34_tracking-M01_0029.fits 30 | C34_tracking-M01_0030.fits 31 | C34_tracking-M01_0031.fits 32 | C34_tracking-M01_0032.fits 33 | C34_tracking-M01_0033.fits 34 | C34_tracking-M01_0034.fits 35 | C34_tracking-M01_0035.fits 36 | C34_tracking-M01_0036.fits 37 | C34_tracking-M01_0037.fits 38 | C34_tracking-M01_0038.fits 39 | C34_tracking-M01_0039.fits 40 | C34_tracking-M01_0040.fits 41 | C34_tracking-M01_0041.fits 42 | C34_tracking-M01_0042.fits 43 | C34_tracking-M01_0043.fits 44 | C34_tracking-M01_0044.fits 45 | C34_tracking-M01_0045.fits 46 | C34_tracking-M01_0046.fits 47 | C34_tracking-M01_0047.fits 48 | C34_tracking-M01_0048.fits 49 | C34_tracking-M01_0049.fits 50 | C34_tracking-M01_0050.fits 51 | C34_tracking-M01_0051.fits 52 | C34_tracking-M01_0052.fits 53 | C34_tracking-M01_0053.fits 54 | C34_tracking-M01_0054.fits 55 | C34_tracking-M01_0055.fits 56 | C34_tracking-M01_0056.fits 57 | C34_tracking-M01_0057.fits 58 | C34_tracking-M01_0058.fits 59 | C34_tracking-M01_0059.fits 60 | C34_tracking-M01_0060.fits 61 | C34_tracking-M01_0061.fits 62 | C34_tracking-M01_0062.fits 63 | C34_tracking-M01_0063.fits 64 | C34_tracking-M01_0064.fits 65 | C34_tracking-M01_0065.fits 66 | C34_tracking-M01_0066.fits 67 | C34_tracking-M01_0067.fits 68 | C34_tracking-M01_0068.fits 69 | C34_tracking-M01_0069.fits 70 | C34_tracking-M01_0070.fits 71 | C34_tracking-M01_0071.fits 72 | C34_tracking-M01_0072.fits 73 | C34_tracking-M01_0073.fits 74 | C34_tracking-M01_0074.fits 75 | C34_tracking-M01_0075.fits 76 | C34_tracking-M01_0076.fits 77 | C34_tracking-M01_0077.fits 78 | C34_tracking-M01_0078.fits 79 | C34_tracking-M01_0079.fits 80 | C34_tracking-M01_0080.fits 81 | C34_tracking-M01_0081.fits 82 | C34_tracking-M01_0082.fits 83 | C34_tracking-M01_0083.fits 84 | C34_tracking-M01_0084.fits 85 | C34_tracking-M01_0085.fits 86 | C34_tracking-M01_0086.fits 87 | C34_tracking-M01_0087.fits 88 | C34_tracking-M01_0088.fits 89 | C34_tracking-M01_0089.fits 90 | C34_tracking-M01_0090.fits 91 | C34_tracking-M01_0091.fits 92 | C34_tracking-M01_0092.fits 93 | C34_tracking-M01_0093.fits 94 | C34_tracking-M01_0094.fits 95 | C34_tracking-M01_0095.fits 96 | C34_tracking-M01_0096.fits 97 | C34_tracking-M01_0097.fits 98 | C34_tracking-M01_0098.fits 99 | C34_tracking-M01_0099.fits 100 | C34_tracking-M01_0100.fits 101 | C34_tracking-M01_0101.fits 102 | C34_tracking-M01_0102.fits 103 | C34_tracking-M01_0103.fits 104 | C34_tracking-M01_0104.fits 105 | C34_tracking-M01_0105.fits 106 | C34_tracking-M01_0106.fits 107 | C34_tracking-M01_0107.fits 108 | C34_tracking-M01_0108.fits 109 | C34_tracking-M01_0109.fits 110 | C34_tracking-M01_0110.fits 111 | C34_tracking-M01_0111.fits 112 | C34_tracking-M01_0112.fits 113 | C34_tracking-M01_0113.fits 114 | C34_tracking-M01_0114.fits 115 | C34_tracking-M01_0115.fits 116 | C34_tracking-M01_0116.fits 117 | C34_tracking-M01_0117.fits 118 | C34_tracking-M01_0118.fits 119 | C34_tracking-M01_0119.fits 120 | C34_tracking-M01_0120.fits 121 | C34_tracking-M01_0121.fits 122 | C34_tracking-M01_0122.fits 123 | C34_tracking-M01_0123.fits 124 | C34_tracking-M01_0124.fits 125 | C34_tracking-M01_0125.fits 126 | C34_tracking-M01_0126.fits 127 | C34_tracking-M01_0127.fits 128 | C34_tracking-M01_0128.fits 129 | C34_tracking-M01_0129.fits 130 | C34_tracking-M01_0130.fits 131 | C34_tracking-M01_0131.fits 132 | C34_tracking-M01_0132.fits 133 | C34_tracking-M01_0133.fits 134 | C34_tracking-M01_0134.fits 135 | C34_tracking-M01_0135.fits 136 | C34_tracking-M01_0136.fits 137 | C34_tracking-M01_0137.fits 138 | C34_tracking-M01_0138.fits 139 | C34_tracking-M01_0139.fits 140 | C34_tracking-M01_0140.fits 141 | C34_tracking-M01_0141.fits 142 | C34_tracking-M01_0142.fits 143 | C34_tracking-M01_0143.fits 144 | -------------------------------------------------------------------------------- /19BeamHeaderUpdate/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | 包含 3 | 合并程序:combine_fits.py 4 | python combine_fits.py [root] [fitslist.txt] 5 | # How to use combine_fits.py to combine the subints from multi-datafiles 6 | # By Wangpei 2018/07/11 7 | 8 | 9 | Two inputs: 10 | -------------------- 11 | 1. [root] is the operational root for storing the output fits file, e.g. /wangpei/work2/test/new, which means that the newly combined fitsfile "new.fits" will be created under the root of "/wangpei/work2/test". 12 | 13 | 2. [fitslist.txt] is the name list of all the fits files you want to combine. Use "ls *.fits > fitsfile.txt". 14 | 15 | * Please copy and keep to run the program file "combine_fits.py" in the same folder as fits datafiles and fitslist.txt. 16 | ** If need, you can cut the frequency range first for the raw datafiles, and then run the combine_fits.py faster. 17 | 18 | 19 | 程序:update_Header-OFFSSUB.py 更新合并文件的OFFSSUB 20 | 用法:ls *.fits > fitslist.txt 21 | python update_Header-OFFSSUB.py fitslist.txt 22 | 23 | 程序:stt_offs_check.py 检查待合并文件的stt是否错误 24 | 用法:ls *.fits > filelist.txt 25 | python stt_offs_check.py 26 | 27 | 28 | 程序:update_Header-TBIN-OFFSSUB.py 29 | 用法见usage.txt 30 | -------------------------------------------------------------------------------- /19BeamHeaderUpdate/stt_offs_check.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | #!/usr/bin/env python 3 | import numpy as np 4 | import pyfits 5 | import sys 6 | #新建filelist.txt文件列表和输出文本output1.txt, output2.txt 7 | 8 | output1 = [] 9 | output2 = [] 10 | filename = np.genfromtxt('filelist.txt',dtype='|S50') 11 | print(filename) 12 | lines = np.shape(filename)[0]-1 13 | print(lines-1) 14 | 15 | hdulist = pyfits.open(filename[0]) 16 | hdu0 = hdulist[0] 17 | header0 = hdu0.header 18 | hdu1 = hdulist[1] 19 | header1 = hdu1.header 20 | imjd0 = header0['STT_IMJD'] 21 | smjd0 = header0['STT_SMJD'] 22 | offt0 = header0['STT_OFFS'] 23 | Offset0 = header1['NSUBOFFS'] 24 | 25 | for line in np.linspace(0,lines,lines): 26 | num = np.int(line) 27 | hdulist = pyfits.open(filename[num]) 28 | hdu0 = hdulist[0] 29 | header0 = hdu0.header 30 | hdu1 = hdulist[1] 31 | header1 = hdu1.header 32 | imjd = header0['STT_IMJD'] 33 | smjd = header0['STT_SMJD'] 34 | offt = header0['STT_OFFS'] 35 | Offset = header1['NSUBOFFS'] 36 | #Sample = header1['NSBLK'] 37 | #Tbins = header1['TBIN'] 38 | Offset1 = Offset - 64*num 39 | if imjd == imjd0 and smjd == smjd0 and offt == offt0 and Offset1 == Offset0 : 40 | datwritf=file('output1.txt','a') 41 | datwritf.write(str(filename[num])+' '+str(imjd)+' '+str(smjd)+' '+str(offt)+' '+str(Offset)+'\n') 42 | else: 43 | datwritf1=file('output2.txt','a') 44 | datwritf1.write(str(filename[num])+' '+str(imjd)+' '+str(smjd)+' '+str(offt)+' '+str(Offset)+'\n') 45 | -------------------------------------------------------------------------------- /19BeamHeaderUpdate/update_Header-OFFSSUB.py: -------------------------------------------------------------------------------- 1 | import fitsio 2 | import sys 3 | import commands 4 | import numpy as np 5 | #from astropy.io import fits 6 | #from astropy.table import Table 7 | 8 | if (len(sys.argv)<2): 9 | print 'Wrong inputs!' 10 | print 'Usage: python update_Header-OFFSSUB.py fitslist.txt' 11 | sys.exit() 12 | 13 | Fitslist = sys.argv[1] 14 | TotNfile = commands.getoutput('cat fitslist.txt | wc -l') 15 | print 'Go through the list to get a total row number' 16 | Nfile=1 17 | 18 | for Line in open(Fitslist): 19 | Line1=" ".join(Line.split()) 20 | Filename=Line1.replace('\n','').split(" ")[0].strip() 21 | hdulist = fitsio.FITS(Filename, 'rw') 22 | hdu1 = hdulist[1] 23 | header1 = hdu1.read_header() 24 | Nsub = header1['NAXIS2'] 25 | tbin = header1['TBIN'] 26 | tsub = header1['NSBLK']*tbin 27 | data = hdu1[:] 28 | offs_sub = np.zeros((Nsub)) 29 | for isub in range(0, Nsub): 30 | offs_sub[isub] = tsub * isub + tsub/2. 31 | # hdu1.write_column('OFFS_SUB', offs_sub) 32 | hdulist.close() 33 | # print offs_sub 34 | print 'Progress:',Nfile, '/', TotNfile, ' ', Filename 35 | print 'OFFS_SUB[31]=', data['OFFS_SUB'][31], '->', offs_sub[31] 36 | Nfile=Nfile+1 37 | -------------------------------------------------------------------------------- /19BeamHeaderUpdate/update_Header-TBIN-OFFSSUB.py: -------------------------------------------------------------------------------- 1 | import fitsio 2 | import sys 3 | import commands 4 | #from astropy.io import fits 5 | #from astropy.table import Table 6 | 7 | if (len(sys.argv)<2): 8 | print 'Wrong inputs!' 9 | print 'Usage: python update_TBIN.py fitslist.txt' 10 | sys.exit() 11 | 12 | Fitslist = sys.argv[1] 13 | TotNfile = commands.getoutput('cat fitslist.txt | wc -l') 14 | print 'Go through the list to get a total row number' 15 | Nfile=1 16 | 17 | 18 | for Line in open(Fitslist): 19 | Line1=" ".join(Line.split()) 20 | Filename=Line1.replace('\n','').split(" ")[0].strip() 21 | hdulist = fitsio.FITS(Filename, 'rw') 22 | hdu1 = hdulist[1] 23 | header1 = hdu1.read_header() 24 | tbin = header1['TBIN'] 25 | tbin_updated = tbin*4. 26 | hdu1.write_key('TBIN', tbin_updated) 27 | data = hdu1[:] 28 | offs_sub = data['OFFS_SUB']*4. 29 | # hdu1.write_key('OFFS_SUB', offs_sub) 30 | hdu1.write_column('OFFS_SUB', offs_sub) 31 | hdulist.close() 32 | print 'Progress:',Nfile, '/', TotNfile, ' ', Filename, 'TBIN=',tbin,'->',tbin_updated 33 | print 'OFFS_SUB[255]=', data['OFFS_SUB'][255], '->', offs_sub[255] 34 | Nfile=Nfile+1 35 | -------------------------------------------------------------------------------- /19BeamHeaderUpdate/usage.txt: -------------------------------------------------------------------------------- 1 | - Note: 2 | update TBIN in 19 beam file header 3 | 4 | - usage 5 | ls *.fits > fitslist.txt 6 | 7 | python update_TBIN.py fitslist.txt 8 | 9 | -------------------------------------------------------------------------------- /Combinefits/fitslist.txt: -------------------------------------------------------------------------------- 1 | C34_tracking-M01_0001.fits 2 | C34_tracking-M01_0002.fits 3 | C34_tracking-M01_0003.fits 4 | C34_tracking-M01_0004.fits 5 | C34_tracking-M01_0005.fits 6 | C34_tracking-M01_0006.fits 7 | C34_tracking-M01_0007.fits 8 | C34_tracking-M01_0008.fits 9 | C34_tracking-M01_0009.fits 10 | C34_tracking-M01_0010.fits 11 | C34_tracking-M01_0011.fits 12 | C34_tracking-M01_0012.fits 13 | C34_tracking-M01_0013.fits 14 | C34_tracking-M01_0014.fits 15 | C34_tracking-M01_0015.fits 16 | C34_tracking-M01_0016.fits 17 | C34_tracking-M01_0017.fits 18 | C34_tracking-M01_0018.fits 19 | C34_tracking-M01_0019.fits 20 | C34_tracking-M01_0020.fits 21 | C34_tracking-M01_0021.fits 22 | C34_tracking-M01_0022.fits 23 | C34_tracking-M01_0023.fits 24 | C34_tracking-M01_0024.fits 25 | C34_tracking-M01_0025.fits 26 | C34_tracking-M01_0026.fits 27 | C34_tracking-M01_0027.fits 28 | C34_tracking-M01_0028.fits 29 | C34_tracking-M01_0029.fits 30 | C34_tracking-M01_0030.fits 31 | C34_tracking-M01_0031.fits 32 | C34_tracking-M01_0032.fits 33 | C34_tracking-M01_0033.fits 34 | C34_tracking-M01_0034.fits 35 | C34_tracking-M01_0035.fits 36 | C34_tracking-M01_0036.fits 37 | C34_tracking-M01_0037.fits 38 | C34_tracking-M01_0038.fits 39 | C34_tracking-M01_0039.fits 40 | C34_tracking-M01_0040.fits 41 | C34_tracking-M01_0041.fits 42 | C34_tracking-M01_0042.fits 43 | C34_tracking-M01_0043.fits 44 | C34_tracking-M01_0044.fits 45 | C34_tracking-M01_0045.fits 46 | C34_tracking-M01_0046.fits 47 | C34_tracking-M01_0047.fits 48 | C34_tracking-M01_0048.fits 49 | C34_tracking-M01_0049.fits 50 | C34_tracking-M01_0050.fits 51 | C34_tracking-M01_0051.fits 52 | C34_tracking-M01_0052.fits 53 | C34_tracking-M01_0053.fits 54 | C34_tracking-M01_0054.fits 55 | C34_tracking-M01_0055.fits 56 | C34_tracking-M01_0056.fits 57 | C34_tracking-M01_0057.fits 58 | C34_tracking-M01_0058.fits 59 | C34_tracking-M01_0059.fits 60 | C34_tracking-M01_0060.fits 61 | C34_tracking-M01_0061.fits 62 | C34_tracking-M01_0062.fits 63 | C34_tracking-M01_0063.fits 64 | C34_tracking-M01_0064.fits 65 | C34_tracking-M01_0065.fits 66 | C34_tracking-M01_0066.fits 67 | C34_tracking-M01_0067.fits 68 | C34_tracking-M01_0068.fits 69 | C34_tracking-M01_0069.fits 70 | C34_tracking-M01_0070.fits 71 | C34_tracking-M01_0071.fits 72 | C34_tracking-M01_0072.fits 73 | C34_tracking-M01_0073.fits 74 | C34_tracking-M01_0074.fits 75 | C34_tracking-M01_0075.fits 76 | C34_tracking-M01_0076.fits 77 | C34_tracking-M01_0077.fits 78 | C34_tracking-M01_0078.fits 79 | C34_tracking-M01_0079.fits 80 | C34_tracking-M01_0080.fits 81 | C34_tracking-M01_0081.fits 82 | C34_tracking-M01_0082.fits 83 | C34_tracking-M01_0083.fits 84 | C34_tracking-M01_0084.fits 85 | C34_tracking-M01_0085.fits 86 | C34_tracking-M01_0086.fits 87 | C34_tracking-M01_0087.fits 88 | C34_tracking-M01_0088.fits 89 | C34_tracking-M01_0089.fits 90 | C34_tracking-M01_0090.fits 91 | C34_tracking-M01_0091.fits 92 | C34_tracking-M01_0092.fits 93 | C34_tracking-M01_0093.fits 94 | C34_tracking-M01_0094.fits 95 | C34_tracking-M01_0095.fits 96 | C34_tracking-M01_0096.fits 97 | C34_tracking-M01_0097.fits 98 | C34_tracking-M01_0098.fits 99 | C34_tracking-M01_0099.fits 100 | C34_tracking-M01_0100.fits 101 | C34_tracking-M01_0101.fits 102 | C34_tracking-M01_0102.fits 103 | C34_tracking-M01_0103.fits 104 | C34_tracking-M01_0104.fits 105 | C34_tracking-M01_0105.fits 106 | C34_tracking-M01_0106.fits 107 | C34_tracking-M01_0107.fits 108 | C34_tracking-M01_0108.fits 109 | C34_tracking-M01_0109.fits 110 | C34_tracking-M01_0110.fits 111 | C34_tracking-M01_0111.fits 112 | C34_tracking-M01_0112.fits 113 | C34_tracking-M01_0113.fits 114 | C34_tracking-M01_0114.fits 115 | C34_tracking-M01_0115.fits 116 | C34_tracking-M01_0116.fits 117 | C34_tracking-M01_0117.fits 118 | C34_tracking-M01_0118.fits 119 | C34_tracking-M01_0119.fits 120 | C34_tracking-M01_0120.fits 121 | C34_tracking-M01_0121.fits 122 | C34_tracking-M01_0122.fits 123 | C34_tracking-M01_0123.fits 124 | C34_tracking-M01_0124.fits 125 | C34_tracking-M01_0125.fits 126 | C34_tracking-M01_0126.fits 127 | C34_tracking-M01_0127.fits 128 | C34_tracking-M01_0128.fits 129 | C34_tracking-M01_0129.fits 130 | C34_tracking-M01_0130.fits 131 | C34_tracking-M01_0131.fits 132 | C34_tracking-M01_0132.fits 133 | C34_tracking-M01_0133.fits 134 | C34_tracking-M01_0134.fits 135 | C34_tracking-M01_0135.fits 136 | C34_tracking-M01_0136.fits 137 | C34_tracking-M01_0137.fits 138 | C34_tracking-M01_0138.fits 139 | C34_tracking-M01_0139.fits 140 | C34_tracking-M01_0140.fits 141 | C34_tracking-M01_0141.fits 142 | C34_tracking-M01_0142.fits 143 | C34_tracking-M01_0143.fits 144 | -------------------------------------------------------------------------------- /Combinefits/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | # How to use combine_fits.py to combine the subints from multi-datafiles 3 | # By Wangpei 2018/07/11 4 | 5 | Usage: 6 | python combine_fits.py [root] [fitslist.txt] 7 | 8 | 9 | Two inputs: 10 | -------------------- 11 | 1. [root] is the operational root for storing the output fits file, e.g. /wangpei/work2/test/new, which means that the newly combined fitsfile "new.fits" will be created under the root of "/wangpei/work2/test". 12 | 13 | 2. [fitslist.txt] is the name list of all the fits files you want to combine. Use "ls *.fits > fitsfile.txt". 14 | 15 | * Please copy and keep to run the program file "combine_fits.py" in the same folder as fits datafiles and fitslist.txt. 16 | ** If need, you can cut the frequency range first for the raw datafiles, and then run the combine_fits.py faster. 17 | -------------------------------------------------------------------------------- /Cutfits/cut.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | line=1 4 | cat filelist.txt | while read LINENAME; do 5 | NUM=`cat filelist.txt | wc -l` 6 | echo "${line}/${NUM} ${Filename}" 7 | Filename=`echo ${LINENAME} | awk '{print $1}'` 8 | python cut_FASTpsrfits_freq_time_splitpol.py 1160 3207 0 31 ${Filename} 9 | 10 | ((line++)) 11 | done 12 | -------------------------------------------------------------------------------- /FASTFitsMerge/FASTFitsMerge.pro: -------------------------------------------------------------------------------- 1 | QT += core 2 | QT -= gui 3 | 4 | CONFIG += c++11 5 | 6 | TARGET = FASTFitsMerge 7 | CONFIG += console 8 | CONFIG -= app_bundle 9 | 10 | TEMPLATE = app 11 | 12 | 13 | unix: CONFIG += link_pkgconfig 14 | unix: PKGCONFIG += cfitsio 15 | 16 | SOURCES += main.cpp \ 17 | fileprovider.cpp \ 18 | fileextractor.cpp \ 19 | fitsutility.cpp \ 20 | filemerger.cpp \ 21 | filenamesystem.cpp \ 22 | maintask.cpp 23 | 24 | # The following define makes your compiler emit warnings if you use 25 | # any feature of Qt which as been marked deprecated (the exact warnings 26 | # depend on your compiler). Please consult the documentation of the 27 | # deprecated API in order to know how to port your code away from it. 28 | DEFINES += QT_DEPRECATED_WARNINGS 29 | 30 | # You can also make your code fail to compile if you use deprecated APIs. 31 | # In order to do so, uncomment the following line. 32 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 33 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 34 | 35 | HEADERS += \ 36 | maintask.h \ 37 | fileprovider.h \ 38 | utility.h \ 39 | fileextractor.h \ 40 | fitsutility.h \ 41 | filemerger.h \ 42 | filenamesystem.h \ 43 | setting.h \ 44 | filefilter.h 45 | -------------------------------------------------------------------------------- /FASTFitsMerge/README.md: -------------------------------------------------------------------------------- 1 | # FASTFitsMerge 2 | 3 | Usage: ./FASTFitsMerge [options] source_dir dest_dir 4 | FAST Fits Extract and Merge program handle the initial fits files and produce new fits files. 5 | 6 | Options: 7 | -h, --help Displays this help. 8 | -v, --version Displays version information. 9 | -f, --force-drifting Treat all tracking files as drifting by force. 10 | -d, --drifting Extract and merge drifting files. 11 | -t, --tracking Extract and merge all tracking files. 12 | -p, --polar-no Only extract data that contains polorization 13 | . The default value is 1. 14 | -b, --end-ch-freq Only extract data that channel frequence >= 15 | . The default value is 290.0. 16 | -e, --begin-ch-freq Only extract data that channel frequence <= 17 | . The default value is 802.0. 18 | -c, --files-count Every files will be squencely merged 19 | to a file. The default value is 2. 20 | 21 | Arguments: 22 | source_dir Source directory that contains initial fits 23 | files. 24 | dest_dir Destination directory. 25 | 26 | -------------------------------------------------------------------------------- /FASTFitsMerge/fileextractor.cpp: -------------------------------------------------------------------------------- 1 | #include "fileextractor.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include "fitsutility.h" 7 | 8 | extern QTextStream *pConsoleOut; 9 | extern QDebug *pConsoleDebug; 10 | 11 | FileExtractor::FileExtractor(QObject *parent) : QObject(parent){ 12 | polarNo=1; 13 | } 14 | 15 | void FileExtractor::SetPolarNo(int polNo){ this->polarNo=polNo;} 16 | 17 | void FileExtractor::SetFrequencyChannelRange(float lowFrequencyChannelFreq, float highFrequencyChannelFreq, bool isChannelDataReverse){ 18 | this->startFrequencyChannelFreq=lowFrequencyChannelFreq; 19 | this->endFrequencyChannelFreq=highFrequencyChannelFreq; 20 | isChannelReverse=isChannelDataReverse; 21 | } 22 | 23 | // set the directory where store the output fits files 24 | void FileExtractor::SetFileDestinationDirectory(QString destinationDirectory, QString destSubDirectory){ 25 | fileDestinationDirectory=destinationDirectory.replace("~",QDir::homePath()); 26 | destDestDir.setPath(destinationDirectory); 27 | if(!destDestDir.exists(destSubDirectory) && !destDestDir.mkdir(destSubDirectory)){ 28 | if(pConsoleOut) *pConsoleOut<<"make directory "< 5 | #include 6 | #include 7 | 8 | // Extract data from initial fits file 9 | class FileExtractor : public QObject 10 | { 11 | Q_OBJECT 12 | 13 | private: 14 | QString fileDestinationDirectory; 15 | //QString destSubDirectory; // this directory will be created under destDestDir. 16 | QDir destDestDir; 17 | long long counter = 0; // the count of fits file that waiting to extract 18 | ///////// extract parameters 19 | int polarNo; 20 | float startFrequencyChannelFreq, endFrequencyChannelFreq; 21 | bool isChannelReverse; 22 | //////// parameters end 23 | 24 | public: 25 | explicit FileExtractor(QObject *parent = nullptr); 26 | 27 | void SetPolarNo(int polNo); 28 | 29 | void SetFrequencyChannelRange(float lowFrequencyChannelFreq, float highFrequencyChannelFreq, bool isChannelDataReverse=false); 30 | 31 | // set the directory where store the output fits files 32 | void SetFileDestinationDirectory(QString destinationDirectory, QString subDirectory="extracted"); 33 | 34 | signals: 35 | // When a fits file has been extracted, this single will be fired. 36 | void Extracted(QString extractedFileName, bool isSuccess); 37 | 38 | public slots: 39 | // extract a fits file 40 | void FitsFileExtract(QString filename, bool isRemove); 41 | 42 | // delete the extracted files in the destination deirectory 43 | void DeleteFiles(); 44 | 45 | }; 46 | 47 | #endif // FILEEXTRACTOR_H 48 | -------------------------------------------------------------------------------- /FASTFitsMerge/filefilter.h: -------------------------------------------------------------------------------- 1 | #ifndef FILEFILTER_H 2 | #define FILEFILTER_H 3 | #include 4 | #include 5 | #include 6 | 7 | typedef enum {DRIFTING,TRACKING} ObserveType; 8 | 9 | // e.g. FP20171111_0-1GHz_Dec-0941_drifting_0002.fits 10 | typedef struct { 11 | int FilterNumber; // number of this filter 12 | QStringList Filenames; //file list 13 | QString PrecedingName; // file name not contain number and extension. FP20171111_0-1GHz_Dec-0941_drifting 14 | QString ExtensionName; // file extention: ".fits" 15 | int NumberLen=0; // how many digitals is the file number. 4 16 | long MinNumber; // minmum file number. 1 17 | bool IsForceDrifting; 18 | int FileMergedCount; // how many files will to merge to a single file 19 | ObserveType Observe; 20 | bool IsLowFreq; 21 | } FileFilter; 22 | 23 | #endif // FILEFILTER_H 24 | -------------------------------------------------------------------------------- /FASTFitsMerge/filemerger.cpp: -------------------------------------------------------------------------------- 1 | #include "filemerger.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "fitsutility.h" 8 | 9 | 10 | extern QTextStream *pConsoleOut; 11 | extern QDebug *pConsoleDebug; 12 | 13 | FileMerger::FileMerger(QObject *parent) : QObject(parent){ 14 | connect(this,&FileMerger::BeginMerge,this,&FileMerger::FileMerge); 15 | } 16 | 17 | // set the directory that copy the merged fits file to. 18 | void FileMerger::SetOutputDirectory(QString dest){ 19 | outputDirectory = dest.replace("~",QDir::homePath()); 20 | } 21 | 22 | 23 | //Merge files to a single file. 24 | void FileMerger::FileMerge(QStringList files, QString destinationFilename){ 25 | if(files.count()==0) { 26 | //qDebug()<<"have not files. emit merged signal. "; 27 | emit Merged(destinationFilename,false); 28 | return; 29 | } 30 | 31 | if(!timer.isValid()) timer.start(); 32 | timer.restart(); 33 | 34 | int len=files.count(); 35 | std::string *fns= new std::string[len]; 36 | for(int i=0;i=0) subDir=destinationFilename.mid(index1+1,index2-index1-1); 43 | QFileInfo finfo(destinationFilename); 44 | QDir dir(outputDirectory); 45 | //if(!subDir.isEmpty() && !dir.exists(subDir)) dir.mkdir(subDir); 46 | QString temp = dir.absolutePath() + QDir::separator() + /*(subDir.isEmpty()?"":(subDir+QDir::separator())) + */finfo.fileName(); 47 | std::string outfilename = temp.toStdString(); 48 | 49 | //merge files 50 | bool isOk=mergeFitsFile(fns,len,outfilename); 51 | delete[] fns; 52 | 53 | if(pConsoleDebug){ 54 | foreach (QString fn, files) { 55 | *pConsoleDebug< 5 | #include 6 | #include 7 | #include 8 | 9 | // merge two or more fits file as a big fits file. 10 | // copy the merged file to another directory. 11 | class FileMerger : public QObject 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit FileMerger(QObject *parent = nullptr); 17 | 18 | // set the directory that copy the merged fits file to. 19 | void SetOutputDirectory(QString dest); 20 | 21 | private: 22 | QString outputDirectory; 23 | QElapsedTimer timer; 24 | 25 | signals: 26 | // the files have been merged 27 | void Merged(QString fileName, bool isSuccess); 28 | 29 | // begin to merge 30 | void BeginMerge(QStringList files, QString outfilename); 31 | 32 | public slots: 33 | //Merge files to a single file. 34 | void FileMerge(QStringList files, QString destinationFilename); 35 | 36 | //Merge files to a single file. 37 | void FileMerge1(QStringList files); 38 | }; 39 | 40 | #endif // FILEMERGER_H 41 | -------------------------------------------------------------------------------- /FASTFitsMerge/filenamesystem.cpp: -------------------------------------------------------------------------------- 1 | #include "filenamesystem.h" 2 | #include 3 | #include 4 | 5 | FileNameSystem::FileNameSystem(QString allinoneName) 6 | { 7 | this->allinoneName=allinoneName; 8 | } 9 | 10 | void FileNameSystem::SetNameHint(FileFilter *filter){ 11 | //approach: filename append "merge" 12 | //int index3 = hint.lastIndexOf("."); 13 | //allinoneName = hint.left(index3)+"_merge"+hint.mid(index3); 14 | // another approach: 15 | if(filter == nullptr || filter->Filenames.count()==0){ 16 | allinoneName = "unkonwnname"; 17 | return; 18 | } 19 | 20 | QString number; 21 | number.setNum(filter->FilterNumber,16); 22 | QFileInfo finfo(filter->Filenames.first()); 23 | QString oldFilename=finfo.fileName(); 24 | int index0 = oldFilename.indexOf("_"); 25 | int index1 = oldFilename.lastIndexOf("_"); 26 | int index2 = oldFilename.lastIndexOf("."); 27 | 28 | allinoneName = oldFilename.left(index0+1) 29 | + oldFilename.mid(index1+1,index2-index1-1).leftJustified(4,'0') 30 | + /*QString::number(filter->FilterNumber)*/ number + (filter->IsLowFreq?"L":"H") + filter->ExtensionName; 31 | } 32 | 33 | QString FileNameSystem::GetAName(){ 34 | return allinoneName; 35 | } 36 | 37 | QString FileNameSystem::GetAName(QStringList *files, FileFilter *filter){ 38 | if(files==nullptr || files->count()==0 || filter==nullptr) return "unkonwnname"; 39 | 40 | QString number; 41 | number.setNum(filter->FilterNumber,16); 42 | QFileInfo finfo(files->at(0)); 43 | QString oldFilename=finfo.fileName(); 44 | int index0 = oldFilename.indexOf("_"); 45 | int index1 = oldFilename.lastIndexOf("_"); 46 | int index2 = oldFilename.lastIndexOf("."); 47 | 48 | return oldFilename.left(index0+1) 49 | + oldFilename.mid(index1+1,index2-index1-1).leftJustified(4,'0') 50 | + /*QString::number(filter->FilterNumber)*/ number + (filter->IsLowFreq?"L":"H") + filter->ExtensionName; 51 | } 52 | -------------------------------------------------------------------------------- /FASTFitsMerge/filenamesystem.h: -------------------------------------------------------------------------------- 1 | #ifndef FILENAMESYSTEM_H 2 | #define FILENAMESYSTEM_H 3 | #include 4 | #include 5 | #include "filefilter.h" 6 | 7 | // outfile name system 8 | class FileNameSystem 9 | { 10 | private: 11 | QString allinoneName; //the all in one file name 12 | 13 | public: 14 | FileNameSystem(QString allinoneName=""); 15 | 16 | // give some hint for generate the file name 17 | void SetNameHint(FileFilter *filter); 18 | 19 | // get a file name with some hint 20 | QString GetAName(QStringList *files, FileFilter *filter); 21 | 22 | // get a file name 23 | QString GetAName(); 24 | }; 25 | 26 | #endif // FILENAMESYSTEM_H 27 | -------------------------------------------------------------------------------- /FASTFitsMerge/fileprovider.cpp: -------------------------------------------------------------------------------- 1 | #include "fileprovider.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "utility.h" 8 | #include "fitsutility.h" 9 | 10 | extern QTextStream *pConsoleOut; 11 | extern QDebug *pConsoleDebug; 12 | 13 | FileProvider::FileProvider(QObject *parent) : QObject(parent){ 14 | 15 | } 16 | 17 | void FileProvider::SetSourceDirectory(QString source){ 18 | sourceDirectory=source.replace("~",QDir::homePath()); 19 | } 20 | 21 | void FileProvider::SetDestinationDirectory(QString destination) { 22 | destinationDirectory=destination.replace("~",QDir::homePath()); 23 | } 24 | 25 | void FileProvider::SetFileFilter(FileFilter filter){ 26 | fileFilter=filter; 27 | } 28 | 29 | void FileProvider::ClearFileFliter(){ 30 | fileFilter=FileFilter(); 31 | } 32 | 33 | void FileProvider::ResetCounter(){ 34 | counterLocker.lockForWrite(); 35 | notHandledCounter=0; 36 | counterLocker.unlock(); 37 | } 38 | 39 | // return the file count waiting to handle. 40 | long FileProvider::Counter(){ 41 | long temp; 42 | counterLocker.lockForRead(); 43 | temp=notHandledCounter; 44 | counterLocker.unlock(); 45 | return temp; 46 | } 47 | 48 | // add one to the file counter 49 | void FileProvider::IncreaseCounter(){ 50 | counterLocker.lockForWrite(); 51 | notHandledCounter++; 52 | counterLocker.unlock(); 53 | } 54 | 55 | // decrease one to the file counter 56 | void FileProvider::DecreaseCounter(){ 57 | counterLocker.lockForWrite(); 58 | notHandledCounter--; 59 | counterLocker.unlock(); 60 | } 61 | 62 | // Read all the files contained in the filter. NOT the source directory. 63 | bool FileProvider::ReadAllFile(){ 64 | notHandledCounter=0; 65 | willExit=false; 66 | if(fileFilter.Filenames.count()==0) return true; 67 | 68 | if(destinationDirectory.isEmpty() || destinationDirectory.isNull()){ 69 | emit FilesCounted(fileFilter.Filenames.count()); 70 | 71 | //copy file to subdeirector 72 | for(int i=0;(i2*fileInfo.size()){ // the file waiting to handle isnot too more and free memory size >double of file size 127 | //qDebug()<<"File provider is copying file "< 5 | #include 6 | #include 7 | #include 8 | #include "filefilter.h" 9 | 10 | //Copy the fits file to other directory. 11 | //Usually, this files should copy to memory, such as /dev/shm 12 | class FileProvider : public QObject 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit FileProvider(QObject *parent = nullptr); 18 | void SetSourceDirectory(QString source); 19 | void SetDestinationDirectory(QString destination); 20 | void SetFileFilter(FileFilter filter); 21 | void ClearFileFliter(); 22 | 23 | private: 24 | QString sourceDirectory; //will search all the directory and files in this directory 25 | QString destinationDirectory; //the files will be stored to this directory 26 | QStringList fileList; // the files that will be handled. 27 | FileFilter fileFilter; 28 | bool willExit=false; 29 | 30 | long notHandledCounter=0; // file count waiting to handle (extract and merge). 31 | QReadWriteLock counterLocker; // locker for counter 32 | int MaxWaitingFiles=4; 33 | 34 | public: 35 | // return the file count wating to handle. 36 | long Counter(); 37 | 38 | void ResetCounter(); 39 | 40 | // add one to the file counter 41 | void IncreaseCounter(); 42 | 43 | // decrease one to the file counter 44 | void DecreaseCounter(); 45 | 46 | // Read all the files contained in the the source directory. 47 | bool ReadAllFile(); 48 | 49 | signals: 50 | // When fits file is ready to extract, this signal will be fired. 51 | void FileReady(QString fullFilename,bool isRemove); 52 | 53 | // the count of files 54 | void FilesCounted(long count); 55 | 56 | // all file copying operations stoped. 57 | void Stoped(); 58 | 59 | public slots: 60 | // delete the files in destination files 61 | void DeleteFiles(); 62 | 63 | void Stop(){ 64 | willExit=true; 65 | } 66 | }; 67 | 68 | #endif // FILEPROVIDER_H 69 | -------------------------------------------------------------------------------- /FASTFitsMerge/fitsutility.h: -------------------------------------------------------------------------------- 1 | #ifndef FITSUTILITY_H 2 | #define FITSUTILITY_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | using namespace std; 13 | 14 | // some information for FAST fits file 15 | typedef struct { 16 | string filename; //fits file name 17 | string telescop; // telescop name 18 | int beamID; // id of beam 19 | long long nSubIntOffs; // subint offset, for continous search mode files 20 | float ver; //version. e.g. 3.4 21 | int hdutype; //ASCII_TBL, BINARY_TBL 22 | int bitpix; //always 8 23 | int nAxis; //always 2 24 | long long colsSize; //size of a row in table 25 | long long nRows; // row count in table. that is, the subint count 26 | int nPols; // how many polarization 27 | int nChannels; // how many channels 28 | int nSamples; // samples per channel in a subint 29 | 30 | long long stt_imjd; 31 | long long stt_smjd; 32 | double stt_offs; 33 | double subIntPeriod; // Length of subintegration, second 34 | double firstSubIntTimeOffset; // the first subint's time offset, second 35 | 36 | long long leadingCol13Size; // in a row, the leading bytes before column 13 DAT_FREQ 37 | long col13ElementWidth; //the element width (unit: byte) 38 | long long leadingCol14Size; // in a row, the leading bytes before column 14 DAT_WTS 39 | long col14ElementWidth; //the element width (unit: byte) 40 | long long leadingCol15Size; // in a row, the leading bytes before column 15 DAT_OFFS 41 | long col15ElementWidth; //the element width (unit: byte) 42 | long long leadingCol16Size; // in a row, the leading bytes before column 16 DAT_SCL 43 | long col16ElementWidth; //the element width (unit: byte) 44 | long long leadingCol17Size; // in a row, the leading bytes before column 17 DATA 45 | long long extensionHduDataOffset; //the data offset of the extenstion hdu. in byte. 46 | } FASTFitsDataInfo; 47 | 48 | // show error informatin on console 49 | void printerror(int status); 50 | 51 | // show fits headers information 52 | void readheader (const char *filename); 53 | 54 | // read fits info from fitsfile 55 | bool readFASTFitsInfo(fitsfile *fptr,FASTFitsDataInfo &info); 56 | 57 | // show information in console. 58 | void printFASTFitsInfo(FASTFitsDataInfo &info); 59 | 60 | // set the OFFS_SUB of second fits file identy as reference fits file. 61 | // note: before calling this function, be sure to close the second fits file 62 | // return fasle when error occured. 63 | bool normalizeOFFS_SUB(const FASTFitsDataInfo& refFitsInfo, FASTFitsDataInfo& info); 64 | 65 | // check wheather two FAST fits can merge. Attension: bitpix 66 | bool canMerge(FASTFitsDataInfo &info1,FASTFitsDataInfo &info2); 67 | 68 | // extract data to a new fits file which name is outFitsFilename. 69 | // info: source fits file information 70 | // the output fits will contain channel between channelNoFrom to channelNoTo and the polar is polNo. 71 | // channelFromNo>=1, channelToNo>1, polNo>=1, channelNoFrom<=channelNoTo 72 | bool extractFits(FASTFitsDataInfo &info, int channelNoFrom, int channelNoTo, int polNo, string outFitsFilename, float centerFreq=0.0); 73 | 74 | // extract data to a new fits file which name is outFitsFilename. 75 | // info: source fits file information 76 | // the output fits will contain channel between channelNoFrom to channelNoTo and the polar is polNo. 77 | // channelFromNo>=1, channelToNo>1, polNo>=1, channelNoFrom<=channelNoTo 78 | bool extractFits(string filename, int channelNoFrom, int channelNoTo, int polNo, string outFitsFilename); 79 | 80 | // extract data to a new fits file which name is outFitsFilename. 81 | // info: source fits file information 82 | // the output fits will contain channels which frequency is between channelFreqFrom to channelFreqTo and the polar is polNo. 83 | bool extractFits(string filename, float channelFreqFrom, float channelFreqTo, int polNo, string outFitsFilename, bool isReverseChannel); 84 | 85 | // append the second fits extension data to the first fits, and output to outFilename file. 86 | bool mergeFitsFile(string inFilenames[], int nInFiles, string outFliename); 87 | 88 | // read the time reletive parameter and store to row, samplesPerRow, timePerSample, allTimeLen. 89 | // Unit: second. 90 | bool getTimeLen(string filename, long *row, long *samplesPerRow, float *timePerSample, float *allTimeLen); 91 | 92 | bool isDataIdent(string filename1,string filename2); 93 | 94 | void dataView(string filename); 95 | 96 | #endif // FITSUTILITY_H 97 | -------------------------------------------------------------------------------- /FASTFitsMerge/maintask.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINTASK_H 2 | #define MAINTASK_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "setting.h" 13 | #include "filefilter.h" 14 | #include "fileprovider.h" 15 | #include "fileextractor.h" 16 | #include "filemerger.h" 17 | #include "filenamesystem.h" 18 | 19 | // work bussiness 20 | class MainTask : public QObject 21 | { 22 | Q_OBJECT 23 | 24 | public: 25 | explicit MainTask(QObject *parent = 0); 26 | explicit MainTask(Settings setting, QObject *parent = 0); 27 | 28 | private: 29 | Settings setting; 30 | QThread fileCopyThread; 31 | QThread fileExtractThread; 32 | QThread fileMergeThread; 33 | 34 | FileMerger fm; 35 | FileProvider fp; 36 | FileExtractor fe; 37 | 38 | //int filesCount = 2; // the number of files that be merged as a big file. 39 | QStringList files; // the list of files waiting to merge. 40 | long totalFiles=0; 41 | 42 | QList filters; 43 | int currentFileFilterIndex; 44 | FileNameSystem nameSystem; 45 | 46 | QElapsedTimer timer; 47 | void GetFilters(QString directory,QStringList filters, QList &filterList); 48 | 49 | //QTextStream consoleOut; 50 | 51 | public slots: 52 | // file is extracted. 53 | void FitsExtracted(QString filename, bool isOk); 54 | 55 | // file is merged. 56 | void FitsMerged(QString filename, bool isOk); 57 | 58 | // when fileprovider is done, the copied file count will fire. 59 | void FileCounted(long count); 60 | 61 | void FileStoped(); 62 | 63 | // to do work. 64 | void run(); 65 | 66 | signals: 67 | void DeleteFiles(); 68 | 69 | // task finished 70 | void finished(); 71 | }; 72 | 73 | #endif // MAINTASK_H 74 | -------------------------------------------------------------------------------- /FASTFitsMerge/setting.h: -------------------------------------------------------------------------------- 1 | #ifndef SETTING_H 2 | #define SETTING_H 3 | 4 | // application configuration 5 | typedef struct { 6 | // directory information 7 | QString SourceDir,DestDir; 8 | // polariazation 9 | int PolNo; 10 | // // channel number 11 | // int BeginChannelNo, EndChannelNo; 12 | // channel frequence 13 | float BeginChannelFreq, EndChannelFreq; 14 | // file count to merge to one 15 | int FileCountToMerge; 16 | // all tracking file to a single one 17 | bool IsForceDrifting; 18 | bool IsHandleDrifting,IsHandleTracking; 19 | 20 | //copy filt to memory 21 | bool IsCopyFileToMem; 22 | 23 | // the max time legth, by minutes 24 | float MaxTimeLen; 25 | 26 | // only filt files, not do other thing 27 | bool OnlyFilt; 28 | 29 | int SpecialFilterNo; 30 | 31 | QStringList FileNameFilters; 32 | } Settings; 33 | 34 | 35 | #endif // SETTING_H 36 | -------------------------------------------------------------------------------- /FASTFitsMerge/utility.h: -------------------------------------------------------------------------------- 1 | #ifndef UTILITY_H 2 | #define UTILITY_H 3 | 4 | #include 5 | 6 | class Utility{ 7 | public: 8 | // get the RAM usage information 9 | static void GetMemInfo(unsigned long *totalMemory_MB, unsigned long *freeMemory_MB){ 10 | struct sysinfo myinfo; 11 | sysinfo(&myinfo); 12 | *totalMemory_MB = (myinfo.mem_unit * myinfo.totalram / 1024 / 1024); 13 | *freeMemory_MB = (myinfo.mem_unit * myinfo.freeram / 1024 / 1024); 14 | } 15 | }; 16 | 17 | 18 | 19 | #endif // UTILITY_H 20 | -------------------------------------------------------------------------------- /FAST_source_arrival_time/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NAOC-pulsar/PeiWang-code/6a01f92ec9f1a32d2c203c8b8dd6955a208af330/FAST_source_arrival_time/.DS_Store -------------------------------------------------------------------------------- /FAST_source_arrival_time/PSR_time.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import ephem 3 | 4 | Dawodang=ephem.Observer() 5 | Dawodang.lat='25.652939' 6 | Dawodang.lon='106.856594' 7 | Dawodang.horizon='-18' # Astronomical twilight uses the value -18 degrees 8 | 9 | Dawodang.date= '2017/12/10' 10 | 11 | src = ephem.FixedBody() 12 | src._ra = '09:22:14.022' # J2000 13 | src._dec = '+06:38:23.3' # J2000 14 | 15 | #M87 12:30:49.4 +12:23:28 16 | #G192.54-11.56 82.868958 12.256222 17 | #J1837+1221 18:37:07.1 +12:21:54.0 18 | #J1916+1225 19:16:20.0 +12:25:53.9 19 | 20 | 21 | src.compute() 22 | trise=Dawodang.previous_rising(src) 23 | print 'previous rise' 24 | print src.alt,src.az,ephem.localtime(trise) 25 | ttrans=Dawodang.next_transit(src) 26 | print 'next transit' 27 | print src.alt,src.az,ephem.localtime(ttrans) 28 | tset=Dawodang.next_setting(src) 29 | print 'next setting' 30 | print src.alt,src.az,ephem.localtime(tset) 31 | print src.ra,src.dec 32 | -------------------------------------------------------------------------------- /FAST_source_arrival_time/shao/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NAOC-pulsar/PeiWang-code/6a01f92ec9f1a32d2c203c8b8dd6955a208af330/FAST_source_arrival_time/shao/.DS_Store -------------------------------------------------------------------------------- /FAST_source_arrival_time/shao/Jname_input.list: -------------------------------------------------------------------------------- 1 | B0031-07 2 | B0329+54 3 | B0525+21 4 | B0823+26 5 | B0834+06 6 | B0919+06 7 | B0950+08 8 | B1133+16 9 | B1237+25 10 | B1541+09 11 | B1859+03 12 | B1859+07 13 | B1900+01 14 | B1907+10 15 | B1919+21 16 | B1929+10 17 | B1933+16 18 | B1937+21 19 | B1946+35 20 | B2000+40 21 | B2016+28 22 | B2020+28 23 | B2111+46 24 | B2154+40 25 | B2217+47 26 | B2310+42 27 | -------------------------------------------------------------------------------- /FAST_source_arrival_time/shao/PSR_transit_time_FAST.list: -------------------------------------------------------------------------------- 1 | PSRJ RA(hh:mm:ss) DEC(hh:mm:ss) RA(deg) DEC(deg) P0(s) DM S400(mJy) S1400(mJy) S2000(mJy) Rise_time transit_time Set_time 2 | B0031-07 00:34:08.8 -07:21:53.4 8.536960 -7.364836 0.942951 10.92 52.00 11.00 * 2017-11-27 18:56:32 2017-11-28 20:04:04.000001 2017-11-28 21:15:33.000001 3 | B0329+54 03:32:59.3 +54:34:43.5 53.247367 54.578769 0.714520 26.76 1500.00 203.00 * 2017-11-27 19:49:24 2017-11-28 23:02:55.000001 2017-11-29 02:20:22.000002 4 | B0525+21 05:28:52.2 +22:00:04 82.217767 22.001111 3.745539 50.94 57.00 9.00 * 2017-11-27 21:57:46 2017-11-29 00:58:10.000002 2017-11-29 04:02:30.000002 5 | B0823+26 08:26:51.3 +26:37:23.7 126.714097 26.623275 0.530661 19.48 73.00 10.00 * 2017-11-28 00:47:56.000001 2017-11-29 03:55:39.000002 2017-11-29 07:07:19.000002 6 | B0834+06 08:37:05.6 +06:10:14.5 129.273508 6.170711 1.273768 12.86 89.00 4.00 * 2017-11-28 01:45:41.000001 2017-11-29 04:05:45.000002 2017-11-29 06:29:44.000002 7 | B0919+06 09:22:14.0 +06:38:23.3 140.558425 6.639806 0.430627 27.30 52.00 4.20 * 2017-11-28 02:29:07.000001 2017-11-29 04:50:45.000002 2017-11-29 07:16:19.000002 8 | B0950+08 09:53:09.3 +07:55:35.7 148.288790 7.926597 0.253065 2.97 400.00 84.00 * 2017-11-28 02:55:41.000001 2017-11-29 05:21:35.000002 2017-11-29 07:51:25.000002 9 | B1133+16 11:36:03.2 +15:51:04.4 174.013532 15.851244 1.187913 4.85 257.00 32.00 * 2017-11-28 04:16:35.000001 2017-11-29 07:04:10.000002 2017-11-28 09:59:38.000001 10 | B1237+25 12:39:40.4 +24:53:49.2 189.918589 24.897025 1.382449 9.26 110.00 10.00 * 2017-11-28 05:02:30.000001 2017-11-28 08:11:30.000001 2017-11-28 11:20:30.000001 11 | B1541+09 15:43:38.8 +09:29:16.3 235.911771 9.487872 0.748448 35.01 78.00 5.90 * 2017-11-27 08:44:05 2017-11-28 11:14:57.000001 2017-11-28 13:49:44.000001 12 | B1859+03 19:01:31.7 +03:31:05.9 285.382422 3.518312 0.655450 402.08 165.00 4.20 * 2017-11-27 12:21:47 2017-11-28 14:32:19.000001 2017-11-28 16:46:47.000001 13 | B1859+07 19:01:38.9 +07:16:34.8 285.412236 7.276335 0.643999 252.81 3.90 0.90 * 2017-11-27 12:08:16 2017-11-28 14:32:25.000001 2017-11-28 17:00:29.000001 14 | B1900+01 19:03:29.9 +01:35:38.3 285.874923 1.593982 0.729304 245.17 58.00 5.50 * 2017-11-27 12:31:47 2017-11-28 14:34:18.000001 2017-11-28 16:40:45.000001 15 | B1907+10 19:09:48.6 +11:02:03.3 287.452891 11.034263 0.283641 149.98 50.00 1.90 * 2017-11-27 12:04:55 2017-11-28 14:40:32.000001 2017-11-28 17:20:05.000001 16 | B1919+21 19:21:44.8 +21:53:02.2 290.436729 21.883958 1.337302 12.44 57.00 6.00 * 2017-11-27 11:52:07 2017-11-28 14:52:22.000001 2017-11-28 17:56:32.000001 17 | B1929+10 19:32:13.9 +10:59:32.4 293.058124 10.992339 0.226518 3.18 303.00 36.00 * 2017-11-27 12:27:22 2017-11-28 15:02:54.000001 2017-11-28 17:42:21.000001 18 | B1933+16 19:35:47.8 +16:16:39.9 293.949275 16.277774 0.358738 158.52 242.00 42.00 * 2017-11-27 12:17:31 2017-11-28 15:06:25.000001 2017-11-28 17:59:15.000001 19 | B1937+21 19:39:38.5 +21:34:59.1 294.910672 21.583091 0.001558 71.02 240.00 13.20 * 2017-11-27 12:10:31 2017-11-28 15:10:13.000001 2017-11-28 18:13:51.000001 20 | B1946+35 19:48:25.0 +35:40:11.0 297.104195 35.669738 0.717311 129.07 108.50 8.30 * 2017-11-27 12:01:02 2017-11-28 15:18:51.000001 2017-11-28 18:40:37.000001 21 | B2000+40 20:02:44.0 +40:50:53.9 300.683460 40.848307 0.905067 131.33 4.70 4.90 * 2017-11-27 12:12:28 2017-11-28 15:33:06.000001 2017-11-28 18:57:39.000001 22 | B2016+28 20:18:03.8 +28:39:54.2 304.515972 28.665059 0.557953 14.20 314.00 30.00 * 2017-11-27 12:37:49 2017-11-28 15:48:30.000001 2017-11-28 19:03:06.000001 23 | B2020+28 20:22:37.0 +28:54:23.1 305.654446 28.906418 0.343402 24.63 71.00 38.00 * 2017-11-27 12:42:03 2017-11-28 15:53:02.000001 2017-11-28 19:07:57.000001 24 | B2111+46 21:13:24.3 +46:44:08.7 318.351281 46.735750 1.014685 141.26 47.20 19.00 * 2017-11-27 13:22:55 2017-11-28 16:43:36.000001 2017-11-28 20:08:13.000001 25 | B2154+40 21:57:01.8 +40:17:45.9 329.257706 40.296107 1.525266 70.86 105.00 17.00 * 2017-11-27 14:06:46 2017-11-28 17:27:13.000001 2017-11-28 20:51:36.000001 26 | B2217+47 22:19:48.1 +47:54:53.9 334.950579 47.914981 0.538469 43.50 42.00 3.00 * 2017-11-27 14:29:43 2017-11-28 17:49:55.000001 2017-11-28 21:14:03.000001 27 | B2310+42 23:13:08.6 +42:53:13.0 348.285920 42.886956 0.349434 17.28 7.30 15.00 * 2017-11-27 15:22:10 2017-11-28 18:43:14.000001 2017-11-28 22:08:13.000001 28 | -------------------------------------------------------------------------------- /FAST_source_arrival_time/shao/SHAO_source_arrival_time.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #Set obs.time,e.g. 2017/05/21 4 | #=============================== 5 | 6 | 7 | OBStime="2018/7/28" 8 | 9 | 10 | Horizon="75" # Maximum Za (degree) 11 | 12 | 13 | #=============================== 14 | 15 | echo "Obs_time = " ${OBStime} 16 | 17 | echo "PSRJ RA(hh:mm:ss) DEC(hh:mm:ss) RA(deg) DEC(deg) P0(s) DM S400(mJy) S1400(mJy) S2000(mJy) Rise_time transit_time Set_time" > PSR_transit_time_FAST.list 18 | 19 | COUNT=1 20 | for NAME in `cat Jname_input.list` ; do 21 | #NAME="J2129+1210A" 22 | 23 | echo "${COUNT} ${NAME}" 24 | 25 | RAJ=`psrcat -c "raj" ${NAME} -x -o short` 26 | DECJ=`psrcat -c "decj" ${NAME} -x -o short` 27 | RAJD=`psrcat -c "rajd" ${NAME} -x -o short` 28 | DECJD=`psrcat -c "decjd" ${NAME} -x -o short` 29 | P0=`psrcat -c "P0" ${NAME} -x -o short` 30 | DM=`psrcat -c "DM" ${NAME} -x -o short` 31 | # W50=`psrcat -c "w50" ${NAME} -x -o short` 32 | # W10=`psrcat -c "w10" ${NAME} -x -o short` 33 | S400=`psrcat -c "S400" ${NAME} -x -o short` 34 | S1400=`psrcat -c "S1400" ${NAME} -x -o short` 35 | S2000=`psrcat -c "S2000" ${NAME} -x -o short` 36 | 37 | python - ${OBStime} ${RAJ} ${DECJ} ${Horizon} < temp.dat 38 | 39 | #!/usr/bin/env python 40 | import numpy as np 41 | import sys 42 | import ephem 43 | 44 | ZAangle = 90.0 - np.float64(sys.argv[4]) 45 | Tianma=ephem.Observer() 46 | Tianma.lat='31:05:13' 47 | Tianma.lon='120:09:48.1' 48 | Tianma.horizon= str(ZAangle) # =(90deg-Maximum Za) 49 | Tianma.date= sys.argv[1] 50 | 51 | src = ephem.FixedBody() 52 | src._ra = sys.argv[2] 53 | src._dec = sys.argv[3] 54 | 55 | #print Tianma.date,src._ra,src._dec 56 | 57 | src.compute() 58 | trise=Tianma.previous_rising(src) 59 | ttrans=Tianma.next_transit(src) 60 | tset=Tianma.next_setting(src) 61 | print ephem.localtime(trise), ephem.localtime(ttrans), ephem.localtime(tset) 62 | #print src.alt,src.az,'next transit : ',ephem.localtime(ttrans) 63 | EOF 64 | 65 | Rise=`cat temp.dat | awk '{print $1,$2}'` 66 | Next_transit=`cat temp.dat | awk '{print $3,$4}'` 67 | Set=`cat temp.dat | awk '{print $5,$6}'` 68 | #echo $Next_transit 69 | echo "${NAME} ${RAJ} ${DECJ} ${RAJD} ${DECJD} ${P0} ${DM} ${S400} ${S1400} ${S2000} ${Rise} ${Next_transit} ${Set}" >> PSR_transit_time_FAST.list 70 | 71 | ((COUNT++)) 72 | done 73 | rm temp.dat 74 | -------------------------------------------------------------------------------- /FAST_source_arrival_time/shao_input_radec/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NAOC-pulsar/PeiWang-code/6a01f92ec9f1a32d2c203c8b8dd6955a208af330/FAST_source_arrival_time/shao_input_radec/.DS_Store -------------------------------------------------------------------------------- /FAST_source_arrival_time/shao_input_radec/Tianma_source_arrival_time_v2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ################################# 4 | ###### Parameters ############### 5 | 6 | OBStime="2018/07/28" #Set obs.time,e.g. 2017/10/13 7 | 8 | ZA=60 # Maximum Za (degree) 9 | 10 | ################################# 11 | 12 | 13 | echo "Obs_time = " ${OBStime} 14 | echo " RA(hms) DEC(dms) Rise_time Transit_time Set_time" 15 | 16 | COUNT=1 17 | cat radec_input.list | while read NAME ; do 18 | 19 | RAJ=`echo ${NAME} | awk '{print $1}'` 20 | DECJ=`echo ${NAME} | awk '{print $NF}'` 21 | 22 | #echo "${NAME}" 23 | 24 | python - ${OBStime} ${RAJ} ${DECJ} ${ZA} < temp.dat 25 | #!/usr/bin/env python 26 | import numpy as np 27 | import sys 28 | import ephem 29 | 30 | ZAangle = 90.0 - np.float64(sys.argv[4]) 31 | Tianma=ephem.Observer() 32 | Tianma.lat='31:05:13' 33 | Tianma.lon='120:09:48.1' 34 | Tianma.horizon= str(ZAangle) # =(90deg-Maximum Za) 35 | Tianma.date= sys.argv[1] 36 | 37 | src = ephem.FixedBody() 38 | src._ra = sys.argv[2] 39 | src._dec = sys.argv[3] 40 | #print Tianma.date,src._ra,src._dec 41 | 42 | src.compute() 43 | trise=Tianma.previous_rising(src) 44 | ttrans=Tianma.next_transit(src) 45 | tset=Tianma.next_setting(src) 46 | print ephem.localtime(trise),ephem.localtime(ttrans),ephem.localtime(tset) 47 | 48 | #print src.alt,src.az,'next transit : ',ephem.localtime(ttrans) 49 | EOF 50 | 51 | Rise_time=`cat temp.dat | awk '{print $1,$2}'` 52 | Transit_time=`cat temp.dat | awk '{print $3,$4}'` 53 | Set_time=`cat temp.dat | awk '{print $5,$6}'` 54 | echo "${COUNT} ${RAJ} ${DECJ} ${Rise_time} ${Transit_time} ${Set_time}" 55 | 56 | ((COUNT++)) 57 | done 58 | rm temp.dat 59 | -------------------------------------------------------------------------------- /FAST_source_arrival_time/shao_input_radec/radec_input.list: -------------------------------------------------------------------------------- 1 | 19:25:19 -6:42:52 2 | -------------------------------------------------------------------------------- /FAST_source_arrival_time/ver1_input_Jname/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NAOC-pulsar/PeiWang-code/6a01f92ec9f1a32d2c203c8b8dd6955a208af330/FAST_source_arrival_time/ver1_input_Jname/.DS_Store -------------------------------------------------------------------------------- /FAST_source_arrival_time/ver1_input_Jname/FAST_source_arrival_time_v1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #Rise, Transit, and Set time at FAST Observatory (UTC+8) 4 | #Set obs.time,e.g. 2017/05/21 5 | 6 | #=============================== 7 | 8 | 9 | OBStime="2018/06/09" 10 | 11 | 12 | Horizon="26.4" # Maximum Za (degree) 13 | 14 | 15 | #=============================== 16 | 17 | 18 | echo "Obs_time = " ${OBStime} 19 | 20 | echo "PSR RA(hh:mm:ss) DEC(dd:mm:ss) RA(deg) DEC(deg) P0(s) DM S400(mJy) S1400(mJy) S2000(mJy) W50(ms) W10(ms) Rise_time transit_time Set_time" > PSR_transit_time_FAST.list 21 | 22 | 23 | COUNT=1 24 | for NAME in `cat Jname_input.list` ; do 25 | #NAME="J2129+1210A" 26 | 27 | echo "${COUNT} ${NAME}" 28 | 29 | RAJ=`psrcat -c "raj" ${NAME} -x -o short` 30 | DECJ=`psrcat -c "decj" ${NAME} -x -o short` 31 | RAJD=`psrcat -c "rajd" ${NAME} -x -o short` 32 | DECJD=`psrcat -c "decjd" ${NAME} -x -o short` 33 | P0=`psrcat -c "P0" ${NAME} -x -o short` 34 | DM=`psrcat -c "DM" ${NAME} -x -o short` 35 | W50=`psrcat -c "w50" ${NAME} -x -o short` 36 | W10=`psrcat -c "w10" ${NAME} -x -o short` 37 | S400=`psrcat -c "S400" ${NAME} -x -o short` 38 | S1400=`psrcat -c "S1400" ${NAME} -x -o short` 39 | S2000=`psrcat -c "S2000" ${NAME} -x -o short` 40 | 41 | python - ${OBStime} ${RAJ} ${DECJ} ${Horizon} < temp.dat 42 | 43 | #!/usr/bin/env python 44 | import numpy as np 45 | import sys 46 | import ephem 47 | 48 | ZAangle = 90.0 - np.float64(sys.argv[4]) 49 | Dawodang=ephem.Observer() 50 | Dawodang.lat='25.652939' 51 | Dawodang.lon='106.856594' 52 | Dawodang.horizon= str(ZAangle) # =(90deg-Maximum Za) 53 | Dawodang.date= sys.argv[1] 54 | 55 | src = ephem.FixedBody() 56 | src._ra = sys.argv[2] 57 | src._dec = sys.argv[3] 58 | 59 | #print Dawodang.date,src._ra,src._dec 60 | 61 | src.compute() 62 | trise=Dawodang.previous_rising(src) 63 | ttrans=Dawodang.next_transit(src) 64 | tset=Dawodang.next_setting(src) 65 | print ephem.localtime(trise), ephem.localtime(ttrans), ephem.localtime(tset) 66 | #print src.alt,src.az,'next transit : ',ephem.localtime(ttrans) 67 | EOF 68 | 69 | Rise=`cat temp.dat | awk '{print $1,$2}'` 70 | Next_transit=`cat temp.dat | awk '{print $3,$4}'` 71 | Set=`cat temp.dat | awk '{print $5,$6}'` 72 | #echo $Next_transit 73 | echo "${NAME} ${RAJ} ${DECJ} ${RAJD} ${DECJD} ${P0} ${DM} ${W50} ${W10} ${S400} ${S1400} ${S2000} ${Rise} ${Next_transit} ${Set}" >> PSR_transit_time_FAST.list 74 | 75 | ((COUNT++)) 76 | done 77 | rm temp.dat 78 | -------------------------------------------------------------------------------- /FAST_source_arrival_time/ver1_input_Jname/Jname_input.list: -------------------------------------------------------------------------------- 1 | J0543+2329 2 | J0629+2415 3 | J0826+2637 4 | J0953+0755 5 | J0621+1002 6 | -------------------------------------------------------------------------------- /FAST_source_arrival_time/ver1_input_Jname/PSR_transit_time_FAST.txt: -------------------------------------------------------------------------------- 1 | PSR RA(hh:mm:ss) DEC(dd:mm:ss) RA(deg) DEC(deg) P0(s) DM S400(mJy) S1400(mJy) S2000(mJy) W50(ms) W10(ms) Rise_time transit_time Set_time 2 | J0543+2329 05:43:09.6 +23:29:05 85.790250 23.484722 0.245975 77.71 6.200 18.900 29.00 9.00 * 2018-06-08 11:34:55.000004 2018-06-09 13:26:39.000005 2018-06-09 15:22:20.000005 3 | J0629+2415 06:29:05.7 +24:15:43.3 97.273867 24.262028 0.476623 84.19 8.800 21.800 31.00 3.20 * 2018-06-08 12:20:09.000004 2018-06-09 14:12:28.000005 2018-06-09 16:08:44.000005 4 | J0826+2637 08:26:51.3 +26:37:23.7 126.714097 26.623275 0.530661 19.48 5.800 12.400 73.00 10.00 * 2018-06-08 14:16:20.000004 2018-06-09 16:09:54.000005 2018-06-09 18:07:24.000005 5 | J0953+0755 09:53:09.3 +07:55:35.7 148.288790 7.926597 0.253065 2.97 9.500 20.600 400.00 84.00 * 2018-06-08 16:18:06.000004 2018-06-09 17:35:50.000005 2018-06-09 18:57:31.000005 6 | (南山25m无对应观测数据)J0621+1002 06:21:22.1 +10:02:38.7 95.342130 10.044095 0.028854 36.60 9.150 * * 1.90 * 2018-06-08 12:38:56.000004 2018-06-09 14:04:40.000005 2018-06-09 15:34:19.000005 7 | -------------------------------------------------------------------------------- /FAST_source_arrival_time/ver2_input_radec/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NAOC-pulsar/PeiWang-code/6a01f92ec9f1a32d2c203c8b8dd6955a208af330/FAST_source_arrival_time/ver2_input_radec/.DS_Store -------------------------------------------------------------------------------- /FAST_source_arrival_time/ver2_input_radec/FAST_source_arrival_time_v2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ################################# 4 | ###### Parameters ############### 5 | 6 | OBStime="2018/07/03" #Set obs.time,e.g. 2017/10/13 7 | 8 | ZA=26.4 # Maximum Za (degree) 9 | 10 | ################################# 11 | 12 | 13 | echo "Obs_time = " ${OBStime} 14 | echo " RA(hms) DEC(dms) Rise_time Transit_time Set_time" 15 | 16 | COUNT=1 17 | cat radec_input.list | while read NAME ; do 18 | 19 | RAJ=`echo ${NAME} | awk '{print $1}'` 20 | DECJ=`echo ${NAME} | awk '{print $NF}'` 21 | 22 | #echo "${NAME}" 23 | 24 | python - ${OBStime} ${RAJ} ${DECJ} ${ZA} < temp.dat 25 | #!/usr/bin/env python 26 | import numpy as np 27 | import sys 28 | import ephem 29 | 30 | ZAangle = 90.0 - np.float64(sys.argv[4]) 31 | Dawodang=ephem.Observer() 32 | Dawodang.lat='25.652939' 33 | Dawodang.lon='106.856594' 34 | Dawodang.horizon= str(ZAangle) # =(90deg-Maximum Za) 35 | Dawodang.date= sys.argv[1] 36 | 37 | src = ephem.FixedBody() 38 | src._ra = sys.argv[2] 39 | src._dec = sys.argv[3] 40 | #print Dawodang.date,src._ra,src._dec 41 | 42 | src.compute() 43 | trise=Dawodang.previous_rising(src) 44 | ttrans=Dawodang.next_transit(src) 45 | tset=Dawodang.next_setting(src) 46 | print ephem.localtime(trise),ephem.localtime(ttrans),ephem.localtime(tset) 47 | 48 | #print src.alt,src.az,'next transit : ',ephem.localtime(ttrans) 49 | EOF 50 | 51 | Rise_time=`cat temp.dat | awk '{print $1,$2}'` 52 | Transit_time=`cat temp.dat | awk '{print $3,$4}'` 53 | Set_time=`cat temp.dat | awk '{print $5,$6}'` 54 | echo "${COUNT} ${RAJ} ${DECJ} ${Rise_time} ${Transit_time} ${Set_time}" 55 | 56 | ((COUNT++)) 57 | done 58 | rm temp.dat 59 | -------------------------------------------------------------------------------- /FAST_source_arrival_time/ver2_input_radec/radec_input.list: -------------------------------------------------------------------------------- 1 | 6:34:07 +04:24:22 2 | 05:41:16.7999 +35:15:35.994 3 | 4:27:50 +36:31:12.0016 4 | 4:30:41 +35:32:59.9973 5 | 4:31:24 +35:00:35.994 6 | 5:06:05 +50:28:47.9984 7 | 5:46:41 +00:26:24 8 | 6:52:58 +47:07:48.0038 9 | 3:42:19 +31:54:35.9995 10 | 3:44:24 +32:02:24.0033 11 | -------------------------------------------------------------------------------- /FAST_source_arrival_time/ver3_input_radec_J2017/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NAOC-pulsar/PeiWang-code/6a01f92ec9f1a32d2c203c8b8dd6955a208af330/FAST_source_arrival_time/ver3_input_radec_J2017/.DS_Store -------------------------------------------------------------------------------- /FAST_source_arrival_time/ver3_input_radec_J2017/FAST_source_arrival_time_v3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #Rise, Transit, and Set time at FAST Observatory (UTC+8) 4 | #Set obs.time,e.g. 2017/05/21 5 | 6 | #=============================== 7 | 8 | 9 | OBStime="2018/01/22" 10 | 11 | 12 | Horizon="26.4" # Maximum Za (degree) 13 | 14 | 15 | #=============================== 16 | 17 | echo "Obs_time = " ${OBStime} 18 | echo " RA(J2000) DEC(J2000) FAST_az FAST_el RA(Now) DEC(Now) Rise_time transit_time Set_time" 19 | 20 | COUNT=1 21 | cat radec_input.list | while read NAME ; do 22 | 23 | RAJ=`echo ${NAME} | awk '{print $1}'` 24 | DECJ=`echo ${NAME} | awk '{print $NF}'` 25 | 26 | #echo "${NAME}" 27 | 28 | python - ${OBStime} ${RAJ} ${DECJ} ${Horizon} < temp.dat 29 | #!/usr/bin/env python 30 | import numpy as np 31 | import sys 32 | import ephem 33 | 34 | ZAangle = 90.0 - np.float64(sys.argv[4]) 35 | Dawodang=ephem.Observer() 36 | Dawodang.lat='25.652939' 37 | Dawodang.lon='106.856594' 38 | Dawodang.horizon= str(ZAangle) # =(90deg-Maximum Za) 39 | Dawodang.date= sys.argv[1] 40 | 41 | src = ephem.FixedBody() 42 | src._ra = sys.argv[2] 43 | src._dec = sys.argv[3] 44 | #print Dawodang.date,src._ra,src._dec,src.ra,src.dec 45 | 46 | src.compute() 47 | trise=Dawodang.previous_rising(src) 48 | ttrans=Dawodang.next_transit(src) 49 | tset=Dawodang.next_setting(src) 50 | print ephem.localtime(trise), ephem.localtime(ttrans), ephem.localtime(tset), src.ra, src.dec, src.alt, src.az 51 | 52 | #print src.alt,src.az,'next transit : ',ephem.localtime(ttrans) 53 | EOF 54 | 55 | Next_transit=`cat temp.dat | awk '{print $7,$8"\t"$1,$2"\t"$3,$4"\t"$5,$6}'` 56 | az=`cat temp.dat | awk '{print $9}'` 57 | Hour_az=`echo "${az}" | sed 's/\:/ /' | awk '{print $1}'` 58 | Min_az=`echo "${az}" | sed 's/\:/ /' | awk '{print $2}' | sed 's/\:/ /'| awk '{print $1}'` 59 | Sec_az=`echo "${az}" | sed 's/\:/ /' | awk '{print $2}' | sed 's/\:/ /'| awk '{print $2}'` 60 | FAST_az=`echo "scale=6; 90-(${Hour_az}+(${Min_az}/60.)+${Sec_az}/3600.)" | bc` 61 | 62 | el=`cat temp.dat | awk '{print $10}'` 63 | Hour_el=`echo "${el}" | sed 's/\:/ /' | awk '{print $1}'` 64 | Min_el=`echo "${el}" | sed 's/\:/ /' | awk '{print $2}' | sed 's/\:/ /'| awk '{print $1}'` 65 | Sec_el=`echo "${el}" | sed 's/\:/ /' | awk '{print $2}' | sed 's/\:/ /'| awk '{print $2}'` 66 | DEG_el=`echo "scale=6; ${Hour_el}+(${Min_el}/60)+(${Sec_el}/3600)" | bc` 67 | FAST_el=`echo "scale=6; 270.0-${DEG_el}" | bc` 68 | 69 | echo "${COUNT} ${RAJ} ${DECJ} ${FAST_el} ${FAST_az} ${Next_transit}" 70 | #echo ${Next_transit} 71 | 72 | ((COUNT++)) 73 | done 74 | rm temp.dat 75 | -------------------------------------------------------------------------------- /FAST_source_arrival_time/ver3_input_radec_J2017/radec_input.list: -------------------------------------------------------------------------------- 1 | 16:41:40.8 36:27:15.4 2 | 16:42:59.9 39:45:26 3 | 17:17:07.39 43:08:09.4 4 | 17:58:25.8 30:30:24.0 5 | 20:18:03.8 28:39:54.2 6 | 20:37:27.4 36:21:24.1 7 | 20:55:31.3 36:30:21.4 8 | 23:02:46.9 44:42:22.0 9 | 01:37:40.6 33:08:03 10 | 02:18:06.3 42:32:17.3 11 | 03:03:00 22:48 12 | 04:08:03.4 42:59:33 13 | 07:44:24.8 37:57:46 14 | 13:31:08.6 30:30:10 15 | -------------------------------------------------------------------------------- /FastFitsTools/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NAOC-pulsar/PeiWang-code/6a01f92ec9f1a32d2c203c8b8dd6955a208af330/FastFitsTools/.DS_Store -------------------------------------------------------------------------------- /FastFitsTools/BeamWeight.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NAOC-pulsar/PeiWang-code/6a01f92ec9f1a32d2c203c8b8dd6955a208af330/FastFitsTools/BeamWeight.py -------------------------------------------------------------------------------- /FastFitsTools/CutByTF.py: -------------------------------------------------------------------------------- 1 | 2 | from FastFitsTools.FitsTools import Fitscut, Fits 3 | from FastFitsTools.FitsTools.FitsOutput import wirtreToFileForFast 4 | 5 | 6 | def usage(): 7 | print """ 8 | 9 | "-f", "file: [ please give ***path/filename*** ]" 10 | "-b", "beginfreq: [ start freq ]" 11 | "-e", "endfreq: [ end freq ]" 12 | "-t", "strattime: [ start time ]" 13 | "-v", "endtime: [ end time ]" 14 | "-d", "dec(J2000):[ dd:mm:ss ]" 15 | "-o", "output: [ output path ]" 16 | 17 | """ 18 | 19 | 20 | 21 | def exeCutFreq(filename, startfreq, endfreq, initaltime, finaltime, dec, output): 22 | fits=Fits(filename) 23 | fits.centerFreq = (startfreq + endfreq) / 2 24 | 25 | fcut=Fitscut( fits,startfreq, endfreq, initaltime, finaltime) 26 | # self.mergePolae(0) 27 | fits_cuted=fcut.cut(dec) 28 | 29 | wirtreToFileForFast(fits_cuted,filename,1,outpath) 30 | 31 | 32 | 33 | 34 | if __name__ == '__main__': 35 | import getopt, sys 36 | 37 | try: 38 | opts, args = getopt.getopt(sys.argv[1:], "h:m:f:b:e:o:z:c:t:v:i:s:l:x:y:d:", 39 | ["help", "mode=", "file=", "beginfreq=", 40 | "endfreq=", "output=", "outname", "strattime=", "endtime", "interval=", 41 | "freqspace=","subintoffset=","Fa","Fb","dec="]) 42 | 43 | except getopt.GetoptError: 44 | # print help information and exit: 45 | usage() 46 | sys.exit(2) 47 | if len(sys.argv) == 1: 48 | usage() 49 | sys.exit(2) 50 | for o, a in opts: 51 | if o in ("-h", "--help"): 52 | usage() 53 | sys.exit() 54 | if o in ("-m", "--mode"): 55 | mode = str(a) 56 | if o in ("-f", "--file"): 57 | filename = str(a) 58 | if o in ("-b", "--beginfreq"): 59 | startfreq = float(a) 60 | if o in ("-e", "--endfreq"): 61 | endfreq = float(a) 62 | if o in ("-o", "--output"): 63 | outpath = str(a) 64 | if o in ("-z", "--outname"): 65 | outname = str(a) 66 | # print outname 67 | if o in ("-c", "--cutid"): 68 | cutid = int(a) 69 | if o in ("-t", "--strattime"): 70 | starttime = float(a) 71 | # print starttime 72 | if o in ("-v", "--endtime"): 73 | endtime = float(a) 74 | if o in ("-i", "--interval"): 75 | interval = float(a) 76 | if o in ("-s", "--freqspace"): 77 | freqSpace = int(a) 78 | 79 | if o in ("-l", "--subintoffset"): 80 | subintoffset = int(a) 81 | if o in ("-d", "--dec"): 82 | dec = str(a) 83 | if o in ("-x", "--Fa"): 84 | aa = float(a) 85 | if o in ("-y", "--Fb"): 86 | bb = float(a) 87 | 88 | exeCutFreq(filename, startfreq, endfreq, starttime, endtime, dec, output) 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /FastFitsTools/FitsTools/.FitsCut.py.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NAOC-pulsar/PeiWang-code/6a01f92ec9f1a32d2c203c8b8dd6955a208af330/FastFitsTools/FitsTools/.FitsCut.py.swp -------------------------------------------------------------------------------- /FastFitsTools/FitsTools/Fits.py: -------------------------------------------------------------------------------- 1 | 2 | import numpy as np 3 | import pyfits 4 | 5 | from FastFitsTools.FitsTools import TimeCal 6 | 7 | 8 | class Fits: 9 | def __init__(self, filename): 10 | hdulist=pyfits.open(filename) 11 | self.telecope = hdulist[0].header['TELESCOP'] 12 | if self.telecope == 'FAST': 13 | self.hdu0 = hdulist[0] 14 | self.data1 = hdulist[1].data 15 | self.header1 = hdulist[1].header 16 | 17 | # number of channel 18 | self.nchan = hdulist[0].header['OBSNCHAN'] 19 | # time of spera 20 | self.nsblk = self.header1['NSBLK'] 21 | 22 | self.initalFreq = self.data1['DAT_FREQ'][0][0] 23 | self.finalFreq = self.data1['DAT_FREQ'][0][np.size(self.data1['DAT_FREQ'][0]) - 1] 24 | 25 | self.float_tsubint_a = np.array(self.data1['TSUBINT']) 26 | self.float_offs_sub_a = np.array(self.data1['OFFS_SUB']) 27 | self.float_lst_sub_a = np.array(self.data1['LST_SUB']) 28 | self.float_ra_sub_a = np.array(self.data1['RA_SUB']) 29 | self.float_dec_sub_a = np.array(self.data1['DEC_SUB']) 30 | self.float_glon_sub_a = np.array(self.data1['GLON_SUB']) 31 | self.float_glat_sub_a = np.array(self.data1['GLAT_SUB']) 32 | self.float_fd_ang_a = np.array(self.data1['FD_ANG']) 33 | self.float_pos_ang_a = np.array(self.data1['POS_ANG']) 34 | self.float_par_ang_a = np.array(self.data1['PAR_ANG']) 35 | self.float_tel_az_a = np.array(self.data1['TEL_AZ']) 36 | self.float_tel_zen_a = np.array(self.data1['TEL_ZEN']) 37 | self.float_dat_freq_a = self.data1['DAT_FREQ'] 38 | self.float_dat_wts_a = self.data1['DAT_WTS'] 39 | self.float_dat_offs_a = self.data1['DAT_OFFS'] 40 | self.float_dat_scl_a = self.data1['DAT_SCL'] 41 | # Number of rows in table (NSUBINT) 42 | self.nsubint = int(self.header1['NAXIS2']) 43 | # totalTime(s) 44 | self.timePerSubint = self.float_tsubint_a[0] 45 | # Sample time (s) 46 | self.sampleTime = self.header1['TBIN'] 47 | # Nr of polarisations 48 | self.Npolae = self.header1['NPOL'] 49 | 50 | self.totalTime = self.timePerSubint * self.nsubint 51 | self.chanBW = self.header1['CHAN_BW'] 52 | self.centerFreq=self.hdu0.header['OBSFREQ'] 53 | 54 | # channel bandwidth 55 | 56 | self.obsbw = self.hdu0.header['OBSBW'] 57 | 58 | # self.chnum = self.hdu0.header['OBSNCHAN'] 59 | 60 | self.stt_imjd = self.hdu0.header['STT_IMJD'] 61 | self.stt_smjd = self.hdu0.header['STT_SMJD'] 62 | self.stt_offs = self.hdu0.header['STT_OFFS'] 63 | self.nsuboffs = self.header1['NSUBOFFS'] 64 | self.float_data = np.array(self.data1['DATA']) 65 | if (self.telecope == 'PARKES'): 66 | self.hdu0 = hdulist[0] 67 | 68 | self.header1 = hdulist[1].header 69 | self.data1 = hdulist[1].data 70 | 71 | self.header3 = hdulist[3].header 72 | self.data3 = hdulist[3].data 73 | # self.initaltime=initaltime 74 | # self.finaltime=finaltime 75 | 76 | self.nchan = self.data1['NCHAN'][0] 77 | 78 | self.nsblk = self.header3['NSBLK'] 79 | self.finalFreq = self.data3['DAT_FREQ'][0][0] 80 | self.initalFreq = self.data3['DAT_FREQ'][0][np.size(self.data3['DAT_FREQ'][0]) - 1] 81 | # print self.initalFreq,self.finalFreq 82 | self.float_indexval_a = np.array(self.data3['INDEXVAL']) 83 | self.float_tsubint_a = np.array(self.data3['TSUBINT']) 84 | self.float_offs_sub_a = np.array(self.data3['OFFS_SUB']) 85 | self.float_lst_sub_a = np.array(self.data3['LST_SUB']) 86 | self.float_ra_sub_a = np.array(self.data3['RA_SUB']) 87 | self.float_dec_sub_a = np.array(self.data3['DEC_SUB']) 88 | self.float_glon_sub_a = np.array(self.data3['GLON_SUB']) 89 | self.float_glat_sub_a = np.array(self.data3['GLAT_SUB']) 90 | self.float_fd_ang_a = np.array(self.data3['FD_ANG']) 91 | self.float_pos_ang_a = np.array(self.data3['POS_ANG']) 92 | self.float_par_ang_a = np.array(self.data3['PAR_ANG']) 93 | self.float_tel_az_a = np.array(self.data3['TEL_AZ']) 94 | self.float_tel_zen_a = np.array(self.data3['TEL_ZEN']) 95 | self.float_aux_dm_a = np.array(self.data3['AUX_DM']) 96 | self.float_aux_rm_a = np.array(self.data3['AUX_RM']) 97 | self.float_dat_freq_a = self.data3['DAT_FREQ'] 98 | 99 | self.float_dat_wts_a = self.data3['DAT_WTS'] 100 | 101 | self.float_dat_offs_a = self.data3['DAT_OFFS'] 102 | 103 | self.float_dat_scl_a = self.data3['DAT_SCL'] 104 | 105 | # Number of rows in table (NSUBINT) 106 | self.nsubint = int(self.data1['NSUB']) 107 | # totalTime(s) 108 | self.timePerSubint = self.float_tsubint_a[0] 109 | # Sample time (s) 110 | self.sampleTime = self.header3['TBIN'] 111 | # Nr of polarisations 112 | self.Npolae = self.data1['NPOL'] 113 | 114 | self.totalTime = self.timePerSubint * self.nsubint 115 | self.chanBW = float(abs(self.data1['CHAN_BW'])) 116 | 117 | 118 | def modifyPHeader(self,dec): 119 | #self.fits.chnum = int(endfreqNetNum - startfreqNetNum) 120 | if (self.telecope == 'FAST'): 121 | self.hdu0.header['OBSFREQ'] = self.centerFreq 122 | 123 | # channel bandwidth 124 | 125 | self.hdu0.header['OBSBW'] = self.obsbw 126 | 127 | self.hdu0.header['OBSNCHAN'] = self.nchan 128 | 129 | #self.fits.stt_imjd = self.fits.hdu0.header['STT_IMJD'] 130 | #self.fits.stt_smjd = self.fits.hdu0.header['STT_SMJD'] 131 | #self.fits.stt_offs = self.fits.hdu0.header['STT_OFFS'] 132 | #self.fits.nsuboffs = self.fits.header1['NSUBOFFS'] 133 | #print self.fits.stt_imjd, self.fits.stt_smjd, self.fits.stt_offs, self.fits.nsuboffs_a 134 | mjd = np.float64( 135 | self.stt_imjd + (np.float64(self.stt_smjd) + np.float64(self.stt_offs)) / np.float64( 136 | 86400) + self.timePerSubint * self.nsuboffs_a / 86400) 137 | 138 | obj = TimeCal.TimeCal(dec, self.totalTime / 2.) 139 | res = obj.calTime(mjd) 140 | ra = res[0] 141 | FAST_az = res[1] 142 | FAST_el = res[2] 143 | RaJ_deg = res[3] 144 | 145 | self.DecJ_deg = res[4] 146 | self.hdu0.header['SRC_NAME'] = 'NONE' 147 | self.hdu0.header['RA'] = ra 148 | self.hdu0.header['DEC'] = dec 149 | self.float_tel_az_a += FAST_az 150 | self.float_tel_zen_a += FAST_el 151 | # self.fits.hdu0.header['STT_CRD1']= 152 | # self.fits.hdu0.header['STT_CRD2'] 153 | self.hdu0.header['TRK_MODE'] = 'NONE' 154 | 155 | if (self.telecope == 'PARKES'): 156 | #self.fits.chnum = int(endfreqNetNum - startfreqNetNum) 157 | 158 | self.hdu0.header['OBSFREQ'] = self.fits.centerFreq 159 | 160 | # channel bandwidth 161 | # print self.fits.chnum , self.fits.chanBW 162 | self.hdu0.header['OBSBW'] = self.obsbw 163 | 164 | self.hdu0.header['OBSNCHAN'] = self.fits.chnum 165 | 166 | 167 | 168 | # self.fits.data1['NSUB']= 169 | -------------------------------------------------------------------------------- /FastFitsTools/FitsTools/Fits.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NAOC-pulsar/PeiWang-code/6a01f92ec9f1a32d2c203c8b8dd6955a208af330/FastFitsTools/FitsTools/Fits.pyc -------------------------------------------------------------------------------- /FastFitsTools/FitsTools/FitsCut.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NAOC-pulsar/PeiWang-code/6a01f92ec9f1a32d2c203c8b8dd6955a208af330/FastFitsTools/FitsTools/FitsCut.pyc -------------------------------------------------------------------------------- /FastFitsTools/FitsTools/FitsMerge.py: -------------------------------------------------------------------------------- 1 | # import psutil 2 | import os 3 | import pyfits 4 | # import beam_weighting as wg 5 | import sys 6 | 7 | import numpy as np 8 | 9 | from bak import TimeCal 10 | 11 | 12 | class FitsMerge: 13 | 14 | def __init__(self, fits1, fits2, flag, accio,tempfdata): 15 | if (flag == 1 and (fits1.telecope != fits2.telecope)): 16 | print 'can not merge fits from diff telescope' 17 | sys.exit() 18 | 19 | self.telecope = fits1.telecope 20 | self.tmp={fits1,fits2,fits1} 21 | 22 | # if self.telecope == 'FAST': 23 | 24 | 25 | #if (self.telecope == 'PARKES'): 26 | 27 | 28 | 29 | # nline=np.size(temp_float_dat_scl)/2/nchan 30 | 31 | 32 | 33 | 34 | def modifyPHeader(self, startfreq, endfreq, startfreqNetNum, endfreqNetNum,dec): 35 | # print startfreq,endfreq,'--' 36 | if (self.telecope == 'FAST'): 37 | 38 | 39 | 40 | # if (self.telecope == 'PARKES'): 41 | 42 | 43 | # @profile 44 | 45 | def merge(self): 46 | 47 | self.tmp[3].float_tsubint_a = np.concatenate( 48 | (np.array(self.tmp[0].data1['TSUBINT']), np.array(self.tmp[1].data1['TSUBINT']))) 49 | self.tmp[3].float_offs_sub_a = np.concatenate( 50 | (np.array(self.tmp[0].data1['OFFS_SUB']), np.array(self.tmp[1].data1['OFFS_SUB']))) 51 | 52 | self.tmp[3].float_lst_sub_a = np.concatenate( 53 | (np.array(self.tmp[0].data1['LST_SUB']), np.array(self.tmp[1].data1['LST_SUB']))) 54 | self.tmp[3].float_ra_sub_a = np.concatenate( 55 | (np.array(self.tmp[0].data1['RA_SUB']), np.array(self.tmp[1].data1['RA_SUB']))) 56 | self.tmp[3].float_dec_sub_a = np.concatenate( 57 | (np.array(self.tmp[0].data1['DEC_SUB']), np.array(self.tmp[1].data1['DEC_SUB']))) 58 | self.tmp[3].float_glon_sub_a = np.concatenate( 59 | (np.array(self.tmp[0].data1['GLON_SUB']), np.array(self.tmp[1].data1['GLON_SUB']))) 60 | self.tmp[3].float_glat_sub_a = np.concatenate( 61 | (np.array(self.tmp[0].data1['GLAT_SUB']), np.array(self.tmp[1].data1['GLAT_SUB']))) 62 | self.tmp[3].float_fd_ang_a = np.concatenate( 63 | (np.array(self.tmp[0].data1['FD_ANG']), np.array(self.tmp[1].data1['FD_ANG']))) 64 | self.tmp[3].float_pos_ang_a = np.concatenate( 65 | (np.array(self.tmp[0].data1['POS_ANG']), np.array(self.tmp[1].data1['POS_ANG']))) 66 | self.tmp[3].float_par_ang_a = np.concatenate( 67 | (np.array(self.tmp[0].data1['PAR_ANG']), np.array(self.tmp[1].data1['PAR_ANG']))) 68 | self.tmp[3].float_tel_az_a = np.concatenate( 69 | (np.array(self.tmp[0].data1['TEL_AZ']), np.array(self.tmp[1].data1['TEL_AZ']))) 70 | self.tmp[3].float_tel_zen_a = np.concatenate( 71 | (np.array(self.tmp[0].data1['TEL_ZEN']), np.array(self.tmp[1].data1['TEL_ZEN']))) 72 | 73 | self.tmp[3].float_dat_freq_a = np.array(self.tmp[0].data1['DAT_FREQ']) 74 | 75 | self.tmp[3].float_dat_wts_a = np.array(self.tmp[0].data1['DAT_WTS']) 76 | 77 | self.tmp[3].float_dat_offs_a = np.concatenate((self.tmp[0].data1['DAT_OFFS'], self.tmp[1].data1['DAT_OFFS'])) 78 | 79 | self.tmp[3].float_dat_scl_a = np.concatenate((self.tmp[0].data1['DAT_SCL'], self.tmp[1].data1['DAT_SCL'])) 80 | 81 | self.nsubint = int(self.header1['NAXIS2']) + int(self.header1_2['NAXIS2']) 82 | # totalTime(s) 83 | self.timePerSubint = self.tmp[3].float_tsubint_a[0] 84 | # Sample time (s) 85 | self.sampleTime = self.header1['TBIN'] 86 | # Nr of polarisations 87 | self.Npolae = self.header1['NPOL'] 88 | 89 | self.totalTime = self.timePerSubint * self.nsubint 90 | self.chanBW = self.header1['CHAN_BW'] 91 | 92 | #self.tmp[3].float_data_1 = tempfdata 93 | #self.tmp[3].float_data_2 = self.tmp[1].data1['DATA'] 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | # 103 | # 104 | # self.float_data=np.concatenate((self.float_data_1,self.float_data_2),axis=3) 105 | # 106 | # self.float_dat_freq = np.concatenate((self.float_dat_freq_a_1,self.float_dat_freq_a_2),axis=1) 107 | # 108 | # self.float_dat_wts = np.concatenate((self.float_dat_wts_a_1,self.float_dat_wts_a_2),axis=1) 109 | # 110 | # self.float_dat_freq = np.concatenate((self.float_dat_freq_a_1,self.float_dat_freq_a_2),axis=1) 111 | # 112 | # self.float_dat_wts = np.concatenate((self.float_dat_wts_a_1,self.float_dat_wts_a_2),axis=1) 113 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /FastFitsTools/FitsTools/FitsOutput.py: -------------------------------------------------------------------------------- 1 | import pyfits 2 | import numpy as np 3 | 4 | def wirtreToFileForFast(fits, filename, i, outpath): 5 | dataformat = str(np.size(fits.float_data2) / int(fits.numSubint)) + 'B' 6 | 7 | dataformat2 = str(fits.chnum) + 'E' 8 | 9 | dataformat3 = str(fits.chnum * 2) + 'E' 10 | 11 | dimformat = '(1,' + str(fits.chnum) + ',' + str(fits.Npolae) + ',' + str(fits.nsblk) + ')' 12 | 13 | dataformatnsblk = str(fits.nsblk) 14 | 15 | column2_data = pyfits.Column(name='TSUBINT', format='1D', array=fits.float_tsubint, unit='s') 16 | 17 | column3_data = pyfits.Column(name='OFFS_SUB', format='1D', array=fits.float_offs_sub, unit='s') 18 | 19 | column4_data = pyfits.Column(name='LST_SUB', format='1D', array=fits.float_lst_sub, unit='s') 20 | 21 | column5_data = pyfits.Column(name='RA_SUB', format='1D', array=fits.float_ra_sub, unit='deg') 22 | 23 | column6_data = pyfits.Column(name='DEC_SUB', format='1D', array=fits.float_dec_sub, unit='deg') 24 | 25 | column7_data = pyfits.Column(name='GLON_SUB', format='1D', array=fits.float_glon_sub, unit='deg') 26 | 27 | column8_data = pyfits.Column(name='GLAT_SUB', format='1D', array=fits.float_glat_sub, unit='deg') 28 | 29 | column9_data = pyfits.Column(name='FD_ANG', format='1E', array=fits.float_fd_ang, unit='deg') 30 | 31 | column10_data = pyfits.Column(name='POS_ANG', format='1E', array=fits.float_pos_ang, unit='deg') 32 | 33 | column11_data = pyfits.Column(name='PAR_ANG', format='1E', array=fits.float_par_ang, unit='deg') 34 | 35 | column12_data = pyfits.Column(name='TEL_AZ', format='1E', array=fits.float_tel_az, unit='deg') 36 | 37 | column13_data = pyfits.Column(name='TEL_ZEN', format='1E', array=fits.float_tel_zen, unit='deg') 38 | 39 | column16_data = pyfits.Column(name='DAT_FREQ', format=dataformat2, array=fits.float_dat_freq, unit='deg') 40 | 41 | column17_data = pyfits.Column(name='DAT_WTS', format=dataformat2, array=fits.float_dat_wts, unit='deg') 42 | 43 | column18_data = pyfits.Column(name='DAT_OFFS', format=dataformat3, array=fits.float_dat_offs, unit='deg') 44 | 45 | column19_data = pyfits.Column(name='DAT_SCL', format=dataformat3, array=fits.float_dat_scl, unit='MHz') 46 | 47 | column20_data = pyfits.Column(name='DATA', format=dataformat, array=fits.float_data2, dim=dimformat, unit='Jy') 48 | 49 | table_hdu = pyfits.new_table( 50 | [column2_data, column3_data, column4_data, column5_data, column6_data, column7_data, column8_data, 51 | column9_data, column10_data, column11_data, column12_data, column13_data, column16_data, column17_data, 52 | column18_data, column19_data, column20_data]) 53 | 54 | table_hdu.header.append(('INT_TYPE', 'TIME', 'Time axis (TIME, BINPHSPERI, BINLNGASC, etc)')) 55 | 56 | table_hdu.header.append(('INT_UNIT', 'SEC', 'Unit of time axis (SEC, PHS (0-1),DEG)')) 57 | 58 | table_hdu.header.append(('SCALE', 'FluxDec', 'Intensiy units (FluxDec/RefFlux/Jansky)')) 59 | 60 | table_hdu.header.append(('NPOL', fits.Npolae, 'Nr of polarisations')) 61 | 62 | table_hdu.header.append(('POL_TYPE', '', 'Polarisation identifier (e.g., AABBCRCI, AA+BB)')) 63 | 64 | table_hdu.header.append(('TBIN', fits.sampleTime, '[s] Time per bin or sample')) 65 | 66 | table_hdu.header.append(('NBIN', 1, 'Nr of bins (PSR/CAL mode; else 1)')) 67 | 68 | table_hdu.header.append(('NBIN_PRD', 0, 'Nr of bins/pulse period (for gated data)')) 69 | 70 | table_hdu.header.append(('PHS_OFFS', 0.0, 'Phase offset of bin 0 for gated data')) 71 | 72 | table_hdu.header.append(('NBITS', 8, 'Nr of bits/datum (SEARCH mode "X" data, else 1)')) 73 | 74 | table_hdu.header.append(('NSUBOFFS', fits.nsuboffs_a, 'Subint offset (Contiguous SEARCH-mode files)')) 75 | 76 | table_hdu.header.append(('NCHAN', fits.chnum, 'Number of channels/sub-bands in this file')) 77 | 78 | table_hdu.header.append(('CHAN_BW', fits.chanBW, '[MHz] Channel/sub-band width')) 79 | 80 | table_hdu.header.append(('NCHNOFFS', 0, 'Channel/sub-band offset for split files')) 81 | 82 | table_hdu.header.append(('NSBLK', dataformatnsblk, 'Samples/row (SEARCH mode, else 1)')) 83 | 84 | table_hdu.header.append(('EXTNAME', 'SUBINT ', 'name of this binary table extension')) 85 | 86 | hdulist2 = pyfits.HDUList([fits.hdu0, table_hdu]) 87 | 88 | hdulist2.writeto(outpath) 89 | print 'file' + outpath + ' write successfully' 90 | 91 | 92 | def wirtreToFileForParkes(fits, filename, i, outpath): 93 | dataformat = str(np.size(fits.float_data2) / int(fits.numSubint)) + 'X' 94 | 95 | dataformat2 = str(fits.chnum) + 'E' 96 | 97 | dataformat3 = str(fits.chnum * 2) + 'E' 98 | 99 | dimformat = '(1,' + str(fits.chnum) + ',' + str(fits.Npolae) + ',' + str(fits.nsblk) + ')' 100 | 101 | dataformatnsblk = str(fits.nsblk) 102 | 103 | column1_data = pyfits.Column(name='INDEXVAL', format='1D', array=fits.float_tsubint) 104 | 105 | column2_data = pyfits.Column(name='TSUBINT', format='1D', array=fits.float_tsubint, unit='s') 106 | 107 | column3_data = pyfits.Column(name='OFFS_SUB', format='1D', array=fits.float_offs_sub, unit='s') 108 | 109 | column4_data = pyfits.Column(name='LST_SUB', format='1D', array=fits.float_lst_sub, unit='s') 110 | 111 | column5_data = pyfits.Column(name='RA_SUB', format='1D', array=fits.float_ra_sub, unit='deg') 112 | 113 | column6_data = pyfits.Column(name='DEC_SUB', format='1D', array=fits.float_dec_sub, unit='deg') 114 | 115 | column7_data = pyfits.Column(name='GLON_SUB', format='1D', array=fits.float_glon_sub, unit='deg') 116 | 117 | column8_data = pyfits.Column(name='GLAT_SUB', format='1D', array=fits.float_glat_sub, unit='deg') 118 | 119 | column9_data = pyfits.Column(name='AUX_DM', format='1D', array=fits.float_aux_dm) 120 | 121 | column10_data = pyfits.Column(name='AUX_RM', format='1D', array=fits.float_aux_rm) 122 | 123 | column11_data = pyfits.Column(name='FD_ANG', format='1E', array=fits.float_fd_ang, unit='deg') 124 | 125 | column12_data = pyfits.Column(name='POS_ANG', format='1E', array=fits.float_pos_ang, unit='deg') 126 | 127 | column13_data = pyfits.Column(name='PAR_ANG', format='1E', array=fits.float_par_ang, unit='deg') 128 | 129 | column14_data = pyfits.Column(name='TEL_AZ', format='1E', array=fits.float_tel_az, unit='deg') 130 | 131 | column15_data = pyfits.Column(name='TEL_ZEN', format='1E', array=fits.float_tel_zen, unit='deg') 132 | 133 | column16_data = pyfits.Column(name='DAT_FREQ', format=dataformat2, array=fits.float_dat_freq, unit='deg') 134 | 135 | column17_data = pyfits.Column(name='DAT_WTS', format=dataformat2, array=fits.float_dat_wts, unit='deg') 136 | 137 | column18_data = pyfits.Column(name='DAT_OFFS', format=dataformat3, array=fits.float_dat_offs, unit='deg') 138 | 139 | column19_data = pyfits.Column(name='DAT_SCL', format=dataformat3, array=fits.float_dat_scl, unit='MHz') 140 | 141 | column20_data = pyfits.Column(name='DATA', format=dataformat, array=fits.float_data2, dim=dimformat, unit='Jy') 142 | 143 | table_hdu = pyfits.new_table( 144 | [column1_data, column2_data, column3_data, column4_data, column5_data, column6_data, column7_data, 145 | column8_data, 146 | column9_data, column10_data, column11_data, column12_data, column13_data, column14_data, column15_data, 147 | column16_data, column17_data, 148 | column18_data, column19_data, column20_data]) 149 | 150 | table_hdu.header.append(('INT_TYPE', 'TIME', 'Time axis (TIME, BINPHSPERI, BINLNGASC, etc)')) 151 | 152 | table_hdu.header.append(('INT_UNIT', 'SEC', 'Unit of time axis (SEC, PHS (0-1),DEG)')) 153 | 154 | table_hdu.header.append(('SCALE', 'UNCAL', 'Intensiy units (FluxDec/RefFlux/Jansky)')) 155 | table_hdu.header.append(('POL_TYPE', "LIN", 'Polarisation identifier (e.g., AABBCRCI, AA+BB)')) 156 | 157 | table_hdu.header.append(('NPOL', int(fits.Npolae), 'Nr of polarisations')) 158 | 159 | table_hdu.header.append(('POL_TYPE', '', 'Polarisation identifier (e.g., AABBCRCI, AA+BB)')) 160 | 161 | table_hdu.header.append(('TBIN', fits.sampleTime, '[s] Time per bin or sample')) 162 | 163 | table_hdu.header.append(('NBIN', 1, 'Nr of bins (PSR/CAL mode; else 1)')) 164 | 165 | table_hdu.header.append(('NBIN_PRD', 0, 'Nr of bins/pulse period (for gated data)')) 166 | 167 | table_hdu.header.append(('PHS_OFFS', 0.0, 'Phase offset of bin 0 for gated data')) 168 | 169 | table_hdu.header.append(('NBITS', 1, 'Nr of bits/datum (SEARCH mode "X" data, else 1)')) 170 | 171 | table_hdu.header.append(('ZERO_OFF', 0, 'Zero offset for SEARCH-mode data')) 172 | 173 | table_hdu.header.append(('SIGNINT', '*', '1 for signed ints in SEARCH-mode data, else 0')) 174 | 175 | table_hdu.header.append(('NSUBOFFS', 0, 'Subint offset (Contiguous SEARCH-mode files)')) 176 | 177 | table_hdu.header.append(('NCHAN', fits.chnum, 'Number of channels/sub-bands in this file')) 178 | 179 | table_hdu.header.append(('CHAN_BW', float(fits.chanBW), '[MHz] Channel/sub-band width')) 180 | 181 | table_hdu.header.append(('DM', 0, '[cm-3 pc] DM for post-detection dedisperion')) 182 | table_hdu.header.append(('RM', 0, '[rad m-2] RM for post-detection deFaraday')) 183 | 184 | table_hdu.header.append(('NCHNOFFS', 0, 'Channel/sub-band offset for split files')) 185 | 186 | table_hdu.header.append(('NSBLK', dataformatnsblk, 'Samples/row (SEARCH mode, else 1)')) 187 | 188 | table_hdu.header.append(('EXTNAME', 'SUBINT ', 'name of this binary table extension')) 189 | 190 | hdulist2 = pyfits.HDUList([fits.hdu0, table_hdu]) 191 | 192 | hdulist2.writeto(outpath) 193 | print 'file' + outpath + ' write successfully' -------------------------------------------------------------------------------- /FastFitsTools/FitsTools/FitsOutput.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NAOC-pulsar/PeiWang-code/6a01f92ec9f1a32d2c203c8b8dd6955a208af330/FastFitsTools/FitsTools/FitsOutput.pyc -------------------------------------------------------------------------------- /FastFitsTools/FitsTools/FitsWeighting.py: -------------------------------------------------------------------------------- 1 | import numexpr as ne 2 | 3 | import numpy as np 4 | 5 | 6 | class FitsWeighting: 7 | def Gvalue(self,dec, tau, totalTime, nsblk, nsubint, float_freq): 8 | c = 299794580.0 9 | pi = np.pi 10 | d = 300 11 | F=1 12 | omega = 2*pi / 3600.000 / 24.000 13 | 14 | float_freq1 = float_freq[0] 15 | 16 | float_time = np.float32(np.linspace(0, totalTime, nsblk * nsubint)) 17 | 18 | float_time = float_time - tau 19 | 20 | float_time = float_time.reshape(float_time.size, 1) 21 | 22 | float_freq1 = float_freq1.reshape(1, float_freq1.size) 23 | 24 | eta = np.dot(float_time, float_freq1) # matrix element 25 | print '1' 26 | pi=np.pi 27 | 28 | eta = ne.evaluate("((-2 * pi * omega * d * 1000000) / (1.22 * c)) * (eta)") 29 | 30 | tem = np.cos(dec * 2 * np.pi / 360) 31 | #for i in range(0,self.numSubint, self.numSubint): # split freq.range into segments 32 | etatmp = eta[:,:] 33 | etatmp = ne.evaluate("(sin(etatmp)/etatmp)**2") 34 | eta[:, :] = ne.evaluate("(F*tem*etatmp)") 35 | 36 | return eta 37 | 38 | 39 | def weighting(self, dec, tau, totalTime,float_data,nsblk, numSubint, float_dat_freq,): 40 | etas = self.Gvalue(dec, tau, totalTime, nsblk, numSubint, float_dat_freq,float_data) 41 | 42 | etas = etas.reshape(self.numSubint, self.nsblk, 1, self.chnum, 1) 43 | # for k in range(0, self.numSubint, self.numSubint): 44 | temdata = self.float_data2 45 | temg = etas 46 | self.float_data2 = ne.evaluate("temg*temdata") 47 | self.float_data2 = np.uint8(self.float_data2) 48 | self.float_data2 = temg 49 | -------------------------------------------------------------------------------- /FastFitsTools/FitsTools/MergrPolo.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | def mergePolae(fits): 3 | # self.Npolae = 1 4 | # if self.flag == 0: 5 | if fits.Npolae > 1: 6 | fits.float_data = np.array(fits.float_data[:, :, 0, :, :]) 7 | fits.Npolae = 1 8 | # if self.flag == 1: 9 | # float_data_1 = np.array(self.float_data_1[:, :, 0, :, :]) 10 | # float_data_2 = np.array(self.float_data_2[:, :, 0, :, :]) 11 | # self.float_data = np.concatenate((float_data_1, float_data_2)) 12 | # self.Npolae = 1 13 | # self.float_data=self.float_data3[:,:,0,:,:]+self.float_data3[:,:,1,:,:] -------------------------------------------------------------------------------- /FastFitsTools/FitsTools/MergrPolo.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NAOC-pulsar/PeiWang-code/6a01f92ec9f1a32d2c203c8b8dd6955a208af330/FastFitsTools/FitsTools/MergrPolo.pyc -------------------------------------------------------------------------------- /FastFitsTools/FitsTools/TimeCal.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | print '# Usage: $python FAST_source_RaJ_DecJ.py MJD DecJ' 5 | 6 | 7 | import sys 8 | import ephem 9 | import datetime as dt 10 | from astropy.time import Time 11 | from astropy.coordinates import SkyCoord 12 | from astropy import units as u 13 | from datetime import datetime 14 | 15 | 16 | class TimeCal: 17 | def __init__(self,_dec,Offset_time): 18 | self.Dawodang = ephem.Observer() 19 | self.Dawodang.lat = '25.652939' 20 | self.Dawodang.lon = '106.8609444' 21 | self.Dawodang.horizon = '-18' # Astronomical twilight uses the value -18 degrees 22 | 23 | ############################## 24 | # Input parameters 25 | 26 | self.src = ephem.FixedBody() 27 | self.src._ra = '00:00:00' 28 | self.src._dec = _dec 29 | # Starttime = 57911.55059692592593 # read MJD time from fits header 30 | 31 | self.Offset_time = Offset_time # half time(sec) between end and start time, ie. beam centre 32 | Offset_arival_time = 236 # interval arrival time(sec) in one day 33 | 34 | 35 | ############################## 36 | # def mjdtolocaltime(self,Starttime): 37 | # t_header = Time(Starttime, format='mjd', scale='utc') 38 | # Starttime_utc = datetime.strptime(str(t_header.datetime), "%Y-%m-%d %H:%M:%S.%f") 39 | # print Starttime_utc # start time in header 40 | 41 | 42 | def calTime(self,Starttime): 43 | #print Starttime 44 | t_header = Time(Starttime, format='mjd', scale='utc') 45 | 46 | tmp_t_header = str(t_header.datetime).split('.') 47 | # print tmp 48 | if tmp_t_header.__len__() == 1: 49 | tmp_t_header[0] = tmp_t_header[0] + '.000001' 50 | # print tmp[0] 51 | else: 52 | tmp_t_header[0] = tmp_t_header[0] + '.' + tmp_t_header[1] 53 | Starttime_utc = datetime.strptime(tmp_t_header[0], "%Y-%m-%d %H:%M:%S.%f") 54 | 55 | # Inital_Ra = datetime.strptime(str(src._ra),"%Y-%m-%d %H:%M:%S.%f") 56 | #print 'Fits start_time(UTC) =', Starttime_utc # start time in header 57 | # Dawodang.date = str(Starttime_utc).split(' ')[0] # Dawodang time = 00:00:00 58 | self.Dawodang.date = str(Starttime_utc) 59 | 60 | # Calculate transit time 61 | 62 | 63 | 64 | # Calculate transit time 65 | 66 | self.src.compute() 67 | ttrans = self.Dawodang.next_transit(self.src) 68 | 69 | t_transit = Time(ephem.localtime(ttrans), scale='utc') # localtime UTC+8h 70 | # print ephem.localtime(ttrans), t_transit.mjd # localtime UTC+8h, transit time (MJD) 71 | Alt = str(self.src.alt).split(':') 72 | Az = str(self.src.az).split(':') 73 | FAST_az = 90.0 - (float(Alt[0]) + (float(Alt[1]) / 60) + float(Alt[2]) / 3600.) 74 | FAST_el = 270.0 - (float(Az[0]) + (float(Az[1]) / 60) + float(Az[2]) / 3600.) 75 | # print 'Ra(0:0:0) Transit:', ephem.localtime(ttrans), t_transit.mjd, src.ra, src.dec, src.alt, src.az, FAST_el, FAST_az 76 | #Transit_utc8 = datetime.strptime(str(t_transit), "%Y-%m-%d %H:%M:%S") 77 | #print t_transit, '@#@' 78 | tmp=str(t_transit).split('.') 79 | #print tmp 80 | if tmp.__len__()==1: 81 | tmp[0]=tmp[0]+'.000001' 82 | #print tmp[0] 83 | else: 84 | tmp[0]=tmp[0]+'.'+tmp[1] 85 | #print tmp[0] 86 | Transit_utc8 = datetime.strptime(tmp[0],"%Y-%m-%d %H:%M:%S.%f") 87 | 88 | 89 | # Compensate start time & transit time 90 | 91 | Delta = Transit_utc8 - Starttime_utc 92 | Offset_sec = 236 * float(Delta.seconds) / 24. / 3600. - float( 93 | self.Offset_time) # compensate periodical delay and modify start_time to beam centre 94 | # print 'Delta time =', Delta 95 | # print 'Offset_sec =', Offset_sec 96 | 97 | Delta_final = Delta + dt.timedelta(seconds=Offset_sec) 98 | # print 'Delta time after offset =', Delta_final 99 | 100 | H24_date = (str(Starttime_utc).split(' ')[0]).split('-') 101 | H24 = dt.datetime(int(H24_date[0]), int(H24_date[1]), int(H24_date[2]), 23, 59, 59) 102 | RaJ = H24 - (Delta_final - dt.timedelta(seconds=3600 * 8 + 1)) 103 | #print '\n', 'Ra(J2000) =', RaJ 104 | 105 | # Ra,Dec 106 | RaJ_h = (str(RaJ).split(' ')[1]).split(':')[0] 107 | RaJ_m = (str(RaJ).split(' ')[1]).split(':')[1] 108 | RaJ_s = (str(RaJ).split(' ')[1]).split(':')[2] 109 | RaJ_hms = str(RaJ_h) + 'h' + str(RaJ_m) + 'm' + str(RaJ_s) + 's' 110 | DecJ_d = str(self.src._dec).split(':')[0] 111 | DecJ_m = str(self.src._dec).split(':')[1] 112 | DecJ_s = str(self.src._dec).split(':')[2] 113 | DecJ_dms = str(DecJ_d) + 'd' + str(DecJ_m) + 'm' + str(DecJ_s) + 's' 114 | RaJ_deg = (str(SkyCoord(RaJ_hms, DecJ_dms, frame='icrs')).split('(')[3]).split(',')[0] 115 | 116 | Dec_flag = DecJ_d.find('-') 117 | if (int(Dec_flag) == 0): 118 | DecJ_deg = float(DecJ_d) - float(DecJ_m) / 60. - float(DecJ_s) / 3600. 119 | else: 120 | DecJ_deg = float(DecJ_d) + float(DecJ_m) / 60. + float(DecJ_s) / 3600. 121 | 122 | # GL,GB 123 | Glb = SkyCoord(ra=float(RaJ_deg) * u.degree, dec=float(DecJ_deg) * u.degree, frame='icrs') 124 | 125 | GL = Glb.galactic.l.degree 126 | GB = Glb.galactic.b.degree 127 | GL = round(float(GL), 2) 128 | GB = round(float(GB), 2) 129 | if (GB < 0): 130 | GB = 'm' + str(GB).split('-')[1] 131 | else: 132 | GB = 'p' + str(GB) 133 | 134 | #print '\n', 'GL(deg) =', GL, ' GB(deg) =', GB 135 | #print '-----------------------------------', '\n' 136 | 137 | return str(RaJ).split(' ')[1], FAST_az, FAST_el, RaJ_deg, DecJ_deg,GL,GB,str(Starttime_utc) 138 | # example to use: 139 | ################################# 140 | #obj=TimeCal('-01:31:11.387',26.2144) 141 | # print obj.mjdtolocaltime(57903.84104453703704) 142 | #print obj.calTime(57987.57606337037037) 143 | 144 | 145 | -------------------------------------------------------------------------------- /FastFitsTools/FitsTools/TimeCal.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NAOC-pulsar/PeiWang-code/6a01f92ec9f1a32d2c203c8b8dd6955a208af330/FastFitsTools/FitsTools/TimeCal.pyc -------------------------------------------------------------------------------- /FastFitsTools/FitsTools/__init__.py: -------------------------------------------------------------------------------- 1 | from Fits import Fits 2 | from FitsCut import Fitscut -------------------------------------------------------------------------------- /FastFitsTools/FitsTools/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NAOC-pulsar/PeiWang-code/6a01f92ec9f1a32d2c203c8b8dd6955a208af330/FastFitsTools/FitsTools/__init__.pyc -------------------------------------------------------------------------------- /FastFitsTools/FitsTools/beamweighting.py: -------------------------------------------------------------------------------- 1 | def Gvalue(self, dec, tau, totalTime, nsblk, nsubint, float_freq, a, b): 2 | c = 299794580.0 3 | pi = np.pi 4 | d = 300 5 | F = b 6 | 7 | tau -= 5 8 | omega = 2 * pi / 3600.000 / 24.000 9 | 10 | float_freq1 = float_freq[0] 11 | 12 | float_time = np.linspace(0, totalTime, nsblk * nsubint) 13 | 14 | float_time = float_time - tau 15 | 16 | float_time = float_time.reshape(float_time.size, 1) 17 | 18 | float_freq1 = float_freq1.reshape(1, float_freq1.size) 19 | 20 | eta = np.dot(float_time, float_freq1) # matrix element 21 | print '1' 22 | pi = np.pi 23 | 24 | eta = ne.evaluate("((-2 * pi * omega * d * 1000000) / (1.22 * c)) * (eta)") 25 | 26 | tem = np.cos(dec * 2 * np.pi / 360) 27 | # for i in range(0,self.numSubint, self.numSubint): # split freq.range into segments 28 | etatmp = eta[:, :] 29 | etatmp = ne.evaluate("(sin(etatmp)/etatmp)**2") 30 | eta[:, :] = ne.evaluate("(F*tem*etatmp)") 31 | 32 | return eta 33 | 34 | def weighting(self,etas ,a,b): 35 | 36 | #for k in range(0, self.numSubint, self.numSubint): 37 | temdata = self.float_data2 38 | ran=temdata.max()/128 39 | temdata=temdata/ran 40 | avg=np.mean(temdata) 41 | temdata=temdata-(avg*0.5) 42 | temdata[temdata<0]=0 43 | temg = etas +a 44 | self.float_data2 = ne.evaluate("temg*temdata") 45 | #self.float_data2 = np.uint8(self.float_data2) 46 | self.float_data2[self.float_data2>255]=255 47 | self.float_data2=self.float_data2.astype(np.uint8) 48 | -------------------------------------------------------------------------------- /FastFitsTools/MassFilePreTreated.py: -------------------------------------------------------------------------------- 1 | def exeCutFreqMergeFitsByTime(self, filename, startfreq, endfreq, initaltime, finaltime, i, outpath, dec, fw, a, b): 2 | self.centerFreq = (startfreq + endfreq - 1) / 2 3 | # self.checkInputs(startfreq, endfreq, initaltime, finaltime) 4 | # initaltime = int(round(initaltime / self.timePerSubint)) * self.timePerSubint 5 | # finaltime = int(round(finaltime / self.timePerSubint)) * self.timePerSubint 6 | # print self.telecope 7 | if (self.telecope == 'FAST'): 8 | startfreqNetNum = int((startfreq - (self.initalFreq - self.chanBW / 2)) * (1. / self.chanBW)) 9 | 10 | endfreqNetNum = int((endfreq - (self.initalFreq - self.chanBW / 2)) * (1. / self.chanBW)) 11 | 12 | 13 | # print '++++++++++++++++',startfreqNetNum,endfreqNetNum 14 | if (self.Npolae > 1): 15 | self.mergePolae(0) 16 | 17 | self.cut(startfreqNetNum, endfreqNetNum, initaltime, finaltime) 18 | self.modifyPHeader(startfreq, endfreq, startfreqNetNum, endfreqNetNum, dec) 19 | 20 | # print startfreqNetNum,endfreqNetNum 21 | if not fw.any(): 22 | etas = self.Gvalue(self.DecJ_deg, self.totalTime / 4, self.totalTime / 2, self.nsblk, self.numSubint, 23 | self.float_dat_freq, a, b) 24 | 25 | etas = etas.reshape(self.numSubint, self.nsblk, 1, self.chnum, 1) 26 | else: 27 | etas = fw 28 | self.weighting(etas, a, b) 29 | if (self.telecope == 'FAST'): 30 | if not (os.path.exists(outpath + '/' + filename.split('/')[len(filename.split('/')) - 1][:10])): 31 | os.mkdir(outpath + '/' + filename.split('/')[len(filename.split('/')) - 1][:10]) 32 | files = filename.split('/')[len(filename.split('/')) - 1] 33 | # timelist = {15: 'A', 30: 'B', 60: 'C', 90: 'D', 120: 'E'} 34 | newpath = outpath + '/' + files[:10] + '/' + \ 35 | files[:len(files) - 9] + str('%04d' % (int(files[len(files) - 9:len(files) - 5]))) + '_' + str( 36 | i) + '.fits' 37 | # len(files) - 9:len( 38 | # files) - 5] + '0' + str( 39 | # i) + '.fits' 40 | # files[:len(files) - 9] + str('%04d' % (int(files[len(files) - 9:len(files) - 5]) + 1)) 41 | self.wirtreToFileForFast(filename, i, newpath) 42 | return etas 43 | -------------------------------------------------------------------------------- /FastFitsTools/MergeByF.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NAOC-pulsar/PeiWang-code/6a01f92ec9f1a32d2c203c8b8dd6955a208af330/FastFitsTools/MergeByF.py -------------------------------------------------------------------------------- /FastFitsTools/MergeByT.py: -------------------------------------------------------------------------------- 1 | def exeCutFreqMergeFitsByTime(self, filename, startfreq, endfreq, initaltime, finaltime, i, outpath, dec, fw, a, b): 2 | self.centerFreq = (startfreq + endfreq - 1) / 2 3 | # self.checkInputs(startfreq, endfreq, initaltime, finaltime) 4 | # initaltime = int(round(initaltime / self.timePerSubint)) * self.timePerSubint 5 | # finaltime = int(round(finaltime / self.timePerSubint)) * self.timePerSubint 6 | # print self.telecope 7 | if (self.telecope == 'FAST'): 8 | startfreqNetNum = int((startfreq - (self.initalFreq - self.chanBW / 2)) * (1. / self.chanBW)) 9 | 10 | endfreqNetNum = int((endfreq - (self.initalFreq - self.chanBW / 2)) * (1. / self.chanBW)) 11 | 12 | 13 | # print '++++++++++++++++',startfreqNetNum,endfreqNetNum 14 | if (self.Npolae > 1): 15 | self.mergePolae(0) 16 | 17 | self.cut(startfreqNetNum, endfreqNetNum, initaltime, finaltime) 18 | self.modifyPHeader(startfreq, endfreq, startfreqNetNum, endfreqNetNum, dec) 19 | 20 | # print startfreqNetNum,endfreqNetNum 21 | if not fw.any(): 22 | etas = self.Gvalue(self.DecJ_deg, self.totalTime / 4, self.totalTime / 2, self.nsblk, self.numSubint, 23 | self.float_dat_freq, a, b) 24 | 25 | etas = etas.reshape(self.numSubint, self.nsblk, 1, self.chnum, 1) 26 | else: 27 | etas = fw 28 | self.weighting(etas, a, b) 29 | if (self.telecope == 'FAST'): 30 | if not (os.path.exists(outpath + '/' + filename.split('/')[len(filename.split('/')) - 1][:10])): 31 | os.mkdir(outpath + '/' + filename.split('/')[len(filename.split('/')) - 1][:10]) 32 | files = filename.split('/')[len(filename.split('/')) - 1] 33 | # timelist = {15: 'A', 30: 'B', 60: 'C', 90: 'D', 120: 'E'} 34 | newpath = outpath + '/' + files[:10] + '/' + \ 35 | files[:len(files) - 9] + str('%04d' % (int(files[len(files) - 9:len(files) - 5]))) + '_' + str( 36 | i) + '.fits' 37 | # len(files) - 9:len( 38 | # files) - 5] + '0' + str( 39 | # i) + '.fits' 40 | # files[:len(files) - 9] + str('%04d' % (int(files[len(files) - 9:len(files) - 5]) + 1)) 41 | self.wirtreToFileForFast(filename, i, newpath) 42 | return etas 43 | -------------------------------------------------------------------------------- /FastFitsTools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NAOC-pulsar/PeiWang-code/6a01f92ec9f1a32d2c203c8b8dd6955a208af330/FastFitsTools/__init__.py -------------------------------------------------------------------------------- /FastFitsTools/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NAOC-pulsar/PeiWang-code/6a01f92ec9f1a32d2c203c8b8dd6955a208af330/FastFitsTools/__init__.pyc -------------------------------------------------------------------------------- /Gal_plot/.GCs-FASTsky_40.txt.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NAOC-pulsar/PeiWang-code/6a01f92ec9f1a32d2c203c8b8dd6955a208af330/Gal_plot/.GCs-FASTsky_40.txt.swp -------------------------------------------------------------------------------- /Gal_plot/.GCs_Npsr-obser.py.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NAOC-pulsar/PeiWang-code/6a01f92ec9f1a32d2c203c8b8dd6955a208af330/Gal_plot/.GCs_Npsr-obser.py.swp -------------------------------------------------------------------------------- /Gal_plot/GCs-FASTsky_40.txt: -------------------------------------------------------------------------------- 1 | NGC 6171 16:32:31.86 -13:03:13.6 0 1 0 1000 2 | NGC 6981 20:53:27.70 -12:32:14.3 0 1 0 1000 3 | NGC 6517 18:01:50.52 -08:57:31.6 4 15 0 3 4 | NGC 6712 18:53:04.30 -08:42:22.0 0 3 0 1000 5 | Pal 11 19:45:14.40 -08:00:26.0 0 2 0 718 6 | NGC 6539 18:04:49.68 -07:35:09.1 1 4 0 30 7 | IC 1276 18:10:44.20 -07:12:27.4 0 1 0 1000 8 | NGC 5634 14:29:37.23 -05:58:35.1 0 2 0 1000 9 | NGC 6366 17:27:44.24 -05:04:47.5 0 1 0 1000 10 | NGC 6254 16:57:09.05 -04:06:01.1 0 3 0 3 11 | NGC 6402 17:37:36.10 -03:14:45.3 0 8 0 5 12 | NGC 6218 16:47:14.18 -01:56:54.7 0 2 0 50 13 | NGC 7089 21:33:27.02 -00:49:23.7 0 20 1 1 14 | Pal 15 16:59:51.00 -00:32:20.0 0 0 0 0 15 | NGC 6535 18:03:50.51 -00:17:51.5 0 0 0 0 16 | Pal 5 15:16:05.25 -00:06:41.8 0 0 0 0 17 | Pal 3 10:05:31.90 +00:04:18.0 0 0 0 0 18 | NGC 6760 19:11:12.01 +01:01:49.7 2 5 0 18 19 | NGC 6749 19:05:15.30 +01:54:03.0 1 4 0 46 20 | NGC 5904 15:18:33.22 +02:04:51.7 5 9 1 1 21 | NGC 6426 17:44:54.65 +03:10:12.5 0 0 0 0 22 | NGC 6934 20:34:11.37 +07:24:16.1 0 3 0 446 23 | NGC 7078 21:29:58.33 +12:10:01.2 8 80 5 1 24 | Pal 13 23:06:44.44 +12:46:19.2 0 0 0 0 25 | Pal 14 16:11:00.60 +14:57:28.0 0 0 0 0 26 | NGC 7006 21:01:29.38 +16:11:14.4 0 1 0 1000 27 | NGC 5053 13:16:27.09 +17:42:00.9 0 0 0 0 28 | NGC 5024 13:12:55.25 +18:10:05.4 1 3 0 456 29 | NGC 4147 12:10:06.30 +18:32:33.5 0 2 0 1000 30 | Pal 10 19:18:02.10 +18:34:18.0 0 5 0 4 31 | NGC 6838 19:53:46.49 +18:46:45.1 1 1 0 1000 32 | NGC 5272 13:42:11.62 +28:22:38.2 4 10 0 2 33 | NGC 5466 14:05:27.29 +28:32:04.0 0 0 0 0 34 | Pal 4 11:29:16.80 +28:58:24.9 0 0 0 0 35 | NGC 6779 19:16:35.57 +30:11:00.5 0 3 0 92 36 | Pal 2 04:46:05.91 +31:22:53.4 0 29 0 15 37 | NGC 6205 16:41:41.24 +36:27:35.5 5 5 0 3 38 | NGC 2419 07:38:08.47 +38:52:56.8 0 1 0 1000 39 | NGC 6341 17:17:07.39 +43:08:09.4 0 13 1 1 40 | NGC 6229 16:46:58.79 +47:31:39.9 0 4 0 1000 -------------------------------------------------------------------------------- /M31-gridding-survey/M31_grid.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | # Wangpei, Ver.20181217 5 | # $python M31_grid.py grid.txt 6 | # Format of grid.txt: "gridpoint | offset_RaJ(arcmin) | offset_DecJ(arcmin)" 7 | 8 | import sys 9 | import datetime as dt 10 | import commands 11 | import numpy as np 12 | from datetime import datetime 13 | 14 | 15 | ########################################## 16 | ############### Parameters ############### 17 | 18 | # M31 central coordnation 19 | M31raJ = '00:42:44.3' 20 | M31decJ = '41:16:09.0' 21 | 22 | # Be set as pointing of P10-N1-M06 (arcmin) 23 | OffsetP10N1M01raJ = '2.59' 24 | OffsetP10N1M01decJ = '-5.11' 25 | ########################################## 26 | 27 | 28 | 29 | if (len(sys.argv)<2): 30 | print '\n', 'Wrong inputs!' 31 | print 'Usage: python M31_grid.py grid.txt', '\n' 32 | sys.exit() 33 | 34 | Pointlist = sys.argv[1] 35 | TotNpoint = commands.getoutput('cat grid.txt | wc -l') 36 | print 'Go through the list to get a total row number' 37 | Npoint=1 38 | 39 | M31DecJ_d = str(M31decJ).split(':')[0] 40 | M31DecJ_m = str(M31decJ).split(':')[1] 41 | M31DecJ_s = str(M31decJ).split(':')[2] 42 | Dec_flag = M31DecJ_d.find('-') 43 | if (int(Dec_flag) == 0 ): 44 | M31DecJ_rad = (float(M31DecJ_d)-float(M31DecJ_m)/60.-float(M31DecJ_s)/3600.)/180*np.pi 45 | else: 46 | M31DecJ_rad = (float(M31DecJ_d)+float(M31DecJ_m)/60.+float(M31DecJ_s)/3600.)/180*np.pi 47 | 48 | 49 | # StartRaJ 50 | OffsetP10N1M01raJ = str(float(OffsetP10N1M01raJ)/15/np.cos(M31DecJ_rad+float(OffsetP10N1M01decJ)/60/180*np.pi)) 51 | OffsetP10N1M01raJm = int(OffsetP10N1M01raJ.split(".")[0]) 52 | Offra_flag = str(OffsetP10N1M01raJ).find('-') 53 | if (int(Offra_flag) == 0 ): 54 | OffsetP10N1M01raJs = -1.*float('0.'+OffsetP10N1M01raJ.split(".")[1])*60. 55 | else: 56 | OffsetP10N1M01raJs = float('0.'+OffsetP10N1M01raJ.split(".")[1])*60. 57 | 58 | M31RaJ = datetime.strptime(M31raJ,"%H:%M:%S.%f") 59 | StartRaJ = M31RaJ + dt.timedelta(hours=0,minutes=OffsetP10N1M01raJm,seconds=OffsetP10N1M01raJs) 60 | StartRaJ = str(StartRaJ).split(' ')[1] 61 | print 'StartRaJ =', StartRaJ 62 | StartRaJ = datetime.strptime(StartRaJ,"%H:%M:%S.%f") 63 | 64 | 65 | # StartDecJ 66 | OffsetP10N1M01decJm = int(OffsetP10N1M01decJ.split(".")[0]) 67 | Offdec_flag = str(OffsetP10N1M01decJ).find('-') 68 | if (int(Offdec_flag) == 0 ): 69 | OffsetP10N1M01decJs = -1.*float('0.'+OffsetP10N1M01decJ.split(".")[1])*60. 70 | else: 71 | OffsetP10N1M01decJs = float('0.'+OffsetP10N1M01decJ.split(".")[1])*60. 72 | 73 | M31H1decJ = datetime.strptime('01:'+M31DecJ_m+':'+M31DecJ_s,"%H:%M:%S.%f") # H01 assumed 74 | StartDecJ = M31H1decJ + dt.timedelta(hours=0,minutes=OffsetP10N1M01decJm,seconds=OffsetP10N1M01decJs) 75 | OffH1 = int((str(StartDecJ).split(' ')[1]).split(':')[0]) 76 | if (OffH1 < 1): 77 | StartDecJ = str(int(M31DecJ_d)-1)+':'+(str(StartDecJ).split(' ')[1]).split(':')[1]+':'+(str(StartDecJ).split(' ')[1]).split(':')[2] 78 | else: 79 | StartDecJ = M31DecJ_d+':'+(str(StartDecJ).split(' ')[1]).split(':')[1]+':'+(str(StartDecJ).split(' ')[1]).split(':')[2] 80 | 81 | print 'StartDecJ =',StartDecJ, '\n' 82 | StartDecJ_d = str(StartDecJ).split(':')[0] 83 | StartDecJ_m = str(StartDecJ).split(':')[1] 84 | StartDecJ_s = str(StartDecJ).split(':')[2] 85 | StartDec_flag = StartDecJ_d.find('-') 86 | if (int(Dec_flag) == 0 ): 87 | StartDecJ_rad = (float(StartDecJ_d)-float(StartDecJ_m)/60.-float(StartDecJ_s)/3600.)/180*np.pi 88 | else: 89 | StartDecJ_rad = (float(StartDecJ_d)+float(StartDecJ_m)/60.+float(StartDecJ_s)/3600.)/180*np.pi 90 | 91 | 92 | # Generate grid 93 | for Line in open(Pointlist): 94 | Line1=" ".join(Line.split()) 95 | Sname=Line1.replace('\n','').split(" ")[0].strip() 96 | OffsetRaJ=Line1.replace('\n','').split(" ")[1].strip() 97 | OffsetDecJ=Line1.replace('\n','').split(" ")[2].strip() 98 | OffsetDecJ_rad=float(OffsetDecJ)/60/180*np.pi 99 | 100 | # N1RaJ 101 | OffsetN1RaJ = str(float(OffsetRaJ)/15/np.cos(StartDecJ_rad+OffsetDecJ_rad)) 102 | OffsetN1raJm = int(OffsetN1RaJ.split(".")[0]) 103 | OffN1ra_flag = str(OffsetN1RaJ).find('-') 104 | if (int(OffN1ra_flag) == 0 ): 105 | OffsetN1raJs = -1.*float('0.'+OffsetN1RaJ.split(".")[1])*60. 106 | else: 107 | OffsetN1raJs = float('0.'+OffsetN1RaJ.split(".")[1])*60. 108 | N1RaJ = StartRaJ + dt.timedelta(hours=0, minutes=OffsetN1raJm, seconds=OffsetN1raJs) 109 | N1RaJ = str(N1RaJ).split(' ')[1] 110 | 111 | # N1DecJ 112 | OffsetN1decJm = int(OffsetDecJ.split(".")[0]) 113 | OffN1dec_flag = str(OffsetDecJ).find('-') 114 | if (int(OffN1dec_flag) == 0 ): 115 | OffsetN1decJs = -1.*float('0.'+OffsetDecJ.split(".")[1])*60. 116 | else: 117 | OffsetN1decJs = float('0.'+OffsetDecJ.split(".")[1])*60. 118 | StartdecJ = datetime.strptime('05:'+StartDecJ_m+':'+StartDecJ_s,"%H:%M:%S.%f") # H05 assumed 119 | N1H1DecJ = StartdecJ + dt.timedelta(hours=0,minutes=OffsetN1decJm,seconds=OffsetN1decJs) 120 | OffN1H1 = int((str(N1H1DecJ).split(' ')[1]).split(':')[0]) 121 | N1DecJ = str(int(StartDecJ_d)+OffN1H1-5)+':'+(str(N1H1DecJ).split(' ')[1]).split(':')[1]+':'+(str(N1H1DecJ).split(' ')[1]).split(':')[2] 122 | 123 | 124 | # N2RaJ 125 | OffsetN2RaJ = float(OffsetRaJ)-1.5 126 | OffsetN2RaJ = str(float(OffsetN2RaJ)/15/np.cos(StartDecJ_rad+OffsetDecJ_rad+ 2.6/60/180*np.pi)) 127 | OffsetN2raJm = int(OffsetN2RaJ.split(".")[0]) 128 | OffN2ra_flag = str(OffsetN2RaJ).find('-') 129 | if (int(OffN2ra_flag) == 0 ): 130 | OffsetN2raJs = -1.*float('0.'+OffsetN2RaJ.split(".")[1])*60. 131 | else: 132 | OffsetN2raJs = float('0.'+OffsetN2RaJ.split(".")[1])*60. 133 | N2RaJ = StartRaJ + dt.timedelta(hours=0, minutes=OffsetN2raJm, seconds=OffsetN2raJs) 134 | N2RaJ = str(N2RaJ).split(' ')[1] 135 | 136 | # N2DecJ 137 | OffsetN2DecJ = str(float(OffsetDecJ)+2.6) 138 | OffsetN2decJm = int(OffsetN2DecJ.split(".")[0]) 139 | OffN2dec_flag = str(OffsetN2DecJ).find('-') 140 | if (int(OffN2dec_flag) == 0 ): 141 | OffsetN2decJs = -1.*float('0.'+OffsetN2DecJ.split(".")[1])*60. 142 | else: 143 | OffsetN2decJs = float('0.'+OffsetN2DecJ.split(".")[1])*60. 144 | N2H1DecJ = StartdecJ + dt.timedelta(hours=0,minutes=OffsetN2decJm,seconds=OffsetN2decJs) 145 | OffN2H1 = int((str(N2H1DecJ).split(' ')[1]).split(':')[0]) 146 | N2DecJ = str(int(StartDecJ_d)+OffN2H1-5)+':'+(str(N2H1DecJ).split(' ')[1]).split(':')[1]+':'+(str(N2H1DecJ).split(' ')[1]).split(':')[2] 147 | 148 | 149 | # N3RaJ 150 | OffsetN3RaJ = str(float(OffsetRaJ)+1.5) 151 | OffsetN3RaJ = str(float(OffsetN3RaJ)/15/np.cos(StartDecJ_rad+OffsetDecJ_rad+ 2.6/60/180*np.pi)) 152 | OffsetN3raJm = int(OffsetN3RaJ.split(".")[0]) 153 | OffN3ra_flag = str(OffsetN3RaJ).find('-') 154 | if (int(OffN3ra_flag) == 0 ): 155 | OffsetN3raJs = -1.*float('0.'+OffsetN3RaJ.split(".")[1])*60. 156 | else: 157 | OffsetN3raJs = float('0.'+OffsetN3RaJ.split(".")[1])*60. 158 | N3RaJ = StartRaJ + dt.timedelta(hours=0, minutes=OffsetN3raJm, seconds=OffsetN3raJs) 159 | N3RaJ = str(N3RaJ).split(' ')[1] 160 | 161 | # N3DecJ 162 | N3DecJ = N2DecJ 163 | 164 | 165 | # N4RaJ 166 | OffsetN4RaJ = str(float(OffsetRaJ)+3.0) 167 | OffsetN4RaJ = str(float(OffsetN4RaJ)/15/np.cos(StartDecJ_rad+OffsetDecJ_rad)) 168 | OffsetN4raJm = int(OffsetN4RaJ.split(".")[0]) 169 | OffN4ra_flag = str(OffsetN4RaJ).find('-') 170 | if (int(OffN4ra_flag) == 0 ): 171 | OffsetN4raJs = -1.*float('0.'+OffsetN4RaJ.split(".")[1])*60. 172 | else: 173 | OffsetN4raJs = float('0.'+OffsetN4RaJ.split(".")[1])*60. 174 | N4RaJ = StartRaJ + dt.timedelta(hours=0, minutes=OffsetN4raJm, seconds=OffsetN4raJs) 175 | N4RaJ = str(N4RaJ).split(' ')[1] 176 | 177 | # N4 DecJ 178 | N4DecJ = N1DecJ 179 | 180 | print '\n', 'Source:', Npoint, 'of', TotNpoint, ' ', Sname 181 | print '------------------------------------------------' 182 | print str(Sname)+'(RaJ2000,DecJ2000) =', N1RaJ, ' ', N1DecJ, '\n' 183 | print 'N1 | RA+0.0arcmin_DEC+0.0arcmin =', N1RaJ, ' ', N1DecJ 184 | print 'N2 | RA-1.5arcmin_DEC+2.6arcmin =', N2RaJ, ' ', N2DecJ 185 | print 'N3 | RA+1.5arcmin_DEC+2.6arcmin =', N3RaJ, ' ', N3DecJ 186 | print 'N4 | RA+3.0arcmin_DEC+0.0arcmin =', N4RaJ, ' ', N4DecJ, '\n' 187 | Npoint=Npoint+1 188 | -------------------------------------------------------------------------------- /M31-gridding-survey/grid.txt: -------------------------------------------------------------------------------- 1 | P-01 42.0 83.2 2 | P-02 42.0 57.2 3 | P-03 42.0 31.2 4 | P-04 21.0 67.6 5 | P-05 21.0 41.6 6 | P-06 21.0 15.6 7 | P-07 21.0 -10.4 8 | P-08 0.0 52.0 9 | P-09 0.0 26.0 10 | P-10 0.0 0.0 11 | P-11 0.0 -26.0 12 | P-12 -21.0 36.4 13 | P-13 -21.0 10.4 14 | P-14 -21.0 -15.6 15 | P-15 -21.0 -41.6 16 | P-16 -42.0 20.8 17 | P-17 -42.0 -5.2 18 | P-18 -42.0 -31.2 19 | P-19 -42.0 -57.2 20 | P-20 -63.0 -46.8 21 | P-21 -63.0 -72.8 22 | -------------------------------------------------------------------------------- /MJD_extract/20170827_Filename.list: -------------------------------------------------------------------------------- 1 | FP20170827_0-1G_3c286_track1_0001.fits 2 | FP20170827_0-1G_3c286_track1_0002.fits 3 | FP20170827_0-1G_3c286_track1_0003.fits 4 | FP20170827_0-1G_3c286_track1_0004.fits 5 | FP20170827_0-1G_3c286_track1_0005.fits 6 | FP20170827_0-1G_3c286_track1_0006.fits 7 | FP20170827_0-1G_3c286_track1_0007.fits 8 | FP20170827_0-1G_3c286_track1_0008.fits 9 | FP20170827_0-1G_3c286_track1_0009.fits 10 | FP20170827_0-1G_3c286_track1_0010.fits 11 | FP20170827_0-1G_3c286_track1_0011.fits 12 | FP20170827_0-1G_3c286_track1_0012.fits 13 | FP20170827_0-1G_3c286_track1_0013.fits 14 | FP20170827_0-1G_3c286_track1_0014.fits 15 | FP20170827_0-1G_3c286_track1_0015.fits 16 | FP20170827_0-1G_3c286_track1_0016.fits 17 | FP20170827_0-1G_3c286_track1_0017.fits 18 | FP20170827_0-1G_3c286_track1_0018.fits 19 | FP20170827_0-1G_3c286_track1_0019.fits 20 | FP20170827_0-1G_3c286_track1_0020.fits 21 | FP20170827_0-1G_3c286_track1_0021.fits 22 | FP20170827_0-1G_3c286_track1_0022.fits 23 | FP20170827_0-1G_3c286_track1_0023.fits 24 | FP20170827_0-1G_3c286_track1_0024.fits 25 | FP20170827_0-1G_3c286_track1_0025.fits 26 | FP20170827_0-1G_3c286_track1_0026.fits 27 | FP20170827_0-1G_3c286_track1_0027.fits 28 | FP20170827_0-1G_3c286_track1_0028.fits 29 | FP20170827_0-1G_3c286_track1_0029.fits 30 | FP20170827_0-1G_3c286_track1_0030.fits 31 | FP20170827_0-1G_3c286_track1_0031.fits 32 | FP20170827_0-1G_3c286_track1_0032.fits 33 | FP20170827_0-1G_3c286_track1_0033.fits 34 | FP20170827_0-1G_3c286_track1_0034.fits 35 | FP20170827_0-1G_3c286_track1_0035.fits 36 | FP20170827_0-1G_3c286_track1_0036.fits 37 | FP20170827_0-1G_3c286_track1_0037.fits 38 | FP20170827_0-1G_3c286_track1_0038.fits 39 | FP20170827_0-1G_3c286_track1_0039.fits 40 | FP20170827_0-1G_3c286_track1_0040.fits 41 | FP20170827_0-1G_3c286_track1_0041.fits 42 | FP20170827_0-1G_3c286_track1_0042.fits 43 | FP20170827_0-1G_3c286_track1_0043.fits 44 | FP20170827_0-1G_3c286_track1_0044.fits 45 | FP20170827_0-1G_3c286_track1_0045.fits 46 | FP20170827_0-1G_3c286_track1_0046.fits 47 | FP20170827_0-1G_3c286_track1_0047.fits 48 | FP20170827_0-1G_3c286_track1_0048.fits 49 | FP20170827_0-1G_3c286_track1_0049.fits 50 | FP20170827_0-1G_3c286_track1_0050.fits 51 | FP20170827_0-1G_3c286_track1_0051.fits 52 | FP20170827_0-1G_3c286_track1_0052.fits 53 | FP20170827_0-1G_3c286_track1_0053.fits 54 | FP20170827_0-1G_3c286_track1_0054.fits 55 | FP20170827_0-1G_3c286_track1_0055.fits 56 | FP20170827_0-1G_3c286_track1_0056.fits 57 | FP20170827_0-1G_3c286_track1_0057.fits 58 | FP20170827_0-1G_3c286_track1_0058.fits 59 | FP20170827_0-1G_3c286_track1_0059.fits 60 | FP20170827_0-1G_3c286_track1_0060.fits 61 | FP20170827_0-1G_3c286_track1_0061.fits 62 | FP20170827_0-1G_3c286_track1_0062.fits 63 | FP20170827_0-1G_3c286_track1_0063.fits 64 | FP20170827_0-1G_3c286_track1_0064.fits 65 | FP20170827_0-1G_3c286_track1_0065.fits 66 | FP20170827_0-1G_3c286_track1_0066.fits 67 | FP20170827_0-1G_3c286_track1_0067.fits 68 | FP20170827_0-1G_3c286_track1_0068.fits 69 | FP20170827_0-1G_3c286_track1_0069.fits 70 | FP20170827_0-1G_3c286_track1_0070.fits 71 | FP20170827_0-1G_3c286_track1_0071.fits 72 | FP20170827_0-1G_3c286_track1_0072.fits 73 | FP20170827_0-1G_3c286_track1_0073.fits 74 | FP20170827_0-1G_3c286_track1_0074.fits 75 | FP20170827_0-1G_3c286_track1_0075.fits 76 | FP20170827_0-1G_3c286_track1_0076.fits 77 | FP20170827_0-1G_3c286_track1_0077.fits 78 | FP20170827_0-1G_3c286_track1_0078.fits 79 | FP20170827_0-1G_3c286_track1_0079.fits 80 | FP20170827_0-1G_3c286_track1_0080.fits 81 | FP20170827_0-1G_3c286_track1_0081.fits 82 | FP20170827_0-1G_3c286_track1_0082.fits 83 | FP20170827_0-1G_3c286_track1_0083.fits 84 | FP20170827_0-1G_3c286_track1_0084.fits 85 | FP20170827_0-1G_3c286_track1_0085.fits 86 | FP20170827_0-1G_3c286_track1_0086.fits 87 | FP20170827_0-1G_3c286_track1_0087.fits 88 | FP20170827_0-1G_3c286_track1_0088.fits 89 | FP20170827_0-1G_3c286_track1_0089.fits 90 | FP20170827_0-1G_3c286_track1_0090.fits 91 | FP20170827_0-1G_3c286_track1_0091.fits 92 | FP20170827_0-1G_3c286_track1_0092.fits 93 | FP20170827_0-1G_3c286_track1_0093.fits 94 | FP20170827_0-1G_3c286_track1_0094.fits 95 | FP20170827_0-1G_3c286_track1_0095.fits 96 | FP20170827_0-1G_3c286_track1_0096.fits 97 | FP20170827_0-1G_3c286_track1_0097.fits 98 | FP20170827_0-1G_3c286_track1_0098.fits 99 | FP20170827_0-1G_3c286_track1_0099.fits 100 | FP20170827_0-1G_3c286_track1_0100.fits 101 | FP20170827_0-1G_3c286_track1_0101.fits 102 | FP20170827_0-1G_3c286_track1_0102.fits 103 | FP20170827_0-1G_3c286_track1_0103.fits 104 | FP20170827_0-1G_3c286_track1_0104.fits 105 | FP20170827_0-1G_3c286_track1_0105.fits 106 | FP20170827_0-1G_3c286_track1_0106.fits 107 | FP20170827_0-1G_3c286_track1_0107.fits 108 | FP20170827_0-1G_3c286_track1_0108.fits 109 | FP20170827_0-1G_3c286_track1_0109.fits 110 | FP20170827_0-1G_3c286_track1_0110.fits 111 | FP20170827_0-1G_3c286_track1_0111.fits 112 | FP20170827_0-1G_3c286_track1_0112.fits 113 | FP20170827_0-1G_3c286_track1_0113.fits 114 | FP20170827_0-1G_3c286_track1_0114.fits 115 | FP20170827_0-1G_3c286_track1_0115.fits 116 | FP20170827_0-1G_3c286_track1_0116.fits 117 | FP20170827_0-1G_3c286_track1_0117.fits 118 | FP20170827_0-1G_3c286_track1_0118.fits 119 | FP20170827_0-1G_3c286_track1_0119.fits 120 | FP20170827_0-1G_3c286_track1_0120.fits 121 | FP20170827_0-1G_3c286_track1_0121.fits 122 | FP20170827_0-1G_3c286_track1_0122.fits 123 | FP20170827_0-1G_3c286_track1_0123.fits 124 | FP20170827_0-1G_3c286_track1_0124.fits 125 | FP20170827_0-1G_3c286_track1_0125.fits 126 | FP20170827_0-1G_3c286_track1_0126.fits 127 | FP20170827_0-1G_3c286_track1_0127.fits 128 | FP20170827_0-1G_3c286_track1_0128.fits 129 | FP20170827_0-1G_3c286_track1_0129.fits 130 | FP20170827_0-1G_3c286_track1_0130.fits 131 | FP20170827_0-1G_3c286_track1_0131.fits 132 | FP20170827_0-1G_3c286_track1_0132.fits 133 | FP20170827_0-1G_3c286_track1_0133.fits 134 | FP20170827_0-1G_3c286_track1_0134.fits 135 | FP20170827_0-1G_3c286_track1_0135.fits 136 | FP20170827_0-1G_3c286_track1_0136.fits 137 | FP20170827_0-1G_3c286_track1_0137.fits 138 | FP20170827_0-1G_3c286_track1_0138.fits 139 | FP20170827_0-1G_3c286_track1_0139.fits 140 | FP20170827_0-1G_3c286_track1_0140.fits 141 | FP20170827_0-1G_3c286_track1_0141.fits 142 | FP20170827_0-1G_3c286_track1_0142.fits 143 | -------------------------------------------------------------------------------- /MJD_extract/MJD2pointing.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ################################ 3 | # Extract pointing(Ra,Dec,GL,GB) from PSR data 4 | ################################ 5 | #. ~/.bashrc 6 | rm output.list 7 | 8 | FLAG=0 9 | DEC=0 10 | 11 | while [ -n "$1" ]; do 12 | case "$1" in 13 | -dec) DEC=$2;; 14 | -h) HELP=1;echo "# HELP :";echo " ";echo "-dec : DEC (dd:mm:ss)";echo "Example :$. filename2pointing.sh -dec 30:00:00";echo " ";; 15 | esac 16 | shift 17 | done 18 | 19 | tot=`cat MJD.list | wc -l` 20 | 21 | for MJD in `cat MJD.list` ; do 22 | let "FLAG = ${FLAG} + 1" 23 | echo "${FLAG}/${tot} MJD=${MJD}" 24 | python - ${MJD} ${DEC} ${FLAG} <> output.list 25 | 26 | import sys 27 | import ephem 28 | import datetime as dt 29 | from astropy.time import Time 30 | from astropy.coordinates import SkyCoord 31 | from astropy import units as u 32 | from datetime import datetime 33 | 34 | Dawodang = ephem.Observer() 35 | Dawodang.lat = '25.652939' 36 | Dawodang.lon = '106.8609444' 37 | Dawodang.horizon ='-18' # Astronomical twilight uses the value -18 degrees 38 | 39 | ############################## 40 | # Input parameters 41 | 42 | src = ephem.FixedBody() 43 | src._ra = '00:00:00' 44 | Starttime = float(sys.argv[1]) # read MJD time from fits header 45 | src._dec = str(sys.argv[2]) 46 | FLAG = int(sys.argv[3]) 47 | Offset_time = 26.2144 # half time(sec) between end and start time, ie. beam centre 48 | Offset_arival_time = 236 # interval arrival time(sec) in one day 49 | ############################## 50 | 51 | # Transfer Fits header MJD --> UTC time 52 | t_header = Time(Starttime,format='mjd',scale='utc') 53 | tmp_t_header = str(t_header.datetime).split('.') 54 | if tmp_t_header.__len__() == 1: 55 | tmp_t_header[0] = tmp_t_header[0] + '.000001' 56 | else: 57 | tmp_t_header[0] = tmp_t_header[0] + '.' + tmp_t_header[1] 58 | Starttime_utc = datetime.strptime(tmp_t_header[0],"%Y-%m-%d %H:%M:%S.%f") 59 | Starttime_BJ = Starttime_utc + dt.timedelta(hours=8) 60 | 61 | #Inital_Ra = datetime.strptime(str(src._ra),"%Y-%m-%d %H:%M:%S.%f") 62 | #print 'Fits start_time (UTC) =', Starttime_utc # start time in header 63 | 64 | #Dawodang.date = str(Starttime_utc).split(' ')[0] # Dawodang time = 00:00:00 65 | Dawodang.date = str(Starttime_utc) 66 | 67 | 68 | # Calculate transit time 69 | src.compute() 70 | ttrans=Dawodang.next_transit(src) 71 | t_transit = Time(ephem.localtime(ttrans),scale='utc') # localtime UTC+8h 72 | #print ephem.localtime(ttrans), t_transit.mjd # localtime UTC+8h, transit time (MJD) 73 | Alt = str(src.alt).split(':') 74 | Az = str(src.az).split(':') 75 | FAST_az = 90.0 - (float(Alt[0])+(float(Alt[1])/60)+float(Alt[2])/3600.) 76 | FAST_el = 270.0 - (float(Az[0])+(float(Az[1])/60)+float(Az[2])/3600.) 77 | #print 'Ra(0:0:0) Transit:', ephem.localtime(ttrans), t_transit.mjd, src.ra, src.dec, src.alt, src.az, FAST_el, FAST_az 78 | tmp=str(t_transit).split('.') 79 | if tmp.__len__()==1: 80 | tmp[0]=tmp[0]+'.000001' 81 | else: 82 | tmp[0]=tmp[0]+'.'+tmp[1] 83 | 84 | #Transit_utc8 = datetime.strptime(str(t_transit),"%Y-%m-%d %H:%M:%S") 85 | Transit_utc8 = datetime.strptime(tmp[0],"%Y-%m-%d %H:%M:%S.%f") 86 | 87 | # Compensate start time & transit time 88 | Delta = Transit_utc8 - Starttime_utc 89 | Offset_sec = 236 * float(Delta.seconds)/24./3600. - float(Offset_time) # compensate periodical delay and modify start_time to beam centre 90 | 91 | Delta_final = Delta + dt.timedelta(seconds = Offset_sec) 92 | 93 | H24_date = (str(Starttime_utc).split(' ')[0]).split('-') 94 | H24 = dt.datetime(int(H24_date[0]), int(H24_date[1]), int(H24_date[2]), 23, 59, 59) 95 | RaJ = H24 - (Delta_final - dt.timedelta(seconds = 3600*8+1)) 96 | 97 | # Ra,Dec 98 | RaJ_h = (str(RaJ).split(' ')[1]).split(':')[0] 99 | RaJ_m = (str(RaJ).split(' ')[1]).split(':')[1] 100 | RaJ_s = (str(RaJ).split(' ')[1]).split(':')[2] 101 | RaJ_hms = str(RaJ_h)+'h'+str(RaJ_m)+'m'+str(RaJ_s)+'s' 102 | DecJ_d = str(src._dec).split(':')[0] 103 | DecJ_m = str(src._dec).split(':')[1] 104 | DecJ_s = str(src._dec).split(':')[2] 105 | DecJ_dms = str(DecJ_d)+'d'+str(DecJ_m)+'m'+str(DecJ_s)+'s' 106 | RaJ_deg = (str(SkyCoord(RaJ_hms, DecJ_dms, frame='icrs')).split('(')[3]).split(',')[0] 107 | 108 | Dec_flag = DecJ_d.find('-') 109 | if (int(Dec_flag) == 0 ): 110 | DecJ_deg = float(DecJ_d)-float(DecJ_m)/60.-float(DecJ_s)/3600. 111 | else: 112 | DecJ_deg = float(DecJ_d)+float(DecJ_m)/60.+float(DecJ_s)/3600. 113 | 114 | # GL,GB 115 | Glb = SkyCoord(ra=float(RaJ_deg)*u.degree, dec=float(DecJ_deg)*u.degree, frame='icrs') 116 | GL = Glb.galactic.l.degree 117 | GB = Glb.galactic.b.degree 118 | GL = round(float(GL),2) 119 | GB = round(float(GB),2) 120 | 121 | print '\n', FLAG 122 | print 'Fits start_time (BJ) =', Starttime_BJ 123 | print 'Ra(J2000) =', RaJ, ' Ra(deg) =', RaJ_deg 124 | print 'Dec(J2000) =', str(src._dec), ' Dec(deg) =', DecJ_deg 125 | print 'GL(deg) =', GL, ' GB(deg) =', GB 126 | 127 | EOF 128 | done 129 | -------------------------------------------------------------------------------- /MJD_extract/filename2pointing.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ################################ 3 | # Extract pointing(Ra,Dec,GL,GB) from PSR data 4 | ################################ 5 | #. ~/.bashrc 6 | rm filelist.txt 7 | rm output.list 8 | 9 | FLAG=0 10 | DEC=0 11 | PATHF=0 12 | 13 | while [ -n "$1" ]; do 14 | case "$1" in 15 | -dec) DEC=$2;; 16 | -path) PATHF=$2;; 17 | -h) HELP=1;echo "# HELP :";echo " ";echo "-dec : DEC (dd:mm:ss)";echo "Path : Path of datafile folder";echo "Example :$. filename2pointing.sh -dec 30:00:00 -path /home/data/20170901";echo " ";; 18 | esac 19 | shift 20 | done 21 | 22 | ls ${PATHF}/*.fits > filelist.txt 23 | tot=`cat filelist.txt | wc -l` 24 | 25 | for DATASF in `cat filelist.txt` ; do 26 | let "FLAG = ${FLAG} + 1" 27 | MJD=`readfile ${PATHF} | grep STT | awk '{print $6}'` 28 | echo "${FLAG}/${tot} ${PATHF} MJD=${MJD}" 29 | python - ${MJD} ${DEC} ${FLAG} ${PATHF} <> output.list 30 | 31 | import sys 32 | import ephem 33 | import datetime as dt 34 | from astropy.time import Time 35 | from astropy.coordinates import SkyCoord 36 | from astropy import units as u 37 | from datetime import datetime 38 | 39 | Dawodang = ephem.Observer() 40 | Dawodang.lat = '25.652939' 41 | Dawodang.lon = '106.8609444' 42 | Dawodang.horizon ='-18' # Astronomical twilight uses the value -18 degrees 43 | 44 | ############################## 45 | # Input parameters 46 | 47 | src = ephem.FixedBody() 48 | src._ra = '00:00:00' 49 | Starttime = float(sys.argv[1]) # read MJD time from fits header 50 | src._dec = str(sys.argv[2]) 51 | FLAG = int(sys.argv[3]) 52 | FileName = str(sys.argv[4]) 53 | Offset_time = 26.2144 # half time(sec) between end and start time, ie. beam centre 54 | Offset_arival_time = 236 # interval arrival time(sec) in one day 55 | ############################## 56 | 57 | # Transfer Fits header MJD --> UTC time 58 | t_header = Time(Starttime,format='mjd',scale='utc') 59 | tmp_t_header = str(t_header.datetime).split('.') 60 | if tmp_t_header.__len__() == 1: 61 | tmp_t_header[0] = tmp_t_header[0] + '.000001' 62 | else: 63 | tmp_t_header[0] = tmp_t_header[0] + '.' + tmp_t_header[1] 64 | Starttime_utc = datetime.strptime(tmp_t_header[0],"%Y-%m-%d %H:%M:%S.%f") 65 | Starttime_BJ = Starttime_utc + dt.timedelta(hours=8) 66 | 67 | #Inital_Ra = datetime.strptime(str(src._ra),"%Y-%m-%d %H:%M:%S.%f") 68 | #print 'Fits start_time (UTC) =', Starttime_utc # start time in header 69 | 70 | #Dawodang.date = str(Starttime_utc).split(' ')[0] # Dawodang time = 00:00:00 71 | Dawodang.date = str(Starttime_utc) 72 | 73 | 74 | # Calculate transit time 75 | src.compute() 76 | ttrans=Dawodang.next_transit(src) 77 | t_transit = Time(ephem.localtime(ttrans),scale='utc') # localtime UTC+8h 78 | #print ephem.localtime(ttrans), t_transit.mjd # localtime UTC+8h, transit time (MJD) 79 | Alt = str(src.alt).split(':') 80 | Az = str(src.az).split(':') 81 | FAST_az = 90.0 - (float(Alt[0])+(float(Alt[1])/60)+float(Alt[2])/3600.) 82 | FAST_el = 270.0 - (float(Az[0])+(float(Az[1])/60)+float(Az[2])/3600.) 83 | #print 'Ra(0:0:0) Transit:', ephem.localtime(ttrans), t_transit.mjd, src.ra, src.dec, src.alt, src.az, FAST_el, FAST_az 84 | tmp=str(t_transit).split('.') 85 | if tmp.__len__()==1: 86 | tmp[0]=tmp[0]+'.000001' 87 | else: 88 | tmp[0]=tmp[0]+'.'+tmp[1] 89 | 90 | #Transit_utc8 = datetime.strptime(str(t_transit),"%Y-%m-%d %H:%M:%S") 91 | Transit_utc8 = datetime.strptime(tmp[0],"%Y-%m-%d %H:%M:%S.%f") 92 | 93 | # Compensate start time & transit time 94 | Delta = Transit_utc8 - Starttime_utc 95 | Offset_sec = 236 * float(Delta.seconds)/24./3600. - float(Offset_time) # compensate periodical delay and modify start_time to beam centre 96 | 97 | Delta_final = Delta + dt.timedelta(seconds = Offset_sec) 98 | 99 | H24_date = (str(Starttime_utc).split(' ')[0]).split('-') 100 | H24 = dt.datetime(int(H24_date[0]), int(H24_date[1]), int(H24_date[2]), 23, 59, 59) 101 | RaJ = H24 - (Delta_final - dt.timedelta(seconds = 3600*8+1)) 102 | 103 | # Ra,Dec 104 | RaJ_h = (str(RaJ).split(' ')[1]).split(':')[0] 105 | RaJ_m = (str(RaJ).split(' ')[1]).split(':')[1] 106 | RaJ_s = (str(RaJ).split(' ')[1]).split(':')[2] 107 | RaJ_hms = str(RaJ_h)+'h'+str(RaJ_m)+'m'+str(RaJ_s)+'s' 108 | DecJ_d = str(src._dec).split(':')[0] 109 | DecJ_m = str(src._dec).split(':')[1] 110 | DecJ_s = str(src._dec).split(':')[2] 111 | DecJ_dms = str(DecJ_d)+'d'+str(DecJ_m)+'m'+str(DecJ_s)+'s' 112 | RaJ_deg = (str(SkyCoord(RaJ_hms, DecJ_dms, frame='icrs')).split('(')[3]).split(',')[0] 113 | 114 | Dec_flag = DecJ_d.find('-') 115 | if (int(Dec_flag) == 0 ): 116 | DecJ_deg = float(DecJ_d)-float(DecJ_m)/60.-float(DecJ_s)/3600. 117 | else: 118 | DecJ_deg = float(DecJ_d)+float(DecJ_m)/60.+float(DecJ_s)/3600. 119 | 120 | # GL,GB 121 | Glb = SkyCoord(ra=float(RaJ_deg)*u.degree, dec=float(DecJ_deg)*u.degree, frame='icrs') 122 | GL = Glb.galactic.l.degree 123 | GB = Glb.galactic.b.degree 124 | GL = round(float(GL),2) 125 | GB = round(float(GB),2) 126 | 127 | print '\n', FLAG, FileName 128 | print 'Fits start_time (BJ) =', Starttime_BJ 129 | print 'Ra(J2000) =', RaJ, ' Ra(deg) =', RaJ_deg 130 | print 'Dec(J2000) =', str(src._dec), ' Dec(deg) =', DecJ_deg 131 | print 'GL(deg) =', GL, ' GB(deg) =', GB 132 | 133 | EOF 134 | done 135 | -------------------------------------------------------------------------------- /MJD_extract/readfile_MJD.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ################################ 3 | # Recorded MJD list for PSR data 4 | ################################ 5 | 6 | FLAG=0 7 | 8 | for DATASF in `cat SGP.list` ; do # loop 9 | let "FLAG = ${FLAG} + 1" 10 | MJD=`readfile /home/data/psr/201708/13/${DATASF} | grep STT | awk '{print $6}'` 11 | echo "${FLAG} ${DATASF} MJD=${MJD}" 12 | echo "${MJD}" >> MJD.list 13 | done 14 | -------------------------------------------------------------------------------- /P-Pdot/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NAOC-pulsar/PeiWang-code/6a01f92ec9f1a32d2c203c8b8dd6955a208af330/P-Pdot/.DS_Store -------------------------------------------------------------------------------- /P-Pdot/BINARY.txt: -------------------------------------------------------------------------------- 1 | 0.003050203104 1.14E-20 2 | 0.003536329153 9.85E-20 3 | 0.003210340709 -1.84E-21 4 | 0.003484992062 -4.59E-20 5 | 0.002100633545 -9.79E-21 6 | 0.002643343297 3.04E-20 7 | 0.003643021000 0 8 | 0.004033181185 3.40E-20 9 | 0.003480463000 0 10 | 0.002830405958 -1.21E-19 11 | 0.007588479807 2.94E-19 12 | 0.004342826696 9.52E-20 13 | 0.002352344000 0 14 | 0.002196660000 0 15 | 0.001877181885 4.97E-21 16 | 0.926275904970 4.46E-15 17 | 0.002573151972 5.16E-21 18 | 0.002960000000 0 19 | 0.024575294791 2.99E-19 20 | 0.002323090532 7.74E-20 21 | 0.002540000000 0 22 | 0.002732588632 1.77E-20 23 | 0.039122656902 2.41E-19 24 | 0.025701739195 7.90E-20 25 | 0.005757451937 5.73E-20 26 | 0.045781816873 1.86E-18 27 | 0.004990575114 1.17E-21 28 | 0.002556367077 7.35E-21 29 | 0.002730000000 0 30 | 0.003861324704 1.24E-20 31 | 0.003061844088 9.59E-21 32 | 0.003148669579 1.75E-20 33 | 0.028853861194 4.73E-20 34 | 0.002868952846 3.38E-21 35 | 0.195670945166 6.85E-19 36 | 0.015542394974 4.40E-20 37 | 0.022699378600 1.76E-18 38 | 2.773460770070 8.92E-16 39 | 0.003478770839 7.79E-21 40 | 0.864872804699 1.05E-16 41 | 0.011109649338 4.89E-20 42 | 0.001999000000 0 43 | 0.003101000000 0 44 | 0.005255749014 1.71E-20 45 | 0.002338514440 2.22E-21 46 | 0.016452929954 4.33E-20 47 | 0.001687987444 1.20E-20 48 | 0.003408000000 0 49 | 0.007474224228 1.77E-20 50 | 0.004665162936 3.00E-20 51 | 0.026309676982 6.30E-20 52 | 0.005109272904 1.80E-21 53 | 0.003102213919 6.09E-20 54 | 0.002630380740 4.01E-21 55 | 0.393898814838 4.31E-15 56 | 0.005070000000 0 57 | 0.043589227063 1.43E-19 58 | 0.003539375658 1.62E-21 59 | 0.001686375410 1.11E-20 60 | 0.034527834648 1.87E-19 61 | 0.003683878711 2.28E-20 62 | 0.088281908234 8.10E-19 63 | 0.147274310480 4.40E-18 64 | 0.006218531948 1.14E-19 65 | 0.001840000000 0 66 | 0.047762507500 2.28E-15 67 | 0.002560371032 2.10E-20 68 | 0.004230000000 0 69 | 0.033163166000 0 70 | 0.002677923197 1.77E-20 71 | 0.009423406718 2.47E-20 72 | 0.002389420758 1.86E-20 73 | 0.005442975160 0 74 | 0.003084233201 0.00E+00 75 | 0.007602203433 2.79E-20 76 | 0.002664216000 0 77 | 0.034117130848 6.80E-20 78 | 0.002011953443 1.41E-20 79 | 0.004110543957 6.42E-21 80 | 0.009347972210 2.45E-20 81 | 0.028634888190 1.42E-19 82 | 0.002194695780 9.81E-21 83 | 0.045248772998 8.17E-19 84 | 0.007987204929 2.43E-20 85 | 0.026744423767 3.15E-19 86 | 0.003589336680 1.86E-20 87 | 0.007946940658 -3.33E-21 88 | 0.002483927570 2.61E-20 89 | 0.002988000000 0 90 | 0.003182000000 0 91 | 0.040934988908 2.72E-20 92 | 0.011359881792 1.31E-19 93 | 0.060822230351 2.49E-19 94 | 0.008486282116 2.70E-20 95 | 0.037904441178 2.42E-18 96 | 0.002056960392 1.62E-20 97 | 0.002159288390 2.93E-21 98 | 0.003575288619 5.25E-20 99 | 0.002605672247 0 100 | 0.003597928510 9.50E-21 101 | 0.014841952251 1.56E-20 102 | 0.003150807653 9.62E-21 103 | 0.011987313000 0 104 | 0.023623444739 5.88E-20 105 | 0.011075750914 6.71E-19 106 | 0.003210000000 0 107 | 0.003320000000 0 108 | 0.763933500000 4.80E-15 109 | 0.003163315868 2.82E-21 110 | 0.003528072000 0 111 | 0.003118000000 0 112 | 0.002487000000 0 113 | 0.004621641525 1.85E-20 114 | 0.005850000000 0 115 | 0.004129145285 1.12E-20 116 | 0.005241566204 -1.30E-19 117 | 0.003593852127 -3.48E-19 118 | 0.007612848711 -6.41E-20 119 | 0.003417770445 1.26E-19 120 | 0.003233737333 3.10E-19 121 | 0.002294727081 2.22E-19 122 | 0.004505158948 1.14E-20 123 | 0.004631196278 3.63E-21 124 | 0.102618288347 2.67E-17 125 | 0.004570136526 8.53E-21 126 | 0.005790151770 8.04E-21 127 | 1.004037456700 1.62E-15 128 | 0.001855732796 7.50E-21 129 | 0.027083183244 2.46E-19 130 | 0.002344559547 2.54E-20 131 | 0.005312550291 1.42E-20 132 | 0.004175017313 7.93E-21 133 | 0.005850095860 2.41E-20 134 | 0.570313411724 2.55E-14 135 | 0.003650328897 1.68E-19 136 | 0.003747154499 3.02E-20 137 | 0.172444360995 1.55E-18 138 | 0.019376303441 9.25E-20 139 | 0.002652129671 2.73E-21 140 | 0.016760127219 -3.29E-19 141 | 0.013495820404 5.87E-19 142 | 0.003793629115 -1.06E-20 143 | 0.011563148390 -3.40E-20 144 | 0.001395954820 0.00E+00 145 | 0.003658590000 0 146 | 0.021228380000 0 147 | 0.002197800000 0 148 | 0.009570190000 0 149 | 0.080337930000 0 150 | 0.003569570000 0 151 | 0.008666900000 0 152 | 0.001676630000 0 153 | 0.001728620000 0 154 | 0.002812000000 0 155 | 0.003289140000 0 156 | 0.002072510000 0 157 | 0.004205180000 0 158 | 0.002999260000 0 159 | 0.002048160000 0 160 | 0.002462590000 0 161 | 0.009684273000 0 162 | 0.034749053000 0 163 | 0.111600837313 5.66E-18 164 | 0.006074542087 1.92E-20 165 | 0.003914873259 1.12E-20 166 | 0.095137808677 9.70E-19 167 | 0.315195982380 0 168 | 0.012786069290 3.10E-20 169 | 0.028461589026 1.02E-18 170 | 0.008869961227 2.63E-20 171 | 0.028961587731 2.19E-18 172 | 0.007453584373 -4.40E-23 173 | 0.012647593587 7.26E-20 174 | 0.334415426505 1.71E-17 175 | 0.023100855284 4.67E-19 176 | 0.009343030845 4.09E-20 177 | 0.002130000000 0 178 | 0.003059448798 -4.34E-21 179 | 0.004186177203 8.23E-20 180 | 0.001660000000 0 181 | 0.032822244860 1.47E-19 182 | 0.104181954797 9.01E-19 183 | 0.002660593317 1.34E-20 184 | 0.004430011629 1.25E-20 185 | 0.003193103554 4.31E-20 186 | 2.504517817860 4.03E-16 187 | 0.279828696565 1.38E-15 188 | 0.004070000000 0 189 | 0.004159000000 0 190 | 0.079832000000 0 191 | 0.005909000000 0 192 | 0.004629000000 0 193 | 0.003931852642 0.00E+00 194 | 0.004039000000 0 195 | 0.004461000000 0 196 | 0.004100000000 0 197 | 0.004553527920 6.80E-21 198 | 0.003630000000 0 199 | 0.041009823581 5.25E-20 200 | 0.520954311129 1.05E-17 201 | 0.005116387644 7.00E-21 202 | 0.003354336083 2.32E-21 203 | 0.035577875500 2.20E-16 204 | 0.029772775333 8.17E-18 205 | 0.004185543937 1.07E-20 206 | 0.003559763768 1.09E-20 207 | 0.004479864047 1.63E-19 208 | 0.004091797381 8.72E-21 209 | 0.005362100549 1.78E-20 210 | 0.002380000000 0 211 | 0.004909239016 5.90E-21 212 | 0.007796776260 4.57E-20 213 | 0.001742399950 9.20E-21 214 | 0.002149912364 1.88E-20 215 | 0.003597898019 1.04E-20 216 | 0.071094897381 1.10E-19 217 | 0.003192940820 0 218 | 0.002789552424 3.32E?21 219 | 0.144073155380 2.03E-14 220 | 0.002560000000 0 221 | 0.002947108069 1.40E-20 222 | 0.004983583941 9.68E-21 223 | 0.003266186571 2.95E-21 224 | 0.003618524251 -6.58E-21 225 | 0.003625745633 1.40E-20 226 | 0.059030003218 8.63E-18 227 | 0.007645872884 2.57E-20 228 | 0.185520160479 1.80E-17 229 | 0.021507233786 4.9E-20 230 | 0.003543431439 3.70E-21 231 | 0.004200101792 0 232 | 0.002634135128 7.5E?22 233 | 0.005084173690 8.80E-21 234 | 0.003170139228 3.70E-21 235 | 0.002710000000 0 236 | 0.013138183344 9.39E-20 237 | 0.004304775550 1.89E-20 238 | 0.020732360563 4.27E-18 239 | 0.004888000000 0 240 | 0.006133166510 2.97E-20 241 | 0.003961655342 2.744E-20 242 | 0.001607401685 1.69E-20 243 | 0.064940388242 4.01E-19 244 | 0.002896215816 8.00E-21 245 | 0.003934524080 7.02E-21 246 | 0.143249900000 1.25E-14 247 | 0.005948957535 1.11E-20 248 | 0.002379878924 5.24E-21 249 | 0.004290000000 0 250 | 0.004508641745 1.27E-20 251 | 0.001990000000 0 252 | 0.007620000000 0 253 | 0.030529296149 4.99E-18 254 | 0.003726348484 2.09E-20 255 | 0.011019329069 -5.18E-20 256 | 0.016052423919 2.98E-20 257 | 0.003119226580 1.47E-20 258 | 0.002609619723 3.34E-20 259 | 0.032817859053 5.87E-20 260 | 0.002977819342 1.52E-21 261 | 0.003600000000 0 262 | 0.006907549393 9.60E-21 263 | 0.002186699772 6.64E-21 264 | 0.002290000000 0 265 | 0.005192324648 1.38E-20 266 | 1.066371071565 5.69E-16 267 | 0.003445251072 2.43E-21 268 | 0.002884226742 1.41E-20 269 | 0.002664216000 -2E-8 270 | 0.002789552424 3.32E-21 271 | 0.021507233786 4.9E-20 272 | 0.002634135128 7.5E-22 273 | 0.003961655342 2.744E-20 274 | 0.420000000000 -4E-11 275 | 0.018511822551 3.1E-20 276 | 0.001840000000 0 277 | 0.003700000000 0 278 | 0.018511822551 3.1E-20 279 | -------------------------------------------------------------------------------- /P-Pdot/MAGNETAR.txt: -------------------------------------------------------------------------------- 1 | 8.688994100000 1.99E-12 2 | 9.078388220000 4.10E-15 3 | 5.762096530000 5.82E-12 4 | 8.047000000000 6.50E-11 5 | 6.452076600000 3.81E-11 6 | 2.069833020000 2.32E-11 7 | 4.326100000000 1.70E-11 8 | 2.594578000000 0 9 | 10.610656280000 8.30E-13 10 | 11.006262400000 1.96E-11 11 | 3.824936000000 5.88E-11 12 | 3.763733080000 1.76E-11 13 | 7.555920000000 5.49E-10 14 | 5.540742829000 2.83E-12 15 | 8.437721060000 2.10E-14 16 | 7.565408400000 3.40E-12 17 | 2.482301800000 7.96E-12 18 | 11.788978400000 4.09E-11 19 | 6.971270000000 0 20 | 11.558713460000 0.00E+00 21 | 5.198346000000 9.20E-11 22 | 3.244980000000 0 23 | 6.979070970300 4.71E-13 24 | -------------------------------------------------------------------------------- /P-Pdot/MSP.txt: -------------------------------------------------------------------------------- 1 | J2129+1210D 0.004803 -1.08e-18 2 | J1750-3703C 0.026569 -9.96e-19 3 | J1910-5959B 0.008358 -7.90e-19 4 | J1748-2446C 0.008436 -6.06e-19 5 | J1801-0857A 0.007176 -5.13e-19 6 | J1910-5959E 0.004572 -4.34e-19 7 | J1701-3006B 0.003594 -3.48e-19 8 | J1748-2021B 0.016760 -3.29e-19 9 | J1701-3006A 0.005242 -1.30e-19 10 | J0024-7204L 0.004346 -1.22e-19 11 | J0024-7204S 0.002830 -1.21e-19 12 | J0024-7204W 0.002352 -8.66e-20 13 | J1801-0857C 0.003739 -6.50e-20 14 | J1701-3006C 0.007613 -6.41e-20 15 | J1748-2021C 0.006227 -5.98e-20 16 | J2140-2310A 0.011019 -5.18e-20 17 | J0024-7204C 0.005757 -4.99e-20 18 | J0024-7204I 0.003485 -4.59e-20 19 | J0024-7204G 0.004040 -4.22e-20 20 | J0024-7204M 0.003677 -3.84e-20 21 | J0024-7204Y 0.002197 -3.52e-20 22 | J1748-2446A 0.011563 -3.40e-20 23 | J0024-7204N 0.003054 -2.19e-20 24 | J1748-2021F 0.003794 -1.05e-20 25 | J0024-7204J 0.002101 -9.79e-21 26 | J1911+0101A 0.003619 -6.58e-21 27 | J0024-7201Z 0.004554 -4.54e-21 28 | J1807-2459A 0.003059 -4.34e-21 29 | J0024-7204D 0.005358 -3.42e-21 30 | J1518+0204B 0.007947 -3.33e-21 31 | J1911+0101B 0.005384 -2.00e-21 32 | J0024-7204H 0.003210 -1.83e-21 33 | J1836-2354B 0.003232 -4.80e-22 34 | J1801-3210 0.007454 -4.44e-23 35 | J2322-2650 0.003463 5.83e-22 36 | J1938+2012 0.002634 7.50e-22 37 | J0514-4002A 0.004991 1.17e-21 38 | J2229+2643 0.002978 1.52e-21 39 | J1216-6410 0.003539 1.62e-21 40 | J1327-0755 0.002678 1.77e-21 41 | J1101-6424 0.005109 1.80e-21 42 | J1910-5959C 0.005277 2.16e-21 43 | J1017-7156 0.002339 2.22e-21 44 | J1836-2354A 0.003354 2.32e-21 45 | J2317+1439 0.003445 2.43e-21 46 | J1745+1017 0.002652 2.73e-21 47 | J1552+5437 0.002428 2.80e-21 48 | J1640+2224 0.003163 2.82e-21 49 | J1544+4937 0.002159 2.93e-21 50 | J1910-5959A 0.003266 2.95e-21 51 | J1946+3417 0.003170 3.12e-21 52 | J1906+0055 0.002790 3.32e-21 53 | J0636+5129 0.002869 3.44e-21 54 | J0931-1902 0.004638 3.63e-21 55 | J1709+2313 0.004631 3.63e-21 56 | J1103-5403 0.003393 3.68e-21 57 | J1933-6211 0.003543 3.87e-21 58 | J1125-6014 0.002630 4.01e-21 59 | J2010-1323 0.005223 4.82e-21 60 | J1905+0400 0.003784 4.91e-21 61 | J0645+5158 0.008853 4.92e-21 62 | J0034-0534 0.001877 4.97e-21 63 | J0101-6422 0.002573 5.16e-21 64 | J2043+1711 0.002380 5.24e-21 65 | J1801-1417 0.003625 5.30e-21 66 | J1721-2457 0.003497 5.54e-21 67 | J1904+0451 0.006092 5.72e-21 68 | J1900+0308 0.004909 5.90e-21 69 | J1843-1448 0.005471 6.21e-21 70 | J1431-5740 0.004111 6.42e-21 71 | J2241-5236 0.002187 6.64e-21 72 | J1825-0319 0.004554 6.80e-21 73 | J1801-0857D 0.004227 6.90e-21 74 | J1023+0038 0.001688 6.93e-21 75 | J1125+7819 0.004202 6.96e-21 76 | J1835-0114 0.005116 7.00e-21 77 | J2019+2425 0.003935 7.02e-21 78 | J0340+4130 0.003299 7.05e-21 79 | J1400-1431 0.003084 7.23e-21 80 | J0557+1550 0.002556 7.35e-21 81 | J1944+2236 0.003618 7.46e-21 82 | J1723-2837 0.001856 7.54e-21 83 | J0751+1807 0.003479 7.79e-21 84 | J1737-0811 0.004175 7.93e-21 85 | J2017+0603 0.002896 7.99e-21 86 | J1719-1438 0.005790 8.04e-21 87 | J1832-0836 0.002719 8.27e-21 88 | J1713+0747 0.004570 8.53e-21 89 | J1853+1303 0.004092 8.72e-21 90 | J1943+2210 0.005084 8.79e-21 91 | J1744-1134 0.004075 8.93e-21 92 | J1955+2527 0.004873 9.12e-21 93 | J1902-5105 0.001742 9.20e-21 94 | J1600-3053 0.003598 9.50e-21 95 | J1843-1113 0.001846 9.55e-21 96 | J1923+2515 0.003788 9.56e-21 97 | J0613-0200 0.003062 9.59e-21 98 | J2236-5527 0.006908 9.60e-21 99 | J1614-2230 0.003151 9.62e-21 100 | J2322+2057 0.004808 9.66e-21 101 | J1910+1256 0.004984 9.68e-21 102 | J1446-4701 0.002195 9.81e-21 103 | J0024-7204ab 0.003705 9.82e-21 104 | J1629-6902 0.006001 1.00e-20 105 | J0030+0451 0.004865 1.02e-20 106 | J1903-7051 0.003598 1.04e-20 107 | J1844+0115 0.004186 1.07e-20 108 | J1850+0124 0.003560 1.09e-20 109 | J1227-4853 0.001686 1.11e-20 110 | J2033+1734 0.005949 1.11e-20 111 | J1658-5324 0.002439 1.12e-20 112 | J1653-2054 0.004129 1.12e-20 113 | J1751-2857 0.003915 1.12e-20 114 | J1708-3506 0.004505 1.14e-20 115 | J0023+0923 0.003050 1.14e-20 116 | J1453+1902 0.005792 1.17e-20 117 | J2234+0611 0.003577 1.20e-20 118 | J0740+6620 0.002886 1.22e-20 119 | J0610-2100 0.003861 1.24e-20 120 | J1813-2621 0.004430 1.25e-20 121 | J1421-4409 0.006386 1.27e-20 122 | J2051-0827 0.004509 1.27e-20 123 | J1747-4036 0.001646 1.31e-20 124 | J1811-2405 0.002661 1.34e-20 125 | J2302+4442 0.005192 1.38e-20 126 | J1911-1114 0.003626 1.39e-20 127 | J1909-3744 0.002947 1.40e-20 128 | J2339-0533 0.002884 1.41e-20 129 | J1431-4715 0.002012 1.41e-20 130 | J1732-5049 0.005313 1.42e-20 131 | J2214+3000 0.003119 1.47e-20 132 | J0711-6830 0.005491 1.49e-20 133 | J1603-7202 0.014842 1.56e-20 134 | J1543-5149 0.002057 1.62e-20 135 | J1959+2048 0.001607 1.69e-20 136 | J1911+1347 0.004626 1.69e-20 137 | J1012+5307 0.005256 1.71e-20 138 | J1944+0907 0.005185 1.73e-20 139 | J0614-3329 0.003149 1.75e-20 140 | J1045-4509 0.007474 1.77e-20 141 | J0337+1715 0.002733 1.77e-20 142 | J1857+0943 0.005362 1.78e-20 143 | J0024-7204X 0.004772 1.84e-20 144 | J1643-1224 0.004622 1.85e-20 145 | J1024-0719 0.005162 1.86e-20 146 | J1342+2822B 0.002389 1.86e-20 147 | J1514-4946 0.003589 1.86e-20 148 | J1903+0327 0.002150 1.88e-20 149 | J1950+2414 0.004305 1.89e-20 150 | J1552-4937 0.006284 1.90e-20 151 | J1750-3703B 0.006075 1.92e-20 152 | J2234+0944 0.003627 2.01e-20 153 | J1730-2304 0.008123 2.02e-20 154 | J2124-3358 0.004931 2.06e-20 155 | J2129-5721 0.003726 2.09e-20 156 | J1311-3430 0.002560 2.10e-20 157 | J1231-1411 0.003684 2.28e-20 158 | J2129+1210H 0.006743 2.40e-20 159 | J1738+0333 0.005850 2.41e-20 160 | J1455-3330 0.007987 2.43e-20 161 | J1435-6100 0.009348 2.45e-20 162 | J1337-6423 0.009423 2.47e-20 163 | J1731-1847 0.002345 2.54e-20 164 | J1918-0642 0.007646 2.57e-20 165 | J1518+0204C 0.002484 2.61e-20 166 | J1757-5322 0.008870 2.63e-20 167 | J1529-3828 0.008486 2.70e-20 168 | J1957+2516 0.003962 2.74e-20 169 | J1405-4656 0.007602 2.79e-20 170 | J1955+2908 0.006133 2.97e-20 171 | J2145-0750 0.016052 2.98e-20 172 | J1048+2339 0.004665 3.00e-20 173 | J1741+1351 0.003747 3.02e-20 174 | J0024-7204O 0.002643 3.03e-20 175 | J1914+0659 0.018512 3.10e-20 176 | J1755-3716 0.012786 3.11e-20 177 | J2129+1210F 0.004027 3.20e-20 178 | J2215+5135 0.002610 3.34e-20 179 | J0024-7204Q 0.004033 3.40e-20 180 | J1804-2717 0.009343 4.09e-20 181 | J1518+0204A 0.005554 4.12e-20 182 | J1816+4510 0.003193 4.31e-20 183 | J1022+1001 0.016453 4.33e-20 184 | J0721-2038 0.015542 4.40e-20 185 | J1901+0300 0.007797 4.57e-20 186 | J0621+1002 0.028854 4.73e-20 187 | J0900-3144 0.011110 4.89e-20 188 | J1933+1726 0.021507 4.90e-20 189 | J1725-3853 0.004792 5.00e-20 190 | J1545-4550 0.003575 5.25e-20 191 | J0437-4715 0.005757 5.73e-20 192 | J1622-6617 0.023623 5.88e-20 193 | J1125-5825 0.003102 6.09e-20 194 | J1056-7117 0.026310 6.30e-20 195 | J0024-7204F 0.002624 6.45e-20 196 | J1038+0032 0.028852 6.70e-20 197 | J1802-2124 0.012648 7.26e-20 198 | J0218+4232 0.002323 7.74e-20 199 | J0407+1607 0.025702 7.90e-20 200 | J1807-2459B 0.004186 8.23e-20 201 | J1745-0952 0.019376 9.25e-20 202 | J1949+3106 0.013138 9.39e-20 203 | J0024-7204U 0.004343 9.52e-20 204 | J0024-7204E 0.003536 9.85e-20 205 | J1939+2134 0.001558 1.05e-19 206 | J1300+1240 0.006219 1.14e-19 207 | J1701-3006D 0.003418 1.26e-19 208 | J1525-5545 0.011360 1.31e-19 209 | J1439-5501 0.028635 1.42e-19 210 | J0024-7204R 0.003480 1.48e-19 211 | J1913+1102 0.027285 1.61e-19 212 | J1850+0242 0.004480 1.63e-19 213 | J1740-5340A 0.003650 1.68e-19 214 | J2053+4650 0.012586 1.72e-19 215 | J2129+1210E 0.004651 1.78e-19 216 | J1757-27 0.017687 2.10e-19 217 | J1701-3006F 0.002295 2.22e-19 218 | J1727-2946 0.027083 2.46e-19 219 | J0024-7204T 0.007588 2.94e-19 220 | J0214+5222 0.024575 2.99e-19 221 | J1701-3006E 0.003234 3.10e-19 222 | J1748-2021E 0.016264 3.12e-19 223 | J1502-6752 0.026744 3.15e-19 224 | J1804-0735 0.023101 4.67e-19 225 | J1750-3703D 0.005140 4.93e-19 226 | J1748-2021D 0.013496 5.87e-19 227 | J0024-7204P 0.003643 6.64e-19 228 | J1623-2631 0.011076 6.71e-19 229 | J2007+2722 0.024497 9.61e-19 230 | J1910-5959D 0.009035 9.64e-19 231 | J1756-2251 0.028462 1.02e-18 232 | J1824-2452A 0.003054 1.62e-18 233 | J0737-3039A 0.022699 1.76e-18 234 | J1801-0857B 0.028962 2.19e-18 235 | J1757-1854 0.021497 2.63e-18 236 | J1823-3021A 0.005440 3.38e-18 237 | J1952+2630 0.020732 4.27e-18 238 | J1841+0130 0.029773 8.17e-18 239 | J0537-6910 0.016122 5.18e-14 240 | -------------------------------------------------------------------------------- /P-Pdot/RRAT.txt: -------------------------------------------------------------------------------- 1 | 1.390000000000 0 2 | 0.354304000000 0 3 | 1.349184471846 5.51E-15 4 | 2.056210000000 0 5 | 1.878500000000 0 6 | 2.188190000000 0 7 | 1.073930000000 0 8 | 1.745000000000 0 9 | 2.180000000000 0 10 | 1.241421391299 5.48E-16 11 | 4.862940000000 0 12 | 5.977492737000 1.20E-13 13 | 1.526085076000 3.59E-15 14 | 0.586778418380 0 15 | 1.723700000000 0 16 | 1.508800000000 0 17 | 1.231290000000 0 18 | 0.358161000000 0 19 | 1.062880000000 0 20 | 2.343480000000 0 21 | 6.355000000000 0 22 | 6.192997000000 0 23 | 3.651200000000 0 24 | 2.642198513200 1.26E-14 25 | 1.106400000000 0 26 | 1.427000000000 0 27 | 0.947903000000 0 28 | 4.758575567900 1.85E-14 29 | 1.046117156733 8.53E-15 30 | 0.364835000000 0 31 | 3.449384953320 6.89E-15 32 | 0.737500000000 0 33 | 0.125229558403 2.29E-15 34 | 0.503000000000 0 35 | 1.296870000000 0 36 | 0.212316409210 1.29E-16 37 | 7.707183007000 9.50E-15 38 | 0.545359720000 0 39 | 6.443000000000 0 40 | 0.237480000000 0 41 | 5.763777003000 1.17E-14 42 | 3.901000000000 0 43 | 3.357000000000 0 44 | 1.421990000000 0 45 | 0.405454000000 0 46 | 0.666804000000 0 47 | 1.320490000000 0 48 | 2.764194869750 4.99E-15 49 | 4.263164032900 5.75E-13 50 | 1.271200000000 0 51 | 0.770620171033 8.78E-15 52 | 0.931900000000 0 53 | 6.597562622700 6.33E-15 54 | 4.476722539800 1.61E-13 55 | 6.795300000000 0 56 | 1.383965000000 0 57 | 4.557820096200 1.45E-13 58 | 3.453200000000 4.52E-15 59 | 0.741761952452 3.22E-15 60 | 6.940000000000 0 61 | 0.923390558580 8.68E-15 62 | 2.177000000000 0 63 | 2.081343459724 1.71E-15 64 | 3.885800000000 0 65 | 0.403000000000 0 66 | 0.409135000000 0 67 | 4.729000000000 0 68 | 0.260014400000 0 69 | 4.634000000000 0 70 | 5.013398000630 1.01E-14 71 | 2.304878837660 5.22E-15 72 | 0.940000000000 0 73 | 1.944700000000 0 74 | 0.868735115025 1.03E-15 75 | -------------------------------------------------------------------------------- /P-Pdot/XDINS.txt: -------------------------------------------------------------------------------- 1 | 3.453004027000 2.76E-14 2 | 8.391115532000 6.98E-14 3 | 11.370385930000 5.60E-14 4 | 10.312522060000 1.12E-13 5 | 6.880000000000 0 6 | 0.173263836028 1.50E-15 7 | 7.055202870000 2.98E-14 8 | 9.428228880000 4.10E-14 9 | -------------------------------------------------------------------------------- /P-Pdot/fast.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NAOC-pulsar/PeiWang-code/6a01f92ec9f1a32d2c203c8b8dd6955a208af330/P-Pdot/fast.xlsx -------------------------------------------------------------------------------- /P-Pdot/p-pdot.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import numpy as np 3 | import matplotlib.pyplot as plt 4 | import xlrd 5 | 6 | xdins=[l.replace('E','e').replace('?','-') for l in open('XDINS.txt')] 7 | #fast=[l.replace('E','e').replace('?','-') for l in open('fast.txt')] 8 | magnetar=[l.replace('E','e').replace('?','-') for l in open('MAGNETAR.txt')] 9 | normal=[l.replace('E','e').replace('?','-') for l in open('NORMAL.txt')] 10 | rrat=[l.replace('E','e').replace('?','-') for l in open('RRAT.txt')] 11 | binary=[l.replace('E','e').replace('?','-') for l in open('BINARY.txt')] 12 | msp=[l.replace('E','e').replace('?','-') for l in open('MSP.txt')] 13 | fast=xlrd.open_workbook('fast.xlsx') 14 | xls_sheet0 = fast.sheets()[0] 15 | xls_sheet1 = fast.sheets()[1] 16 | 17 | p1=[float(l.split()[0])for l in binary] 18 | pdot1=[float(l.split()[1])for l in binary] 19 | p2=[float(l.split()[0])for l in magnetar] 20 | pdot2=[float(l.split()[1])for l in magnetar] 21 | p3=[float(l.split()[0])for l in normal] 22 | pdot3=[float(l.split()[1])for l in normal] 23 | p4=[float(l.split()[0])for l in rrat] 24 | pdot4=[float(l.split()[1])for l in rrat] 25 | p5=[float(l.split()[0])for l in xdins] 26 | pdot5=[float(l.split()[1])for l in xdins] 27 | p6=[float(l.split()[1])for l in msp] 28 | pdot6=[float(l.split()[2])for l in msp] 29 | p7=np.array(xls_sheet0.col_values(1))/1000 30 | pdot7=xls_sheet0.col_values(2) 31 | p8=np.array(xls_sheet1.col_values(1))/1000 32 | pdot8=xls_sheet1.col_values(2) 33 | 34 | p=np.arange(0.001,20,0.1) 35 | B1=3.2**-2*1e-10/p 36 | B2=3.2**-2*1e-14/p 37 | B3=3.2**-2*1e-18/p 38 | B4=3.2**-2*1e-22/p 39 | N1=1.585*1e-12*p 40 | N2=1.585*1e-14*p 41 | N3=1.585*1e-16*p 42 | N4=1.585*1e-18*p 43 | E1=1e8*(p**3*1e15)/(3.95*1e31) 44 | E2=1e7*(p**3*1e15)/(3.95*1e31) 45 | E3=1e6*(p**3*1e15)/(3.95*1e31) 46 | E4=1e5*(p**3*1e15)/(3.95*1e31) 47 | E5=1e4*(p**3*1e15)/(3.95*1e31) 48 | E6=1e3*(p**3*1e15)/(3.95*1e31) 49 | E7=1e2*(p**3*1e15)/(3.95*1e31) 50 | E8=1e1*(p**3*1e15)/(3.95*1e31) 51 | E9=1e0*(p**3*1e15)/(3.95*1e31) 52 | 53 | fig=plt.figure() 54 | ax=fig.add_subplot(111) 55 | ax.set_xscale("log") 56 | ax.set_yscale("log") 57 | ax.set_ylim(5e-22,1e-3) 58 | ax.set_xlim(1e-3,20) 59 | 60 | l1=ax.scatter(p1,pdot1,c='r',marker='o',alpha=0.5,cmap=plt.cm.Blues,edgecolor='none',label='BINARY',s=40) 61 | l2=ax.scatter(p2,pdot2,c='b',marker='^',alpha=0.5,cmap=plt.cm.Blues,edgecolor='none',label='MAGNETAR',s=50) 62 | l3=ax.scatter(p3,pdot3,c='k',marker='.',alpha=0.7,cmap=plt.cm.Blues,edgecolor='none',label='NORMAL',s=20) 63 | l4=ax.scatter(p4,pdot4,c='g',marker='s',alpha=0.6,cmap=plt.cm.Blues,edgecolor='none',label='RRAT',s=50) 64 | l5=ax.scatter(p5,pdot5,c='c',marker='*',alpha=0.5,cmap=plt.cm.Blues,edgecolor='none',label='XDINS',s=60) 65 | l6=ax.scatter(p6,pdot6,c='',marker='o',alpha=0.5,cmap=plt.cm.Blues,label='MSP',s=20) 66 | l6dot=ax.scatter(p6,pdot6,c='k',marker='.',alpha=0.5,cmap=plt.cm.Blues,edgecolor='none',s=20) 67 | l7=ax.scatter(p7,pdot7,c='m',marker='_',alpha=0.6,cmap=plt.cm.Blues,edgecolor='m',linewidths=1,label='FAST(upper_limit)',s=150) 68 | l8=ax.scatter(p8,pdot8,c='w',marker='*',alpha=1,cmap=plt.cm.Blues,edgecolor='m',linewidths=2.5,label='FAST(timing)',s=150) 69 | 70 | ax.plot(p,B1,'--k',alpha=0.5) #B=10^14Gauss 71 | ax.plot(p,B2,'--k',alpha=0.5) #B=10^12Gauss 72 | ax.plot(p,B3,'--k',alpha=0.5) #B=10^10Gauss 73 | ax.plot(p,B4,'--k',alpha=0.5) #B=10^8Gauss 74 | ax.plot(p,N1,':k',alpha=0.5) #T=10^4yr 75 | ax.plot(p,N2,':k',alpha=0.5) #T=10^6yr 76 | ax.plot(p,N3,':k',alpha=0.5) #T=10^8yr 77 | ax.plot(p,N4,':k',alpha=0.5) #T=10^10yr 78 | ax.plot(p,E1,'-.r',alpha=0.9) #Edot=10^38erg/s 79 | ax.plot(p,E2,'-.r',alpha=0.9) #Edot=10^37erg/s 80 | ax.plot(p,E3,'-.r',alpha=0.9) #Edot=10^36erg/s 81 | ax.plot(p,E4,'-.r',alpha=0.9) #Edot=10^35erg/s 82 | ax.plot(p,E5,'-.r',alpha=0.9) #Edot=10^34erg/s 83 | ax.plot(p,E6,'-.r',alpha=0.9) #Edot=10^33erg/s 84 | ax.plot(p,E7,'-.r',alpha=0.9) #Edot=10^32erg/s 85 | ax.plot(p,E8,'-.r',alpha=0.9) #Edot=10^31erg/s 86 | ax.plot(p,E9,'-.r',alpha=0.9) #Edot=10^30erg/s 87 | 88 | ax.text(0.0012,1e-8, r'$B_s = 10^{14} G$',alpha=0.8, rotation=-8) 89 | ax.text(0.0011,1e-12, r'$10^{12} G$',alpha=0.8, rotation=-8) 90 | ax.text(0.0011,1e-16, r'$10^{10} G$',alpha=0.8, rotation=-8) 91 | ax.text(0.0011,1e-20, r'$10^{8} G$',alpha=0.8, rotation=-8) 92 | ax.text(0.007,3e-14, r'$\tau$ = $10000 yr$',alpha=0.9, rotation=9) 93 | ax.text(0.01,3e-16, r'$10^6 yr$',alpha=0.9, rotation=9) 94 | ax.text(0.01,3e-18, r'$10^8 yr$',alpha=0.9, rotation=9) 95 | ax.text(0.01,0.9e-20, r'$10^{10} yr$',alpha=0.9, rotation=9) 96 | ax.text(6,6e-6, r'$\dot{E}$ = $10^{38} erg/s$',color='r',alpha=0.9, rotation=30) 97 | ax.text(10,7e-8, r'$10^{36}$',color='r',alpha=0.9, rotation=30) 98 | ax.text(10,7e-10, r'$10^{34}$',color='r',alpha=0.9, rotation=30) 99 | ax.text(10,7e-12, r'$10^{32}$',color='r',alpha=0.9, rotation=30) 100 | ax.text(10,7e-14, r'$10^{30}$',color='r',alpha=0.9, rotation=30) 101 | ax.legend(handles = [l1,l2,l3,l4,l5,l6,l7,l8], labels = [], loc = 'upper left') 102 | plt.annotate('Upper limit', xy=(0.2, 1e-9), xytext=(0.2, 1e-7), alpha=0.2, color='m', arrowprops=dict(facecolor='m', alpha=0.2, edgecolor='none', shrink=50)) 103 | plt.xlabel('Rotation Period (s)') 104 | plt.ylabel('dP/dt (s/s)') 105 | plt.show() 106 | -------------------------------------------------------------------------------- /PSRCAT_matching/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NAOC-pulsar/PeiWang-code/6a01f92ec9f1a32d2c203c8b8dd6955a208af330/PSRCAT_matching/.DS_Store -------------------------------------------------------------------------------- /PSRCAT_matching/DataList: -------------------------------------------------------------------------------- 1 | PM0056_00861_ACCEL_50_10_ACCEL_Cand_5.pfd.png 289.6960525 15.66966806 11.400452 35 2 | PM0056_00861_ACCEL_50_5_ACCEL_Cand_4.pfd.png 289.6960525 15.66966806 164.763834 217 3 | PM0056_00861_ACCEL_50_6_ACCEL_Cand_1.pfd.png 289.6960525 15.66966806 136.060119 459 4 | PM0056_00861_ACCEL_50_8_ACCEL_Cand_6.pfd.png 289.6960525 15.66966806 20.000467 28 5 | PM0056_008C1_ACCEL_50_11_ACCEL_Cand_1.pfd.png 289.42763 16.08632583 187.994182 399 6 | PM0056_008C1_ACCEL_50_12_ACCEL_Cand_9.pfd.png 289.42763 16.08632583 961.943615 36.5 7 | PM0056_008C1_ACCEL_50_13_ACCEL_Cand_3.pfd.png 289.42763 16.08632583 780.697855 243 8 | PM0056_008C1_ACCEL_50_14_ACCEL_Cand_14.pfd.png 289.42763 16.08632583 13.183977 43 9 | PM0056_008C1_ACCEL_50_15_ACCEL_Cand_10.pfd.png 289.42763 16.08632583 8.36537 51 10 | PM0056_008C1_ACCEL_50_16_ACCEL_Cand_12.pfd.png 289.42763 16.08632583 291.909372 22 11 | -------------------------------------------------------------------------------- /PSRCAT_matching/matching.list: -------------------------------------------------------------------------------- 1 | file Jname DELTA_(deg) DELTA_P0(ms) DELTA_DM Num of Harm. 2 | PM0056_00861_ACCEL_50_8_ACCEL_Cand_6.pfd.png J1910+1256 3.47 -.016 (.3%) 10.07 L 4 3 | PM0056_00861_ACCEL_50_8_ACCEL_Cand_6.pfd.png J1911+1347 2.54 -.374 (8.0%) 2.99 L 4 4 | PM0056_008C1_ACCEL_50_14_ACCEL_Cand_14.pfd.png J1911+1347 2.71 .232 (5.0%) -12.01 L 3 5 | PM0056_008C1_ACCEL_50_14_ACCEL_Cand_14.pfd.png J1917+1353 2.18 -.208 (.1%) 51.54 H 15 6 | PM0056_008C1_ACCEL_50_15_ACCEL_Cand_10.pfd.png J1911+1347 2.71 .444 (9.5%) -20.01 L 2 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Codes from Pei Wang 2 | -------------------------------------------------------------------------------- /Timing/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NAOC-pulsar/PeiWang-code/6a01f92ec9f1a32d2c203c8b8dd6955a208af330/Timing/.DS_Store -------------------------------------------------------------------------------- /Timing/.FTp_stt_mod_19beams.sh.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NAOC-pulsar/PeiWang-code/6a01f92ec9f1a32d2c203c8b8dd6955a208af330/Timing/.FTp_stt_mod_19beams.sh.swp -------------------------------------------------------------------------------- /Timing/FTp_SMJD_OFFS_mod.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | . ~/.bashrc 3 | 4 | ###### NOTES for FAST Timing (FTp smjd_offset) ###### 5 | ##################################################### 6 | # 7 | # FTplist.txt is the only-one input-file which is xxx.FTp file list. 8 | # The FTp and RAW_fits files must be included in the same folder when code running. 9 | # 10 | # (The cutted Fits files seems lost the smjd_offset(NSUBOFFS) in header1, so use RAW_fits as input safely.) 11 | # 12 | ##################################################### 13 | 14 | line=1 15 | cat FTplist.txt | while read FNAME; do 16 | NUM=`cat FTplist.txt | wc -l` 17 | 18 | VAP=`vap -c stt_imjd,stt_smjd,stt_offs ${FNAME} | grep FTp` 19 | 20 | Filename=`echo ${VAP} | awk '{print $1}'` 21 | Fitsname=`echo ${Filename} | sed "s/\_tot/ /" | awk '{print $1}'` 22 | IMJD=`echo ${VAP} | awk '{print $2}'` 23 | SMJD=`echo ${VAP} | awk '{print $3}'` 24 | OFFS=`echo ${VAP} | awk '{print $4}'` 25 | 26 | python - ${Fitsname}.fits < temp.dat 27 | #!/usr/bin/env python 28 | import numpy as np 29 | import pyfits 30 | import sys 31 | 32 | name=sys.argv[1] 33 | hdulist = pyfits.open(name) 34 | hdu0 = hdulist[0] 35 | header0 = hdu0.header 36 | hdu1 = hdulist[1] 37 | header1 = hdu1.header 38 | 39 | stt_imjd = header0['STT_IMJD'] 40 | stt_smjd = header0['STT_SMJD'] 41 | stt_offt = header0['STT_OFFS'] 42 | Offset = header1['NSUBOFFS'] 43 | Sample = header1['NSBLK'] 44 | Tbins = header1['TBIN'] 45 | 46 | # int and reminder number are splited in smjd and offs. 47 | 48 | temp_smjd = stt_smjd+(np.float64(Offset)*np.float64(Sample)*np.float64(Tbins)) 49 | mod_smjd = int(temp_smjd) 50 | rem_smjd = np.float64(temp_smjd) - mod_smjd 51 | mod_offs = stt_offt+rem_smjd 52 | if (mod_offs > 1): 53 | mod_smjd = mod_smjd + int(mod_offs) 54 | mod_offs = mod_offs - int(mod_offs) 55 | print stt_imjd, mod_smjd, mod_offs, Offset 56 | EOF 57 | 58 | Fits_imjd=`cat temp.dat | awk '{print $1}'` 59 | Fmod_smjd=`cat temp.dat | awk '{print $2}'` 60 | Fits_offs=`cat temp.dat | awk '{print $3}'` 61 | Offsetsub=`cat temp.dat | awk '{print $4}'` 62 | echo "" 63 | echo "${line}/${NUM} Offset ${Offsetsub}Subints for ${Filename}" 64 | echo "FTp input : imjd=${IMJD} smjd=${SMJD} offs=${OFFS}" 65 | echo "Mod output: imjd=${Fits_imjd} smjd=${Fmod_smjd} offs=${Fits_offs}" 66 | echo "" 67 | psredit -c ext:stt_smjd="${Fmod_smjd}",ext:stt_offs="${Fits_offs}" -m ${FNAME} 68 | 69 | rm temp.dat 70 | ((line++)) 71 | done 72 | -------------------------------------------------------------------------------- /Timing/FTp_stt_mod_19beams.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | . ~/.bashrc 3 | 4 | ###### NOTES for FAST Timing (FTp smjd_offset) ###### 5 | ##################################################### 6 | # 7 | # FTplist.txt is the only-one input-file which is xxx.FTp file list. 8 | # The FTp and RAW_fits files must be included in the same folder when code running. 9 | # 10 | # (The cutted Fits files seems lost the smjd_offset(NSUBOFFS) in header1, so use RAW_fits as input safely.) 11 | # 12 | ##################################################### 13 | 14 | line=1 15 | cat FTplist.txt | while read FNAME; do 16 | NUM=`cat FTplist.txt | wc -l` 17 | 18 | VAP=`vap -c stt_imjd,stt_smjd,stt_offs ${FNAME} | grep FTp` 19 | 20 | Filename=`echo ${VAP} | awk '{print $1}'` 21 | Fitsname=`echo ${Filename} | sed "s/\.FTp/ /" | awk '{print $1}'` 22 | IMJD=`echo ${VAP} | awk '{print $2}'` 23 | SMJD=`echo ${VAP} | awk '{print $3}'` 24 | OFFS=`echo ${VAP} | awk '{print $4}'` 25 | 26 | python - ${Fitsname} < temp.dat 27 | #!/usr/bin/env python 28 | import numpy as np 29 | import pyfits 30 | import sys 31 | 32 | name=sys.argv[1] 33 | hdulist = pyfits.open(name) 34 | hdu0 = hdulist[0] 35 | header0 = hdu0.header 36 | hdu1 = hdulist[1] 37 | header1 = hdu1.header 38 | 39 | stt_imjd = header0['STT_IMJD'] 40 | stt_smjd = header0['STT_SMJD'] 41 | stt_offt = header0['STT_OFFS'] 42 | Offset = header1['NSUBOFFS'] 43 | Sample = header1['NSBLK'] 44 | Tbins = header1['TBIN'] 45 | 46 | # int and reminder number are splited in smjd and offs. 47 | 48 | #temp_smjd = stt_smjd+(np.float64(Offset)*np.float64(Sample)*np.float64(Tbins)) 49 | #mod_smjd = int(temp_smjd) 50 | #rem_smjd = np.float64(temp_smjd) - mod_smjd 51 | #mod_offs = stt_offt+rem_smjd 52 | #if (mod_offs > 1): 53 | # mod_smjd = mod_smjd + int(mod_offs) 54 | # mod_offs = mod_offs - int(mod_offs) 55 | #print stt_imjd, mod_smjd, mod_offs, Offset 56 | print stt_imjd, stt_smjd, stt_offt, Offset 57 | EOF 58 | 59 | Fits_imjd=`cat temp.dat | awk '{print $1}'` 60 | Fmod_smjd=`cat temp.dat | awk '{print $2}'` 61 | Fits_offs=`cat temp.dat | awk '{print $3}'` 62 | Offsetsub=`cat temp.dat | awk '{print $4}'` 63 | echo "" 64 | # echo "${line}/${NUM} Offset ${Offsetsub}Subints for ${Filename}" 65 | echo "${line}/${NUM} update for ${Filename}" 66 | echo "FTp input : imjd=${IMJD} smjd=${SMJD} offs=${OFFS}" 67 | echo "Mod output: imjd=${Fits_imjd} smjd=${Fmod_smjd} offs=${Fits_offs}" 68 | echo "" 69 | psredit -c ext:stt_smjd="${Fmod_smjd}",ext:stt_offs="${Fits_offs}" -m ${FNAME} 70 | 71 | rm temp.dat 72 | ((line++)) 73 | done 74 | -------------------------------------------------------------------------------- /Timing/FTplist.txt: -------------------------------------------------------------------------------- 1 | FP20180107_0-1GHz_J1713+0747_tracking_0010_tot_1160_3207_0_31.fits_mod.FTp 2 | FP20180107_0-1GHz_J1713+0747_tracking_0011_tot_1160_3207_0_31.fits_mod.FTp 3 | -------------------------------------------------------------------------------- /Timing/George_timing_pipeline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NAOC-pulsar/PeiWang-code/6a01f92ec9f1a32d2c203c8b8dd6955a208af330/Timing/George_timing_pipeline.png -------------------------------------------------------------------------------- /Timing/stt_offs_check.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | #!/usr/bin/env python 3 | import numpy as np 4 | import pyfits 5 | import sys 6 | #新建filelist.txt文件列表和输出文本output1.txt, output2.txt 7 | 8 | output1 = [] 9 | output2 = [] 10 | filename = np.genfromtxt('filelist.txt',dtype='|S50') 11 | print(filename) 12 | lines = np.shape(filename)[0]-1 13 | print(lines-1) 14 | 15 | hdulist = pyfits.open(filename[0]) 16 | hdu0 = hdulist[0] 17 | header0 = hdu0.header 18 | hdu1 = hdulist[1] 19 | header1 = hdu1.header 20 | imjd0 = header0['STT_IMJD'] 21 | smjd0 = header0['STT_SMJD'] 22 | offt0 = header0['STT_OFFS'] 23 | Offset0 = header1['NSUBOFFS'] 24 | 25 | for line in np.linspace(0,lines,lines): 26 | num = np.int(line) 27 | hdulist = pyfits.open(filename[num]) 28 | hdu0 = hdulist[0] 29 | header0 = hdu0.header 30 | hdu1 = hdulist[1] 31 | header1 = hdu1.header 32 | imjd = header0['STT_IMJD'] 33 | smjd = header0['STT_SMJD'] 34 | offt = header0['STT_OFFS'] 35 | Offset = header1['NSUBOFFS'] 36 | #Sample = header1['NSBLK'] 37 | #Tbins = header1['TBIN'] 38 | Offset1 = Offset - 64*num 39 | if imjd == imjd0 and smjd == smjd0 and offt == offt0 and Offset1 == Offset0 : 40 | datwritf=file('output1.txt','a') 41 | datwritf.write(str(filename[num])+' '+str(imjd)+' '+str(smjd)+' '+str(offt)+' '+str(Offset)+'\n') 42 | else: 43 | datwritf1=file('output2.txt','a') 44 | datwritf1.write(str(filename[num])+' '+str(imjd)+' '+str(smjd)+' '+str(offt)+' '+str(Offset)+'\n') 45 | -------------------------------------------------------------------------------- /Timing/脉冲星计时流程wangpei.txt: -------------------------------------------------------------------------------- 1 | 2 | =============================== 3 | FAST脉冲星计时(Timing)操作流程 4 | =============================== 5 | 6 | (对于跟踪数据,可对单次连续观测多个观测文件计时,也可采用多天多次的数据进行较长时间跨度计时;对于漂移扫描观测,只能采用多天多次的数据计时。) 7 | 8 | 9 | 所需软件:Shell、Python、Psrcat、Dspsr、Psrchive、Tempo2,及Pgplot、py库等配合程序。 10 | 11 | 软件准备: 12 | 13 | - 计时处理软件的站点信息添加: 14 | 添加到$TEMPO2/observatory/observatories.dat的最后一行,但目前值为手机GPS测量的望远镜坐标原点,并不准确,以后还依赖VLBI测量。目前至少馈源高度的百米差值在ToA上表现为10^-6s的钟差。 15 | ###For FAST Temporarily ##### 16 | -166850.0 5506860.0 2744940.0 FAST fast 17 | 18 | - 计时处理软件的时钟修正添加:(毫微秒级) 19 | 测时还需 Tempo2 中添加对站点时钟的修正,在$TEMPO2/clock/目录,添加 fast2gps.clk 文件。在 par 文件中添加: CLK_CORR_CHAIN fast2gps.clk, gps2utc.clk,utc2tai.clk, tai2tt_tai.clk 20 | 21 | 22 | ———————————————————————————————————————————————————————————————————————————————— 23 | 24 | 1. 根据观测日志统计已观测脉冲星的时间和次数(跟踪观测和漂移扫描均可),确保数据集中有对应文件,0-1GHz既可。 25 | 26 | 2. 挑出包含脉冲星的数据文件。对跟踪数据,任一文件都包含脉冲星信号。对漂移扫描,使用源到达程序“FAST_source_arrival_time”计算源到达中天时刻,并找到相应的数据。 27 | 28 | 3. 在集群个人账户内,根据源名称建文件夹,文件夹内使用ln -s链接对应脉冲星数据文件。 29 | 30 | 4. 使用切文件程序“cut.sh和cut_FASTpsrfits_freq_time_splitpol.py”对数据的频率范围,按照接收机和干扰情况进行批量切割,进行预处理并输出新fits。 31 | 32 | 5. 根据源折叠参数(P0、DM),使用fold.sh在同层目录对*fits进行dspsr折叠和psrchive消干扰和频率、时间积分,产生.FTp脉冲轮廓文件。如果轮廓信噪比不高,使用Pdmp优化折叠参数(P0、DM)后,进行再次批量折叠,最优化脉冲轮廓。 33 | 34 | 6. 使用pav -D *FTp检查平均脉冲轮廓,删除无信号的fits、ar、arz、FTp文件。 35 | 36 | 7. 对FTp文件进行时间补偿,ls *FTp > FTplist.txt, 运行Modmjd.sh更新FTp文件的stt_imjd,stt_smjd,stt_offs时间变量。 37 | 38 | 8. 选取最大信噪比脉冲轮廓FTp作为计算ToA模板:cp xxx.FTp xxx.std 39 | 40 | 9. 产生计时源的星历psrcat -e2 xxx > xxx.par,删除par中误差等多余信息,对于新脉冲星可直接编写par。 41 | 42 | 10. 计算每个FTp文件的脉冲到达时间ToA,以Tempo2格式输出:pat -f “tempo2 i” -s xxx.std *FTp > xxx.tim 43 | 44 | 11. 使用Tempo2做参数拟合残差分布,给出计时结果:tempo2 -gr plk -f xxx.par xxx.tim (需要图形界面Xwindow) 45 | 46 | 12. 得到残差为白噪声的new.par文件,使用psradd命令 把好数据.FT 文件(按照new.par参数)连接,得到new.std,再用pam命令把new.std叠加得到总积分轮廓。 47 | psradd -F -E new.par `std.txt` -o new.std 48 | 其中std.txt 的内容就是 那些好数据的文件名,多个.FTp文件名。 49 | pam -DFTp -m new.std 50 | 51 | 13. 通过残差拟合更新par文件,重新折叠,产生ToA后再次运行Tempo2计时,直到结果无法进一步改善。 52 | 53 | 54 | * 对于计时调试阶段需,首先检查单次连续观测多个观测文件整秒补偿stt_offs的一致性:vap -c stt_imjd,stt_smjd,stt_offs *.arz。 55 | ** 完成结果后,尽量删除ar,仅保留FTp,arz文件,节省存储空间。 56 | 57 | -------------------------------------------------------------------------------- /beamWeighting/Beam_weighting.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import numpy as np 3 | import fitsio 4 | import sys 5 | import math 6 | #import commands 7 | #from astropy.io import fits 8 | #from astropy.table import Table 9 | 10 | 11 | 12 | #--------------- 13 | #beam weight 14 | def beamWeight(filename, scale, percent, flag, plotset): 15 | #settings 16 | C = 299794580.0 17 | D = 300.0 18 | #Pi = 3.141592654 19 | Pi = math.pi 20 | Omega = 2.*Pi/3600./24. 21 | Filename = filename 22 | Scale = scale 23 | Percent = percent 24 | Flag = flag 25 | 26 | #read file 27 | hdulist = fitsio.FITS(Filename, 'rw') 28 | hdu1 = hdulist[1] 29 | hdu0 = hdulist[0] 30 | header1 = hdu1.read_header() 31 | header0 = hdu0.read_header() 32 | data1=hdulist[1][:] 33 | Time_subint = header1['TBIN']*header1['NSBLK'] 34 | Freq_chann = header1['CHAN_BW'] 35 | Freq_start = header0['OBSFREQ']-(header0['OBSNCHAN']/2.)*Freq_chann 36 | 37 | Nsub = np.array(data1['DAT_WTS']).shape[0] 38 | Nchan = np.array(data1['DAT_WTS']).shape[1] 39 | Tau = round(Time_subint * Nsub * Percent) 40 | Weight = np.zeros((Nsub,Nchan)) 41 | 42 | for isub in range(0,Nsub): 43 | Time = Time_subint * isub 44 | for ichan in range(0,Nchan): 45 | Freq = Freq_start + ichan*Freq_chann 46 | if (Flag == 1): 47 | Weight[isub,ichan] = 1 48 | else : 49 | Eta = -2.*Pi*Omega*(Time-Tau)/(1.22*(C/Freq/1000000.)/D) 50 | Weight[isub,ichan] = Scale*(math.sin(Eta)/Eta)**2. 51 | # Weight[isub,ichan] = Scale*math.cos(Dec*2.*Pi/360.)*(math.sin(Eta)/Eta)**2. 52 | print Weight.shape 53 | if (Flag == 1): 54 | Dat_wts = Weight 55 | else : 56 | Dat_wts = data1['DAT_WTS']*Weight 57 | hdu1.write_column('DAT_WTS', Dat_wts) 58 | hdulist.close() 59 | print 'DAT_WTS[',int(Nsub*Percent),',',Nchan,']=', data1['DAT_WTS'][int(Nsub*Percent),Nchan-1], '->', Dat_wts[int(Nsub*Percent),Nchan-1] 60 | print 'DAT_WTS[',Nsub,',',Nchan,']=', data1['DAT_WTS'][Nsub-1,Nchan-1], '->', Dat_wts[Nsub-1,Nchan-1] 61 | if (plotset == 1): 62 | plotWeight(Nsub, Nchan, Dat_wts) 63 | 64 | 65 | 66 | #------------------------------- 67 | #plot the weight 68 | def plotWeight(Nsub, Nchan, Weight): 69 | from matplotlib import pyplot as plt 70 | from mpl_toolkits.mplot3d import Axes3D 71 | fig = plt.figure() 72 | ax = Axes3D(fig) 73 | X = range(0, Nsub) 74 | Y = range(0, Nchan) 75 | X, Y = np.meshgrid(X, Y) 76 | Z = Weight 77 | ax.plot_surface(X, Y, Z.T, rstride=1, cstride=1, cmap='rainbow') 78 | plt.show() 79 | 80 | 81 | if __name__ == "__main__": 82 | 83 | #check input 84 | Flag = 0 85 | if (len(sys.argv)==2): 86 | #Fitslist = sys.argv[1] 87 | #Flag = 1 mean reset the weight 88 | Flag = 1 89 | plotset = 0 90 | Scale = 0 91 | Percent = 0 92 | Filename = sys.argv[1] 93 | print 'Reset for the "DAT_WTS"' 94 | beamWeight(Filename, Scale, Percent, Flag, plotset) 95 | 96 | elif (len(sys.argv) == 4): 97 | #elif (len(sys.argv) == 5): 98 | Flag = 0 99 | plotset = 0 100 | Scale = float(sys.argv[1]) # Between 0 and 1 101 | Percent = float(sys.argv[2]) # Between 0 and 1 102 | Filename = sys.argv[3] 103 | beamWeight(Filename, Scale, Percent, Flag, plotset) 104 | 105 | elif (len(sys.argv) == 5): 106 | Flag = 0 107 | plotset = 0 108 | Scale = float(sys.argv[1]) # Between 0 and 1 109 | Percent = float(sys.argv[2]) # Between 0 and 1 110 | Filename = sys.argv[3] 111 | plotset = int(sys.argv[4]) 112 | beamWeight(Filename, Scale, Percent, Flag, plotset) 113 | 114 | else : 115 | print 'Wrong inputs!' 116 | print 'Weight Usage: python *.py Scale(0-1) Time_percent(0-1) filename plotset(1)' 117 | print 'Weight Usage: python *.py Scale(0-1) Time_percent(0-1) filename' 118 | print 'Reset Usage: python *.py filename' 119 | sys.exit() 120 | -------------------------------------------------------------------------------- /coordination/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NAOC-pulsar/PeiWang-code/6a01f92ec9f1a32d2c203c8b8dd6955a208af330/coordination/.DS_Store -------------------------------------------------------------------------------- /coordination/J20002deg.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | import sys 5 | from astropy.coordinates import SkyCoord 6 | from astropy import units as u 7 | 8 | 9 | RaJ = '23:36:36.586975' # hh:mm:ss (J2000) 10 | DecJ = '-6:29:35.7' # dd:mm:ss (J2000) 11 | 12 | 13 | # Ra,Dec 14 | RaJ_h = str(RaJ).split(':')[0] 15 | RaJ_m = str(RaJ).split(':')[1] 16 | RaJ_s = str(RaJ).split(':')[2] 17 | RaJ_hms = str(RaJ_h)+'h'+str(RaJ_m)+'m'+str(RaJ_s)+'s' 18 | DecJ_d = str(DecJ).split(':')[0] 19 | DecJ_m = str(DecJ).split(':')[1] 20 | DecJ_s = str(DecJ).split(':')[2] 21 | DecJ_dms = str(DecJ_d)+'d'+str(DecJ_m)+'m'+str(DecJ_s)+'s' 22 | RaJ_deg = (str(SkyCoord(RaJ_hms, DecJ_dms, frame='icrs')).split('(')[3]).split(',')[0] 23 | 24 | Dec_flag = DecJ_d.find('-') 25 | if (int(Dec_flag) == 0 ): 26 | DecJ_deg = float(DecJ_d)-float(DecJ_m)/60.-float(DecJ_s)/3600. 27 | else: 28 | DecJ_deg = float(DecJ_d)+float(DecJ_m)/60.+float(DecJ_s)/3600. 29 | 30 | if (int(Dec_flag) == 0 and int(DecJ_d) == 0): 31 | DecJ_deg = '-'+str(DecJ_deg) 32 | 33 | 34 | # GL,GB 35 | Glb = SkyCoord(ra=float(RaJ_deg)*u.degree, dec=float(DecJ_deg)*u.degree, frame='icrs') 36 | GL = Glb.galactic.l.degree 37 | GB = Glb.galactic.b.degree 38 | GL = round(float(GL),2) 39 | GB = round(float(GB),2) 40 | GLJ = Glb.galactic.l 41 | GBJ = Glb.galactic.b 42 | 43 | print '\n', 'Ra(J2000) =', RaJ, ' Dec(J2000) =', DecJ, '\n', 'Ra(deg) =', RaJ_deg, ' Dec(deg) =', DecJ_deg, '\n', 'GL(J2000) =', GLJ, ' GB(J2000) =', GBJ, '\n', 'GL(deg) =', format(GL,'.2f'), ' GB(deg) =', format(GB,'.2f'), '\n' 44 | -------------------------------------------------------------------------------- /coordination/J20002deg_batch.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | import numpy as np 5 | import sys 6 | from astropy.coordinates import SkyCoord 7 | from astropy import units as u 8 | 9 | iput_radec=np.genfromtxt('radec_dms_input.list', dtype='string') 10 | Num_row = int((str(iput_radec[:,0].shape).split(',')[0]).split('(')[1]) 11 | RaJ=iput_radec[:,0] #hh:mm:ss (J2000) 12 | DecJ=iput_radec[:,1] #dd:mm:ss (J2000) 13 | 14 | print '\n',"RaJ2000 | DecJ2000 | RaJ2000_deg | DecJ2000_deg | GLJ2000 | GBJ2000 | GLJ2000_deg | GBJ2000_deg" 15 | 16 | # Ra,Dec 17 | for i in range(0, Num_row): 18 | RaJ_h = str(RaJ[i]).split(':')[0] 19 | RaJ_m = str(RaJ[i]).split(':')[1] 20 | RaJ_s = str(RaJ[i]).split(':')[2] 21 | RaJ_hms = str(RaJ_h)+'h'+str(RaJ_m)+'m'+str(RaJ_s)+'s' 22 | RaJ2000 = str(RaJ_h)+':'+str(RaJ_m)+':'+str(RaJ_s) 23 | DecJ_d = str(DecJ[i]).split(':')[0] 24 | DecJ_m = str(DecJ[i]).split(':')[1] 25 | DecJ_s = str(DecJ[i]).split(':')[2] 26 | DecJ_dms = str(DecJ_d)+'d'+str(DecJ_m)+'m'+str(DecJ_s)+'s' 27 | DecJ2000 = str(DecJ_d)+':'+str(DecJ_m)+':'+str(DecJ_s) 28 | RaJ_deg = (str(SkyCoord(RaJ_hms, DecJ_dms, frame='icrs')).split('(')[3]).split(',')[0] 29 | Dec_flag = DecJ_d.find('-') 30 | if (int(Dec_flag) == 0 ): 31 | DecJ_deg = float(DecJ_d)-float(DecJ_m)/60.-float(DecJ_s)/3600. 32 | else: 33 | DecJ_deg = float(DecJ_d)+float(DecJ_m)/60.+float(DecJ_s)/3600. 34 | 35 | if (int(Dec_flag) == 0 and int(DecJ_d) == 0): 36 | DecJ_deg = '-'+str(DecJ_deg) 37 | 38 | # GL,GB 39 | Glb = SkyCoord(ra=float(RaJ_deg)*u.degree, dec=float(DecJ_deg)*u.degree, frame='icrs') 40 | GL = Glb.galactic.l.degree 41 | GB = Glb.galactic.b.degree 42 | GL = round(float(GL),2) 43 | GB = round(float(GB),2) 44 | GLJ = Glb.galactic.l 45 | GBJ = Glb.galactic.b 46 | 47 | print RaJ2000,DecJ2000,RaJ_deg,DecJ_deg,GLJ,GBJ,GL,GB 48 | print '\n' 49 | # print '\n', 'Ra(J2000) =', RaJ, ' Dec(J2000) =', DecJ, ' Ra(deg) =', RaJ_deg, ' Dec(deg) =', DecJ_deg, ' GL(J2000) =', GLJ, ' GB(J2000) =', GBJ, ' GL(deg) =', GL, ' GB(deg) =', GB, '\n' 50 | -------------------------------------------------------------------------------- /coordination/deg2J2000_batch.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | print '# Usage: $python deg2J2000_batch.py' 5 | print '# Input_file: radec_deg_input.list' 6 | 7 | from astropy.coordinates import SkyCoord 8 | from astropy import units as u 9 | import numpy as np 10 | 11 | iput_radec = np.genfromtxt('radec_deg_input.list', dtype='string') 12 | Num_row = int((str(iput_radec[:,0].shape).split(',')[0]).split('(')[1]) 13 | RaJ_deg = iput_radec[:,0] #deg (J2000) 14 | DecJ_deg = iput_radec[:,1] #deg (J2000) 15 | 16 | print "RaJ2000_deg | DecJ2000_deg | RaJ2000_hms | DecJ2000_dms | GLJ2000_deg | GBJ2000_deg" 17 | 18 | # RaJ2000,DecJ2000 19 | for i in range(0, Num_row): 20 | aaa = np.float32(RaJ_deg[i]) 21 | bbb = np.float32(DecJ_deg[i]) 22 | c = SkyCoord(ra=aaa*u.degree, dec=bbb*u.degree) 23 | RaJ_DecJ = c.to_string('hmsdms') 24 | RaJ2000 = str(RaJ_DecJ).split(' ')[0] 25 | DecJ2000 = str(RaJ_DecJ).split(' ')[1] 26 | # print '\n', 'RaJ2000 =', RaJ2000, ' DecJ2000 =', DecJ2000 27 | 28 | # GL,GB 29 | Glb = SkyCoord(ra=aaa*u.degree, dec=bbb*u.degree, frame='icrs') 30 | GL = Glb.galactic.l.degree 31 | GB = Glb.galactic.b.degree 32 | GL = round(float(GL),2) 33 | GB = round(float(GB),2) 34 | 35 | RaJ2000 = RaJ2000.replace('h',':') 36 | RaJ2000 = RaJ2000.replace('m',':') 37 | RaJ2000 = RaJ2000.replace('s','') 38 | DecJ2000 = DecJ2000.replace('d',':') 39 | DecJ2000 = DecJ2000.replace('m',':') 40 | DecJ2000 = DecJ2000.replace('s','') 41 | 42 | print RaJ_deg[i], DecJ_deg[i], RaJ2000, DecJ2000, GL ,GB 43 | -------------------------------------------------------------------------------- /coordination/radec_deg_input.list: -------------------------------------------------------------------------------- 1 | 310.29 47.60 2 | 301.10 33.65 3 | 308.76 36.54 4 | 170.16 7.22 5 | 49.57 2.91 6 | 246.95 32.32 7 | 284.28 0.96 8 | 333.12 7.13 9 | 283.23 2.02 10 | 285.13 3.64 11 | 310.58 42.25 12 | 309.98 41.92 13 | 85.32 35.26 14 | -------------------------------------------------------------------------------- /coordination/radec_dms_input.list: -------------------------------------------------------------------------------- 1 | 21:29:58 12:10:01 2 | 12:30:49 12:23:28 3 | -------------------------------------------------------------------------------- /downSampleCode/cut_downsamping.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | Downsamp=1 4 | 5 | line=1 6 | cat filelist.txt | while read LINENAME; do 7 | NUM=`cat filelist.txt | wc -l` 8 | echo "${line}/${NUM} ${Filename}" 9 | Filename=`echo ${LINENAME} | awk '{print $1}'` 10 | python Downsamp_FASTpsrfits_freq_time_splitpol.py 1024 3071 0 255 ${Downsamp} ${Filename} # for FAST 19beams format (Freq:1.05-1.45GHz) 11 | # python Downsamp_FASTpsrfits_freq_time_splitpol.py 1160 3207 0 62 ${Downsamp} ${Filename} # for FAST Ultra-wide band receiver format (Freq:290-802MHz) 12 | ((line++)) 13 | done 14 | -------------------------------------------------------------------------------- /downSampleCode/频率通道重采样程序示例.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NAOC-pulsar/PeiWang-code/6a01f92ec9f1a32d2c203c8b8dd6955a208af330/downSampleCode/频率通道重采样程序示例.pdf -------------------------------------------------------------------------------- /fits_plot/plotfits.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import numpy as np 3 | #import pyfits 4 | import astropy.io.fits as pyfits 5 | import os 6 | import datetime 7 | import time 8 | import sys 9 | from decimal import Decimal 10 | secperday = 3600 * 24 11 | 12 | if (len(sys.argv)<4): 13 | print 'too few input parameters!' 14 | print 'example:' 15 | print 'python fitsio_cut_freq_time_splitpol.py startn endn startchan endchan FAST.fits' 16 | sys.exit() 17 | 18 | startn=int(sys.argv[1]) 19 | endn=int(sys.argv[2]) 20 | startfreq=int(sys.argv[3]) 21 | endfreq=int(sys.argv[4]) 22 | filename=sys.argv[5] 23 | 24 | 25 | hdulist = pyfits.open(filename) 26 | print 'hdu list length', len(hdulist) 27 | hdu0 = hdulist[0] 28 | hdu1 = hdulist[1] 29 | #hdu2 = hdulist[2] 30 | data1 = hdu1.data['data'] 31 | #data2 = hdu2.data 32 | header1 = hdu1.header 33 | print hdu0.header 34 | print hdu1.header 35 | print data1.shape 36 | 37 | fchannel = hdulist['SUBINT'].data[0]['DAT_FREQ'] 38 | fch1 = fchannel[0] 39 | obsfreq = hdu0.header['OBSFREQ'] 40 | obsnchan = hdu0.header['OBSNCHAN'] 41 | obsbw = hdu0.header['OBSBW'] 42 | fmin = obsfreq - obsbw/2. 43 | fmax = obsfreq + obsbw/2. 44 | nf = obsnchan 45 | df = hdu1.header['CHAN_BW'] 46 | tsamp = hdu1.header['TBIN'] 47 | nsubint = hdu1.header['NAXIS2'] 48 | samppersubint = int(hdu1.header['NSBLK']) 49 | nsamp = nsubint * samppersubint 50 | sourename = hdu0.header['SRC_NAME'] 51 | ra = hdu0.header['RA'] 52 | dec = hdu0.header['DEC'] 53 | #tstart = Decimal("%d.%d" % (hdu0.header['STT_IMJD'], hdu0.header['STT_SMJD'])) 54 | subintoffset = hdu1.header['NSUBOFFS'] 55 | tstart = "%.13f" % (Decimal(hdu0.header['STT_IMJD']) + Decimal(hdu0.header['STT_SMJD'] + tsamp * samppersubint * subintoffset )/secperday ) 56 | nbits = hdu0.header['BITPIX'] 57 | header = hdu0.header + hdu1.header 58 | dtype = '' 59 | 60 | print 'freq %s MHz, nchan %d, bw %s MHz' % ( obsfreq, obsnchan, obsbw) 61 | print 'MJD:', tstart 62 | print 'fch1, df', fch1, df 63 | 64 | print 'data.shape:', data1.shape 65 | 66 | a,b,c,d,e = data1.shape 67 | d = (endfreq - startfreq) 68 | if c > 1: 69 | data = data1[startn:endn,:,0,startfreq:endfreq,:].squeeze().reshape((-1,d)) 70 | else: 71 | data = data1.squeeze().reshape((-1,d)) 72 | l, m = data.shape 73 | print data.shape 74 | #data = data.reshape(l/64, 64, d).sum(axis=1) 75 | #data -= data.mean(axis=0).transpose().astype(np.uint64) 76 | 77 | from pylab import * 78 | imshow(data.T, aspect='auto',cmap=get_cmap("hot"),origin="lower" ) 79 | colorbar() 80 | #plot(data.sum(axis=0)) 81 | #plot(data.sum(axis=1)) 82 | show() 83 | -------------------------------------------------------------------------------- /fits_plot/plotfits2png.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | #import pyfits 3 | import numpy as np 4 | import astropy.io.fits as pyfits 5 | from astropy.time import Time 6 | import os 7 | import datetime as dt 8 | from datetime import datetime 9 | import time 10 | import sys 11 | import string 12 | from decimal import Decimal 13 | from decimal import getcontext 14 | secperday = 3600 * 24 15 | 16 | np.set_printoptions(suppress=True) 17 | 18 | #check input 19 | if (len(sys.argv)==2): 20 | filename=sys.argv[1] 21 | 22 | elif (len(sys.argv)==6): 23 | filename=sys.argv[5] 24 | 25 | else : 26 | print 'wrong input parameters!' 27 | print 'example:' 28 | print 'python *.py startn endn startchan endchan FAST.fits' 29 | print 'python *.py FAST.fits' 30 | sys.exit() 31 | 32 | starttime=datetime.now() 33 | print 'start time:',starttime 34 | 35 | #read file 36 | hdulist = pyfits.open(filename) 37 | hdu0 = hdulist[0] 38 | hdu1 = hdulist[1] 39 | data1 = hdu1.data['data'] 40 | header1 = hdu1.header 41 | 42 | fchannel = hdulist['SUBINT'].data[0]['DAT_FREQ'] 43 | fch1 = fchannel[0] 44 | obsnchan = hdu0.header['OBSNCHAN'] 45 | nf = obsnchan 46 | df = hdu1.header['CHAN_BW'] 47 | tsamp = hdu1.header['TBIN'] 48 | nsubint = hdu1.header['NAXIS2'] 49 | samppersubint = int(hdu1.header['NSBLK']) 50 | 51 | ''' 52 | obsfreq = hdu0.header['OBSFREQ'] 53 | obsbw = hdu0.header['OBSBW'] 54 | fmin = obsfreq - obsbw/2. 55 | fmax = obsfreq + obsbw/2. 56 | nsamp = nsubint * samppersubint 57 | sourename = hdu0.header['SRC_NAME'] 58 | ra = hdu0.header['RA'] 59 | dec = hdu0.header['DEC'] 60 | subintoffset = hdu1.header['NSUBOFFS'] 61 | nbits = hdu0.header['BITPIX'] 62 | ''' 63 | 64 | #MJD time for Ultra-wide band receiver 65 | #tstart = "%.13f" % (Decimal(hdu0.header['STT_IMJD']) + Decimal(hdu0.header['STT_SMJD'] + tsamp * samppersubint * subintoffset )/secperday ) 66 | #MJD time for 19-beams 67 | tstart = "%.13f" % (Decimal(hdu0.header['STT_IMJD']) + (Decimal(hdu0.header['STT_SMJD']) + Decimal(hdu0.header['STT_OFFS']) )/secperday) 68 | 69 | # Transfer Fits header MJD --> UTC time 70 | #Starttime = string.atof(tstart) 71 | Starttime = float(tstart) 72 | t_header = Time(Starttime,format='mjd',scale='utc') 73 | tmp_t_header = str(t_header.datetime).split('.') 74 | if tmp_t_header.__len__() == 1: 75 | tmp_t_header[0] = tmp_t_header[0] + '.000001' 76 | else: 77 | tmp_t_header[0] = tmp_t_header[0] + '.' + tmp_t_header[1] 78 | 79 | Starttime_utc = datetime.strptime(tmp_t_header[0],"%Y-%m-%d %H:%M:%S.%f") 80 | Starttime_BJ = Starttime_utc + dt.timedelta(hours=8) 81 | print "file record start time: ", Starttime_BJ 82 | 83 | #close file 84 | hdulist.close() 85 | 86 | 87 | #input check 88 | if (len(sys.argv)==2): 89 | startn = 0 90 | endn = nsubint-1 91 | startfreq = 400 92 | endfreq = nf-400 93 | 94 | elif (len(sys.argv)==6): 95 | startn=int(sys.argv[1]) 96 | endn=int(sys.argv[2]) 97 | startfreq=int(sys.argv[3]) 98 | endfreq=int(sys.argv[4]) 99 | if startn < 0 or startn >= endn : 100 | startn = 0 101 | print "error startn, change to ", startn 102 | if endn >= nsubint or endn < 0: 103 | endn = nsubint-1 104 | print "error endn, change to ", endn 105 | if startfreq < 0 or startfreq >= endfreq : 106 | startfreq = 400 107 | print "error startfreq, change to ", startfreq 108 | if endfreq >= nf or endfreq < 0: 109 | endfreq = nf-400 110 | print "error endfreq, change to ", endfreq 111 | 112 | else : 113 | print "unknown error, quit!" 114 | sys.exit() 115 | 116 | 117 | #File information out put 118 | #name, mjd, time, freq 119 | name = 'filename: '+filename.split('/')[-1] 120 | mjd = str('MJD: %s' %(tstart)) 121 | plottime = str('plot length: %s s' % ( (endn - startn)*samppersubint*tsamp) ) 122 | freq = str('plot Frequence: %sMHz - %sMHz' % (round( fch1+startfreq*df, 2 ), round( fch1+endfreq*df, 2 ))) 123 | BJtime = Starttime_BJ.strftime("%Y-%m-%d %H:%M:%S") 124 | 125 | 126 | #information out put 127 | print "hdu list length ", len(hdulist) 128 | print 'data.shape:', data1.shape 129 | print 'MJD:', tstart 130 | print 'fch1, df', fch1, df 131 | #print 'freq %s MHz, nchan %d, bw %s MHz' % ( obsfreq, obsnchan, obsbw) 132 | #print 'file length %f tsamp %f nsamp %f' %(tsamp*nsamp,tsamp,nsamp) 133 | 134 | # ASCII file out 135 | bandpassfilename=(filename.split('/')[-1])[:-5]+'.bandpass' 136 | print "out put bandpass file name: %s " %(bandpassfilename) 137 | 138 | from pylab import * 139 | #from matplotlib.ticker import MultipleLocator 140 | 141 | switch_backend('ps') 142 | downsamp = 64 143 | a,b,c,d,e = data1.shape 144 | d = (endfreq - startfreq) 145 | bandpassout = np.zeros((d,c+1)) 146 | for i in range(d): 147 | bandpassout[i,0] = fch1+(startfreq+i)*df 148 | 149 | fig = figure(figsize=(16,4.5*c), dpi=80) 150 | fig.text(0.1,0.91,name+"\n"+mjd+"\nBJ Time: "+BJtime, fontsize = 15) 151 | fig.text(0.5,0.91,plottime+"\n"+freq+"\n", fontsize = 15) 152 | 153 | # set plot labels 154 | floattimelabel = [round(timepoint,1) for timepoint in np.arange(0, (endn - startn)*1.1*samppersubint/downsamp, (endn - startn)*samppersubint/10./downsamp ) ] 155 | strtimelabel = [str(round(timepoint,2)) for timepoint in np.arange(startn*samppersubint*tsamp, endn*samppersubint*tsamp+(endn - startn)*samppersubint*tsamp/10, (endn - startn)*samppersubint*tsamp/10.) ] 156 | 157 | floatfreqlabel = [round(freqpoint,1) for freqpoint in np.arange(0, (endfreq- startfreq)*1.2, (endfreq - startfreq)/5.) ] 158 | strfreqlabel = [str(round(freqpoint,0)) for freqpoint in np.arange(fch1+startfreq*df, fch1+endfreq*df+(fch1+endfreq*df - (fch1+startfreq*df))/5, (fch1+endfreq*df - (fch1+startfreq*df))/5.)] 159 | 160 | for i in range(c): 161 | 162 | #reshape downsample the data 163 | data = data1[startn:endn,:,i,startfreq:endfreq,:].squeeze().reshape((-1,d)) 164 | l, m = data.shape 165 | data = data.reshape(l/downsamp, downsamp, d).sum(axis=1) 166 | 167 | bandpass = np.sum(data,axis=0) 168 | bandpassout[:,i+1] = bandpass 169 | print "shape of output data",data.shape 170 | #data -= data.mean(axis=0).transpose().astype(np.uint64) 171 | #subplotnum=int(str(2*c)+'1'+str(2*i+1)) 172 | subplotnum=int(str(c)+str(c)+str(2*i+1)) 173 | ax=fig.add_subplot(subplotnum) 174 | #ax.imshow(data.T, aspect='auto') 175 | im = ax.imshow(data.T, aspect='auto',cmap=get_cmap("hot"),origin="lower" ) 176 | title('pic of fits'+'pol '+str(i+1), fontsize = 10) 177 | ax.set_xlabel('time (s)', fontsize = 10) 178 | ax.set_ylabel('pol'+str(i+1)+'\n'+'channel(MHz)', fontsize = 10) 179 | #ax.set_xticklabels([str(round(timepoint,1)) for timepoint in np.arange(startn*samppersubint*tsamp, endn*samppersubint*tsamp, (endn - startn)*samppersubint*tsamp/10) ]) 180 | #xlabel set 181 | xticks(floattimelabel, strtimelabel) 182 | yticks(floatfreqlabel, strfreqlabel) 183 | 184 | fig.colorbar(im, ax = ax) 185 | #ax.set_xlim(startn*samppersubint*tsamp, endn*samppersubint*tsamp) 186 | #ax.set_ylim(fch1+startfreq*obsbw, fch1+endfreq*obsbw) 187 | #if i < 1 : 188 | # title(filename.split('/')[-1]) 189 | 190 | #subplotnum=int(str(2*c)+'1'+str(2*i+2)) 191 | subplotnum=int(str(c)+str(c)+str(2*i+2)) 192 | ax=fig.add_subplot(subplotnum) 193 | ax.plot(bandpass) 194 | title('bandpass of '+'pol'+str(i+1), fontsize = 10) 195 | ax.set_ylabel('bandpass of '+'pol'+str(i+1), fontsize = 10) 196 | ax.set_xlabel('channel', fontsize = 10) 197 | xticks(floatfreqlabel, strfreqlabel) 198 | #xticks(, [str(round(freqpoint,0)) for freqpoint in np.arange(fch1+startfreq*df, fch1+endfreq*df+(fch1+endfreq*df - (fch1+startfreq*df))/5, (fch1+endfreq*df - (fch1+startfreq*df))/5)]) 199 | #ax.set_xlim(0.,d) 200 | #ax.set_xlim(fch1+startfreq*obsbw, fch1+endfreq*obsbw) 201 | #colorbar() 202 | #plot(data.sum(axis=0)) 203 | #plot(data.sum(axis=1)) 204 | #show() 205 | #xlabel('time (s)') 206 | 207 | imgfilename=(filename.split('/')[-1])[:-5]+'.png' 208 | print "creating img: ", imgfilename 209 | savefig(imgfilename) 210 | print "finish out put img file" 211 | #clf() 212 | 213 | #bandpass out put 214 | f = open(bandpassfilename, 'w') 215 | f.write('MHz pol1 pol2\n') 216 | for i in range(d): 217 | f.write(str(bandpassout[i,:]).strip('[').strip(']').strip()+'\n') 218 | f.close() 219 | #print bandpassout 220 | 221 | #endtime=datetime.now() 222 | endtime=dt.datetime.now() 223 | print 'START:',starttime 224 | print 'END:',endtime 225 | print 'DURATION:',(endtime-starttime).seconds,' sec' 226 | -------------------------------------------------------------------------------- /fits_plot/usage.txt: -------------------------------------------------------------------------------- 1 | fitsio_cutfreq.py: cut file only have one pol. 2 | usage: python *.py filename startfref endfref newfile 3 | 4 | fitsio_cut_freq_time_splitpol.py: cut file have two pols. 5 | usage: python *.py filename startchan endchan startTime endTime filename 6 | 7 | fastFitsCut.py: cut file have two pols. 8 | Same function as fitsio_cut_freq_time_splitpol.py but more faster. 9 | usage: 10 | python *.py [-f1 startchannel] [-f2 endchannel] [-t1 startsubint] [-t2 endsubint] FAST.fits 11 | python *.py -[help/version] 12 | example: 13 | python fastFitsCut.py -f1 1000 -f2 3000 -t1 0 -t2 31 FAST.fits 14 | python fastFitsCut.py -f1 1000 FAST.fits (From channel 1000 to end. All subint) 15 | (if someone lost, the input will be set to a default num.) 16 | 17 | get_bandpass.py: get bandpass from fits file. 18 | usage: def function can be found in fitsio_combinePolBinary.py 19 | 20 | get_nos.py: get signal and noise from fits file. 21 | usage: def function can be found in fitsio_combinePolBinary.py 22 | 23 | plotbinary.py: plot one channel of the binary file(create by simulateSimplePsr_mcc). 24 | usage: python *.py binaryfile 25 | 26 | plotfits.py: plot fast fits files. 27 | python *.py startsubint endsubint startchannel endchannel FAST.fits 28 | python *.py 0 31 1000 3000 FAST.fits 29 | 30 | fits_combinePolBinary.py: combine fits file with binary file to a new file with one pol 31 | usage: python *.py fitsfile binaryfile combinedfile 32 | -------------------------------------------------------------------------------- /pointing/FAST_source_RaJ_DecJ.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | print '# Usage: $python FAST_source_RaJ_DecJ.py MJD DecJ(Now)(dd:mm:ss)' 5 | 6 | 7 | import sys 8 | import ephem 9 | import datetime as dt 10 | from astropy.time import Time 11 | from astropy.coordinates import SkyCoord 12 | from astropy import units as u 13 | from datetime import datetime 14 | 15 | Dawodang = ephem.Observer() 16 | Dawodang.lat = '25.652939' 17 | Dawodang.lon = '106.8609444' 18 | Dawodang.horizon ='-18' # Astronomical twilight uses the value -18 degrees 19 | 20 | src = ephem.FixedBody() 21 | src._ra = '00:00:00' # Epoch J2000 22 | Offset_arival_time = 236 # interval arrival time(sec) in one day 23 | 24 | ############################## 25 | # Input parameters 26 | 27 | Starttime=float(sys.argv[1]) 28 | decJnow = str(sys.argv[2]) 29 | 30 | #Offset_time = 26.2144 # half time(unit is sec) between end and start time, ie. beam centre 31 | Offset_time = 0 32 | ############################## 33 | 34 | 35 | # Transfer Fits header MJD --> UTC time 36 | 37 | t_header = Time(Starttime,format='mjd',scale='utc') 38 | tmp_t_header = str(t_header.datetime).split('.') 39 | if tmp_t_header.__len__() == 1: 40 | tmp_t_header[0] = tmp_t_header[0] + '.000001' 41 | else: 42 | tmp_t_header[0] = tmp_t_header[0] + '.' + tmp_t_header[1] 43 | Starttime_utc = datetime.strptime(tmp_t_header[0],"%Y-%m-%d %H:%M:%S.%f") 44 | Starttime_BJ = Starttime_utc + dt.timedelta(hours=8) 45 | 46 | #Inital_Ra = datetime.strptime(str(src._ra),"%Y-%m-%d %H:%M:%S.%f") 47 | print '\n', '-----------------------------------' 48 | print 'Fits start_time (UTC) =', Starttime_utc # start time in header 49 | print 'Fits start_time (BJ) =', Starttime_BJ 50 | Dawodang.date = str(Starttime_utc).split(' ')[0] # Dawodang time = 00:00:00 51 | #Dawodang.date = str(Starttime_utc) 52 | 53 | 54 | 55 | # Convert to Epoch J2000 56 | 57 | Jnowequatorial = ephem.Equatorial('00:00:00', decJnow, epoch=str(Starttime_utc)) 58 | J2000equatorial = ephem.Equatorial(Jnowequatorial, epoch=ephem.J2000) 59 | Dec_J2000 = ('%s %s' % (J2000equatorial.ra, J2000equatorial.dec)).split(' ')[1] 60 | src._dec = Dec_J2000 61 | 62 | 63 | # Calculate transit time 64 | 65 | src.compute() 66 | ttrans=Dawodang.next_transit(src) 67 | t_transit = Time(ephem.localtime(ttrans),scale='utc') # localtime UTC+8h 68 | #print ephem.localtime(ttrans), t_transit.mjd # localtime UTC+8h, transit time (MJD) 69 | Alt = str(src.alt).split(':') 70 | Az = str(src.az).split(':') 71 | FAST_az = 90.0 - (float(Alt[0])+(float(Alt[1])/60)+float(Alt[2])/3600.) 72 | FAST_el = 270.0 - (float(Az[0])+(float(Az[1])/60)+float(Az[2])/3600.) 73 | #print 'Ra(0:0:0) Transit:', ephem.localtime(ttrans), t_transit.mjd, src.ra, src.dec, src.alt, src.az, FAST_el, FAST_az 74 | tmp=str(t_transit).split('.') 75 | if tmp.__len__()==1: 76 | tmp[0]=tmp[0]+'.000001' 77 | else: 78 | tmp[0]=tmp[0]+'.'+tmp[1] 79 | 80 | #Transit_utc8 = datetime.strptime(str(t_transit),"%Y-%m-%d %H:%M:%S") 81 | Transit_utc8 = datetime.strptime(tmp[0],"%Y-%m-%d %H:%M:%S.%f") 82 | 83 | 84 | # Compensate start time & transit time 85 | 86 | Delta = Transit_utc8 - Starttime_utc 87 | Offset_sec = 236 * float(Delta.seconds)/24./3600. - float(Offset_time) # compensate periodical delay and modify start_time to beam centre 88 | #print 'Delta time =', Delta 89 | #print 'Offset_sec =', Offset_sec 90 | 91 | Delta_final = Delta + dt.timedelta(seconds = Offset_sec) 92 | #print 'Delta time after offset =', Delta_final 93 | 94 | H24_date = (str(Starttime_utc).split(' ')[0]).split('-') 95 | H24 = dt.datetime(int(H24_date[0]), int(H24_date[1]), int(H24_date[2]), 23, 59, 59) 96 | RaJ = H24 - (Delta_final - dt.timedelta(seconds = 3600*8+1)) 97 | 98 | src._ra = str(RaJ).split(' ')[1] 99 | src.compute() 100 | dtrans=Dawodang.next_transit(src) 101 | 102 | Dtransit = str(Time(ephem.localtime(dtrans),scale='utc')).split('.') 103 | if Dtransit.__len__()==1: 104 | Dtransit[0]=Dtransit[0]+'.000001' 105 | else: 106 | Dtransit[0]=Dtransit[0]+'.'+Dtransit[1] 107 | d_transit = datetime.strptime(Dtransit[0],"%Y-%m-%d %H:%M:%S.%f") 108 | Delta_ra = Starttime_BJ - d_transit 109 | #print 'd_transit, Delta_ra = ', d_transit, Delta_ra 110 | RaJ += Delta_ra 111 | 112 | 113 | EJ2000 = ephem.Equatorial(str(RaJ).split(' ')[1], Dec_J2000, epoch=ephem.J2000) 114 | EJnow = ephem.Equatorial(EJ2000, epoch=str(Starttime_utc)) 115 | print '\n', 'Ra( now ) =', ('%s %s' % (EJnow.ra, EJnow.dec)).split(' ')[0], ' Dec( now ) =', decJnow 116 | print '\n', 'Ra(J2000) =', str(RaJ).split(' ')[1], ' Dec(J2000) =', Dec_J2000 117 | 118 | 119 | # Ra,Dec 120 | RaJ_h = (str(RaJ).split(' ')[1]).split(':')[0] 121 | RaJ_m = (str(RaJ).split(' ')[1]).split(':')[1] 122 | RaJ_s = (str(RaJ).split(' ')[1]).split(':')[2] 123 | RaJ_hms = str(RaJ_h)+'h'+str(RaJ_m)+'m'+str(RaJ_s)+'s' 124 | DecJ_d = str(src._dec).split(':')[0] 125 | DecJ_m = str(src._dec).split(':')[1] 126 | DecJ_s = str(src._dec).split(':')[2] 127 | DecJ_dms = str(DecJ_d)+'d'+str(DecJ_m)+'m'+str(DecJ_s)+'s' 128 | RaJ_deg = (str(SkyCoord(RaJ_hms, DecJ_dms, frame='icrs')).split('(')[3]).split(',')[0] 129 | 130 | Dec_flag = DecJ_d.find('-') 131 | if (int(Dec_flag) == 0 ): 132 | DecJ_deg = float(DecJ_d)-float(DecJ_m)/60.-float(DecJ_s)/3600. 133 | else: 134 | DecJ_deg = float(DecJ_d)+float(DecJ_m)/60.+float(DecJ_s)/3600. 135 | 136 | print '\n', 'Ra(deg) =', RaJ_deg, ' Dec(deg) =', DecJ_deg 137 | 138 | # GL,GB 139 | Glb = SkyCoord(ra=float(RaJ_deg)*u.degree, dec=float(DecJ_deg)*u.degree, frame='icrs') 140 | GL = Glb.galactic.l.degree 141 | GB = Glb.galactic.b.degree 142 | GL = round(float(GL),2) 143 | GB = round(float(GB),2) 144 | if (GB < 0): 145 | GB = 'm'+str(GB).split('-')[1] 146 | else: 147 | GB = 'p'+str(GB) 148 | 149 | 150 | print '\n', 'GL(deg) =', GL, ' GB(deg) =', GB 151 | print '\n', 'FAST_el(deg) =', FAST_el, ' FAST_az(deg) =', FAST_az 152 | print '-----------------------------------', '\n' 153 | -------------------------------------------------------------------------------- /pointing/FAST_source_RaJ_manual.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | # $python FAST_source_RaJ_170707.py MJD 5 | 6 | 7 | import sys 8 | import ephem 9 | import datetime as dt 10 | from astropy.time import Time 11 | from astropy.coordinates import SkyCoord 12 | from astropy import units 13 | from datetime import datetime 14 | 15 | Dawodang = ephem.Observer() 16 | Dawodang.lat = '25.652939' 17 | Dawodang.lon = '106.8609444' 18 | Dawodang.horizon ='-18' # Astronomical twilight uses the value -18 degrees 19 | 20 | src = ephem.FixedBody() 21 | src._ra = '00:00:00' 22 | Offset_arival_time = 236 # interval arrival time(sec) in one day 23 | 24 | ############################## 25 | # Input parameters 26 | 27 | Offset_time = 26.2144 # half time(sec) between end and start time, ie. beam centre 28 | 29 | decJnow = '30:30:10' 30 | Starttime = 57911.55059692592593 # read MJD time from fits header 31 | 32 | ############################## 33 | 34 | # Transfer Fits header MJD --> UTC time 35 | 36 | t_header = Time(Starttime,format='mjd',scale='utc') 37 | tmp_t_header = str(t_header.datetime).split('.') 38 | if tmp_t_header.__len__() == 1: 39 | tmp_t_header[0] = tmp_t_header[0] + '.000001' 40 | else: 41 | tmp_t_header[0] = tmp_t_header[0] + '.' + tmp_t_header[1] 42 | Starttime_utc = datetime.strptime(tmp_t_header[0],"%Y-%m-%d %H:%M:%S.%f") 43 | Starttime_BJ = Starttime_utc + dt.timedelta(hours=8) 44 | 45 | #Inital_Ra = datetime.strptime(str(src._ra),"%Y-%m-%d %H:%M:%S.%f") 46 | print '\n', '-----------------------------------' 47 | print 'Fits start_time (UTC) =', Starttime_utc # start time in header 48 | print 'Fits start_time (BJ) =', Starttime_BJ 49 | Dawodang.date = str(Starttime_utc).split(' ')[0] # Dawodang time = 00:00:00 50 | #Dawodang.date = str(Starttime_utc) 51 | 52 | 53 | 54 | # Convert to Epoch J2000 55 | 56 | Jnowequatorial = ephem.Equatorial('00:00:00', decJnow, epoch=str(Starttime_utc)) 57 | J2000equatorial = ephem.Equatorial(Jnowequatorial, epoch=ephem.J2000) 58 | Dec_J2000 = ('%s %s' % (J2000equatorial.ra, J2000equatorial.dec)).split(' ')[1] 59 | src._dec = Dec_J2000 60 | 61 | 62 | # Calculate transit time 63 | 64 | src.compute() 65 | ttrans=Dawodang.next_transit(src) 66 | t_transit = Time(ephem.localtime(ttrans),scale='utc') # localtime UTC+8h 67 | #print ephem.localtime(ttrans), t_transit.mjd # localtime UTC+8h, transit time (MJD) 68 | Alt = str(src.alt).split(':') 69 | Az = str(src.az).split(':') 70 | FAST_az = 90.0 - (float(Alt[0])+(float(Alt[1])/60)+float(Alt[2])/3600.) 71 | FAST_el = 270.0 - (float(Az[0])+(float(Az[1])/60)+float(Az[2])/3600.) 72 | #print 'Ra(0:0:0) Transit:', ephem.localtime(ttrans), t_transit.mjd, src.ra, src.dec, src.alt, src.az, FAST_el, FAST_az 73 | tmp=str(t_transit).split('.') 74 | if tmp.__len__()==1: 75 | tmp[0]=tmp[0]+'.000001' 76 | else: 77 | tmp[0]=tmp[0]+'.'+tmp[1] 78 | 79 | #Transit_utc8 = datetime.strptime(str(t_transit),"%Y-%m-%d %H:%M:%S") 80 | Transit_utc8 = datetime.strptime(tmp[0],"%Y-%m-%d %H:%M:%S.%f") 81 | 82 | 83 | # Compensate start time & transit time 84 | 85 | Delta = Transit_utc8 - Starttime_utc 86 | Offset_sec = 236 * float(Delta.seconds)/24./3600. - float(Offset_time) # compensate periodical delay and modify start_time to beam centre 87 | #print 'Delta time =', Delta 88 | #print 'Offset_sec =', Offset_sec 89 | 90 | Delta_final = Delta + dt.timedelta(seconds = Offset_sec) 91 | #print 'Delta time after offset =', Delta_final 92 | 93 | H24_date = (str(Starttime_utc).split(' ')[0]).split('-') 94 | H24 = dt.datetime(int(H24_date[0]), int(H24_date[1]), int(H24_date[2]), 23, 59, 59) 95 | RaJ = H24 - (Delta_final - dt.timedelta(seconds = 3600*8+1)) 96 | 97 | src._ra = str(RaJ).split(' ')[1] 98 | src.compute() 99 | dtrans=Dawodang.next_transit(src) 100 | Dtransit = str(Time(ephem.localtime(dtrans),scale='utc')).split('.') 101 | if Dtransit.__len__()==1: 102 | Dtransit[0]=Dtransit[0]+'.000001' 103 | else: 104 | Dtransit[0]=Dtransit[0]+'.'+Dtransit[1] 105 | d_transit = datetime.strptime(Dtransit[0],"%Y-%m-%d %H:%M:%S.%f") 106 | Delta_ra = Starttime_BJ - d_transit 107 | #print 'd_transit, Delta_ra = ', d_transit, Delta_ra 108 | RaJ += Delta_ra 109 | 110 | 111 | EJ2000 = ephem.Equatorial(str(RaJ).split(' ')[1], Dec_J2000, epoch=ephem.J2000) 112 | EJnow = ephem.Equatorial(EJ2000, epoch=str(Starttime_utc)) 113 | print '\n', 'Ra( now ) =', ('%s %s' % (EJnow.ra, EJnow.dec)).split(' ')[0], ' Dec( now ) =', decJnow 114 | print '\n', 'Ra(J2000) =', str(RaJ).split(' ')[1], ' Dec(J2000) =', Dec_J2000 115 | 116 | 117 | # Ra,Dec 118 | RaJ_h = (str(RaJ).split(' ')[1]).split(':')[0] 119 | RaJ_m = (str(RaJ).split(' ')[1]).split(':')[1] 120 | RaJ_s = (str(RaJ).split(' ')[1]).split(':')[2] 121 | RaJ_hms = str(RaJ_h)+'h'+str(RaJ_m)+'m'+str(RaJ_s)+'s' 122 | DecJ_d = str(src._dec).split(':')[0] 123 | DecJ_m = str(src._dec).split(':')[1] 124 | DecJ_s = str(src._dec).split(':')[2] 125 | DecJ_dms = str(DecJ_d)+'d'+str(DecJ_m)+'m'+str(DecJ_s)+'s' 126 | RaJ_deg = (str(SkyCoord(RaJ_hms, DecJ_dms, frame='icrs')).split('(')[3]).split(',')[0] 127 | 128 | Dec_flag = DecJ_d.find('-') 129 | if (int(Dec_flag) == 0 ): 130 | DecJ_deg = float(DecJ_d)-float(DecJ_m)/60.-float(DecJ_s)/3600. 131 | else: 132 | DecJ_deg = float(DecJ_d)+float(DecJ_m)/60.+float(DecJ_s)/3600. 133 | 134 | print '\n', 'Ra(deg) =', RaJ_deg, ' Dec(deg) =', DecJ_deg 135 | 136 | # GL,GB 137 | Glb = SkyCoord(ra=float(RaJ_deg)*u.degree, dec=float(DecJ_deg)*u.degree, frame='icrs') 138 | GL = Glb.galactic.l.degree 139 | GB = Glb.galactic.b.degree 140 | GL = round(float(GL),2) 141 | GB = round(float(GB),2) 142 | if (GB < 0): 143 | GB = 'm'+str(GB).split('-')[1] 144 | else: 145 | GB = 'p'+str(GB) 146 | 147 | 148 | print '\n', 'GL(deg) =', GL, ' GB(deg) =', GB 149 | print '\n', 'FAST_el(deg) =', FAST_el, ' FAST_az(deg) =', FAST_az 150 | print '-----------------------------------', '\n' 151 | -------------------------------------------------------------------------------- /scintillation/heatmap-plot.py: -------------------------------------------------------------------------------- 1 | # -- coding: utf-8 -- 2 | #!/usr/bin/env python 3 | import numpy as np 4 | from matplotlib import pyplot as plt 5 | from matplotlib import cm 6 | from matplotlib import axes 7 | 8 | 9 | filename = np.genfromtxt('filelist.txt',dtype='|S50') #输入列表 10 | print(filename) 11 | lines = np.shape(filename)[0] #列表行数 12 | print(lines) 13 | 14 | name = str(filename[0]) 15 | a0 = np.loadtxt(name) 16 | h = 2048 17 | w0 = int(a0[a0.shape[0]-1,0])+1 18 | data = np.zeros((w0,h)) 19 | for i in range(a0.shape[0]): 20 | x0 = int(a0[i,0]) 21 | y0 = int(a0[i,1]) 22 | data[x0,y0]=a0[i,2] 23 | 24 | for line in range(lines): 25 | if line > 0: 26 | num = np.int(line) 27 | name = str(filename[num]) #调用文件 28 | a = np.loadtxt(name) #将文件转置为数组 29 | #h = 2048 #行数为2048 30 | w = int(a[a.shape[0]-1,0])+1 31 | w0 = w + w0 32 | data1 = np.zeros((w,h)) 33 | for i in range(a.shape[0]): 34 | x1 = int(a[i,0]) 35 | y1 = int(a[i,1]) 36 | data1[x1,y1]=a[i,2] #给二维数组赋值 37 | # f = file(filename[num]+'_trans_SNR.txt','a') 38 | # np.savetxt(f,data,fmt='%7.2f') 39 | data = np.vstack((data,data1)) 40 | xlabels = np.zeros(w0) 41 | ylabels = np.zeros(h) 42 | for i in range(w0): 43 | xlabels[i]=i 44 | for i in range(h): 45 | ylabels[i] = i 46 | #for i in range(w): 47 | # b[i+1,0]=i 48 | #for i in range(h): 49 | # b[0,i+1]=i 50 | 51 | def draw_heatmap(data,xlabels,ylabels): 52 | # cmap = cm.Blues 53 | cmap = cm.get_cmap('RdYlBu_r') 54 | figure = plt.figure(facecolor='w') 55 | ax = figure.add_subplot(1,1,1,position=[0.1,0.1,0.1,0.1]) 56 | ax.set_ylabel('sub') #y轴标签 57 | #ax.set_yticks(range(len(ylabels))) 58 | #ax.set_yticklabels(ylabels) 59 | ax.set_xlabel('chan') #x轴标签 60 | #ax.set_xticks(range(len(xlabels))) 61 | #ax.set_xticklabels(xlabels) 62 | ax.set_title(filename[num]) #添加标题 63 | vmax=data[0][0] 64 | vmin=data[0][0] 65 | for i in data: 66 | for j in i: 67 | if j>vmax: 68 | vmax=j 69 | if j0.99): 39 | stt_offs_start = np.int(0) 40 | stt_smjd_start = np.int(stt_smjd + 1) 41 | else: 42 | print 'STT_OFFS NOT counting from integer seconds!' 43 | sys.exit() 44 | stt_imjd_start = np.int(stt_imjd) 45 | stt_smjd_start = np.int(stt_smjd) 46 | 47 | T_file = nline*nsblk*tbin 48 | stt_imjd_updated = stt_imjd_start + np.int((Nfile-1)*T_file/86400) 49 | stt_smjd_updated = stt_smjd_start + np.int((Nfile-1)*T_file) 50 | stt_offs_updated = stt_offs_start + np.int(Nfile-1)*Decimal(T_file) - np.int(np.int(Nfile-1)*Decimal(T_file)) 51 | if(stt_offs_updated>1): 52 | stt_smjd_updated = stt_smjd_updated + 1. 53 | stt_offs_updated = stt_offs_updated - 1. 54 | 55 | hdu0.write_key('STT_IMJD', stt_imjd_updated) 56 | hdu0.write_key('STT_SMJD', stt_smjd_updated) 57 | hdu0.write_key('STT_OFFS', stt_offs_updated) 58 | # data = hdu1[:] 59 | # offs_sub = data['OFFS_SUB']*4. 60 | # hdu1.write_key('OFFS_SUB', offs_sub) 61 | # hdu1.write_column('OFFS_SUB', offs_sub) 62 | hdulist.close() 63 | print 'Progress:',Nfile, '/', TotNfile, ' ', Filename, '\n', 'STT_offs=', stt_offs,'->', stt_offs_updated, 'Delta_offs=', stt_offs_updated-stt_offs 64 | print 'STT_imjd=', stt_imjd,'->', stt_imjd_updated 65 | print 'STT_smjd=', stt_smjd,'->', stt_smjd_updated, '\n' 66 | # print 'OFFS_SUB[255]=', data['OFFS_SUB'][255], '->', offs_sub[255] 67 | Nfile=Nfile+1 68 | -------------------------------------------------------------------------------- /update_fitsheader/update_pos.py: -------------------------------------------------------------------------------- 1 | import fitsio 2 | import os, sys 3 | 4 | filename = sys.argv[1] 5 | 6 | hdulist = fitsio.FITS(filename, 'rw') 7 | hdulist[0].write_key('RA', '17:17:07.39') 8 | hdulist[0].write_key('DEC', '43:08:09.4') 9 | 10 | hdulist.close() 11 | --------------------------------------------------------------------------------