From 695871e23c7dc0a937fb2f09b2c40bb81ad62823 Mon Sep 17 00:00:00 2001 From: gibsongreen Date: Fri, 22 Nov 2024 00:11:09 -0500 Subject: [PATCH] add cell to allow creation of output variable --- .../HASP/DataDiagnostic/DataDiagnostics.ipynb | 98 +++++++++++++------ 1 file changed, 70 insertions(+), 28 deletions(-) diff --git a/notebooks/HASP/DataDiagnostic/DataDiagnostics.ipynb b/notebooks/HASP/DataDiagnostic/DataDiagnostics.ipynb index 13fed8642..62e521d63 100644 --- a/notebooks/HASP/DataDiagnostic/DataDiagnostics.ipynb +++ b/notebooks/HASP/DataDiagnostic/DataDiagnostics.ipynb @@ -152,17 +152,17 @@ }, "outputs": [], "source": [ - "import matplotlib.pyplot as plt\n", - "import numpy as np\n", "from astropy.io import fits\n", "from astropy.table import vstack\n", "from astroquery.mast import Observations\n", - "import glob\n", + "\n", "import os\n", + "import glob\n", "import shutil\n", + "import numpy as np\n", "from pathlib import Path\n", + "import matplotlib.pyplot as plt\n", "%matplotlib widget\n", - "import io\n", "\n", "plt.rcParams['figure.figsize'] = 10, 6\n", "plt.style.use('seaborn-v0_8-colorblind')\n", @@ -292,7 +292,7 @@ }, "outputs": [], "source": [ - "output = io.StringIO()\n", + "%%capture output\n", "\n", "# Querying and downloading calibrated products\n", "query_ex1 = Observations.query_criteria(\n", @@ -336,10 +336,17 @@ ")\n", "\n", "# Organizing the files \n", - "consolidate_files(datadir_ex1)\n", - "\n", + "consolidate_files(datadir_ex1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "with open('output.txt', 'a') as file:\n", - " file.write(output.getvalue())" + " file.write(output.stdout)" ] }, { @@ -753,12 +760,19 @@ "metadata": {}, "outputs": [], "source": [ - "output = io.StringIO()\n", - "!swrapper -i ./12715/newcoadddata -o ./12715/newcoadddata/products -k\n", + "%%capture output\n", "\n", - "# Write the captured output to a file\n", + "!swrapper -i ./12715/newcoadddata -o ./12715/newcoadddata/products -k" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "with open('output.txt', 'a') as file:\n", - " file.write(output.getvalue())" + " file.write(output.stdout)" ] }, { @@ -911,7 +925,7 @@ "metadata": {}, "outputs": [], "source": [ - "output = io.StringIO()\n", + "%%capture output\n", "\n", "# Querying and downloading calibrated products\n", "query_ex2 = Observations.query_criteria(\n", @@ -959,10 +973,17 @@ ")\n", "\n", "# Organizing the files \n", - "consolidate_files(datadir_ex2)\n", - "\n", + "consolidate_files(datadir_ex2)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "with open('output.txt', 'a') as file:\n", - " file.write(output.getvalue())" + " file.write(output.stdout)" ] }, { @@ -1143,16 +1164,23 @@ "metadata": {}, "outputs": [], "source": [ - "output = io.StringIO()\n", + "%%capture output\n", "\n", "!swrapper -i ./16655/newcoadddata_p-0.05 -o ./16655/newcoadddata_p-0.05/products -k -t -999\n", "!swrapper -i ./16655/newcoadddata_p-0.025 -o ./16655/newcoadddata_p-0.025/products -k -t -999\n", "!swrapper -i ./16655/newcoadddata_p0.0 -o ./16655/newcoadddata_p0.0/products -k -t -999\n", "!swrapper -i ./16655/newcoadddata_p0.025 -o ./16655/newcoadddata_p0.025/products -k -t -999\n", - "!swrapper -i ./16655/newcoadddata_p0.05 -o ./16655/newcoadddata_p0.05/products -k -t -999\n", - "\n", + "!swrapper -i ./16655/newcoadddata_p0.05 -o ./16655/newcoadddata_p0.05/products -k -t -999" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "with open('output.txt', 'a') as file:\n", - " file.write(output.getvalue())" + " file.write(output.stdout)" ] }, { @@ -1296,7 +1324,7 @@ }, "outputs": [], "source": [ - "output = io.StringIO()\n", + "%%capture output\n", "\n", "# Querying and downloading calibrated products\n", "query_ex3 = Observations.query_criteria(\n", @@ -1342,10 +1370,17 @@ ")\n", "\n", "# Organizing the files \n", - "consolidate_files(datadir_ex3)\n", - "\n", + "consolidate_files(datadir_ex3)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "with open('output.txt', 'a') as file:\n", - " file.write(output.getvalue())" + " file.write(output.stdout)" ] }, { @@ -1481,12 +1516,19 @@ }, "outputs": [], "source": [ - "output = io.StringIO()\n", - "\n", - "!swrapper -i ./16196/ -o ./16196/products_nofluxfilter -t -999\n", + "%%capture output\n", "\n", + "!swrapper -i ./16196/ -o ./16196/products_nofluxfilter -t -999" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "with open('output.txt', 'a') as file:\n", - " file.write(output.getvalue())" + " file.write(output.stdout)" ] }, {