From 5e23a70b7938e990133c4c1dd8e02bc55dd570da Mon Sep 17 00:00:00 2001 From: Sarah Blunt Date: Thu, 29 Feb 2024 13:28:41 -0600 Subject: [PATCH] update notebook with latest changes --- docs/tutorials/ONeil-ObsPriors.ipynb | 62 +++++++++++++++------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/docs/tutorials/ONeil-ObsPriors.ipynb b/docs/tutorials/ONeil-ObsPriors.ipynb index ae959c59..bd7f208b 100644 --- a/docs/tutorials/ONeil-ObsPriors.ipynb +++ b/docs/tutorials/ONeil-ObsPriors.ipynb @@ -6,16 +6,16 @@ "source": [ "# Using the O'Neil (2019) Observation-based Priors\n", "\n", - "by Sarah Blunt (2020)" + "by Sarah Blunt (2024)" ] }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ - "%matploltib \n", + "# TODO: write tutorial intro\n", "\n", "import numpy as np\n", "import multiprocessing as mp\n", @@ -33,7 +33,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -41,20 +41,28 @@ "\n", "# system parameters\n", "num_secondary_bodies = 1\n", - "system_mass = 1.75 # [Msol]\n", - "plx = 51.44 # [mas]\n", - "mass_err = 0.05 # [Msol]\n", - "plx_err = 0.12 # [mas]\n", + "system_mass = 1.75 # [Msol]\n", + "plx = 51.44 # [mas]\n", "\n", "# MCMC parameters\n", "num_temps = 10\n", "num_walkers = 50\n", - "num_threads = mp.cpu_count() # or a different number if you prefer\n", + "num_threads = mp.cpu_count() # or a different number if you prefer\n", "\n", "\n", "my_driver = driver.Driver(\n", - " filename, 'MCMC', num_secondary_bodies, system_mass, plx, mass_err=mass_err, plx_err=plx_err,\n", - " mcmc_kwargs={'num_temps': num_temps, 'num_walkers': num_walkers, 'num_threads': num_threads}\n", + " filename,\n", + " \"MCMC\",\n", + " num_secondary_bodies,\n", + " system_mass,\n", + " plx,\n", + " mass_err=0,\n", + " plx_err=0,\n", + " mcmc_kwargs={\n", + " \"num_temps\": num_temps,\n", + " \"num_walkers\": num_walkers,\n", + " \"num_threads\": num_threads,\n", + " },\n", ")" ] }, @@ -92,31 +100,27 @@ ], "source": [ "# convert input sep/PA measurements to RA/decl\n", - "sep = np.array(my_driver.system.data_table['quant1'])\n", - "sep_err = np.array(my_driver.system.data_table['quant1_err'])\n", - "pa = np.radians(np.array(my_driver.system.data_table['quant2']))\n", - "pa_err = np.radians(np.array(my_driver.system.data_table['quant2_err']))\n", + "sep = np.array(my_driver.system.data_table[\"quant1\"])\n", + "sep_err = np.array(my_driver.system.data_table[\"quant1_err\"])\n", + "pa = np.radians(np.array(my_driver.system.data_table[\"quant2\"]))\n", + "pa_err = np.radians(np.array(my_driver.system.data_table[\"quant2_err\"]))\n", "\n", "\n", - "ra_err = np.sqrt(\n", - " (np.cos(pa) * sep_err)**2 + \n", - " (sep * np.sin(pa) * pa_err)**2\n", - ")\n", - "dec_err = np.sqrt(\n", - " (np.sin(pa) * sep_err)**2 + \n", - " (sep * np.cos(pa) * pa_err)**2\n", - ")\n", + "ra_err = np.sqrt((np.cos(pa) * sep_err) ** 2 + (sep * np.sin(pa) * pa_err) ** 2)\n", + "dec_err = np.sqrt((np.sin(pa) * sep_err) ** 2 + (sep * np.cos(pa) * pa_err) ** 2)\n", "\n", "\n", - "epochs = np.array(my_driver.system.data_table['epoch'])\n", + "epochs = np.array(my_driver.system.data_table[\"epoch\"])\n", "\n", "# define the `ObsPrior` object\n", "my_obsprior = priors.ObsPrior(ra_err, dec_err, epochs)\n", "\n", + "# TODO: change the basis\n", + "\n", "print(my_driver.system.param_idx)\n", "\n", "# set the priors on `sma`, `ecc`, `tau`, `mtot`, and `plx` to point to this object\n", - "for i in [0, 1, 5, 6, 7]:\n", + "for i in [0, 1, 5]:\n", " my_driver.system.sys_priors[i] = my_obsprior\n", "\n", "my_driver.system.sys_priors" @@ -163,15 +167,15 @@ "source": [ "n_pts = 10\n", "\n", - "# make an array of sample orbits to compute lnprob: maybe 1000 orbits long, drawn from uniform dists in all 5 params\n" + "# make an array of sample orbits to compute lnprob: maybe 1000 orbits long, drawn from uniform dists in all 5 params" ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3.7.6 64-bit ('python3.7': conda)", + "display_name": "python3.11", "language": "python", - "name": "python37664bitpython37conda5785220be34f4f6fa52b2ff37321b463" + "name": "python3" }, "language_info": { "codemirror_mode": { @@ -183,7 +187,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.6" + "version": "3.11.4" } }, "nbformat": 4,