Skip to content

Commit

Permalink
legacy ephemeris and kwargs checks hotfix (2.1.12 release) (#337)
Browse files Browse the repository at this point in the history
* Fixes applying t0 when importing legacy dataset which use phase.
* Fixes ignoring other compute options when running checks on kwargs during run_compute.
  • Loading branch information
kecnry authored Jun 12, 2019
1 parent 9377a50 commit 4e8050f
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 24 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ To understand how to use PHOEBE, please consult the [tutorials, scripts and manu
CHANGELOG
----------

### 2.1.12 - legacy ephemeris and kwargs checks hotfix

* Fixes applying t0 when importing legacy dataset which use phase.
* Fixes ignoring other compute options when running checks on kwargs during run_compute.

### 2.1.11 - legacy dataset import hotfix

* Fixes loading legacy datasets which use phase (by translating to time with the current ephemeris).
Expand Down
2 changes: 1 addition & 1 deletion phoebe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"""

__version__ = '2.1.11'
__version__ = '2.1.12'

import os
import sys as _sys
Expand Down
18 changes: 13 additions & 5 deletions phoebe/frontend/bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,8 @@ def get_hierarchy(self):
"""
return self._hierarchy_param

def _kwargs_checks(self, kwargs, additional_allowed_keys=[],
def _kwargs_checks(self, kwargs, on_filter={},
additional_allowed_keys=[],
additional_forbidden_keys=[],
warning_only=False):
"""
Expand All @@ -1404,14 +1405,15 @@ def _kwargs_checks(self, kwargs, additional_allowed_keys=[],
if isinstance(value, dict):
for k,v in value.items():
self._kwargs_checks({'{}@{}'.format(key, k): v},
on_filter=on_filter,
additional_allowed_keys=additional_allowed_keys+['{}@{}'.format(key, k)],
additional_forbidden_keys=additional_forbidden_keys,
warning_only=warning_only
)

continue

for param in self.filter(qualifier=key).to_list():
for param in self.filter(qualifier=key, **on_filter).to_list():
if hasattr(param, 'valid_selection'):
if not param.valid_selection(value):
msg = "{}={} not valid with choices={}".format(key, value, param.choices)
Expand Down Expand Up @@ -2889,7 +2891,9 @@ def compute_pblums(self, compute=None, **kwargs):

# don't allow things like model='mymodel', etc
forbidden_keys = parameters._meta_fields_filter
self._kwargs_checks(kwargs, additional_forbidden_keys=forbidden_keys)
self._kwargs_checks(kwargs,
on_filter={'compute': compute, 'dataset': datasets, 'component': components},
additional_forbidden_keys=forbidden_keys)

if compute is None:
if len(self.computes)==1:
Expand Down Expand Up @@ -2970,7 +2974,9 @@ def add_compute(self, kind=compute.phoebe, **kwargs):

# since we've already processed (so that we can get the new qualifiers),
# we'll only raise a warning
self._kwargs_checks(kwargs, warning_only=True)
self._kwargs_checks(kwargs,
on_filter={'compute': kwargs['compute']},
warning_only=True)

return self.get_compute(**metawargs)

Expand Down Expand Up @@ -3141,7 +3147,9 @@ def run_compute(self, compute=None, model=None, detach=False,
allowed_kwargs = ['skip_checks', 'jobid']
if conf.devel:
allowed_kwargs += ['mesh_init_phi']
self._kwargs_checks(kwargs, allowed_kwargs)
self._kwargs_checks(kwargs,
on_filter={'compute': compute},
additional_allowed_keys=allowed_kwargs)

if not kwargs.get('skip_checks', False):
passed, msg = self.run_checks(computes=computes, **kwargs)
Expand Down
31 changes: 16 additions & 15 deletions phoebe/frontend/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import logging
from phoebe import conf
from phoebe.distortions import roche
from phoebe.constraints.builtin import t0_ref_to_supconj
# from phoebe.constraints.builtin import t0_ref_to_supconj

import libphoebe
logger = logging.getLogger("IO")
Expand Down Expand Up @@ -255,8 +255,8 @@ def load_lc_data(filename, indep, dep, indweight=None, mzero=None, bundle=None,
load_file = os.path.join(path, filename)
lcdata = np.loadtxt(load_file)
ncol = len(lcdata[0])
#check if there are enough columns for errors

#check if there are enough columns for errors
if ncol >= 3:
sigma = True
# convert standard weight to standard deviation
Expand All @@ -268,7 +268,7 @@ def load_lc_data(filename, indep, dep, indweight=None, mzero=None, bundle=None,
else:
logger.warning('A sigma column was mentioned in the .phoebe file but is not present in the lc data file')

#if phase convert to time
#if phase convert to time
if indep == 'Phase':
logger.warning("Phoebe 2 doesn't accept phases, converting to time with respect to the given ephemeris")
times = bundle.to_time(lcdata[:,0])
Expand Down Expand Up @@ -552,7 +552,7 @@ def load_legacy(filename, add_compute_legacy=True, add_compute_phoebe=True):

# create datasets and fill with the correct parameters
for x in range(len(params)):

pname = params[:,0][x]
pname = pname.split('.')[0]
val = params[:,1][x].strip('"')
Expand Down Expand Up @@ -605,9 +605,9 @@ def load_legacy(filename, add_compute_legacy=True, add_compute_phoebe=True):
d.pop('value') #avoiding possible conflicts
#
#

eb.flip_constraint(solve_for='t0_supconj', constraint_func='t0_ref_supconj', **d)

# elif pnew == 'filter':
# make sure t0 accounts for any phase shift present in phoebe 1
try:
Expand Down Expand Up @@ -668,7 +668,8 @@ def load_legacy(filename, add_compute_legacy=True, add_compute_phoebe=True):
elif 'secondary' in morphology:
eb.add_constraint('semidetached', component='secondary')


#make sure constraints have been applied
eb.run_delayed_constraints()


# First LC
Expand Down Expand Up @@ -819,11 +820,11 @@ def load_legacy(filename, add_compute_legacy=True, add_compute_phoebe=True):
eb.set_value(qualifier='pblum_ref', component='secondary', value='self', dataset=dataid)

#set ldlaw

ldlaws_1to2= {'Linear cosine law': 'linear', 'Logarithmic law': 'logarithmic', 'Square root law': 'square_root'}
if ldlaw == 'Linear cosine law':
logger.warning('Linear cosine law is not currently supported. Converting to linear instead')

value = ldlaws_1to2[ldlaw]#val[0].lower()+val[1::]

# since ld_coeffs is dataset specific make sure there is at least one dataset
Expand Down Expand Up @@ -942,11 +943,11 @@ def load_legacy(filename, add_compute_legacy=True, add_compute_phoebe=True):
eb.set_value_all(check_visible= False, **d)

#set ldlaw

ldlaws_1to2= {'Linear cosine law': 'linear', 'Logarithmic law': 'logarithmic', 'Square root law': 'square_root'}
if ldlaw == 'Linear cosine law':
logger.warning('Linear cosine law is not currently supported. Converting to linear instead')

value = ldlaws_1to2[ldlaw]#val[0].lower()+val[1::]

# since ld_coeffs is dataset specific make sure there is at least one dataset
Expand Down Expand Up @@ -1065,7 +1066,7 @@ def load_legacy(filename, add_compute_legacy=True, add_compute_phoebe=True):
# #
# #
# eb.flip_constraint(solve_for='t0_supconj', constraint_func='t0_ref_supconj', **d)

# # elif pnew == 'filter':
# # make sure t0 accounts for any phase shift present in phoebe 1
# try:
Expand Down Expand Up @@ -1130,10 +1131,10 @@ def load_legacy(filename, add_compute_legacy=True, add_compute_phoebe=True):
# # get rid of seconddary coefficient if ldlaw is linear
# eb.flip_constraint(solve_for='t0_ref', constraint_func='t0_ref_supconj')
#hack because we know hjd0 has been added at this point.
#if lc_indep is in phases
#if lc_indep is in phases
#flip back all constraints
# get rid of seconddary coefficient if ldlaw is linear

eb.flip_constraint(solve_for='t0_ref', constraint_func='t0_ref_supconj')

if contact_binary:
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,12 @@ def run(self):
# Main setup
#
setup (name = 'phoebe',
version = '2.1.11',
description = 'PHOEBE 2.1.11',
version = '2.1.12',
description = 'PHOEBE 2.1.12',
author = 'PHOEBE development team',
author_email = '[email protected]',
url = 'http://github.com/phoebe-project/phoebe2',
download_url = 'https://github.com/phoebe-project/phoebe2/tarball/2.1.11',
download_url = 'https://github.com/phoebe-project/phoebe2/tarball/2.1.12',
packages = ['phoebe', 'phoebe.parameters', 'phoebe.frontend', 'phoebe.constraints', 'phoebe.dynamics', 'phoebe.distortions', 'phoebe.algorithms', 'phoebe.atmospheres', 'phoebe.backend', 'phoebe.utils', 'phoebe.dependencies', 'phoebe.dependencies.autofig', 'phoebe.dependencies.nparray', 'phoebe.dependencies.unitsiau2015'],
install_requires=['numpy>=1.10','scipy>=0.17','astropy>=1.0,<3.0'],
package_data={'phoebe.atmospheres':['tables/wd/*', 'tables/passbands/*'],
Expand Down

0 comments on commit 4e8050f

Please sign in to comment.