From 4c38729e3dfc80b31c96cef03de234c043e19e44 Mon Sep 17 00:00:00 2001 From: Ewoud Date: Wed, 31 Oct 2018 11:25:22 +0100 Subject: [PATCH 1/2] Small paramObj cleanup --- paramObj.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/paramObj.py b/paramObj.py index 7c11ea5..b86ca2b 100644 --- a/paramObj.py +++ b/paramObj.py @@ -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): @@ -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) From ea1970f18f1b8cefaa0f44c7c17ee31afcb45646 Mon Sep 17 00:00:00 2001 From: Ewoud Date: Mon, 5 Nov 2018 18:08:01 +0100 Subject: [PATCH 2/2] A small notebook to play with the data a bit... --- FindingBadFreqs.ipynb | 99 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 FindingBadFreqs.ipynb diff --git a/FindingBadFreqs.ipynb b/FindingBadFreqs.ipynb new file mode 100644 index 0000000..c1c63a0 --- /dev/null +++ b/FindingBadFreqs.ipynb @@ -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 +}