Top-level interface to the rest of the package
@ipynb_doc
def phase_demo():
"""
### Demonstrate the phase_view with Vela and Geminga
This uses the `phase_view` function to generate a view with cells that are folded according
to the specified period, relative to UTC {ref_date}.
{out1}
{out2}
{thefig}
"""
plt.rc('font', size=16)
year = 365.25; ref_date='2008'; precess=53.05
fig, (ax1,ax2) = plt.subplots(1,2, figsize=(15,5)) # sharey=True)
plt.subplots_adjust(wspace=0.25)
thefig = figure(fig, width=800)
with capture(f'Vela setup, {precess}-day period') as out1:
vela = WtLike('Vela pulsar')
pv = vela.phase_view( period=precess, nbins=25);
pv.plot(ax=ax1, xlim=(0,1), ylim=(0.97,1.03))
with capture(f'Geminga setup: {year}-day period') as out2:
geminga = WtLike('Geminga')
gv = geminga.phase_view(year, nbins=50, reference=ref_date)
gv.plot(ax=ax2, xlim=(0,1))
return locals()
if Config().valid:
phase_demo()
full = None
# code for the demo--this shouid be collapsed
@ipynb_doc
def wtlike_demo(clear=False):
"""
## Test/Demonstration with 3C 279
> Note that this also demonstrates using the `ipynb_doc` decorator to have a single Jupyterlab cell generate a document
{out1}
First, the weekly light curve:
{fig1}
Replot the figure with an expanded scale to see position of a flare:
{fig2}
{out3} {fig3}
{out4} {fig4}
Table of BB fits
{bb_table}
This can be compared with Figure 4 from the [Kerr paper](https://arxiv.org/pdf/1910.00140.pdf)
{kerr_fig4}
"""
global full
with capture('Setup 3C 279') as out1:
full = WtLike('3C 279', clear=clear)
fig1 = figure(
full.plot(yscale='log', ylim=(0.2,20), figsize=(15,5), xlabel='MJD', fmt='.', fignum=1),
caption='Full scale', width=600)
fig2 = figure(
full.plot( figsize=(15,5), xlabel='MJD', fmt='o', fignum=2, xlim=(57100, 57300),),
width=600)
with capture_hide('Define orbit-based subset around large flare at MJD 57189') as out3:
orbit = full.view((57186, 57191, 0))
fig3 = figure(
orbit.plot(fmt='o', tzero=57186, fignum=3 ),
width=600)
with capture_hide('Apply BB and overplot it with the cells on which it is based') as out4:
bborbit = orbit.bb_view()
fig4 = figure(
bborbit.plot(fmt='o', tzero=57186, fignum=4),
width=600)
bb_table = orbit.fluxes
kerr_fig4 = image('kerr_fig4.png', width=600, caption=None)
return locals()
if Config().valid:
wtlike_demo( False)