Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
99 changes: 99 additions & 0 deletions FindingBadFreqs.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from observation import Observation\n",
"from folding import timeFolding\n",
"import numpy as np\n",
"from matplotlib.pyplot import subplots, show\n",
"from dispersionMeasure import dedispersion"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"obs = Observation(\"examples/huispulsar_filterbank/2017-09-20-07:05:00_B0329+54.fil\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"folded = timeFolding(obs.data, 500, obs.pulsar.period, obs.data==0, obs.times)\n",
"foldedscaled = (folded - folded.mean(axis=0))/folded.std(axis=0)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"fig, ax = subplots()\n",
"ax.matshow(foldedscaled)\n",
"show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"obs2 = Observation(\"examples/B1133+16_filterbank/2018-01-19-21:16:50_B1133+16.fil\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"folded2 = timeFolding(obs2.data, 500, obs2.pulsar.period, obs2.data==0, obs2.times)\n",
"foldedscaled2 = (folded2 - folded2.mean(axis=0))/folded2.std(axis=0)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"fig, ax = subplots()\n",
"dedisp=dedispersion(folded, obs, obs.pulsar.period, obs.pulsar.DM)\n",
"ax.plot(dedisp)\n",
"show()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
16 changes: 6 additions & 10 deletions paramObj.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,9 @@ class AttrDict(dict):
""" Dictionary subclass whose entries can be accessed by attributes
(as well as normally).
"""
def __init__(self, *args, dict_data=None, **kwargs):
if dict_data is None:
super(AttrDict, self).__init__(*args, **kwargs)
self.__dict__ = self
else:
super(AttrDict, self).__init__(self.from_nested_dict(dict_data))
self.__dict__ = self
def __init__(self, *args, **kwargs):
super(AttrDict, self).__init__(*args, **kwargs)
self.__dict__ = self

@staticmethod
def from_nested_dict(data):
Expand Down Expand Up @@ -63,7 +59,7 @@ def __init__(self,paramyml, defaults=Path(__file__).parent/'defaults.yml'):
# Input validation can happen here
assert 'FileName' in usercfg, 'Provide observation parameters'
assert 'Output' in usercfg, 'Provide output information'
super(Config, self).__init__(dict_data=cfg) # Magic...
super(Config, self).__init__(AttrDict.from_nested_dict(cfg)) # Magic...

self.usercfg = AttrDict(usercfg)
self.defaults= AttrDict(defaults)
self.usercfg = AttrDict.from_nested_dict(usercfg)
self.defaults= AttrDict.from_nested_dict(defaults)