From 7a6104139eb0364e12be7a1c67c4ae670de0377d Mon Sep 17 00:00:00 2001 From: Iva Laginja Date: Sun, 2 Jun 2019 17:22:34 -0400 Subject: [PATCH 01/20] I updated the general configfile to be up-to-date with the most recent changes. --- HST_python/config.ini | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/HST_python/config.ini b/HST_python/config.ini index 26569ec5..9a61ec22 100644 --- a/HST_python/config.ini +++ b/HST_python/config.ini @@ -20,6 +20,13 @@ grid_selection = fit_time run_name = wl_time_wm3d plotting = True outlier_limit_std = 3. +errors = hessian +; "hessian" or "confidence" + + +[smooth_model] +resolution = 0.0001 +half_range = 0.2 [planet_parameters] ; Rp/R* estimate - th transit depth @@ -31,7 +38,7 @@ epoch = 57957.970153390 ; deg inclin = 87.34635 -; deg +; deg ecc = 0.0 ; deg From 60ab781290cbbfeffe06750cd3930acd84e03753 Mon Sep 17 00:00:00 2001 From: Iva Laginja Date: Fri, 14 Jun 2019 10:08:58 -0400 Subject: [PATCH 02/20] Created environment.yml --- environment.yml | 109 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 environment.yml diff --git a/environment.yml b/environment.yml new file mode 100644 index 00000000..fc4c686d --- /dev/null +++ b/environment.yml @@ -0,0 +1,109 @@ +# ONLY PYTHON 3 SUPPORT! +# +# ``conda env create --file environment.yml`` +# or +# ``conda env create --name --file environment.yml`` + + +name: hstmarg +channels: + - http://ssb.stsci.edu/astroconda + - defaults +dependencies: + - astropy=3.1.2=py36h1de35cc_0 + - atomicwrites=1.3.0=py36_1 + - attrs=19.1.0=py36_1 + - blas=1.0=mkl + - ca-certificates=2019.1.23=0 + - cycler=0.10.0=py36_0 + - freetype=2.5.5=2 + - icu=54.1=0 + - libcxx=4.0.1=hcfea43d_1 + - libcxxabi=4.0.1=hcfea43d_1 + - libedit=3.1.20181209=hb402a30_0 + - libffi=3.2.1=h475c297_4 + - libgfortran=3.0.1=h93005f0_2 + - libpng=1.6.30=1 + - matplotlib=2.0.2=np113py36_0 + - mkl=2017.0.3=0 + - more-itertools=6.0.0=py36_0 + - ncurses=6.1=h0a44026_1 + - numpy=1.14.2=py36ha9ae307_0 + - openssl=1.1.1b=h1de35cc_1 + - pandas=0.20.3=py36_0 + - pluggy=0.9.0=py36_0 + - psutil=5.6.1=py36h1de35cc_0 + - py=1.8.0=py36_0 + - pyparsing=2.2.0=py36_0 + - pyqt=5.6.0=py36_2 + - pytest=4.3.1=py36_0 + - pytest-arraydiff=0.3=py36h39e3cac_0 + - pytest-astropy=0.5.0=py36_0 + - pytest-doctestplus=0.3.0=py36_0 + - pytest-openfiles=0.3.2=py36_0 + - pytest-remotedata=0.3.1=py36_0 + - python=3.6.8=haf84260_0 + - python-dateutil=2.6.1=py36_0 + - pytz=2017.2=py36_0 + - qt=5.6.2=2 + - readline=7.0=h1de35cc_5 + - scipy=0.19.1=np113py36_0 + - setuptools=40.8.0=py36_0 + - sip=4.18=py36_0 + - six=1.12.0=py36_0 + - sqlite=3.27.2=ha441bb4_0 + - tk=8.6.8=ha441bb4_0 + - wheel=0.33.1=py36_0 + - xz=5.2.4=h1de35cc_4 + - zlib=1.2.11=0 + - pip: + - appnope==0.1.0 + - backcall==0.1.0 + - bleach==3.1.0 + - certifi==2019.3.9 + - chardet==3.0.4 + - colorama==0.4.1 + - decorator==4.4.0 + - defusedxml==0.5.0 + - entrypoints==0.3 + - gitdb2==2.0.5 + - gitpython==2.1.11 + - idna==2.8 + - ipykernel==5.1.0 + - ipython==7.4.0 + - ipython-genutils==0.2.0 + - jedi==0.13.3 + - jinja2==2.10 + - jsonschema==3.0.1 + - jupyter-client==5.2.4 + - jupyter-core==4.4.0 + - markupsafe==1.1.1 + - mgefit==5.0.12 + - mistune==0.8.4 + - nbconvert==5.4.1 + - nbdime==1.0.5 + - nbformat==4.4.0 + - notebook==5.7.6 + - pandocfilters==1.4.2 + - parso==0.3.4 + - pexpect==4.6.0 + - pickleshare==0.7.5 + - pip==19.0.3 + - prometheus-client==0.6.0 + - prompt-toolkit==2.0.9 + - ptyprocess==0.6.0 + - pygments==2.3.1 + - pyrsistent==0.14.11 + - pyzmq==18.0.1 + - requests==2.21.0 + - send2trash==1.5.0 + - sherpa==4.11.0 + - smmap2==2.0.5 + - terminado==0.8.1 + - testpath==0.4.2 + - tornado==6.0.2 + - traitlets==4.3.2 + - urllib3==1.24.1 + - wcwidth==0.1.7 + - webencodings==0.5.1 + From 234270b36bf39c0464295eb1ec0f269747ffa273 Mon Sep 17 00:00:00 2001 From: Iva Laginja Date: Fri, 14 Jun 2019 10:43:29 -0400 Subject: [PATCH 03/20] Added MIT license --- LICENCE.txt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENCE.txt diff --git a/LICENCE.txt b/LICENCE.txt new file mode 100644 index 00000000..0df79aab --- /dev/null +++ b/LICENCE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Hannah R. Wakeford + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From ea1c3666823f134dda05fd4fa4dbf23899653471 Mon Sep 17 00:00:00 2001 From: Iva Laginja Date: Fri, 14 Jun 2019 11:28:11 -0400 Subject: [PATCH 04/20] Create CITATION.txt --- CITATION.txt | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 CITATION.txt diff --git a/CITATION.txt b/CITATION.txt new file mode 100644 index 00000000..9f63f958 --- /dev/null +++ b/CITATION.txt @@ -0,0 +1,32 @@ +To reference [NEWNAME] in publications, please cite both of the following: + +- Wakeford et al.: "Marginalizing Instrument Systematics in HST WFC3 Transit Light Curves", 2016 ApJ 819 10 +- NATIVE SOFTWARE DOI: [...] + +We provide the following LaTeX/BibTeX acknowledgment if there is no specific place to cite the above: +"This research made use of [NEWNAME] \citep{SOFTWARE-DOI}, a software package developed based on the +work of \cite{wakeford2016}." + +@SOFTWARE{ + ..fill this in once we have a DOI... +} + +@ARTICLE{wakeford2016, + author = {{Wakeford}, H.~R. and {Sing}, D.~K. and {Evans}, T. and {Deming}, D. and + {Mandell}, A.}, + title = "{Marginalizing Instrument Systematics in HST WFC3 Transit Light Curves}", + journal = {\apj}, + keywords = {methods: data analysis, planets and satellites: atmospheres, techniques: spectroscopic, Astrophysics - Earth and Planetary Astrophysics}, + year = "2016", + month = "Mar", + volume = {819}, + number = {1}, + eid = {10}, + pages = {10}, + doi = {10.3847/0004-637X/819/1/10}, +archivePrefix = {arXiv}, + eprint = {1601.02587}, + primaryClass = {astro-ph.EP}, + adsurl = {https://ui.adsabs.harvard.edu/abs/2016ApJ...819...10W}, + adsnote = {Provided by the SAO/NASA Astrophysics Data System} +} From d8996c89b8856150adfb440e847c4dcf8f6f5dad Mon Sep 17 00:00:00 2001 From: Iva Laginja Date: Fri, 14 Jun 2019 11:36:33 -0400 Subject: [PATCH 05/20] Update .gitignore with .idea/ --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 351c5844..c662b7f9 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ config_local.ini outputs/ .ipynb_checkpoints/ +.idea/ From 59533652157d30cc0a664fd4526fd06791c3ac9e Mon Sep 17 00:00:00 2001 From: Iva Laginja Date: Fri, 14 Jun 2019 11:38:43 -0400 Subject: [PATCH 06/20] deleted the .idea folder and its contents (not needed in VC) --- .idea/HST_Marginalization.iml | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 .idea/HST_Marginalization.iml diff --git a/.idea/HST_Marginalization.iml b/.idea/HST_Marginalization.iml deleted file mode 100644 index 52b220be..00000000 --- a/.idea/HST_Marginalization.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - \ No newline at end of file From 3aff6b76d3bd70d33da5e4b32031a01e5c00577a Mon Sep 17 00:00:00 2001 From: Iva Laginja Date: Fri, 14 Jun 2019 11:40:27 -0400 Subject: [PATCH 07/20] Deleted "outputs" folder. Should be off-repo, see configfile. From 72f0207f08d4b3e78356a61bdacb9ad69e95a879 Mon Sep 17 00:00:00 2001 From: Iva Laginja Date: Fri, 14 Jun 2019 11:43:07 -0400 Subject: [PATCH 08/20] Removed ipynb checkpoints and pycache --- .../InteractivePlotting-checkpoint.ipynb | 397 ------------------ .../NumpyData-checkpoint.ipynb | 209 --------- .../G141_lightcurve_circle.cpython-36.pyc | Bin 16826 -> 0 bytes .../__pycache__/__init__.cpython-36.pyc | Bin 155 -> 0 bytes 4 files changed, 606 deletions(-) delete mode 100644 HST_python/.ipynb_checkpoints/InteractivePlotting-checkpoint.ipynb delete mode 100644 HST_python/.ipynb_checkpoints/NumpyData-checkpoint.ipynb delete mode 100644 HST_python/__pycache__/G141_lightcurve_circle.cpython-36.pyc delete mode 100644 HST_python/__pycache__/__init__.cpython-36.pyc diff --git a/HST_python/.ipynb_checkpoints/InteractivePlotting-checkpoint.ipynb b/HST_python/.ipynb_checkpoints/InteractivePlotting-checkpoint.ipynb deleted file mode 100644 index 9798bd69..00000000 --- a/HST_python/.ipynb_checkpoints/InteractivePlotting-checkpoint.ipynb +++ /dev/null @@ -1,397 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Interactive plotting - how to not need to wait till your code is finished to see your pretty plots\n", - "\n", - "It is super annoying when you have a script that needs a while to finish and you have no clue what is going on in the meantime. Sometimes it will be useful so plot intermediate results to have a sanity chek or an early sneak-peak.\n", - "\n", - "Interactive plotting is a bit different when you use it in interactive Python (ipython), a notebook or when you run a script. I am not sure how much notebooks actually support interactive plotting at all, but it seemed easier to plug my examples into a notebook and then you can go ahead and copy-paste the code into an actual script, run it and see how it goes.\n", - "\n", - "This is the reason why I, very un-notebook-like, dumped all the code into a single cell instead of using the advantage of a notebook to \"cell your code up\" - split it up I guess, but I like \"celling up\" now :P" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "# Let's get starte with imports\n", - "import os\n", - "import numpy as np\n", - "import matplotlib.pyplot as plt" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The pyplot functoin plt.ion() comes up a lot when working with interactive plotting, but I think it is only really needed when you work in ipython, so that your console doesn't hang itself up as soon as it creates a plot. It's not needed when using interactive plotting in a script.\n", - "\n", - "First, let's look at a standard plotting example, in which your plot is blocking your script from continnuing to run:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Creating some fake data\n", - "x = np.arange(0, 4*np.pi, 0.1)\n", - "y = [np.sin(i) for i in x]\n", - "\n", - "# Normal plot, which gets generated when script hits this point in your code and then it won't resume until you close\n", - "# the figure.\n", - "plt.plot(x, y)\n", - "plt.title('This plot is blocking your script from continuing to run.')\n", - "plt.show()\n", - "\n", - "print('See? This line appears only after you close the figure.')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Using plt.draw() instead of plt.show() will close the\n", - "figure immediately, which is great if you want to keep your script running, but you also won't have any time to look at your figure:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Creating some fake data again, because I am actually running this in an independent script.\n", - "x = np.arange(0, 4*np.pi, 0.1)\n", - "y = [np.sin(i) for i in x]\n", - "y2 = [2*b for b in y]\n", - "y3 = [c-1 for c in y]\n", - "\n", - "plt.plot(x, y, 'r.')\n", - "plt.draw()\n", - "\n", - "plt.plot(x, y2, 'k-')\n", - "plt.draw()\n", - "\n", - "plt.plot(x, y3, 'b')\n", - "plt.draw()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This is why we need to add plt.pause([[sec]) after each plt.draw() statement, so that the figure actually gets displayed:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "# Creating some fake data again, because I am actually running this in an independent script.\n", - "x = np.arange(0, 4*np.pi, 0.1)\n", - "y = [np.sin(i) for i in x]\n", - "y2 = [2*b for b in y]\n", - "y3 = [c-1 for c in y]\n", - "\n", - "plt.plot(x, y, 'r.')\n", - "plt.draw()\n", - "plt.pause(1.0)\n", - "\n", - "plt.plot(x, y2, 'k-')\n", - "plt.draw()\n", - "plt.pause(1.0)\n", - "\n", - "plt.plot(x, y3, 'b')\n", - "plt.draw()\n", - "plt.pause(1.0)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The downside is that the figure disappears once the script is done. If you want to keep the last version of your figure open, you can use plt.show() at your very last version of your figure again:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "# Creating some fake data again, because I am actually running this in an independent script.\n", - "x = np.arange(0, 4*np.pi, 0.1)\n", - "y = [np.sin(i) for i in x]\n", - "y2 = [2*b for b in y]\n", - "y3 = [c-1 for c in y]\n", - "\n", - "plt.plot(x, y, 'r.')\n", - "plt.draw()\n", - "plt.pause(1.0)\n", - "\n", - "plt.plot(x, y2, 'k-')\n", - "plt.draw()\n", - "plt.pause(1.0)\n", - "\n", - "plt.plot(x, y3, 'b')\n", - "plt.show()\n", - "\n", - "print('Keep in mind that this will keep your script from continuing/finishing at this point.')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "You can simply put a plt.show() statement at the end of your code if you want to run your entire script and then keep the final figure open until you manually close it (and hence finish your script)." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "# Creating some fake data again, because I am actually running this in an independent script.\n", - "x = np.arange(0, 4*np.pi, 0.1)\n", - "y = [np.sin(i) for i in x]\n", - "y2 = [2*b for b in y]\n", - "y3 = [c-1 for c in y]\n", - "\n", - "plt.plot(x, y, 'r.')\n", - "plt.draw()\n", - "plt.pause(1.0)\n", - "\n", - "plt.plot(x, y2, 'k-')\n", - "plt.draw()\n", - "plt.pause(1.0)\n", - "\n", - "plt.plot(x, y3, 'b')\n", - "#plt.draw() # Depending on what your code looks like, you might not need this plt.draw() and plt.pause().\n", - "plt.pause(1.0) # But it's probably a good idea to keep them there anyway.\n", - "\n", - "print('Now I am putting plt.show() at the very end of my script, so that it fully finishes before I get all the time \\\n", - " in the world to admire that beautiful final figure of mine.')\n", - "\n", - "plt.show()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The argument in plt.pause() will mostly be very short, because it is only needed to display your figure, but yo don't actually want to delay your script for too long for no reason." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "# Creating some fake data again, because I am actually running this in an independent script.\n", - "x = np.arange(0, 4*np.pi, 0.1)\n", - "y = [np.sin(i) for i in x]\n", - "y2 = [2*b for b in y]\n", - "y3 = [c-1 for c in y]\n", - "\n", - "for n in range(20):\n", - " y4 = [np.sin(i+n) for i in x]\n", - " plt.plot(x, y4)\n", - " plt.draw()\n", - " plt.pause(0.05)\n", - "\n", - "print('Note how we went through all the sine functions very quickly.')\n", - "\n", - "plt.show()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Often enough you don't want your new data to overplot your old data, but you want to plot it on a clean canvas. you can do this by inserting plt.clf() any time you want to clean your figure (clf = clean figure).\n", - "\n", - "I took the plt.show() out in this example because it would just be displaying a blank figure, waiting for me to close it." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "# Creating some fake data again, because I am actually running this in an independent script.\n", - "x = np.arange(0, 4*np.pi, 0.1)\n", - "y = [np.sin(i) for i in x]\n", - "y2 = [2*b for b in y]\n", - "y3 = [c-1 for c in y]\n", - "\n", - "for n in range(20):\n", - " y4 = [np.sin(i+n) for i in x]\n", - " plt.plot(x, y4)\n", - " plt.draw()\n", - " plt.pause(0.05)\n", - " plt.clf()\n", - "\n", - "print('Note how we went through all the sine functions very quickly.')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "You can play around with if-statements if you still want to use plt.show() at the end of your script to keep the figure displayed." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "# Creating some fake data again, because I am actually running this in an independent script.\n", - "x = np.arange(0, 4*np.pi, 0.1)\n", - "y = [np.sin(i) for i in x]\n", - "y2 = [2*b for b in y]\n", - "y3 = [c-1 for c in y]\n", - "\n", - "for n in range(20):\n", - " y4 = [np.sin(i+n) for i in x]\n", - " plt.plot(x, y4)\n", - " plt.draw()\n", - " plt.pause(0.05)\n", - " if n != np.max(range(20)):\n", - " plt.clf()\n", - "\n", - "print('And whoop we can still admire our final figure for as long as we want to.')\n", - "\n", - "plt.show()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "And finally, of course you can also save your final figure:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "# Creating some fake data again, because I am actually running this in an independent script.\n", - "x = np.arange(0, 4*np.pi, 0.1)\n", - "y = [np.sin(i) for i in x]\n", - "y2 = [2*b for b in y]\n", - "y3 = [c-1 for c in y]\n", - "\n", - "for n in range(20):\n", - " y4 = [np.sin(i+n) for i in x]\n", - " plt.plot(x, y4)\n", - " plt.draw()\n", - " plt.pause(0.05)\n", - " if n != np.max(range(20)):\n", - " plt.clf()\n", - "\n", - "print('And whoop we can still admire our final figure for as long as we want to.')\n", - "\n", - "plt.savefig('fig_test.pdf')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "And if you want to save it AND to have it open in a pyplot window until you decide to close it, this should work:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Creating some fake data again, because I am actually running this in an independent script.\n", - "x = np.arange(0, 4*np.pi, 0.1)\n", - "y = [np.sin(i) for i in x]\n", - "y2 = [2*b for b in y]\n", - "y3 = [c-1 for c in y]\n", - "\n", - "for n in range(20):\n", - " y4 = [np.sin(i+n) for i in x]\n", - " plt.plot(x, y4)\n", - " plt.draw()\n", - " plt.pause(0.05)\n", - " if n != np.max(range(20)):\n", - " plt.clf()\n", - "\n", - "print('And whoop we can still admire our final figure for as long as we want to.')\n", - "\n", - "plt.savefig('fig_test.pdf')\n", - "plt.show()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "# In case you're running this in thsi notebook after all (which won't make the plots interactive), you can delete\n", - "# your test figure with:\n", - "os.remove('fig_test.pdf')" - ] - } - ], - "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.6.2" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/HST_python/.ipynb_checkpoints/NumpyData-checkpoint.ipynb b/HST_python/.ipynb_checkpoints/NumpyData-checkpoint.ipynb deleted file mode 100644 index 0221a600..00000000 --- a/HST_python/.ipynb_checkpoints/NumpyData-checkpoint.ipynb +++ /dev/null @@ -1,209 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# How to quickly save and load data with numpy\n", - "\n", - "Sometimes data is generated in your code that doesn't need to be save in a pretty, human-readable way, but we would still like to save it somewhere so that we can retrieve it later.\n", - "Numpy has a couple of pretty nifty functions for that and a general overview can be found here:\n", - "https://docs.scipy.org/doc/numpy/reference/routines.io.html\n", - "\n", - "We will be focussing on numpy.savez(), a function that lets to save arrays to .npz files, which are basically zipped files." - ] - }, - { - "cell_type": "code", - "execution_count": 52, - "metadata": {}, - "outputs": [], - "source": [ - "# Let's ge tour numpy in\n", - "import numpy as np\n", - "import os # so that we can delete the file later" - ] - }, - { - "cell_type": "code", - "execution_count": 36, - "metadata": {}, - "outputs": [], - "source": [ - "# Generate some random arrays\n", - "x = np.arange(10)\n", - "y = np.array(([2,3,4,6,4,4,5,4,4,5,6,4,5,56,6,5,3,4], [4,3,4,56,6,7,8,9,7,6,6,], ['Hello!', 'Why', 'not', 'strings?']))\n", - "z = np.ones((13,13))\n", - "many = np.array([[3,4,5], [6,4,52]])\n", - "more = np.ones((4,17))" - ] - }, - { - "cell_type": "code", - "execution_count": 37, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "x shape: (10,)\n", - "y shape: (3,)\n", - "z shape: (13, 13)\n", - "many shape: (2, 3)\n", - "more shape: (4, 17)\n" - ] - } - ], - "source": [ - "# It's good practice to double check your data:\n", - "print('x shape: ', x.shape)\n", - "print('y shape: ', y.shape)\n", - "print('z shape: ', z.shape)\n", - "print('many shape: ', many.shape)\n", - "print('more shape: ', more.shape)" - ] - }, - { - "cell_type": "code", - "execution_count": 38, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "x type: \n", - "y type: \n", - "z type: \n", - "more type: \n" - ] - } - ], - "source": [ - "print('x type: ', type(x))\n", - "print('y type: ', type(y))\n", - "print('z type: ', type(z))\n", - "print('more type: ', type(more))" - ] - }, - { - "cell_type": "code", - "execution_count": 42, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "This will save it to your current directory btw, whereever you opened this notebook in.\n" - ] - } - ], - "source": [ - "# We can now save that to a .npz file\n", - "\n", - "# We need a name for our file\n", - "filename = 'numpy_file_1'\n", - "\n", - "# And this is how we save it\n", - "np.savez(filename, name_1=x, name_2=y, name_3=z, name_4=many, name_5=more)\n", - "\n", - "print('This will save it to your current directory btw, whereever you opened this notebook in.')" - ] - }, - { - "cell_type": "code", - "execution_count": 43, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['name_1', 'name_2', 'name_3', 'name_4', 'name_5']\n" - ] - } - ], - "source": [ - "# Now that we saved it, load it back into this notebook.\n", - "in_data = np.load(filename+'.npz')\n", - "\n", - "# Check what data is hidden in our loaded file\n", - "print(in_data.files)" - ] - }, - { - "cell_type": "code", - "execution_count": 47, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[ 3 4 5]\n", - " [ 6 4 52]]\n" - ] - } - ], - "source": [ - "# Want to acces the array with name array_name_2? Here we go!\n", - "short = in_data['name_4']\n", - "print(short)" - ] - }, - { - "cell_type": "code", - "execution_count": 45, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Type of short: \n", - "Shape of short: (2, 3)\n" - ] - } - ], - "source": [ - "print('Type of short: ', type(short))\n", - "print('Shape of short: ', short.shape)" - ] - }, - { - "cell_type": "code", - "execution_count": 53, - "metadata": {}, - "outputs": [], - "source": [ - "short\n", - "\n", - "# And delete the file now, so that we don't clutter your current working directory.\n", - "os.remove(filename+'.npz')" - ] - } - ], - "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.6.2" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/HST_python/__pycache__/G141_lightcurve_circle.cpython-36.pyc b/HST_python/__pycache__/G141_lightcurve_circle.cpython-36.pyc deleted file mode 100644 index c78053cf6baff82d2633b32d515d0f89715e75fb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16826 zcmd5@Nq8K`b)FS790DLVk^ncgD2fC~V1NNgN`fho5Wxj9HUmRaYLXf^rh5hr%uElv zd$6fGb^ zmw@c*SJhSTy?XD}tL4>9babRT*T(OTzZDAoODOQy0r(0Y=Rd-skRDP)dRUK?!sUn> z2@@PGMb#L8$JIFAu~J((p(gmZcqv)lr|#o$TPaoEukHt&(377CsqIFGzHdG9Fl_%) zPpO?oeC@zmm(i*3-;JoDPI4mehjc8 z;p2dxmhcI{Cnfw8;Aa3I(-r+`z^5d967aJUeg^Pq37-OdM#9em9+dEDz(W!~1Nbb5 z2lXMq=Ola<@USstoa+mzBgU{X(ih@SY%Q&yL*GY{=jm?vXh=`@hSV|RtT6_71aQVU zWjt$~HZsN;V-Q%58z+pXiYay6Xg3ZShmC$?z!*1<8b=Jpc-rVTP8!ebwnJ;t<$yl3W2rfgYI^UggO+ z28WbFt-_g4-N`%`B;p#5`(Gnb*33!}VG0t1-0s}GwsfsQMzIaIW>*|#B%_!GrDB2E zN|8iguxb@u*>IHVwz~>pii-46t0+df>TW|Awzi#C6iCcANHj_w`f`*_o~Lf7fXFOY zE!)*9E*k2D*@Y4-idk_jMa$74a2RtP)}+bRtRh>hN7EJ zo=g+;R%%5j4WU9*RSRMwnZb(J@kz>wc!k`rp+1zuby9F))*QcRvx%N)K-|J%>OsxS zueaDI7a1%gt<Enc6=Ld7e#W^Y3@ zU`KW18ul=J1TQa@p?0OJ<=3?$*#rpYZM3=JJF*UAcX5fqFt zxF>f`bP5^|Ncb_yLiaO##8~$Bu%f}d(Q8mZ7bPRyT?H879Z5A5LN*AaBNZraO$;v0 z2FtJ_;uU6EF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|%q7Z(R>|2VwVT?I7_hj*aiv{)p!UFd!|~>gKw0-=Why+MT_hCy zB_O0CL?CD$Xvjm7O>we9WWBAFMd86cba?3lweLyAYKjvU4Lh4K=c8S?R!O%@=Adg? zlH{DAc&`MgsCN%JlszsMs(64?1%x98cq(1(-BZAM>5vt;P;|9hW*f}t>b^QRy4uq! z7Sz=r>pm4ecoLU-D@RyBwQ__4p(TF4Bt>yRWE$*1u4Ej%RNbQ`QMgx2y!3G`iONFK z8eGs`!=f^wLs3)cki(qIeO#ER<)|GEkiImxs5Wia{6jaMxYaz3Zw_C_T#SU<+G63( zXnPp{BFR`XoD3hrLuq^XB$WY z)p#G;cZRzNOE?+r!q;TDC)^e7uS3Zg@`q5TJ=_&R&1g@e4R9=+j0|QgmV;aauh@TRAekX7HcDEMq4>UKN`FNj)S}KFr?QL=1{cGC+DR7 z2yqPAH2*{rHU#gcd2%_2tEX=+V|<>>y+du(I{D=B#*?8Vwl@> zKxxyFq@6$_&q=zjNZ=RsQ?uli#!hZ%!cXL|s>tVZY8O8ZKi9d4Kdj0YqkG;s5{u diff --git a/HST_python/__pycache__/__init__.cpython-36.pyc b/HST_python/__pycache__/__init__.cpython-36.pyc deleted file mode 100644 index 04f591c72f13dd603be2973f56f1dfc6e143f7a8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 155 zcmXr!<>g{bHHu~cg2x~N1{i@12OutH0TL+;!3>&=ek&P@K*9*(mxq36acWVqer8T$ zdS+f$qP|Oha%paAUP-aOduEBgM{r2IZ(V!Z From 40a710ee4f13840a6795176e7d8e793c81742ce4 Mon Sep 17 00:00:00 2001 From: Iva Laginja Date: Fri, 14 Jun 2019 12:18:36 -0400 Subject: [PATCH 09/20] Update README.md --- README.md | 67 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 59 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index af5a210f..045e1a5b 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,69 @@ -# HST Marginalization +# HST marginalization - NEWNAME -This code performs Levenberg-Marquardt least-squares minimization across a grid of stochastic systematic models to produce marginalised transit parameters given a WFC3 G141 lightcurve for a specified wavelength range. +This code performs Levenberg-Marquardt least-squares minimization across a grid of stochastic systematic models to produce marginalized transit parameters given a lightcurve for a specified wavelength range. -This code follows the method outlined in Wakeford, et al. (2016, ApJ, 819, 1), using marginalisation across a stochastic grid of models. -The program makes use of the analytic transit model in Mandel & Agol (2002, ApJ Letters, 580, L171-175) and Lavenberg-Markwardt least squares minimisation using the IDL routine MPFIT (Markwardt, 2009, Book:Astronomical Data Analysis Software and Systems XVIII, 411, 251, Astronomical Society of the Pacific Conference Series). -Here a 4-parameter limb darkening law is used as outlined in Claret, 2010 and Sing et al. 2010. +This was developed and tested for data from Wide Field Camera 3 (WFC3) on the Hubble Space Telescope (HST), specifically with the G141 grid, as published in Wakeford et al. (2016, ApJ, 819, 1). Future work includes plans to extend this to other WFC3 grids, STIS data, and eventually data from the James Webb Space Telescope (JWST). -####################################### -Current instructions to make stuff run: +This code follows the method outlined in Wakeford, et al. (2016), using marginalization across a stochastic grid of models. The program makes use of the analytic transit model in Mandel & Agol (2002, ApJ Letters, 580, L171-175) and a Levenberg-Marquardt least squares minimization using [Sherpa](https://sherpa.readthedocs.io/en/latest/), a Python package for modeling and fitting data. The model uses a 4-parameter limb darkening law, as outlined in Claret (2010) and Sing et al. (2010). +This package was built from the original IDL code used for the analysis in Wakeford et al. (2016), initially translated by Matthew Hill and then further adapted and transformed into a full astronomy Python package by Iva Laginja. -CONFIGURATION FILE: +## Getting Started + +### Prerequisites + +What things you need to install the software and how to install them + +``` +Give examples +``` + +### Configuration file The main configuration file is config.ini, which holds all of your simulation paramers. This file, however, is version controlled, and the paths to local directories will get messed up if you push this file. This is why config.ini is supposed to be a TEMPLATE. In order to make it work for you, use config_local.ini to set all your parametere, since it will override the config.ini. Make sure you tell your version control system to ignore config_local.ini! + +### Output data + +Where your data will be saved. + +### Minimum working example + +A step by step series of examples that tell you how to get a development env running + +Say what the step will be + +``` +Give the example +``` + +And repeat + +``` +until finished +``` + +End with an example of getting some data out of the system or using it for a little demo + +## Contributing + +We still need to create this file, but once it's there: +Please read [CONTRIBUTING.md]() for details on our code of conduct, and the process for submitting pull requests to us. + +## Authors + +* **Hannah R. Wakefort** - *Method author* - [@hwakeford](https://github.com/hwakeford) +* **Iva Laginja** - *Upgrades and builds leading up to release 1.0.0* - [@ivalaginja](https://github.com/ivalaginja) +* **Matthew Hill** - *Translation from IDL to Python* - [@mattjhill](https://github.com/mattjhill) + +## License + +This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details + +## Acknowledgments + +* Matthew Hill for a functional translation from IDL to Python +* Iva Laginja for finding `Sherpa`, making the clunky `mpfit` dispensable +* The [`Sherpa' team](https://github.com/sherpa/sherpa), providing a fantastic package and answering fast to GitHub issues From 24e270a8db8ed4c89f3e55ffd618af9a9f2d4c20 Mon Sep 17 00:00:00 2001 From: Iva Laginja Date: Fri, 14 Jun 2019 12:25:25 -0400 Subject: [PATCH 10/20] Addded license shield to readme and fixed some typos --- README.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 045e1a5b..2a753d01 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ + +[![MIT License][license-shield]][license-url] + + # HST marginalization - NEWNAME This code performs Levenberg-Marquardt least-squares minimization across a grid of stochastic systematic models to produce marginalized transit parameters given a lightcurve for a specified wavelength range. @@ -49,21 +53,26 @@ End with an example of getting some data out of the system or using it for a lit ## Contributing -We still need to create this file, but once it's there: +We still need to create this file, but once it's there: Please read [CONTRIBUTING.md]() for details on our code of conduct, and the process for submitting pull requests to us. ## Authors -* **Hannah R. Wakefort** - *Method author* - [@hwakeford](https://github.com/hwakeford) +* **Hannah R. Wakeford** - *Method author* - [@hrwakeford](https://github.com/hrwakeford) * **Iva Laginja** - *Upgrades and builds leading up to release 1.0.0* - [@ivalaginja](https://github.com/ivalaginja) * **Matthew Hill** - *Translation from IDL to Python* - [@mattjhill](https://github.com/mattjhill) ## License -This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details +This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.txt) file for details ## Acknowledgments * Matthew Hill for a functional translation from IDL to Python * Iva Laginja for finding `Sherpa`, making the clunky `mpfit` dispensable -* The [`Sherpa' team](https://github.com/sherpa/sherpa), providing a fantastic package and answering fast to GitHub issues +* The [`Sherpa` team](https://github.com/sherpa/sherpa), providing a fantastic package and answering fast to GitHub issues + + + +[license-shield]: https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square +[license-url]: https://choosealicense.com/licenses/mit \ No newline at end of file From c9142dfa8597b239db87475c69d114e03c79f83e Mon Sep 17 00:00:00 2001 From: Iva Laginja Date: Sat, 15 Jun 2019 00:55:07 -0400 Subject: [PATCH 11/20] Finished the readme; package name change pending. --- README.md | 97 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 75 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 2a753d01..43c46bcd 100644 --- a/README.md +++ b/README.md @@ -1,55 +1,107 @@ [![MIT License][license-shield]][license-url] +![Python version][python-version-url] # HST marginalization - NEWNAME This code performs Levenberg-Marquardt least-squares minimization across a grid of stochastic systematic models to produce marginalized transit parameters given a lightcurve for a specified wavelength range. -This was developed and tested for data from Wide Field Camera 3 (WFC3) on the Hubble Space Telescope (HST), specifically with the G141 grid, as published in Wakeford et al. (2016, ApJ, 819, 1). Future work includes plans to extend this to other WFC3 grids, STIS data, and eventually data from the James Webb Space Telescope (JWST). +This was developed and tested for data from Wide Field Camera 3 (WFC3) on the Hubble Space Telescope (HST), specifically with the G141 spectroscopic grism, as published in Wakeford et al. (2016, ApJ, 819, 1). Future work includes plans to extend this to other WFC3 grids, STIS data, and eventually data from the James Webb Space Telescope (JWST). -This code follows the method outlined in Wakeford, et al. (2016), using marginalization across a stochastic grid of models. The program makes use of the analytic transit model in Mandel & Agol (2002, ApJ Letters, 580, L171-175) and a Levenberg-Marquardt least squares minimization using [Sherpa](https://sherpa.readthedocs.io/en/latest/), a Python package for modeling and fitting data. The model uses a 4-parameter limb darkening law, as outlined in Claret (2010) and Sing et al. (2010). +This code follows the method outlined in Wakeford, et al. (2016), using marginalization across a stochastic grid of models. The program makes use of the analytic transit model in Mandel & Agol (2002, ApJ Letters, 580, L171-175) and a Levenberg-Marquardt least squares minimization using [Sherpa](https://sherpa.readthedocs.io/en/latest/), a Python package for modeling and fitting data. The transit model uses a 4-parameter limb darkening law, as outlined in Claret (2010) and Sing et al. (2010). This package was built from the original IDL code used for the analysis in Wakeford et al. (2016), initially translated by Matthew Hill and then further adapted and transformed into a full astronomy Python package by Iva Laginja. +Note how this is not an installable package, but you will always need to clone it if you want to work with it. + ## Getting Started -### Prerequisites +### Quickstart -What things you need to install the software and how to install them +This is not an installable package, so you will always need to clone it if you want to work with it. -``` -Give examples -``` +This section will you give all the necessary terminal commands to go from opening our GitHub page in the browser to having +reduced results on your local machine. For a more thorough description of the individual steps, please continue to the section +**Prerequisites** and beyond. -### Configuration file +We assume that you have `conda` and `git` installed. -The main configuration file is config.ini, which holds all of your simulation paramers. This file, -however, is version controlled, and the paths to local directories will get messed up if you push this -file. This is why config.ini is supposed to be a TEMPLATE. In order to make it work for you, -use config_local.ini to set all your parametere, since it will override the config.ini. Make sure you tell your version control system to ignore config_local.ini! +- Create the `hstmarg` environment: +```$ conda env create --file environment.yml``` -### Output data +- Navigate to the directory you want to clone the repository into: +```$ cd /User/YourUser/repos/``` -Where your data will be saved. +- Clone the repository: +```$ git clone https://github.com/hrwakeford/HST_Marginalization.git``` -### Minimum working example +- Copy the file `config.ini`, name the copy `config_local.ini` and add the line `config_local.ini` into your `.gitignore`. -A step by step series of examples that tell you how to get a development env running +- Open your local configfile `config_loca.ini` and edit the entries `[data_paths][local_path]` to point to your local repo clone, e.g.: +```ini +[data_paths] +local_path = /Users/YourUser/repos/HST_Marginalization +``` + +- In the same file, define with `[data_paths][output_path]` where your output data should be saved to, e.g.: +```ini +[data_paths] +... +output_path = /Users/YourUser/ +``` -Say what the step will be +- Navigate to inside the actual package: +```$ cd HST_python``` + +- Run the marginalization on the demo data from the template: +```$ python marginalization.py``` + +The script takes a short while to run and will output messages to the terminal and save the final data to the path you +specified under `[data_paths][output_path]` in your `config_local.ini`! + +### Prerequisites + +We highly recommend the usage of the package and environment manager [Conda](https://docs.conda.io/projects/conda/en/latest/index.html), +which is free and runs on Windows, macOS and Linux. We have included an [environment](environment.yml) file in our repository +from which you can directly build a new conda environment in which we have tested our package. We developed and tested our + package with **Python 3.6.8** in **conda 4.6.7**. + + Run ``` -Give the example +conda env create --file environment.yml ``` -And repeat +to build the environment, or optionally ``` -until finished +conda env create --name --file environment.yml ``` -End with an example of getting some data out of the system or using it for a little demo +to give the environment your own name. + +### Configuration file + +The main configuration file is config.ini, which holds all of your simulation paramers. This specific file, +however, is version controlled, and the paths to local directories will get messed up if you push or pull this +file; you might also lose the changes you made to the parameters. This is why config.ini is supposed to be used as a **TEMPLATE**. + +In order to make it work for you, copy `config.ini` and rename the copy to `config_local.ini`. In this **local configfile**, +you can set all your parameters, and it will override the config.ini at runtime. **Make sure you add `config_local.ini` to +your `.gitignore` file!** + +### Output data + +The relevant data files and plots from your run will be saved to the directory you specify under **`output_path`** in your +local configfile. *This data will be overwritten with every new run*, so make sure to move or rename results you want to +keep permanently. + +### Changing data or the parameters + +We provide demo data for the exoplanet WASP-17b, which is one of the datasets analyzed in Wakeford et al. (2016). +Currently we only support the marginalization of WFC3/G141 datasets. If you want to perform the marginalization on a different +transit dataset, you have to add it to the data folder and update the planetary parameters in your local configfile. ## Contributing @@ -75,4 +127,5 @@ This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.tx [license-shield]: https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square -[license-url]: https://choosealicense.com/licenses/mit \ No newline at end of file +[license-url]: https://choosealicense.com/licenses/mit +[python-version-url]: https://img.shields.io/badge/Python-3.6,-green.svg?style=flat \ No newline at end of file From 4b514716b41668f55f82585a01dd92dc919f9f51 Mon Sep 17 00:00:00 2001 From: Iva Laginja Date: Sat, 15 Jun 2019 00:57:14 -0400 Subject: [PATCH 12/20] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 43c46bcd..624c4f15 100644 --- a/README.md +++ b/README.md @@ -128,4 +128,4 @@ This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.tx [license-shield]: https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square [license-url]: https://choosealicense.com/licenses/mit -[python-version-url]: https://img.shields.io/badge/Python-3.6,-green.svg?style=flat \ No newline at end of file +[python-version-url]: https://img.shields.io/badge/Python-3.6-green.svg?style=flat From 7ad26015877853c2f5290ec5e2e1c40a673833d9 Mon Sep 17 00:00:00 2001 From: Iva Laginja Date: Sat, 15 Jun 2019 01:06:31 -0400 Subject: [PATCH 13/20] Update README.md --- README.md | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 624c4f15..cd3b740d 100644 --- a/README.md +++ b/README.md @@ -28,13 +28,19 @@ reduced results on your local machine. For a more thorough description of the in We assume that you have `conda` and `git` installed. - Create the `hstmarg` environment: -```$ conda env create --file environment.yml``` +```bash +$ conda env create --file environment.yml +``` - Navigate to the directory you want to clone the repository into: -```$ cd /User/YourUser/repos/``` +```bash +$ cd /User/YourUser/repos/ +``` - Clone the repository: -```$ git clone https://github.com/hrwakeford/HST_Marginalization.git``` +```bash +$ git clone https://github.com/hrwakeford/HST_Marginalization.git +``` - Copy the file `config.ini`, name the copy `config_local.ini` and add the line `config_local.ini` into your `.gitignore`. @@ -52,10 +58,14 @@ output_path = /Users/YourUser/ ``` - Navigate to inside the actual package: -```$ cd HST_python``` +```bash +$ cd HST_python +``` - Run the marginalization on the demo data from the template: -```$ python marginalization.py``` +```bash +$ python marginalization.py +``` The script takes a short while to run and will output messages to the terminal and save the final data to the path you specified under `[data_paths][output_path]` in your `config_local.ini`! @@ -69,13 +79,13 @@ from which you can directly build a new conda environment in which we have teste Run -``` +```bash conda env create --file environment.yml ``` to build the environment, or optionally -``` +```bash conda env create --name --file environment.yml ``` From 5a31f26d2baf2414c25748453ae45372ca7498c6 Mon Sep 17 00:00:00 2001 From: Iva Laginja Date: Sat, 15 Jun 2019 01:11:07 -0400 Subject: [PATCH 14/20] Updated output path to be global --- HST_python/config.ini | 4 ++-- HST_python/marginalization.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/HST_python/config.ini b/HST_python/config.ini index 9a61ec22..756c68f2 100644 --- a/HST_python/config.ini +++ b/HST_python/config.ini @@ -3,9 +3,9 @@ ; Please use the semi-column for commenting [data_paths] -local_path = /Users/ilaginja/Documents/HST-Marginalization +local_path = /Users/MyUser/repos/HST-Marginalization data_path = data -output_path = outputs +output_path = /Users/MyUser/data current_model = W17 [limb_darkening] diff --git a/HST_python/marginalization.py b/HST_python/marginalization.py index 9c414396..21bbfaf5 100755 --- a/HST_python/marginalization.py +++ b/HST_python/marginalization.py @@ -625,7 +625,7 @@ def total_marg(x, y, err, sh, wavelength, outDir, run_name, plotting=True): start_time = time.time() localDir = CONFIG_INI.get('data_paths', 'local_path') - outDir = os.path.join(localDir, CONFIG_INI.get('data_paths', 'output_path')) + outDir = CONFIG_INI.get('data_paths', 'output_path') curr_model = CONFIG_INI.get('data_paths', 'current_model') dataDir = os.path.join(localDir, os.path.join(localDir, CONFIG_INI.get('data_paths', 'data_path')), curr_model) From 8da8d0751c20e32d7454763466f6e9fead62a117 Mon Sep 17 00:00:00 2001 From: Iva Laginja Date: Sat, 15 Jun 2019 01:23:03 -0400 Subject: [PATCH 15/20] Update README.md with configfile explanation --- README.md | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cd3b740d..9cdc0f20 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,55 @@ keep permanently. We provide demo data for the exoplanet WASP-17b, which is one of the datasets analyzed in Wakeford et al. (2016). Currently we only support the marginalization of WFC3/G141 datasets. If you want to perform the marginalization on a different -transit dataset, you have to add it to the data folder and update the planetary parameters in your local configfile. +transit dataset, you have to add it to the data folder and update the planetary parameters in your local configfile. + +**The configfile** has the following structure, except here we added some extra comments for clarity: +```ini +[data_paths] +local_path = /Users/MyUser/repos/HST-Marginalization ; your global path to the repo clone +data_path = data ; local path to the input data +output_path = /Users/MyUser/data ; global path ot the output directory +current_model = W17 ; data selection; refers to section in configfile + +[limb_darkening] +ld_model = 3D +metallicity = -1.0 +Teff = 6550 +logg = 4.5 + +[system_parameters] +instrument = WFC3 +grating = G141 +grid_selection = fit_time +run_name = wl_time_wm3d + +[technical_parameters] +plotting = True +outlier_limit_std = 3. +errors = hessian ; error method to be used, "hessian" or "confidence" + +[smooth_model] +resolution = 0.0001 +half_range = 0.2 + +;[planet_parameters] - make a new section for new data +[W17] +rl = 0.12169232 ; Rp/R* estimate - th transit depth +epoch = 57957.970153390 ; in MJD +inclin = 87.34635 ; inclination in deg +ecc = 0.0 ; eccentricity in deg +omega = 0.0 ; deg +Per = 3.73548535 ; planet period in days +aor = 7.0780354 ;a/r* (unitless) --> "distance of the planet from the star (meters)/stellar radius (meters)" + +[constants] +dtosec = 86400 ; conversion factor from days to seconds +HST_period = 0.06691666 ; Hubbe Space Telescope period in days +``` + +## Error calculation + +We said we needed to elaborate on the error estimation in the code... ## Contributing From 4c99877a9265532d79152bd19cfa7855be57fccc Mon Sep 17 00:00:00 2001 From: Iva Laginja Date: Sat, 15 Jun 2019 01:37:19 -0400 Subject: [PATCH 16/20] Updated configfile with individual planet system sections. --- HST_python/config.ini | 33 ++++++++++++++++++--------------- HST_python/marginalization.py | 23 +++++++++++++---------- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/HST_python/config.ini b/HST_python/config.ini index 756c68f2..e58b4ca3 100644 --- a/HST_python/config.ini +++ b/HST_python/config.ini @@ -14,40 +14,43 @@ metallicity = -1.0 Teff = 6550 logg = 4.5 -[technical_parameters] +[system_parameters] +instrument = WFC3 grating = G141 grid_selection = fit_time run_name = wl_time_wm3d + +[technical_parameters] plotting = True outlier_limit_std = 3. errors = hessian ; "hessian" or "confidence" - [smooth_model] resolution = 0.0001 half_range = 0.2 -[planet_parameters] -; Rp/R* estimate - th transit depth +;[planet_parameters] - make a new section for new data +[W17] +lightcurve_file = W17_white_lightcurve_test_data.txt +wvln_file = W17_wavelength_test_data.txt rl = 0.12169232 - -; in MJD epoch = 57957.970153390 - -; deg inclin = 87.34635 - -; deg ecc = 0.0 - -; deg omega = 0.0 - -; period in days Per = 3.73548535 +aor = 7.0780354 -;a/r* is unitless --> "distance of the planet from the star (meters)/stellar radius (meters)" +[W6] +lightcurve_file = W6_wlspec_lightcurve_test_data.txt +wvln_file = W6_wlspec_wavelength_test_data.txt +rl = 0.12169232 +epoch = 57957.970153390 +inclin = 87.34635 +ecc = 0.0 +omega = 0.0 +Per = 3.73548535 aor = 7.0780354 [constants] diff --git a/HST_python/marginalization.py b/HST_python/marginalization.py index 21bbfaf5..66d7f8c1 100755 --- a/HST_python/marginalization.py +++ b/HST_python/marginalization.py @@ -116,14 +116,14 @@ def total_marg(x, y, err, sh, wavelength, outDir, run_name, plotting=True): # Define limb darkening directory, which is inside this package limbDir = os.path.join('..', 'Limb-darkening') ld_model = CONFIG_INI.get('limb_darkening', 'ld_model') - grat = CONFIG_INI.get('technical_parameters', 'grating') + grat = CONFIG_INI.get('system_parameters', 'grating') _uLD, c1, c2, c3, c4, _cp1, _cp2, _cp3, _cp4, _aLD, _bLD = limb_dark_fit(grat, wavelength, M_H, Teff, logg, limbDir, ld_model) # SELECT THE SYSTEMATIC GRID OF MODELS TO USE # 1 in the grid means the parameter is fixed, 0 means it is free # grid_selection: either one from 'fix_time', 'fit_time', 'fit_inclin', 'fit_msmpr' or 'fit_ecc' - grid_selection = CONFIG_INI.get('technical_parameters', 'grid_selection') + grid_selection = CONFIG_INI.get('system_parameters', 'grid_selection') grid = marg.wfc3_systematic_model_grid_selection(grid_selection) nsys, nparams = grid.shape # nsys = number of systematic models, nparams = number of parameters @@ -617,24 +617,27 @@ def total_marg(x, y, err, sh, wavelength, outDir, run_name, plotting=True): if __name__ == '__main__': - """ - This is a translation of the W17_lightcurve_test.pro - """ # Figure out how much time it takes to run this code. start_time = time.time() + # What data are we using? + exoplanet = CONFIG_INI.get('data_paths', 'current_model') + print('\nWORKING ON EXOPLANET {}\n'.format(exoplanet)) + + # Set up the data paths localDir = CONFIG_INI.get('data_paths', 'local_path') outDir = CONFIG_INI.get('data_paths', 'output_path') - curr_model = CONFIG_INI.get('data_paths', 'current_model') - dataDir = os.path.join(localDir, os.path.join(localDir, CONFIG_INI.get('data_paths', 'data_path')), curr_model) + dataDir = os.path.join(localDir, os.path.join(localDir, CONFIG_INI.get('data_paths', 'data_path')), exoplanet) # Read in the txt file for the lightcurve data - x, y, err, sh = np.loadtxt(os.path.join(dataDir, 'W17_white_lightcurve_test_data.txt'), skiprows=7, unpack=True) - wavelength = np.loadtxt(os.path.join(dataDir, 'W17_wavelength_test_data.txt'), skiprows=3) + get_timeseries = CONFIG_INI.get(exoplanet, 'lightcurve_file') + get_wvln = CONFIG_INI.get(exoplanet, 'wvln_file') + x, y, err, sh = np.loadtxt(os.path.join(dataDir, get_timeseries), skiprows=7, unpack=True) + wavelength = np.loadtxt(os.path.join(dataDir, get_wvln), skiprows=3) # What to call the run and whether to turn plotting on - run_name = CONFIG_INI.get('technical_parameters', 'run_name') + run_name = CONFIG_INI.get('system_parameters', 'run_name') plotting = CONFIG_INI.getboolean('technical_parameters', 'plotting') # Run the main function From 98edd40eb9e6692e58e29b2091dd6e006d0d1062 Mon Sep 17 00:00:00 2001 From: Iva Laginja Date: Sat, 15 Jun 2019 01:56:48 -0400 Subject: [PATCH 17/20] Reduced overall comments in top of scripts. --- HST_python/marginalization.py | 19 ++++++------------- HST_python/margmodule.py | 4 +++- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/HST_python/marginalization.py b/HST_python/marginalization.py index 66d7f8c1..2458b838 100755 --- a/HST_python/marginalization.py +++ b/HST_python/marginalization.py @@ -1,34 +1,27 @@ """ This code is based on Hannah Wakeford's IDL code for lightcurve extraction with marginalization over a set of -systematic models. The original IDL scipts used are: -G141_lightcurve_circle.pro - the translation of this code is in the G141_lightcurve_circle() function -W17_lightcurve_test.pro - the translation of this code is in the main() function - +systematic models. Initially, the python code used a python translation of the IDL MPFIT library instead of built LM fitters because for some reason neither the script least_squares method, the Astropy wrapper, or the lmfit package find the same minimum as the IDL code. -The python translation of MPFIT is consistent with the IDL code. In theory, all of these packages use the same method, -so there may be some tuning parameters that need to be adjusted to agree with MPFIT (error tolerance, etc.). -The python translation of mpfit (mpfit.py) comes from; -https://github.com/scottransom/presto/blob/master/lib/python/mpfit.py -This showed to be really flaky though, so we ditched all of that and are now using the fitting package Sherpa. +Using the python version of mpfit showed to be really flaky though, so we ditched all of that and are now using the +fitting package Sherpa. limb_darkening.py contains a python translation of the 3D limb darkening code in the original IDL. It uses Astropy -for fitting the models. Again, the two are not exactly consistent but in this case the difference is small (good to -about 3 decimals). +for fitting the models. Initial translation of Python to IDL was done by Matthew Hill (mhill92@gmail). Continued translation and implementation of Sherpa by Iva Laginja (laginja.iva@gmail.com). """ -import numpy as np import os import time +from shutil import copy +import numpy as np import matplotlib.pyplot as plt import astropy.units as u from astropy.constants import G -from shutil import copy from sherpa.data import Data1D from sherpa.optmethods import LevMar diff --git a/HST_python/margmodule.py b/HST_python/margmodule.py index f1364044..75c089b1 100644 --- a/HST_python/margmodule.py +++ b/HST_python/margmodule.py @@ -1,4 +1,6 @@ -"""Helper module for transit marginalization.""" +""" +Helper module for transit marginalization. +""" import os import numpy as np From 6e7fbe7f802b919c4ed1fb6593ec5c59f95f9d0b Mon Sep 17 00:00:00 2001 From: Iva Laginja Date: Sat, 15 Jun 2019 01:57:36 -0400 Subject: [PATCH 18/20] refactored 'planet_parameters' section to 'exoplanet' variable for section. --- HST_python/config.ini | 1 + HST_python/marginalization.py | 8 ++++---- HST_python/margmodule.py | 13 +++++++------ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/HST_python/config.ini b/HST_python/config.ini index e58b4ca3..cd8ca77d 100644 --- a/HST_python/config.ini +++ b/HST_python/config.ini @@ -45,6 +45,7 @@ aor = 7.0780354 [W6] lightcurve_file = W6_wlspec_lightcurve_test_data.txt wvln_file = W6_wlspec_wavelength_test_data.txt +; these numbers are currently wrong rl = 0.12169232 epoch = 57957.970153390 inclin = 87.34635 diff --git a/HST_python/marginalization.py b/HST_python/marginalization.py index 2458b838..18be0231 100755 --- a/HST_python/marginalization.py +++ b/HST_python/marginalization.py @@ -34,7 +34,7 @@ import margmodule as marg -def total_marg(x, y, err, sh, wavelength, outDir, run_name, plotting=True): +def total_marg(exoplanet, x, y, err, sh, wavelength, outDir, run_name, plotting=True): """ Produce marginalized transit parameters from WFC3 G141 lightcurve for specified wavelength range. @@ -92,11 +92,11 @@ def total_marg(x, y, err, sh, wavelength, outDir, run_name, plotting=True): tzero = x[0] * u.d # first time data point nexposure = len(img_date) # Total number of exposures in the observation - Per = CONFIG_INI.getfloat('planet_parameters', 'Per') * u.d # period, converted to seconds in next line + Per = CONFIG_INI.getfloat(exoplanet, 'Per') * u.d # period, converted to seconds in next line Per = Per.to(u.s) constant1 = ((G * np.square(Per)) / (4 * np.square(np.pi))) ** (1 / 3) - aor = CONFIG_INI.getfloat('planet_parameters', 'aor') # this is unitless -> "distance of the planet from the star (meters)/stellar radius (meters)" + aor = CONFIG_INI.getfloat(exoplanet, 'aor') # this is unitless -> "distance of the planet from the star (meters)/stellar radius (meters)" MsMpR = (aor / constant1) ** 3. # density of the system in kg/m^3 "(Mass of star (kg) + Mass of planet (kg))/(Radius of star (m)^3)" # LIMB DARKENING @@ -634,7 +634,7 @@ def total_marg(x, y, err, sh, wavelength, outDir, run_name, plotting=True): plotting = CONFIG_INI.getboolean('technical_parameters', 'plotting') # Run the main function - total_marg(x, y, err, sh, wavelength, outDir, run_name, plotting) + total_marg(exoplanet, x, y, err, sh, wavelength, outDir, run_name, plotting) end_time = time.time() print('\nTime it took to run the code:', (end_time-start_time)/60, 'min') diff --git a/HST_python/margmodule.py b/HST_python/margmodule.py index 75c089b1..2d73ca56 100644 --- a/HST_python/margmodule.py +++ b/HST_python/margmodule.py @@ -12,12 +12,13 @@ from config import CONFIG_INI # Read planet parameters from configfile -RL = CONFIG_INI.getfloat('planet_parameters', 'rl') -EPOCH = CONFIG_INI.getfloat('planet_parameters', 'epoch') -INCLIN = CONFIG_INI.getfloat('planet_parameters', 'inclin') -ECC = CONFIG_INI.getfloat('planet_parameters', 'ecc') -OMEGA = CONFIG_INI.getfloat('planet_parameters', 'omega') -PERIOD = CONFIG_INI.getfloat('planet_parameters', 'Per') +exoplanet = CONFIG_INI.get('data_paths', 'current_model') +RL = CONFIG_INI.getfloat(exoplanet, 'rl') +EPOCH = CONFIG_INI.getfloat(exoplanet, 'epoch') +INCLIN = CONFIG_INI.getfloat(exoplanet, 'inclin') +ECC = CONFIG_INI.getfloat(exoplanet, 'ecc') +OMEGA = CONFIG_INI.getfloat(exoplanet, 'omega') +PERIOD = CONFIG_INI.getfloat(exoplanet, 'Per') def transit_circle(p, fjac=None, x=None, y=None, err=None, sh=None, silent=True): From 62af6ec159393826d32a226db5e881928599322a Mon Sep 17 00:00:00 2001 From: Iva Laginja Date: Sat, 15 Jun 2019 02:12:42 -0400 Subject: [PATCH 19/20] Deleted the out-of-Sherpa transit function (mpfit legacy). --- HST_python/margmodule.py | 64 ++-------------------------------------- 1 file changed, 2 insertions(+), 62 deletions(-) diff --git a/HST_python/margmodule.py b/HST_python/margmodule.py index 2d73ca56..be35a2c4 100644 --- a/HST_python/margmodule.py +++ b/HST_python/margmodule.py @@ -21,66 +21,6 @@ PERIOD = CONFIG_INI.getfloat(exoplanet, 'Per') -def transit_circle(p, fjac=None, x=None, y=None, err=None, sh=None, silent=True): - """ - This function will be deleted once Sherpa is in place - :param p: - :param fjac: - :param x: - :param y: - :param err: - :param sh: - :return: - """ - - HSTper = CONFIG_INI.getfloat('constants', 'HST_period') - day_to_sec = CONFIG_INI.getfloat('constants', 'dtosec') - - # Define each of the parameters that are read into the fitting routine - rl = p[0] - epoch = p[2] - inclin = p[3] - MsMpR = p[4] - Per = p[7] - T0 = p[8] - c1 = p[9] - c2 = p[10] - c3 = p[11] - c4 = p[12] - - if not silent: - print(epoch) - phase = phase_calc(x, epoch, Per/day_to_sec) - HSTphase = phase_calc(x, T0, HSTper) - - if not silent: - print('phase[0] = {}'.format(phase[0])) - - # Calculate the impact parameter as a function of the planetary phase across the star. - b0 = impact_param(Per, MsMpR, phase, inclin) # b0 in stellar radii - if not silent: - print(b0) - - # Occultnl would be replaced with BATMAN if possible. The main result we need is the rl - radius ratio - # The c1-c4 are the non-linear limb-darkening parameters - # b0 is the impact parameter function and I am not sure how this is handled in BATMAN - I will also look into this. - mulimb0, mulimbf = occultnl(rl, c1, c2, c3, c4, b0) - systematic_model = sys_model(phase, HSTphase, sh, p[13], p[14], p[15], p[16], p[17], p[18], p[19], p[20], p[21]) - - # model fit to data = transit model * baseline flux (flux0) * systematic model - model = mulimb0 * p[1] * systematic_model - # this would be the break point to get the model values - # return model - print('Rp/R* = {}'.format(p[0])) - resids = (y - model) / p[1] - - print('Scatter = {}'.format(np.std(resids))) - print('-----------------------------------') - print(' ') - - return [0, (y - model) / err] - - def _transit_model(pars, x, sh): """ Transit model by Mandel & Agol (2002). @@ -426,7 +366,7 @@ def marginalization(array, error, weight): @u.quantity_input(per=u.s, incl=u.rad) def impact_param(per, msmpr, phase, incl): """ - Calculate impact parameter + Calculate impact parameter. :param per: period in seconds :param msmpr: MsMpR :param phase: phase @@ -442,7 +382,7 @@ def impact_param(per, msmpr, phase, incl): def sys_model(phase, hst_phase, sh, m_fac, hstp1, hstp2, hstp3, hstp4, xshift1, xshift2, xshift3, xshift4): """ - Systematic model for WFC3 data + Systematic model for WFC3 data. :param phase: :param hst_phase: :param sh: array corresponding to the shift in wavelength position on the detector throughout the visit From 93075fc2878923693466515e5bac27455cbbd63a Mon Sep 17 00:00:00 2001 From: Iva Laginja Date: Sat, 15 Jun 2019 02:13:00 -0400 Subject: [PATCH 20/20] Deleted big function comment bc of redundancy with readme. --- HST_python/marginalization.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/HST_python/marginalization.py b/HST_python/marginalization.py index 18be0231..ed92c033 100755 --- a/HST_python/marginalization.py +++ b/HST_python/marginalization.py @@ -38,19 +38,6 @@ def total_marg(exoplanet, x, y, err, sh, wavelength, outDir, run_name, plotting= """ Produce marginalized transit parameters from WFC3 G141 lightcurve for specified wavelength range. - Perform Levenberg-Marquardt least-squares minimization across a grid of stochastic systematic models to produce - marginalised transit parameters given a WFC3 G141 lightcurve for a specified wavelength range. - - AUTHOR: - Hannah R. Wakeford, - stellarplanet@gmail.com - - CITATIONS: - This procedure follows the method outlined in Wakeford, et al. (2016, ApJ, 819, 1), using marginalisation across a - stochastic grid of models. The program makes use of the analytic transit model in Mandel & Agol (2002, ApJ Letters, - 580, L171-175) and Lavenberg-Markwardt least squares minimisation using the Python package Sherpa. - Here, a 4-parameter limb darkening law is used as outlined in Claret, 2010 and Sing et al. 2010. - MAJOR PROGRAMS INCLUDED IN THIS ROUTINE: - LIMB-DARKENING (from limb_darkening.py) This requires the G141.WFC3.sensitivity.sav file, template.sav, kuruczlist.sav, and the kurucz folder with all