Skip to content

Commit

Permalink
Merge pull request #501 from bourque/pep8-sweep
Browse files Browse the repository at this point in the history
PEP8 sweep of repo for Tier 2 Software Standards
  • Loading branch information
bourque authored Jul 6, 2021
2 parents 7c96a16 + 75ef0d1 commit 1f63642
Show file tree
Hide file tree
Showing 34 changed files with 4,834 additions and 4,847 deletions.
44 changes: 22 additions & 22 deletions exoctk/atmospheric_retrievals/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,20 @@ def example(method):

# Fit for the stellar radius and planetary mass using Gaussian priors. This
# is a way to account for the uncertainties in the published values
pw.fit_info.add_gaussian_fit_param('Rs', 0.02*R_sun)
pw.fit_info.add_gaussian_fit_param('Mp', 0.04*M_jup)
pw.fit_info.add_gaussian_fit_param('Rs', 0.02 * R_sun)
pw.fit_info.add_gaussian_fit_param('Mp', 0.04 * M_jup)

# Fit for other parameters using uniform priors
pw.fit_info.add_uniform_fit_param('Rp', 0.9*(1.4 * R_jup), 1.1*(1.4 * R_jup))
pw.fit_info.add_uniform_fit_param('T', 0.5*1200, 1.5*1200)
pw.fit_info.add_uniform_fit_param('Rp', 0.9 * (1.4 * R_jup), 1.1 * (1.4 * R_jup))
pw.fit_info.add_uniform_fit_param('T', 0.5 * 1200, 1.5 * 1200)
pw.fit_info.add_uniform_fit_param("log_scatt_factor", 0, 1)
pw.fit_info.add_uniform_fit_param("logZ", -1, 3)
pw.fit_info.add_uniform_fit_param("log_cloudtop_P", -0.99, 5)
pw.fit_info.add_uniform_fit_param("error_multiple", 0.5, 5)

# Define bins, depths, and errors
pw.wavelengths = 1e-6*np.array([1.119, 1.1387])
pw.bins = [[w-0.0095e-6, w+0.0095e-6] for w in pw.wavelengths]
pw.wavelengths = 1e-6 * np.array([1.119, 1.1387])
pw.bins = [[w - 0.0095e-6, w + 0.0095e-6] for w in pw.wavelengths]
pw.depths = 1e-6 * np.array([14512.7, 14546.5])
pw.errors = 1e-6 * np.array([50.6, 35.5])

Expand Down Expand Up @@ -176,20 +176,20 @@ def example_aws_short(method):

# Fit for the stellar radius and planetary mass using Gaussian priors. This
# is a way to account for the uncertainties in the published values
pw.fit_info.add_gaussian_fit_param('Rs', 0.02*R_sun)
pw.fit_info.add_gaussian_fit_param('Mp', 0.04*M_jup)
pw.fit_info.add_gaussian_fit_param('Rs', 0.02 * R_sun)
pw.fit_info.add_gaussian_fit_param('Mp', 0.04 * M_jup)

# Fit for other parameters using uniform priors
pw.fit_info.add_uniform_fit_param('Rp', 0.9*(1.4 * R_jup), 1.1*(1.4 * R_jup))
pw.fit_info.add_uniform_fit_param('T', 0.5*1200, 1.5*1200)
pw.fit_info.add_uniform_fit_param('Rp', 0.9 * (1.4 * R_jup), 1.1 * (1.4 * R_jup))
pw.fit_info.add_uniform_fit_param('T', 0.5 * 1200, 1.5 * 1200)
pw.fit_info.add_uniform_fit_param("log_scatt_factor", 0, 1)
pw.fit_info.add_uniform_fit_param("logZ", -1, 3)
pw.fit_info.add_uniform_fit_param("log_cloudtop_P", -0.99, 5)
pw.fit_info.add_uniform_fit_param("error_multiple", 0.5, 5)

# Define bins, depths, and errors
pw.wavelengths = 1e-6*np.array([1.119, 1.1387])
pw.bins = [[w-0.0095e-6, w+0.0095e-6] for w in pw.wavelengths]
pw.wavelengths = 1e-6 * np.array([1.119, 1.1387])
pw.bins = [[w - 0.0095e-6, w + 0.0095e-6] for w in pw.wavelengths]
pw.depths = 1e-6 * np.array([14512.7, 14546.5])
pw.errors = 1e-6 * np.array([50.6, 35.5])

Expand Down Expand Up @@ -228,19 +228,19 @@ def example_aws_long(method):
pw.set_parameters(params)

if method == 'multinest':
pw.fit_info.add_gaussian_fit_param('Rs', 0.02*R_sun)
pw.fit_info.add_gaussian_fit_param('Mp', 0.04*M_jup)
pw.fit_info.add_uniform_fit_param('Rp', 0.9*(1.39 * R_jup), 1.1*(1.39 * R_jup))
pw.fit_info.add_gaussian_fit_param('Rs', 0.02 * R_sun)
pw.fit_info.add_gaussian_fit_param('Mp', 0.04 * M_jup)
pw.fit_info.add_uniform_fit_param('Rp', 0.9 * (1.39 * R_jup), 1.1 * (1.39 * R_jup))
pw.fit_info.add_uniform_fit_param('T', 300, 3000)
pw.fit_info.add_uniform_fit_param("log_scatt_factor", 0, 2)
pw.fit_info.add_uniform_fit_param("logZ", -1, 3)
pw.fit_info.add_uniform_fit_param("log_cloudtop_P", -0.99, 7)
pw.fit_info.add_uniform_fit_param("error_multiple", 0.5, 5)
elif method == 'emcee':
pw.fit_info.add_gaussian_fit_param('Rs', 0.02*R_sun)
pw.fit_info.add_gaussian_fit_param('Mp', 0.04*M_jup)
pw.fit_info.add_uniform_fit_param('Rp', 0, np.inf, 0.9*(1.39 * R_jup), 1.1*(1.39 * R_jup))
pw.fit_info.add_uniform_fit_param('T', 300, 3000, 0.5*1476.81, 1.5*1476.81)
pw.fit_info.add_gaussian_fit_param('Rs', 0.02 * R_sun)
pw.fit_info.add_gaussian_fit_param('Mp', 0.04 * M_jup)
pw.fit_info.add_uniform_fit_param('Rp', 0, np.inf, 0.9 * (1.39 * R_jup), 1.1 * (1.39 * R_jup))
pw.fit_info.add_uniform_fit_param('T', 300, 3000, 0.5 * 1476.81, 1.5 * 1476.81)
pw.fit_info.add_uniform_fit_param("log_scatt_factor", 0, 5, 0, 2)
pw.fit_info.add_uniform_fit_param("logZ", -1, 3)
pw.fit_info.add_uniform_fit_param("log_cloudtop_P", -0.99, 7)
Expand Down Expand Up @@ -287,11 +287,11 @@ def get_example_data(object_name):
df = pandas.read_csv(data_file, names=['wavelengths', 'bin_sizes', 'depths', 'errors'])

# Remove and rows outside of wavelength range (3e-7 to 3e-5)
df = df.loc[(1e-6*df['wavelengths'] - 1e-6*df['bin_sizes'] >= 3e-7) & (1e-6*df['wavelengths'] + 1e-6*df['bin_sizes'] <= 3e-5)]
df = df.loc[(1e-6 * df['wavelengths'] - 1e-6 * df['bin_sizes'] >= 3e-7) & (1e-6 * df['wavelengths'] + 1e-6 * df['bin_sizes'] <= 3e-5)]

# Parse the data
wavelengths = 1e-6*np.array(df['wavelengths'])
bin_sizes = 1e-6*np.array(df['bin_sizes'])
wavelengths = 1e-6 * np.array(df['wavelengths'])
bin_sizes = 1e-6 * np.array(df['bin_sizes'])
depths = np.array(df['depths'])
errors = np.array(df['errors'])

Expand Down
68 changes: 34 additions & 34 deletions exoctk/contam_visibility/astro_funcx.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,9 @@
epsilon = 23.43929 * D2R # obliquity of the ecliptic J2000


def pa(tgt_c1, tgt_c2, obj_c1, obj_c2):
"""Calculates position angle of object at tgt position.
Parameters
----------
tgt_c1: float
The RA of the target.
tgt_c2: float
The Dec of the target.
obj_c1: float
The RA of the reference.
obj_c2: float
The Dec of the reference.
Returns
-------
float
The position angle.
"""
y = cos(obj_c2) * sin(obj_c1 - tgt_c1)
c = cos(obj_c2) * sin(tgt_c2) * cos(obj_c1 - tgt_c1)
x = sin(obj_c2) * cos(tgt_c2) - c
p = atan2(y, x)
if p < 0.:
p += PI2
if p >= PI2:
p -= PI2
return p


def delta_pa_no_roll(pos1_c1, pos1_c2, pos2_c1, pos2_c2):
"""Calculates the change in position angle between two positions with no
roll about V1
"""Calculates the change in position angle between two positions
with no roll about V1
Parameters
----------
Expand Down Expand Up @@ -96,8 +66,8 @@ def dist(obj1_c1, obj1_c2, obj2_c1, obj2_c2):


def JWST_same_ori(tgt0_c1, tgt0_c2, p0, tgt_c1, tgt_c2):
"""Calculates normal orientation of second target, given first target's
orientation is normal. This is in Ecliptic coordinates!
"""Calculates normal orientation of second target, given first
target's orientation is normal. This is in Ecliptic coordinates!
Parameters
----------
Expand All @@ -124,6 +94,36 @@ def JWST_same_ori(tgt0_c1, tgt0_c2, p0, tgt_c1, tgt_c2):
return pp


def pa(tgt_c1, tgt_c2, obj_c1, obj_c2):
"""Calculates position angle of object at tgt position.
Parameters
----------
tgt_c1: float
The RA of the target.
tgt_c2: float
The Dec of the target.
obj_c1: float
The RA of the reference.
obj_c2: float
The Dec of the reference.
Returns
-------
float
The position angle.
"""
y = cos(obj_c2) * sin(obj_c1 - tgt_c1)
c = cos(obj_c2) * sin(tgt_c2) * cos(obj_c1 - tgt_c1)
x = sin(obj_c2) * cos(tgt_c2) - c
p = atan2(y, x)
if p < 0.:
p += PI2
if p >= PI2:
p -= PI2
return p


def unit_limit(x):
""" Forces value to be in [-1, 1]
Expand Down
Loading

0 comments on commit 1f63642

Please sign in to comment.