Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
ea60a04
Add additional folder and 3 examples to start with
Fonotec Oct 23, 2018
c609140
Adding filterbank examples
Fonotec Oct 23, 2018
0d4785e
Add an example for the raw data
Fonotec Oct 23, 2018
467c5fa
Merge branch 'master' of https://github.com/Fonotec/PSF into examplef…
Fonotec Oct 25, 2018
3e23d94
Make the buurpulsar and huispulsar example working and add structure …
Fonotec Oct 27, 2018
d389cb1
Adding updated buurpulsar raw file example
Fonotec Oct 27, 2018
7ce3051
Add the suggestion of Ewoud
Fonotec Oct 27, 2018
ed7b0d5
Make the run.sh files suitable to run on a module system (e.g. Kaptey…
Fonotec Oct 27, 2018
2777d2d
Add an other change as suggested by Ewoud
Fonotec Oct 27, 2018
0f99f9f
Add huispulsar_raw example and use better data for buurpulsar_raw
Fonotec Oct 28, 2018
e15e2a8
change name of downloaded file such that it doesnot has a space
Fonotec Oct 28, 2018
5f43fa2
change run.sh for filterbank format
Fonotec Oct 28, 2018
fff4339
Add module that can read the filterbank metadata
Fonotec Oct 28, 2018
e668b01
Read in the correct parameters from the filterbank header file
Fonotec Oct 28, 2018
9a305e6
Fix type and clean observation.py
Fonotec Oct 28, 2018
4b4b4a7
Put the example YAML files in the example folder
Fonotec Oct 28, 2018
346675b
Add a bit of documentation
Fonotec Oct 28, 2018
955d110
Make a make file that downloads the filterbank libary of Tammo Jan
Fonotec Oct 28, 2018
6196746
remove make.sh and use blimpy
Fonotec Oct 28, 2018
ee1bfdf
Load the data using blimpy
Fonotec Oct 28, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,12 @@ __pycache__/
# Data files
*.dat
*.fits
*.fits.gz

# Files downloades from Tammo-Jan gitlab
filterbank.py
sigproc.py
psr_constants.py

# Data directory on Kapteyn
data
17 changes: 17 additions & 0 deletions examples/B1133+16_filterbank/B1133+16param.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Information about the data file

FileName: '2018-01-19-21:16:50_B1133+16.fil'

# Folding parameters
Folding:
nbins: 500 # Number of bins for folding
nbinsdedisp: 500 # Number of bins for dedispersed profile

# Output parameters
Output:
OutputDir: './output'
SavePlots: true

ChiFit: false

GrasMaaier: {}
6 changes: 6 additions & 0 deletions examples/B1133+16_filterbank/getData.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
wget https://charon.camras.nl/public/pulsars/2018-01-19-21%3A16%3A50_B1133+16.txt

wget https://charon.camras.nl/public/pulsars/2018-01-19-21%3A16%3A50_B1133+16.fil


16 changes: 16 additions & 0 deletions examples/B1133+16_filterbank/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# Download the observation data if it is not present
if [ ! -e 2018-01-19-21%3A16%3A50_B1133+16.txt ]
then
echo "Dowloading the observation data"
./getData.sh
fi

# Run PSF
echo "Run PSF"
if command -v python3 &>/dev/null; then
python3 ../../main.py B1133+16param.yml
else
python ../../main.py B1133+16param.yml
fi
15 changes: 15 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Examples

In this folder there are several examples that use the code on different datasets. If you want to run an example go to the folder of the example and run the examle by doing:

`./run.sh`

This will run the example, show the output and store the output in the output folder.

## Type of examples

Currently there are four types of examples:
1. The pulsars with normal fits data.
2. The pulsars with raw data.
3. The pulsars with filterbank files (not working).
4. The pulsars with a chifit (not working).
17 changes: 17 additions & 0 deletions examples/buurpulsar/buurpulsarParam.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Information about the data file

FileName: 'B2016+28_10-04-2018.fits.gz'

# Folding parameters
Folding:
nbins: 500 # Number of bins for folding
nbinsdedisp: 500 # Number of bins for dedispersed profile

# Output parameters
Output:
OutputDir: './output'
SavePlots: true

ChiFit: false

GrasMaaier: {}
4 changes: 4 additions & 0 deletions examples/buurpulsar/getData.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
wget www.astro.rug.nl/~camras/data/CAMRAS/obs-10-04-2018/B2016+28_10-04-2018.fits.gz


17 changes: 17 additions & 0 deletions examples/buurpulsar/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# Download the observation data if it is not present
if [ ! -e B2016+28_10-04-2018.fits.gz ]
then
echo "Dowloading the observation data"
./getData.sh
fi

# Run PSF
echo "Run PSF"
if command -v python3 &>/dev/null; then
python3 ../../main.py buurpulsarParam.yml
else
python ../../main.py buurpulsarParam.yml
fi

23 changes: 23 additions & 0 deletions examples/buurpulsar_raw/buurpulsarRawParam.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Information about the data file

FileName: 'B2016-28_10-04-2018.dat'
RawData: true
FileFormat: 'raw'
ObsMetaData:
ObsDate: '2017-12-30T12:30:00(UTC)'
PulsarName: 'B2016+28'
MixFreq: 405

# Folding parameters
Folding:
nbins: 200 # Number of bins for folding
nbinsdedisp: 200 # Number of bins for dedispersed profile

# Output parameters
Output:
OutputDir: './output'
SavePlots: true

ChiFit: false

GrasMaaier: {}
2 changes: 2 additions & 0 deletions examples/buurpulsar_raw/getData.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
wget http://www.astro.rug.nl/~camras/data/obs-10-04-2018/B2016-28_10-04-2018.dat
17 changes: 17 additions & 0 deletions examples/buurpulsar_raw/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# Download the observation data if it is not present
if [ ! -e B2016+28_406MHz_2017-12-30.raw ]
then
echo "Dowloading the observation data"
./getData.sh
fi

# Run PSF
echo "Run PSF"
if command -v python3 &>/dev/null; then
python3 ../../main.py buurpulsarRawParam.yml
else
python ../../main.py buurpulsarRawParam.yml
fi

4 changes: 4 additions & 0 deletions examples/huispulsar/getData.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
wget www.astro.rug.nl/~camras/data/obs-10-04-2018/B0329+54_10-04-2018.fits.gz


17 changes: 17 additions & 0 deletions examples/huispulsar/huispulsarParam.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Information about the data file

FileName: 'B0329+54_10-04-2018.fits.gz'

# Folding parameters
Folding:
nbins: 500 # Number of bins for folding
nbinsdedisp: 500 # Number of bins for dedispersed profile

# Output parameters
Output:
OutputDir: './output'
SavePlots: true

ChiFit: false

GrasMaaier: {}
17 changes: 17 additions & 0 deletions examples/huispulsar/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# Download the observation data if it is not present
if [ ! -e B0329+54_10-04-2018.fits.gz ]
then
echo "Dowloading the observation data"
./getData.sh
fi

# Run PSF
echo "Run PSF"
if command -v python3 &>/dev/null; then
python3 ../../main.py huispulsarParam.yml
else
python ../../main.py huispulsarParam.yml
fi

22 changes: 22 additions & 0 deletions examples/huispulsar_chifit/chifitparam.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Information about the data file

FileName: 'B0329+54_10-04-2018.fits.gz'

# Folding parameters
Folding:
nbins: 500 # Number of bins for folding
nbinsdedisp: 500 # Number of bins for dedispersed profile

# Output parameters
Output:
OutputDir: './output'
SavePlots: true

ChiFit:
Ntries: 1000
nbins_time: 1000
nbins_freq: 1000
trywidth: 1e-3
FitFunc: 'Lorentzian'

GrasMaaier: {}
4 changes: 4 additions & 0 deletions examples/huispulsar_chifit/getData.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
wget www.astro.rug.nl/~camras/data/obs-10-04-2018/B0329+54_10-04-2018.fits.gz


16 changes: 16 additions & 0 deletions examples/huispulsar_chifit/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# Download the observation data if it is not present
if [ ! -e B0329+54_10-04-2018.fits.gz ]
then
echo "Dowloading the observation data"
./getData.sh
fi

# Run PSF
echo "Run PSF"
if command -v python3 &>/dev/null; then
python3 ../../main.py huispulsarParam.yml
else
python ../../main.py huispulsarParam.yml
fi
5 changes: 5 additions & 0 deletions examples/huispulsar_filterbank/getData.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
wget https://charon.camras.nl/public/pulsars/2017-09-20-07%3A05%3A00_B0329+54.txt

wget https://charon.camras.nl/public/pulsars/2017-09-20-07%3A05%3A00_B0329+54.fil

17 changes: 17 additions & 0 deletions examples/huispulsar_filterbank/huispulsarFilterbankParam.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Information about the data file

FileName: '2017-09-20-07:05:00_B0329+54.fil'

# Folding parameters
Folding:
nbins: 500 # Number of bins for folding
nbinsdedisp: 500 # Number of bins for dedispersed profile

# Output parameters
Output:
OutputDir: './output'
SavePlots: true

ChiFit: false

GrasMaaier: {}
17 changes: 17 additions & 0 deletions examples/huispulsar_filterbank/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# Download the observation data if it is not present
if [ ! -e 2017-09-20-07:05:00_B0329+54.fil ]
then
echo "Dowloading the observation data"
./getData.sh
fi

# Run PSF
echo "Run PSF"
if command -v python3 &>/dev/null; then
python3 ../../main.py huispulsarFilterbankParam.yml
else
python ../../main.py huispulsarFilterbankParam.yml
fi

3 changes: 3 additions & 0 deletions examples/huispulsar_raw/getData.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
wget -O B0329+54.2016.11.18.1038.5min.dat http://www.astro.rug.nl/~camras/data/obs-18-11-2016/B0329%2054.2016.11.18.1038.5min.dat

23 changes: 23 additions & 0 deletions examples/huispulsar_raw/huispulsarParam.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Information about the data file

FileName: 'B0329+54.2016.11.18.1038.5min.dat'
RawData: true
FileFormat: 'raw'
ObsMetaData:
ObsDate: '2016-11-18T10:38:00.00(UTC)'
PulsarName: 'B0329+54'
MixFreq: 405

# Folding parameters
Folding:
nbins: 500 # Number of bins for folding
nbinsdedisp: 500 # Number of bins for dedispersed profile

# Output parameters
Output:
OutputDir: './output'
SavePlots: true

ChiFit: false

GrasMaaier: {}
17 changes: 17 additions & 0 deletions examples/huispulsar_raw/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# Download the observation data if it is not present
if [ ! -e B0329+54.2016.11.18.1038.5min.dat ]
then
echo "Dowloading the observation data"
./getData.sh
fi

# Run PSF
echo "Run PSF"
if command -v python3 &>/dev/null; then
python3 ../../main.py huispulsarParam.yml
else
python ../../main.py huispulsarParam.yml
fi

File renamed without changes.
File renamed without changes.
21 changes: 21 additions & 0 deletions filterBank.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python

from collections import defaultdict

# https://stackoverflow.com/questions/28385822/reading-data-separated-by-colon-per-line-in-python
def filterBankReadMetaData(filename):
result = defaultdict(list)
with open(filename) as inf:
print(inf)
for line in inf:
name, score = line.split(": ", 1)
name = name.rstrip()
score = score.rstrip('\n')
result[name].append(score)
return result






22 changes: 18 additions & 4 deletions observation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
from astropy import units as u
from barcen import barcen_times, barcen_freqs
from loadData import loader
from pathlib import Path
from filterBank import filterBankReadMetaData
from blimpy import Waterfall

def calc_central_freqs(mix_freq, throwhighestfreqaway=True):
timevoltage = 1/(70e6) # (s), the time of each voltage measurement
Expand Down Expand Up @@ -43,20 +46,31 @@ def __init__(self, cfg=None, fitsfile=None):
self.psr_name = header['SRC_NAME']
self.obs_start_isot = header['DATE-OBS']
self.mix_freq = header['FREQMIX']
elif fileformat.endswith('fil'):
self.using_fits = False
obs = Waterfall(filename)
header = obs.header
self.psr_name = header[b'source_name']
self.obs_start_isot = header[b'tstart']
# Tammo-Jan doesn't store the mix frequency
self.mix_freq = header[b'fch1']-21.668359375
self.data = obs.data
#raise NotImplementedError('Filterbank supported yet!')
else:
self.using_fits = False
self.psr_name = cfg.ObsMetaData.PulsarName
self.obs_start_isot = cfg.ObsMetaData.ObsDate
self.mix_freq = cfg.ObsMetaData.MixFreq
if fileformat.endswith('fil'):
raise NotImplementedError('Filterbank supported yet!')
elif fileformat.endswith('raw'):
if fileformat.endswith('raw'):
assert cfg.RawData, 'Need to supply the metadata!'
self.data = loader(cfg.FileName).astype(np.uint32)
else:
raise ValueError('Unrecognized format')

self.obs_start = Time(self.obs_start_isot)
if fileformat.endswith('fil'):
self.obs_start = Time(self.obs_start_isot,format='jd')
else:
self.obs_start = Time(self.obs_start_isot)
dt = 64*512/(70e6)
self.obs_dur = len(self.data) * dt
self.obs_end = self.obs_start + self.obs_dur * u.s
Expand Down
Loading