Skip to content

Commit

Permalink
custom survey notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
Gijs Mulders (Laptop) committed Jan 29, 2020
1 parent c431aad commit 7248f20
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 20 deletions.
2 changes: 1 addition & 1 deletion EPOS/classes.py
Expand Up @@ -325,7 +325,7 @@ def set_survey(self, xvar, yvar, eff_2D, Rstar=1.0, Mstar=1.0, vet_2D=None):
'\n: (nx,ny)={}, (nx,ny={})'.format(self.eff_2D.shape,
self.vetting.shape))

self.completeness_novet= self.completeness
self.completeness_novet= 1.*self.completeness
self.completeness*= self.vetting

self.DetectionEfficiency=True
Expand Down
10 changes: 5 additions & 5 deletions EPOS/plot/occurrence.py
Expand Up @@ -59,7 +59,7 @@ def all(epos, color=None, alpha_fac=None):
else:
print ('\nNo occurrence to plot, did you run EPOS.occurrence.all()? \n')

def colored(epos, Bins=False, Poly=False):
def colored(epos, Bins=False, Poly=False, NB=False):

f, (ax, axb) = plt.subplots(1,2, gridspec_kw = {'width_ratios':[20, 1]})
f.subplots_adjust(wspace=0)
Expand All @@ -69,7 +69,7 @@ def colored(epos, Bins=False, Poly=False):
ax.set_title(name)

helpers.set_axes(ax, epos, Trim=True)
#if epos.plot['']
#helpers.set_axes(ax, epos, Trim=hasattr(epos, 'xtrim'))

#ax.plot(epos.obs_xvar, epos.obs_yvar, ls='', marker='.', mew=0, ms=5.0, color='k')

Expand Down Expand Up @@ -117,7 +117,7 @@ def colored(epos, Bins=False, Poly=False):
ax.text(xbin[1]/xnudge,ybin[0]*ynudge,'n={}'.format(n), ha='right',
size=size)

helpers.save(plt, epos.plotdir+'occurrence/bins')
helpers.save(plt, epos.plotdir+'occurrence/bins', NB=NB)
elif Poly:
occpoly= epos.occurrence['poly']
for k, (xc, yc, coords, n, inbin, occ, err) in enumerate(
Expand All @@ -136,9 +136,9 @@ def colored(epos, Bins=False, Poly=False):
#ax.text(xbin[1]/xnudge,ybin[0]*ynudge,'n={}'.format(n), ha='right',
# size=size)

helpers.save(plt, epos.plotdir+'occurrence/poly')
helpers.save(plt, epos.plotdir+'occurrence/poly', NB=NB)
else:
helpers.save(plt, epos.plotdir+'occurrence/colored')
helpers.save(plt, epos.plotdir+'occurrence/colored', NB=NB)

def integrated(epos, MCMC=False, Planets=False, NB=False):

Expand Down
14 changes: 8 additions & 6 deletions EPOS/plot/parametric.py
Expand Up @@ -17,7 +17,7 @@ def oneD(epos, PlotZoom=False, MCMC=False, Occ=False):
# works with occ??
oneD_y(epos, PlotZoom=PlotZoom, MCMC=MCMC, PlotQ=True)

def oneD_x(epos, PlotZoom=False, MCMC=False, Occ=False, Log=True, NB=False):
def oneD_x(epos, PlotZoom=False, MCMC=False, Occ=False, Log=True, Init=True, NB=False):

if Occ:
fname= 'occurrence/posterior' if MCMC else 'occurrence/input'
Expand All @@ -33,7 +33,8 @@ def oneD_x(epos, PlotZoom=False, MCMC=False, Occ=False, Log=True, NB=False):
fname+= '.linear'

# initial guess
pps, _, pdf0_X, _= periodradius(epos, Init=True, ybin=ybin)
if Init:
pps, _, pdf0_X, _= periodradius(epos, Init=True, ybin=ybin)
if MCMC:
# best-fit parameters
pps, _, pdf_X, _= periodradius(epos, ybin=ybin)
Expand Down Expand Up @@ -69,7 +70,7 @@ def oneD_x(epos, PlotZoom=False, MCMC=False, Occ=False, Log=True, NB=False):
label='Starting Guess')
ax.plot(epos.MC_xvar, pdf_X, marker='',ls='-',color='k',
label='Best Fit')
else:
elif Init:
if 'P break' in epos.fitpars.keys2d:
ax.axvline(epos.fitpars.get('P break', Init=True), ls='-', color='gray')
ax.plot(epos.MC_xvar, pdf0_X, marker='',ls='-',color='k')
Expand Down Expand Up @@ -115,7 +116,7 @@ def oneD_x(epos, PlotZoom=False, MCMC=False, Occ=False, Log=True, NB=False):
helpers.save(plt, epos.plotdir+fname+'_x', NB=NB)
#print epos.plotdir+fname+'_x'

def oneD_y(epos, PlotZoom=False, MCMC=False, PlotQ=False, Occ=False, Convert=False, NB=False):
def oneD_y(epos, PlotZoom=False, MCMC=False, PlotQ=False, Occ=False, Convert=False, NB=False, Init=True):
if Occ:
fname= 'occurrence/posterior' if MCMC else 'occurrence/input'
xbin= epos.xzoom
Expand All @@ -127,7 +128,8 @@ def oneD_y(epos, PlotZoom=False, MCMC=False, PlotQ=False, Occ=False, Convert=Fal
title= 'Marginalized Distribution ({:.2g}-{:.0f} days)'.format(*epos.xtrim)

# initial guess
pps, _, _, pdf0_Y= periodradius(epos, Init=True, xbin=xbin, Convert=Convert)
if Init:
pps, _, _, pdf0_Y= periodradius(epos, Init=True, xbin=xbin, Convert=Convert)
if MCMC:
# best-fit parameters
pps, _, _, pdf_Y= periodradius(epos, xbin=xbin, Convert=Convert)
Expand Down Expand Up @@ -182,7 +184,7 @@ def oneD_y(epos, PlotZoom=False, MCMC=False, PlotQ=False, Occ=False, Convert=Fal
ax.plot(yvar, ypdf*yscale, color='b', alpha=0.1)
ax.plot(yvar, pdf0_Y*yscale, marker='',ls=':',color='k', label='starting guess')
ax.plot(yvar, pdf_Y*yscale, marker='',ls='-',color='k', label='best-fit')
else:
elif Init:
if 'R break' in epos.fitpars.keys2d:
ax.axvline(epos.fitpars.get('R break', Init=True), ls='-', color='gray')

Expand Down
12 changes: 9 additions & 3 deletions EPOS/run.py
Expand Up @@ -278,12 +278,18 @@ def prep_obs(epos):

x= epos.obs_xvar[ix&iy]
y= epos.obs_yvar[ix&iy]
t= epos.obs_tdur[ix&iy]

for key, var in zip(['x','y','t'], [x,y,t]):
for key, var in zip(['x','y'], [x,y]):
z[key]= np.sort(var) # add (x0,0) and (x1,1)?
z[key+' cum']= np.arange(z[key].size,dtype=float)
z[key+' cdf']= z[key+' cum']/z[key+' cum'][-1]

if hasattr(epos, 'obs_tdur') and not epos.RV:
t= epos.obs_tdur[ix&iy]

for key, var in zip(['t'], [t]):
z[key]= np.sort(var) # add (x0,0) and (x1,1)?
z[key+' cum']= np.arange(z[key].size,dtype=float)
z[key+' cdf']= z[key+' cum']/z[key+' cum'][-1]

# multis
z['multi']={}
Expand Down
8 changes: 5 additions & 3 deletions docs/index.rst
Expand Up @@ -52,6 +52,7 @@ Familiarize yourself with the code is to take a look at the :doc:`notebooks`
tutorials/parameteric_mode.ipynb
tutorials/multiplanet_mode.ipynb
tutorials/radial_velocity.ipynb
tutorials/custom_survey.ipynb

.. toctree::
:maxdepth: 2
Expand Down Expand Up @@ -98,10 +99,11 @@ Version Notes:

:1.0.1: first public release
:1.0.2: pip installable version
:1.1.0: radial velocity without Monte Carlo |ImageLink|_
:1.1.0: radial velocity without Monte Carlo
:2.0.2: planet formation models |ImageLink|_

.. |ImageLink| image:: https://zenodo.org/badge/132065382.svg
.. _ImageLink: https://zenodo.org/badge/latestdoi/132065382
.. |ImageLink| image:: https://zenodo.org/DOI/10.5281/zenodo.3515380.svg
.. _ImageLink: https://doi.org/10.5281/zenodo.3515380

Indices and tables
------------------
Expand Down
3 changes: 2 additions & 1 deletion docs/notebooks.rst
Expand Up @@ -6,7 +6,8 @@ Examples

* :ref:`/tutorials/parameteric_mode.ipynb` (:download:`save to disk </tutorials/parameteric_mode.ipynb>`)
* :ref:`/tutorials/multiplanet_mode.ipynb` (:download:`save to disk </tutorials/multiplanet_mode.ipynb>`)
*
* :ref:`/tutorials/custom_survey.ipynb` (:download:`save to disk </tutorials/custom_survey.ipynb.ipynb>`)


The notebooks are also viewable on `github <https://github.com/GijsMulders/epos/docs/tutorials>`_

Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/parameteric_mode.ipynb
Expand Up @@ -756,7 +756,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
"version": "3.7.5"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 7248f20

Please sign in to comment.