Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jktebop backend: exposure time support #728

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion .github/workflows/on_pr_test_python_31x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,23 @@ jobs:
- name: Test photodynam install
run: |
python -c "import photodynam"


- name: Setup GNU Fortran
uses: modflowpy/install-gfortran-action@v1

- name: Install jktebop
run: |
wget https://www.astro.keele.ac.uk/jkt/codes/jktebop-v43.tgz
tar -xvzf jktebop-v43.tgz
cd jktebop43
gfortran -o jktebop jktebop.f
echo $(pwd) >> $GITHUB_PATH
cd ..

- name: Test jktebop install
run: |
jktebop

- name: Run tests
run: |
pytest --verbose --capture=no --full-trace tests/nosetests/
16 changes: 16 additions & 0 deletions .github/workflows/on_pr_test_python_37.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,22 @@ jobs:
run: |
python -c "import photodynam"

- name: Setup GNU Fortran
uses: modflowpy/install-gfortran-action@v1

- name: Install jktebop
run: |
wget https://www.astro.keele.ac.uk/jkt/codes/jktebop-v43.tgz
tar -xvzf jktebop-v43.tgz
cd jktebop43
gfortran -o jktebop jktebop.f
echo $(pwd) >> $GITHUB_PATH
cd ..

- name: Test jktebop install
run: |
jktebop

- name: Run tests
run: |
pytest --verbose --capture=no tests/nosetests/
16 changes: 16 additions & 0 deletions .github/workflows/on_pr_test_python_38.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,22 @@ jobs:
run: |
python -c "import photodynam"

- name: Setup GNU Fortran
uses: modflowpy/install-gfortran-action@v1

- name: Install jktebop
run: |
wget https://www.astro.keele.ac.uk/jkt/codes/jktebop-v43.tgz
tar -xvzf jktebop-v43.tgz
cd jktebop43
gfortran -o jktebop jktebop.f
echo $(pwd) >> $GITHUB_PATH
cd ..

- name: Test jktebop install
run: |
jktebop

- name: Run tests
run: |
pytest --verbose --capture=no tests/nosetests/
17 changes: 17 additions & 0 deletions .github/workflows/on_pr_test_python_39.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,23 @@ jobs:
run: |
python -c "import photodynam"

- name: Setup GNU Fortran
uses: modflowpy/install-gfortran-action@v1

- name: Install jktebop
run: |
wget https://www.astro.keele.ac.uk/jkt/codes/jktebop-v43.tgz
tar -xvzf jktebop-v43.tgz
cd jktebop43
gfortran -o jktebop jktebop.f
echo $(pwd) >> $GITHUB_PATH
cd ..

- name: Test jktebop install
run: |
echo $PATH
jktebop

- name: Run tests
run: |
pytest --verbose --capture=no --full-trace tests/nosetests/
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ MANIFEST
*.log
*.txt
*.png
*.so
*.egg-info
.DS_Store
libphoebe.so

*.swp
42 changes: 34 additions & 8 deletions phoebe/backend/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -2145,8 +2145,11 @@ def _worker_setup(self, b, compute, infolist, **kwargs):
rA = b.get_value(qualifier='requiv', component=starrefs[0], context='component', unit=u.solRad, **_skip_filter_checks)
rB = b.get_value(qualifier='requiv', component=starrefs[1], context='component', unit=u.solRad, **_skip_filter_checks)
sma = b.get_value(qualifier='sma', component=orbitref, context='component', unit=u.solRad, **_skip_filter_checks)
sma_A = b.get_value(qualifier='sma', component=starrefs[0], context='component', unit=u.solRad, **_skip_filter_checks)
sma_B = b.get_value(qualifier='sma', component=starrefs[1], context='component', unit=u.solRad, **_skip_filter_checks)
incl = b.get_value(qualifier='incl', component=orbitref, context='component', unit=u.deg, **_skip_filter_checks)
q = b.get_value(qualifier='q', component=orbitref, context='component', **_skip_filter_checks)
ecc = b.get_value(qualifier='ecc', component=orbitref, context='component', **_skip_filter_checks)
ecosw = b.get_value(qualifier='ecosw', component=orbitref, context='component', **_skip_filter_checks)
esinw = b.get_value(qualifier='esinw', component=orbitref, context='component', **_skip_filter_checks)

Expand All @@ -2162,12 +2165,18 @@ def _worker_setup(self, b, compute, infolist, **kwargs):
ringsize=ringsize,
distortion_method=distortion_method,
irrad_method=irrad_method,
fti_method=fti_method,
fti_oversample=fti_oversample,
rA=rA, rB=rB,
sma=sma, incl=incl, q=q,
ecosw=ecosw, esinw=esinw,
gravbA=gravbA, gravbB=gravbB,
period=period, t0_supconj=t0_supconj,
pblums=kwargs.get('pblums'))
pblums=kwargs.get('pblums'),
sma_A=sma_A,
sma_B=sma_B,
ecc=ecc
)

def _run_single_dataset(self, b, info, **kwargs):
"""
Expand All @@ -2183,25 +2192,41 @@ def _run_single_dataset(self, b, info, **kwargs):
rA = kwargs.get('rA')
rB = kwargs.get('rB')
sma = kwargs.get('sma')
sma_A = kwargs.get('sma_A')
sma_B = kwargs.get('sma_B')
incl = kwargs.get('incl')
q = kwargs.get('q')
if distortion_method == 'sphere':
q *= -1
ecosw = kwargs.get('ecosw')
esinw = kwargs.get('esinw')
ecc = kwargs.get('ecc')
gravbA = kwargs.get('gravbA')
gravbB = kwargs.get('gravbB')
period = kwargs.get('period')
t0_supconj = kwargs.get('t0_supconj')

# get dataset-dependent things that we need
ldfuncA = b.get_value(qualifier='ld_func', component=starrefs[0], dataset=info['dataset'], context='dataset', **_skip_filter_checks)
ldfuncB = b.get_value(qualifier='ld_func', component=starrefs[1], dataset=info['dataset'], context='dataset', **_skip_filter_checks)
ds_ps = b.filter(dataset=info['dataset'], context='dataset', **_skip_filter_checks)
ldfuncA = ds_ps.get_value(qualifier='ld_func', component=starrefs[0], **_skip_filter_checks)
ldfuncB = ds_ps.get_value(qualifier='ld_func', component=starrefs[1], **_skip_filter_checks)

computeparams = b.filter(compute=compute, context='compute', **_skip_filter_checks)
fti_method = computeparams.get_value(qualifier='fti_method', dataset=info['dataset'], fti_method=kwargs.get('fti_method', None), default='none', **_skip_filter_checks)
if fti_method == 'jktebop':
fti_oversample = computeparams.get_value(qualifier='fti_oversample', dataset=info['dataset'], fti_oversample=kwargs.get('fti_oversample', None), **_skip_filter_checks)
else:
fti_oversample = 0

if 'exptime' in ds_ps.qualifiers:
exptime = ds_ps.get_value(qualifier='exptime', unit=u.s, **_skip_filter_checks)
else:
exptime = 0.0

# use check_visible=False to access the ld_coeffs from
# compute_ld_coeffs(set_value=True) done in _worker_setup
ldcoeffsA = b.get_value(qualifier='ld_coeffs', component=starrefs[0], dataset=info['dataset'], context='dataset', **_skip_filter_checks)
ldcoeffsB = b.get_value(qualifier='ld_coeffs', component=starrefs[1], dataset=info['dataset'], context='dataset', **_skip_filter_checks)
ldcoeffsA = ds_ps.get_value(qualifier='ld_coeffs', component=starrefs[0], **_skip_filter_checks)
ldcoeffsB = ds_ps.get_value(qualifier='ld_coeffs', component=starrefs[1], **_skip_filter_checks)

if irrad_method == "biaxial-spheroid":
albA = b.get_value(qualifier='irrad_frac_refl_bol', component=starrefs[0], context='component', **_skip_filter_checks)
Expand Down Expand Up @@ -2337,7 +2362,8 @@ def _run_single_dataset(self, b, info, **kwargs):
#~ fi.write('rv2 llaqr-rv2.dat llaqr-rv2.out 55.0 -10.0 0 0\n')
if info['kind'] == 'rv':
# NOTE: we disable systemic velocity as it will be added in bundle.run_compute
K = np.pi * (sma*u.solRad).to(u.km).value * np.sin((incl*u.deg).to(u.rad).value) / (period*u.d).to(u.s).value
sma_ = sma_A if info['component'] == starrefs[0] else sma_B
K = np.pi * 2*(sma_*u.solRad).to(u.km).value * np.sin((incl*u.deg).to(u.rad).value) / ((period*u.d).to(u.s).value * np.sqrt(1-ecc**2))
fi.write('{} {} {} {} {} 0 0\n'.format('rv1' if info['component'] == starrefs[0] else 'rv2', tmpfilenamervin, tmpfilenamervout, K, 0.0))


Expand All @@ -2346,8 +2372,8 @@ def _run_single_dataset(self, b, info, **kwargs):
# occupying a total time interval of NINTERVAL (seconds) by including this line:
# NUMI [numint] [ninterval]

# TODO: allow exposure times?

if fti_method == 'oversample' and fti_oversample > 0 and exptime > 0:
fi.write(f'NUMI {fti_oversample} {exptime}\n')

fi.close()

Expand Down
8 changes: 6 additions & 2 deletions phoebe/parameters/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,10 @@ def jktebop(**kwargs):
treatment of `distortion_method`.
* `irrad_method` (string, optional, default='none'): method to use for
irradiation (ellc does not support irradiation).
* `fti_method` (string, optional, default='none'): method to use when accounting
for finite exposure times. NEW IN 2.4.11.
* `fti_oversample` (int, optional, default=1): number of integration points
used to account for finite exposure time. Only used if `fti_method`='oversample'.

Returns
--------
Expand Down Expand Up @@ -559,8 +563,8 @@ def jktebop(**kwargs):
params += [ChoiceParameter(qualifier='distortion_method', value=kwargs.get('distortion_method', 'sphere/biaxial spheroid'), choices=["sphere/biaxial spheroid", "sphere"], description='Method to use for distorting stars (applies to all components). sphere/biaxial-spheroid: spheres for eclipse shapes and biaxial spheroid for calculation of ellipsoidal effects and reflection, sphere: sphere for eclipse shapes and no ellipsoidal or reflection effects')]
params += [ChoiceParameter(qualifier='irrad_method', value=kwargs.get('irrad_method', 'biaxial-spheroid'), choices=['none', 'biaxial-spheroid'], description='Which method to use to handle all irradiation effects')]

params += [ChoiceParameter(qualifier='fti_method', copy_for = {'kind': ['lc'], 'dataset': '*'}, dataset='_default', value=kwargs.get('fti_method', 'none'), choices=['none', 'oversample'], description='How to handle finite-time integration (when non-zero exptime)')]
params += [IntParameter(visible_if='fti_method:oversample', qualifier='fti_oversample', copy_for={'kind': ['lc'], 'dataset': '*'}, dataset='_default', value=kwargs.get('fti_oversample', 5), limits=(1,None), default_unit=u.dimensionless_unscaled, description='Number of times to sample per-datapoint for finite-time integration')]
params += [ChoiceParameter(qualifier='fti_method', copy_for = {'kind': ['lc'], 'dataset': '*'}, dataset='_default', value=kwargs.get('fti_method', 'none'), choices=['none', 'jktebop', 'oversample'], description='How to handle finite-time integration (when non-zero exptime). jktebop: use jktebop\'s native oversampling. oversample: use phoebe\'s oversampling')]
params += [IntParameter(visible_if='fti_method:jktebop|oversample', qualifier='fti_oversample', copy_for={'kind': ['lc'], 'dataset': '*'}, dataset='_default', value=kwargs.get('fti_oversample', 5), limits=(1, None), default_unit=u.dimensionless_unscaled, description='number of integration points used to account for finite exposure time.')]

return ParameterSet(params)

Expand Down
4 changes: 2 additions & 2 deletions phoebe/parameters/figure/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ def _figure_style_nosources(b, cycler='default', **kwargs):

params += [ChoiceParameter(qualifier='color', value=b._mplcolorcyclers.get(cycler).get(kwargs.get('color', None)), choices=_mplcolors, description='Default color when plotted via run_figure')]

params += [ChoiceParameter(qualifier='marker', value=b._mplmarkercyclers.get(cycler).get(kwargs.get('marker', None)) if kwargs.get('marker', None) is not "None" else "None", choices=["None"] + _mplmarkers, description='Default marker when plotted via run_figure')]
params += [ChoiceParameter(qualifier='marker', value=b._mplmarkercyclers.get(cycler).get(kwargs.get('marker', None)) if kwargs.get('marker', None) != "None" else "None", choices=["None"] + _mplmarkers, description='Default marker when plotted via run_figure')]

params += [ChoiceParameter(qualifier='linestyle', value=b._mpllinestylecyclers.get(cycler).get(kwargs.get('linestyle', None)) if kwargs.get('linestyle', None) is not "None" else "None", choices=["None"] + _mpllinestyles, description='Default linestyle when plotted via run_figure')]
params += [ChoiceParameter(qualifier='linestyle', value=b._mpllinestylecyclers.get(cycler).get(kwargs.get('linestyle', None)) if kwargs.get('linestyle', None) != "None" else "None", choices=["None"] + _mpllinestyles, description='Default linestyle when plotted via run_figure')]

return params

Expand Down
101 changes: 101 additions & 0 deletions tests/nosetests/test_jktebop_agreement/jktebop1.rv1.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# TIME RV_STAR_A ERROR PHASE MODEL (O-C)
0.000000 1.00000 -1.000000 0.00000000 0.00000 1.00000
0.010101 1.00000 -1.000000 0.01010100 -8.50328 9.50328
0.020202 1.00000 -1.000000 0.02020200 -16.97233 17.97233
0.030303 1.00000 -1.000000 0.03030300 -25.37303 26.37303
0.040404 1.00000 -1.000000 0.04040400 -33.67156 34.67156
0.050505 1.00000 -1.000000 0.05050500 -41.83451 42.83451
0.060606 1.00000 -1.000000 0.06060600 -49.82901 50.82901
0.070707 1.00000 -1.000000 0.07070700 -57.62287 58.62287
0.080808 1.00000 -1.000000 0.08080800 -65.18470 66.18470
0.090909 1.00000 -1.000000 0.09090900 -72.48405 73.48405
0.101010 1.00000 -1.000000 0.10101000 -79.49154 80.49154
0.111111 1.00000 -1.000000 0.11111100 -86.17894 87.17894
0.121212 1.00000 -1.000000 0.12121200 -92.51933 93.51933
0.131313 1.00000 -1.000000 0.13131300 -98.48718 99.48718
0.141414 1.00000 -1.000000 0.14141400 -104.05845 105.05845
0.151515 1.00000 -1.000000 0.15151500 -109.21073 110.21073
0.161616 1.00000 -1.000000 0.16161600 -113.92324 114.92324
0.171717 1.00000 -1.000000 0.17171700 -118.17704 119.17704
0.181818 1.00000 -1.000000 0.18181800 -121.95497 122.95497
0.191919 1.00000 -1.000000 0.19191900 -125.24184 126.24184
0.202020 1.00000 -1.000000 0.20202000 -128.02440 129.02440
0.212121 1.00000 -1.000000 0.21212100 -130.29145 131.29145
0.222222 1.00000 -1.000000 0.22222200 -132.03387 133.03387
0.232323 1.00000 -1.000000 0.23232300 -133.24464 134.24464
0.242424 1.00000 -1.000000 0.24242400 -133.91887 134.91887
0.252525 1.00000 -1.000000 0.25252500 -134.05387 135.05387
0.262626 1.00000 -1.000000 0.26262600 -133.64907 134.64907
0.272727 1.00000 -1.000000 0.27272700 -132.70612 133.70612
0.282828 1.00000 -1.000000 0.28282800 -131.22882 132.22882
0.292929 1.00000 -1.000000 0.29292900 -129.22310 130.22310
0.303030 1.00000 -1.000000 0.30303000 -126.69704 127.69704
0.313131 1.00000 -1.000000 0.31313100 -123.66082 124.66082
0.323232 1.00000 -1.000000 0.32323200 -120.12667 121.12667
0.333333 1.00000 -1.000000 0.33333300 -116.10881 117.10881
0.343434 1.00000 -1.000000 0.34343400 -111.62342 112.62342
0.353535 1.00000 -1.000000 0.35353500 -106.68856 107.68856
0.363636 1.00000 -1.000000 0.36363600 -101.32410 102.32410
0.373737 1.00000 -1.000000 0.37373700 -95.55166 96.55166
0.383838 1.00000 -1.000000 0.38383800 -89.39445 90.39445
0.393939 1.00000 -1.000000 0.39393900 -82.87729 83.87729
0.404040 1.00000 -1.000000 0.40404000 -76.02642 77.02642
0.414141 1.00000 -1.000000 0.41414100 -68.86941 69.86941
0.424242 1.00000 -1.000000 0.42424200 -61.43509 62.43509
0.434343 1.00000 -1.000000 0.43434300 -53.75339 54.75339
0.444444 1.00000 -1.000000 0.44444400 -45.85525 46.85525
0.454545 1.00000 -1.000000 0.45454500 -37.77246 38.77246
0.464646 1.00000 -1.000000 0.46464600 -29.53758 30.53758
0.474747 1.00000 -1.000000 0.47474700 -21.18376 22.18376
0.484848 1.00000 -1.000000 0.48484800 -12.74464 13.74464
0.494949 1.00000 -1.000000 0.49494900 -4.25420 5.25420
0.505051 1.00000 -1.000000 0.50505100 4.25420 -3.25420
0.515152 1.00000 -1.000000 0.51515200 12.74464 -11.74464
0.525253 1.00000 -1.000000 0.52525300 21.18376 -20.18376
0.535354 1.00000 -1.000000 0.53535400 29.53758 -28.53758
0.545455 1.00000 -1.000000 0.54545500 37.77246 -36.77246
0.555556 1.00000 -1.000000 0.55555600 45.85525 -44.85525
0.565657 1.00000 -1.000000 0.56565700 53.75339 -52.75339
0.575758 1.00000 -1.000000 0.57575800 61.43509 -60.43509
0.585859 1.00000 -1.000000 0.58585900 68.86941 -67.86941
0.595960 1.00000 -1.000000 0.59596000 76.02642 -75.02642
0.606061 1.00000 -1.000000 0.60606100 82.87729 -81.87729
0.616162 1.00000 -1.000000 0.61616200 89.39445 -88.39445
0.626263 1.00000 -1.000000 0.62626300 95.55166 -94.55166
0.636364 1.00000 -1.000000 0.63636400 101.32410 -100.32410
0.646465 1.00000 -1.000000 0.64646500 106.68856 -105.68856
0.656566 1.00000 -1.000000 0.65656600 111.62342 -110.62342
0.666667 1.00000 -1.000000 0.66666700 116.10881 -115.10881
0.676768 1.00000 -1.000000 0.67676800 120.12667 -119.12667
0.686869 1.00000 -1.000000 0.68686900 123.66082 -122.66082
0.696970 1.00000 -1.000000 0.69697000 126.69704 -125.69704
0.707071 1.00000 -1.000000 0.70707100 129.22310 -128.22310
0.717172 1.00000 -1.000000 0.71717200 131.22882 -130.22882
0.727273 1.00000 -1.000000 0.72727300 132.70612 -131.70612
0.737374 1.00000 -1.000000 0.73737400 133.64907 -132.64907
0.747475 1.00000 -1.000000 0.74747500 134.05387 -133.05387
0.757576 1.00000 -1.000000 0.75757600 133.91887 -132.91887
0.767677 1.00000 -1.000000 0.76767700 133.24464 -132.24464
0.777778 1.00000 -1.000000 0.77777800 132.03387 -131.03387
0.787879 1.00000 -1.000000 0.78787900 130.29145 -129.29145
0.797980 1.00000 -1.000000 0.79798000 128.02440 -127.02440
0.808081 1.00000 -1.000000 0.80808100 125.24184 -124.24184
0.818182 1.00000 -1.000000 0.81818200 121.95497 -120.95497
0.828283 1.00000 -1.000000 0.82828300 118.17704 -117.17704
0.838384 1.00000 -1.000000 0.83838400 113.92324 -112.92324
0.848485 1.00000 -1.000000 0.84848500 109.21073 -108.21073
0.858586 1.00000 -1.000000 0.85858600 104.05845 -103.05845
0.868687 1.00000 -1.000000 0.86868700 98.48718 -97.48718
0.878788 1.00000 -1.000000 0.87878800 92.51933 -91.51933
0.888889 1.00000 -1.000000 0.88888900 86.17894 -85.17894
0.898990 1.00000 -1.000000 0.89899000 79.49154 -78.49154
0.909091 1.00000 -1.000000 0.90909100 72.48405 -71.48405
0.919192 1.00000 -1.000000 0.91919200 65.18470 -64.18470
0.929293 1.00000 -1.000000 0.92929300 57.62287 -56.62287
0.939394 1.00000 -1.000000 0.93939400 49.82901 -48.82901
0.949495 1.00000 -1.000000 0.94949500 41.83451 -40.83451
0.959596 1.00000 -1.000000 0.95959600 33.67156 -32.67156
0.969697 1.00000 -1.000000 0.96969700 25.37303 -24.37303
0.979798 1.00000 -1.000000 0.97979800 16.97233 -15.97233
0.989899 1.00000 -1.000000 0.98989900 8.50328 -7.50328
1.000000 1.00000 -1.000000 0.00000000 0.00000 1.00000
Loading