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

Sourcery refactored master branch #24

Merged
merged 2 commits into from
Feb 15, 2024
Merged
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
7 changes: 2 additions & 5 deletions octotribble/Combine_nod_spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

Script that take one imput parameter which is the path to the normobs directory

Needs functions/modules to get the filenames, export to a fits tablefile, change fits hdr
Needs functions/modules to get the filenames, export them to a fits tablefile, change fits hdr
"""
import argparse
import fnmatch
Expand Down Expand Up @@ -48,10 +48,7 @@ def SumNods(Spectra, Headers, Pos="All", Norm="None"):
If want to be more sure the correct nods are added the headers
should be checked for its nod position.
"""
if Pos == "All":
NodNum = len(Spectra)
else:
NodNum = len(Spectra) / 2.0
NodNum = len(Spectra) if Pos == "All" else len(Spectra) / 2.0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SumNods refactored with the following changes:

  • Replace if statement with if expression

# print("number of nods ", NodNum)
# if Headers[i]["HIERARCH ESO SEQ NODPOS"] == Pos:
NodSum = np.zeros_like(Spectra[0])
Expand Down
10 changes: 5 additions & 5 deletions octotribble/Compare_pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def ccf_astro(spectrum1, spectrum2, rvmin=0, rvmax=200, drv=1):
s = False
w, f = spectrum1
tw, tf = spectrum2
if not len(w) or not len(tw):
if not (len(w) and len(tw)):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ccf_astro refactored with the following changes:

  • Simplify logical expression

return 0, 0, 0, 0, 0
c = 299792.458
drvs = np.arange(rvmin, rvmax, drv)
Expand Down Expand Up @@ -441,7 +441,7 @@ def main(fname, fname2, lines=False, model=False, telluric=False, sun=False,
else:
print('Warning: Solar spectrum not available in wavelength range.')
sun = False
elif sun and model:
elif sun:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function main refactored with the following changes:

  • Remove redundant conditional

print('Warning: Both solar spectrum and a model spectrum are selected. Using model spectrum.')
sun = False

Expand Down Expand Up @@ -495,7 +495,7 @@ def main(fname, fname2, lines=False, model=False, telluric=False, sun=False,
if ccf != 'none':
if ccf in ['sun', 'both'] and sun:
# remove tellurics from the Solar spectrum
if telluric and sun:
if telluric:
print('Correcting solar spectrum for tellurics...')
i_sun = i_sun / i_tel
print('Calculating CCF for the Sun...')
Expand Down Expand Up @@ -628,9 +628,9 @@ def main(fname, fname2, lines=False, model=False, telluric=False, sun=False,
elif rv1 and rv2:
ax1.set_title(
'{0!s}\nSun/model: {1!s} km/s, telluric: {2!s} km/s'.format(fname, rv1, rv2))
elif rv1 and not rv2:
elif rv1:
ax1.set_title('{0!s}\nSun/model: {1!s} km/s'.format(fname, rv1))
elif not rv1 and rv2:
elif rv2:
ax1.set_title('{0!s}\nTelluric: {1!s} km/s'.format(fname, rv2))
elif ccf == 'model':
ax1.set_title('{0!s}\nModel(CCF): {1!s} km/s'.format(fname, rv1))
Expand Down
4 changes: 1 addition & 3 deletions octotribble/Convolution/IP_Convolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ def unitary_Gauss(x, center, fwhm):
sigma = np.abs(fwhm) / (2 * np.sqrt(2 * np.log(2)))
Amp = 1.0 / (sigma * np.sqrt(2 * np.pi))
tau = -((x - center)**2) / (2 * (sigma**2))
result = Amp * np.exp(tau)

return result
return Amp * np.exp(tau)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function unitary_Gauss refactored with the following changes:

  • Inline variable that is only used once



def fast_convolve(wav_val, R, wav_extended, flux_extended, fwhm_lim):
Expand Down
4 changes: 1 addition & 3 deletions octotribble/Convolution/IP_compare_single_vs_multiproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ def unitary_Gauss(x, center, fwhm):
sigma = np.abs(fwhm) / (2 * np.sqrt(2 * np.log(2)))
Amp = 1.0 / (sigma * np.sqrt(2 * np.pi))
tau = -((x - center) ** 2) / (2 * (sigma ** 2))
result = Amp * np.exp(tau)

return result
return Amp * np.exp(tau)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function unitary_Gauss refactored with the following changes:

  • Inline variable that is only used once



def fast_convolve(wav_val, R, wav_extended, flux_extended, fwhm_lim):
Expand Down
4 changes: 1 addition & 3 deletions octotribble/Convolution/IP_multi_Convolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ def unitary_Gauss(x, center, fwhm):
sigma = np.abs(fwhm) / (2 * np.sqrt(2 * np.log(2)))
Amp = 1.0 / (sigma * np.sqrt(2 * np.pi))
tau = -((x - center) ** 2) / (2 * (sigma ** 2))
result = Amp * np.exp(tau)

return result
return Amp * np.exp(tau)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function unitary_Gauss refactored with the following changes:

  • Inline variable that is only used once



def fast_convolve(wav_val, R, wav_extended, flux_extended, fwhm_lim):
Expand Down
6 changes: 2 additions & 4 deletions octotribble/Doppler_factor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@ def doppler_factor_shift(wave, velocity):
beta = velocity / constants.c
doppler_factor = ((1 + beta) / (1 - beta)) ** 0.5

y = wave * doppler_factor
return y
return wave * doppler_factor
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function doppler_factor_shift refactored with the following changes:

  • Inline variable that is only used once



def doppler_shift(wave, velocity):
"""Doppler shift using non-realtivistically."""
beta = velocity / constants.c
y = wave * (1 + beta)
return y
return wave * (1 + beta)
Comment on lines -31 to +30
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function doppler_shift refactored with the following changes:

  • Inline variable that is only used once



shift_factor = doppler_factor_shift(wavelength, rv)
Expand Down
3 changes: 1 addition & 2 deletions octotribble/Misc/tick_label_modification.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
def convert_labels_to_rv(x, labels):
x_mid = np.mean(x)
c = 299792.458 # km/s
transform = ["{0:2.1f}".format((label / x_mid) * c) for label in labels]
return transform
return ["{0:2.1f}".format((label / x_mid) * c) for label in labels]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function convert_labels_to_rv refactored with the following changes:

  • Inline variable that is only used once



x = np.arange(10) + 2110
Expand Down
12 changes: 4 additions & 8 deletions octotribble/RVCalculations.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@

def Calculate_RV(Lambda, deltalambda):
c = 299792458. # m/s
V = [c * deltalambda / lmda for lmda in Lambda]
return V
return [c * deltalambda / lmda for lmda in Lambda]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Calculate_RV refactored with the following changes:

  • Inline variable that is only used once



def Calculate_WLshift(wav, v):
Expand All @@ -27,22 +26,19 @@ def Calculate_WLshift(wav, v):
if isinstance(v, (int, float)):
return (v / c) * wav
else:
deltalambda = [(v / c) * lmda for lmda in wav]
return deltalambda
return [(v / c) * lmda for lmda in wav]
Comment on lines -30 to +29
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Calculate_WLshift refactored with the following changes:

  • Inline variable that is only used once



def Calc_RV(Lambda, deltalambda):
# Fixed wavelength
c = 299792458. # m/s
V = [c * (delta / Lambda) for delta in deltalambda]
return V
return [c * (delta / Lambda) for delta in deltalambda]
Comment on lines -37 to +35
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Calc_RV refactored with the following changes:

  • Inline variable that is only used once



def Calc_WLshift(Lambda, vels):
# Fixed wavelength
c = 299792458. # m/s
V = [(vel / c) * Lambda for vel in vels]
return V
return [(vel / c) * Lambda for vel in vels]
Comment on lines -44 to +41
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Calc_WLshift refactored with the following changes:

  • Inline variable that is only used once

# NIR range we have
# 2110 nm to 2170 nm

Expand Down
14 changes: 6 additions & 8 deletions octotribble/SpectralTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ def wl_interpolation(wl, spec, ref_wl, method="scipy", kind="linear", verbose=Fa
v_print = print if verbose else lambda *a, **k: None

starttime = time.time()
if method == "scipy":
v_print(kind + " scipy interpolation")
linear_interp = interp1d(wl, spec, kind=kind)
new_spec = linear_interp(ref_wl)
elif method == "numpy":
if method == "numpy":
if kind.lower() is not "linear":
v_print("Warning: Cannot do " + kind + " interpolation with numpy, switching to linear")
v_print("Linear numpy interpolation")
new_spec = np.interp(ref_wl, wl, spec) # 1-d peicewise linear interpolat
elif method == "scipy":
v_print(kind + " scipy interpolation")
linear_interp = interp1d(wl, spec, kind=kind)
new_spec = linear_interp(ref_wl)
Comment on lines -123 to +131
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function wl_interpolation refactored with the following changes:

  • Simplify conditional into switch-like form

else:
v_print("Method was given as " + method)
raise("Interpolation method not correct")
Expand All @@ -150,9 +150,7 @@ def unitary_Gauss(x, center, FWHM):
sigma = np.abs(FWHM) / (2 * np.sqrt(2 * np.log(2)))
amp = 1.0 / (sigma * np.sqrt(2 * np.pi))
tau = -((x - center)**2) / (2 * (sigma**2))
result = amp * np.exp(tau)

return result
return amp * np.exp(tau)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function unitary_Gauss refactored with the following changes:

  • Inline variable that is only used once



def fast_convolve(wav_val, R, wav_extended, flux_extended, fwhm_lim):
Expand Down
3 changes: 1 addition & 2 deletions octotribble/Tapas/tapas_spectra_namer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ def _parser():
parser.add_argument("-k", "--keep_original", help="Keep the original file", action="store_true")
parser.add_argument("-s", "--species", help="Specify constituents if known e.g. h20, noh20", type=str)

args = parser.parse_args()
return args
return parser.parse_args()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _parser refactored with the following changes:

  • Inline variable that is only used once



def main(fname, extract=False, prefix="", keep_original=False, species=False):
Expand Down
3 changes: 1 addition & 2 deletions octotribble/Tapas/tapas_xml_request_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ def _parser():
parser.add_argument("-n", "--request_number", help="Tapas request number. Iterate on previous request number.",
type=int)
parser.add_argument("-v", "--verbose", action="store_true", help="Turn on verbosity.")
args = parser.parse_args()
return args
return parser.parse_args()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _parser refactored with the following changes:

  • Inline variable that is only used once



def main(fname=("/home/jneal/Phd/data/Crires/BDs-DRACS/HD30501-1/Combined_Nods/"
Expand Down
8 changes: 4 additions & 4 deletions octotribble/combine_nod_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

def combine_errors(chips=range(1, 5), save_path=None):
"""Assumes the current directory contains the files for the nod cycle."""
# Update header
from datetime import datetime
Comment on lines +11 to +12
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function combine_errors refactored with the following changes:

  • Hoist statements out of for/while loops
  • Replace unneeded comprehension with generator

for chip in chips:
# print("Chip", chip)
ms_files = sorted(glob("C*_{0}.*ms.fits.*".format(chip)))
Expand All @@ -19,8 +21,8 @@ def combine_errors(chips=range(1, 5), save_path=None):
assert len(norm_sum_file) == 1
norm_sum_file = norm_sum_file[0]
# Check ms_file and norm_file match the start of norm_sum_file
assert any([os.path.basename(norm_sum_file)[0:29] in name for name in ms_files])
assert any([os.path.basename(norm_sum_file)[0:29] in name for name in norm_files])
assert any(os.path.basename(norm_sum_file)[0:29] in name for name in ms_files)
assert any(os.path.basename(norm_sum_file)[0:29] in name for name in norm_files)

# Combine Spectrum errors quadratically
square_error = np.zeros(1024)
Expand Down Expand Up @@ -48,8 +50,6 @@ def combine_errors(chips=range(1, 5), save_path=None):

assert error_spectrum.shape == sum_spectrum.shape

# Update header
from datetime import datetime
header["history"] = "Errors combined on {}".format(datetime.now())
header["comment"] = "Errors normalized, added in quadrature, then divide by number of nods"

Expand Down
3 changes: 1 addition & 2 deletions octotribble/extraction/dracs_quicklooks2017.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ def _parser():
choices=["1", "2", "3"],
default=None,
)
args = parser.parse_args()
return args
return parser.parse_args()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _parser refactored with the following changes:

  • Inline variable that is only used once



def main(chip=None, band=None, showplots=False):
Expand Down
9 changes: 2 additions & 7 deletions octotribble/extraction/plot_mixed_combination.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,11 @@ def _parser():
choices=["1", "2", "3", "4"],
default=None,
)
args = parser.parse_args()
return args
return parser.parse_args()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _parser refactored with the following changes:

  • Inline variable that is only used once



def main(chip=None, showplots=False):
if chip is None:
chips = range(1, 5)
else:
chips = [int(chip)]

chips = range(1, 5) if chip is None else [int(chip)]
Comment on lines -38 to +37
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function main refactored with the following changes:

  • Replace if statement with if expression

dir_path = os.getcwd()

intermediate_path = os.path.join(dir_path, "Intermediate_steps", "")
Expand Down
6 changes: 2 additions & 4 deletions octotribble/file_renamer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ def _parser():
parser.add_argument('filenames', nargs='+', type=str, help='List of Filenames')
parser.add_argument("-x", "--cut", type=str, default=":", help="Character to Remove (cut)")
parser.add_argument("-v", "--paste", type=str, default="", help="Character to replace with (paste)")
args = parser.parse_args()
return args
return parser.parse_args()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _parser refactored with the following changes:

  • Inline variable that is only used once



def char_replace(fname, remove_char, replace_char=""):
Expand Down Expand Up @@ -48,8 +47,7 @@ def char_replace(fname, remove_char, replace_char=""):

"""
name_parts = fname.split(remove_char)
new_name = replace_char.join(name_parts)
return new_name
return replace_char.join(name_parts)
Comment on lines -51 to +50
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function char_replace refactored with the following changes:

  • Inline variable that is only used once



def main(filenames, cut=":", paste=""):
Expand Down
32 changes: 21 additions & 11 deletions octotribble/grid_chisquare.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,38 @@ def chi_squared(observed, expected, error=None):


def parallel_chisqr_1D(iter_1, obs, model, model_params, n_jobs=4):
grid = Parallel(n_jobs=n_jobs)(delayed(chi_squared)(obs, model(a, *model_params)) for a in iter_1)
return grid
return Parallel(n_jobs=n_jobs)(
delayed(chi_squared)(obs, model(a, *model_params)) for a in iter_1
)
Comment on lines -34 to +36
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function parallel_chisqr_1D refactored with the following changes:

  • Inline variable that is only used once



# @memory.cache
def parallel_chisqr_2D(iter_1, iter_2, obs, model, model_params, n_jobs=4):
grid = Parallel(n_jobs=n_jobs)(delayed(chi_squared)(obs, model(a, b, *model_params))
for a in iter_1 for b in iter_2)
return grid
return Parallel(n_jobs=n_jobs)(
delayed(chi_squared)(obs, model(a, b, *model_params))
for a in iter_1
for b in iter_2
)
Comment on lines -40 to +45
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function parallel_chisqr_2D refactored with the following changes:

  • Inline variable that is only used once



# @memory.cache
def parallel_chisqr_3D(iter_1, iter_2, iter_3, obs, model, model_params, n_jobs=4):
grid = Parallel(n_jobs=n_jobs)(delayed(chi_squared)(obs, model(a, b, c, *model_params))
for a in iter_1 for b in iter_2 for c in iter_3)
return grid
return Parallel(n_jobs=n_jobs)(
delayed(chi_squared)(obs, model(a, b, c, *model_params))
for a in iter_1
for b in iter_2
for c in iter_3
)
Comment on lines -47 to +55
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function parallel_chisqr_3D refactored with the following changes:

  • Inline variable that is only used once



def parallel_chisqr_4D(iter_1, iter_2, iter_3, iter_4, obs, model, model_params, n_jobs=4):
grid = Parallel(n_jobs=n_jobs)(delayed(chi_squared)(obs, model(a, b, c, d, *model_params))
for a in iter_1 for b in iter_2 for c in iter_3 for d in iter_4)
return grid
return Parallel(n_jobs=n_jobs)(
delayed(chi_squared)(obs, model(a, b, c, d, *model_params))
for a in iter_1
for b in iter_2
for c in iter_3
for d in iter_4
)
Comment on lines -53 to +65
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function parallel_chisqr_4D refactored with the following changes:

  • Inline variable that is only used once



# @memory.cache
Expand Down
8 changes: 2 additions & 6 deletions octotribble/normalize/cont_norm.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ def _parser():
help="Calculate normalization fucntion errors on the flux.")
parser.add_argument("-p", "--plot", default=False, action="store_true",
help="Plot normalized result.")
args = parser.parse_args()
return args
return parser.parse_args()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _parser refactored with the following changes:

  • Inline variable that is only used once



def main():
Expand Down Expand Up @@ -69,10 +68,7 @@ def main():


fitssave = args.fitsname.replace(".fits", ".{!s}.fits".format(args.suffix))
if len(data) == 2:
fits.writeto(fitssave, norm_flux, header=hdr)
else:
fits.writeto(fitssave, norm_flux, header=hdr)
fits.writeto(fitssave, norm_flux, header=hdr)
Comment on lines -72 to +71
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function main refactored with the following changes:

  • Hoist repeated code outside conditional statement



def flux_error(wave, flux, c):
Expand Down
3 changes: 1 addition & 2 deletions octotribble/normalize/fitsnorm.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ def _parser():
parser.add_argument("filename", type=str,
help="Specturm to continuum normalize.")

args = parser.parse_args()
return args
return parser.parse_args()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _parser refactored with the following changes:

  • Inline variable that is only used once



if __name__ == "__main__":
Expand Down
3 changes: 1 addition & 2 deletions octotribble/obs_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ def _parser():
parser.add_argument("-o", "--output", help="Specify output filename", default=False)
parser.add_argument("-s", "--separator", help="Separator for time section of fits", default=":")

args = parser.parse_args()
return args
return parser.parse_args()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _parser refactored with the following changes:

  • Inline variable that is only used once



def main(fname, output=False, separator=":", verbose=True):
Expand Down
13 changes: 2 additions & 11 deletions octotribble/phoenix_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,8 @@ def find_closest_phoenix(data_dir, teff, logg, feh, alpha=None):
closest_logg = loggs[np.abs(loggs - logg).argmin()]
closest_feh = fehs[np.abs(fehs - feh).argmin()]

if alpha is not None:
if abs(alpha) > 0.2:
print("Warning! Alpha is outside acceptable range -0.2->0.2")
closest_alpha = alphas[np.abs(alphas - alpha).argmin()]
phoenix_glob = ("/Z{2:+4.1f}.Alpha={3:+5.2f}/*{0:05d}{1:4.2f}"
"{2:+4.1f}.Alpha={3:+5.2f}.PHOENIX*.fits"
"").format(closest_teff, closest_logg, closest_feh,
closest_alpha)
else:
phoenix_glob = ("/Z{2:+4.1f}/*{0:05d}{1:4.2f}{2:+4.1f}.PHOENIX*.fits"
"").format(closest_teff, closest_logg, closest_feh)
phoenix_glob = ("/Z{2:+4.1f}/*{0:05d}{1:4.2f}{2:+4.1f}.PHOENIX*.fits"
"").format(closest_teff, closest_logg, closest_feh)
Comment on lines -45 to +46
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function find_closest_phoenix refactored with the following changes:

  • Remove redundant conditional

files = glob.glob(data_dir + phoenix_glob)
if len(files) > 1:
print("More than one file returned")
Expand Down
Loading
Loading