Skip to content

Commit

Permalink
update notebook with latest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sblunt committed Feb 29, 2024
1 parent b296de1 commit 5e23a70
Showing 1 changed file with 33 additions and 29 deletions.
62 changes: 33 additions & 29 deletions docs/tutorials/ONeil-ObsPriors.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -33,28 +33,36 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"filename = \"{}/GJ504.csv\".format(orbitize.DATADIR)\n",
"\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",
")"
]
},
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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": {
Expand All @@ -183,7 +187,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.11.4"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 5e23a70

Please sign in to comment.