Skip to content

Commit

Permalink
Added option to use narrow priors for the periods
Browse files Browse the repository at this point in the history
  • Loading branch information
nicochunger committed Sep 12, 2018
1 parent b9d0b3f commit f7d6670
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
19 changes: 14 additions & 5 deletions src/real_data/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def read_config(configfile, nplanets, narrow):
:param string config: string indicating path to configuration file.
:param int nplanets: integer with the number of planets to be used in the model
:param bool narrow: Boolean indicating whether to use the narrow priors for
the planet periods.
:param float narrow: Float indicating how wide to take the narrow priors.
If it is 0, broad priors will be used instead.
"""

# Import configuration file as module
Expand All @@ -50,18 +50,27 @@ def read_config(configfile, nplanets, narrow):
# Make copy of all relavant dictionaries and lists
datadict, fpdict, driftdict, harpsdict = map(dict.copy, c.configdicts)
planet_periods = list.copy(c.planet_periods)
periods_std = list.copy(c.periods_std)
# Create input_dict in acordance to number of planets in the model
input_dict = {'harps': harpsdict, 'drift1': driftdict}
for i in range(1, nplanets+1):
input_dict.update({f'planet{i}': copy.deepcopy(fpdict)})
if narrow:
# Change the prior range for the planet periods
# # Lower limit
# input_dict[f'planet{i}']['period'][2][1] = (1-narrow) * \
# planet_periods[i-1]
# # Upper limit
# input_dict[f'planet{i}']['period'][2][2] = (1+narrow) * \
# planet_periods[i-1]

# Lower limit
input_dict[f'planet{i}']['period'][2][1] = planet_periods[i-1] - 4
input_dict[f'planet{i}']['period'][2][1] = planet_periods[i-1] - \
5*periods_std[i-1]
# Upper limit
input_dict[f'planet{i}']['period'][2][2] = planet_periods[i-1] + 4
input_dict[f'planet{i}']['period'][2][2] = planet_periods[i-1] + \
5*periods_std[i-1]

print('\nInput Dict')
pprint(input_dict)
# Create prior instances
priordict = priors.prior_constructor(input_dict, {})
Expand Down
3 changes: 2 additions & 1 deletion src/real_data/configfiles/hd40307_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
'slope': [0.0, 1, ['Uniform', 0., 50.]],
}

planet_periods = [9.62, 20.41, 4.31, 51.56]
planet_periods = [9.6208, 20.418, 4.311, 51.56, 204.5]
periods_std = [0.0009, 0.005, 0.0003, 0.08, 1]

configdicts = [datadict, fpdict, driftdict, harpsdict]
9 changes: 4 additions & 5 deletions src/real_data/ppc_harps.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,16 @@
help='Number of repeats in slice sampling. As: nrep*ndim')
parser.add_argument('-prec', type=float, default=0.01,
help='Precision criterion for termination.')
parser.add_argument('-narrow', type=float, default=0,
help='Wether to use the narrow priors for the periods.')

# TODO Change this parameter for the new real data
# TODO Change this parameter for other instruments (?)
# parser.add_argument('-inst', type=str, default=1,
# help='Which dataset to analyze.')

parser.add_argument('--noclust', action='store_false',
help='If clustering should be turned off.')

parser.add_argument('--narrow', action='store_true',
help='Wether to use the narrow priors for the periods.')

parser.add_argument('--resume', action='store_true',
help='If the previous run should be resumed.')

Expand All @@ -69,7 +68,7 @@

# Assign modelpath
# modelpath = f'configfiles/hd40307_k{nplanets}.py'
modelpath = f'configfiles/hd40307_model.py'
modelpath = 'configfiles/hd40307_model.py'

# Generate dictionaries
parnames, datadict, priordict, fixedpardict = config.read_config(
Expand Down

0 comments on commit f7d6670

Please sign in to comment.