Skip to content

Commit

Permalink
Fix the E712 pep8
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristian Pozo Gonzalez committed Oct 10, 2024
1 parent 3028c34 commit 6b363e8
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions ptiming_ana/cphase/pulsarphase_cal.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def DL3_calphase(
parname = str(os.path.basename(file).replace(".fits", "")) + ".par"

# Calculate phases
if use_interpolation == False:
if not use_interpolation:
model = create_files(timelist, ephem, timname, parname, obs=obs)
if timname is None:
barycent_toas, phases = compute_phases_from_times_model(times, model)
Expand Down Expand Up @@ -494,7 +494,7 @@ def DL2_calphase(
timname = str(os.path.basename(dl2file).replace(".h5", "")) + ".tim"
parname = str(os.path.basename(dl2file).replace(".h5", "")) + ".par"

if use_interpolation == False:
if not use_interpolation:
model = create_files(timelist, ephem, timname, parname, obs=obs)
barycent_toas, phase = get_phase_list_from_tim(timname, model, pickle)
phase = phase.frac
Expand Down
6 changes: 3 additions & 3 deletions ptiming_ana/cphase/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ def merge_dl2_pulsar(directory, run_number, output_dir, src_dep=False):
df_list.append(df_i)

# Include source dependent information if it is the case
if src_dep == True:
if src_dep:
df_i_src = pd.read_hdf(
file, key=dl2_params_src_dep_lstcam_key, float_precision=20
)
df_src_list.append(df_i_src)

df = pd.concat(df_list)
if src_dep == True:
if src_dep:
df_src = pd.concat(df_src_list)

# Write the new merged dataframe into a file
Expand All @@ -76,7 +76,7 @@ def merge_dl2_pulsar(directory, run_number, output_dir, src_dep=False):
metadata = global_metadata()
write_metadata(metadata, output_file)

if src_dep == False:
if not src_dep:
write_dl2_dataframe(df, output_file, meta=metadata)

else:
Expand Down
8 changes: 4 additions & 4 deletions ptiming_ana/phaseogram/lightcurve.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def draw_background(self, pulsar_phases, color, hline=True):
)

# Add hline for background level reference (default True)
if hline == True:
if hline:
plt.hlines(
y=np.mean(
(
Expand Down Expand Up @@ -256,7 +256,7 @@ def draw_fitting(self, pulsar_phases, color, density=False, label=None):
elif pulsar_phases.fitting.model == "gaussian":
y = gaussian(x, *pulsar_phases.fitting.params)

if density == True:
if density:
width = 1 / len(self.lc[0])
weight = np.ones(len(y)) / (np.sum(self.lc[0]) * width)
y = y * weight
Expand Down Expand Up @@ -397,14 +397,14 @@ def show_phaseogram(
self.draw_stats(pulsar_phases, phase_limits, stats)

# Plot regions (default True)
if background == True:
if background:
self.draw_background(pulsar_phases, colorb, hline)

for i in range(0, len(signal)):
self.draw_peakregion(pulsar_phases, signal[i], color=colorP[i])

# Plot fitted distribution (default True)
if fit == True:
if fit:
try:
self.draw_fitting(pulsar_phases, color=colorfit)
except AttributeError:
Expand Down
12 changes: 6 additions & 6 deletions ptiming_ana/phaseogram/penergy_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def run(self, pulsarana):

self.Parray[i].init_regions()

if self.Parray[i].do_fit == True:
if self.Parray[i].do_fit:
self.Parray[i].setFittingParams(
self.Parray[i].fit_model,
self.Parray[i].binned,
Expand Down Expand Up @@ -136,7 +136,7 @@ def run(self, pulsarana):

self.Parray_integral[i].init_regions()

if self.Parray_integral[i].do_fit == True:
if self.Parray_integral[i].do_fit:
self.Parray_integral[i].setFittingParams(
self.Parray_integral[i].fit_model,
self.Parray_integral[i].binned,
Expand Down Expand Up @@ -264,17 +264,17 @@ def show_joined_Energy_fits(self, integral=None):
histogram_array = self.Parray

for i in range(0, len(histogram_array)):
if histogram_array[i].fitting.check_fit_result() == True:
if histogram_array[i].fitting.check_fit_result():
fig = plt.figure(figsize=(17, 8))
break
elif (
i == len(histogram_array) - 1
and histogram_array[i].fitting.check_fit_result() == False
and not histogram_array[i].fitting.check_fit_result()
):
print("No fit available for any energy bin")
return
for i in range(0, len(histogram_array)):
if histogram_array[i].fitting.check_fit_result() == True:
if histogram_array[i].fitting.check_fit_result():
histogram_array[i].histogram.draw_fitting(
histogram_array[i],
color="C" + str(i),
Expand Down Expand Up @@ -390,7 +390,7 @@ def show_Energy_fitresults(self, integral=None):
+ f"{self.energy_edges[i]*1000:.2f}-{self.energy_edges[i+1]*1000:.2f}"
+ "\n"
)
if histogram_array[i].fitting.check_fit_result() == True:
if histogram_array[i].fitting.check_fit_result():
fit_results[i] = histogram_array[i].show_fit_results()
else:
print("No fit available for this energy range")
Expand Down
2 changes: 1 addition & 1 deletion ptiming_ana/phaseogram/pfitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def run(self, pulsar_phases):

self.est_initial_values(pulsar_phases)
# Do the fitting
if self.binned == True:
if self.binned:
self.fit_Binned(pulsar_phases)
else:
self.fit_ULmodel(pulsar_phases)
Expand Down
8 changes: 4 additions & 4 deletions ptiming_ana/phaseogram/pulsar_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def set_config(self, configuration_file):

# Read files
self.filter_data = conf["cuts"]["filter_data"]
if conf["flags"]["DL2_format"] == True:
if conf["flags"]["DL2_format"]:
if os.path.isdir(conf["pulsar_file_dir"]):
self.setLSTInputFile(
dirname=conf["pulsar_file_dir"],
Expand Down Expand Up @@ -275,7 +275,7 @@ def set_config(self, configuration_file):
else:
self.setParamCuts(zd_cut=conf["cuts"]["zd_range"])

elif conf["flags"]["fits_format"] == True:
elif conf["flags"]["fits_format"]:
self.setFermiInputFile(filename=conf["pulsar_file_dir"])

else:
Expand All @@ -297,7 +297,7 @@ def set_config(self, configuration_file):
P3_limits=conf["phase_regions"]["P3"],
)

if conf["phase_binning"]["custom_binning"] == False:
if conf["phase_binning"]["custom_binning"]:
self.setBinning(
conf["phase_binning"]["nbins"],
xmin=conf["phase_binning"]["xmin"],
Expand Down Expand Up @@ -445,7 +445,7 @@ def execute_stats(self, tobs):
self.tobs = tobs

# Fit the histogram using PeakFitting class. If binned is False, an Unbinned Likelihood method is used for the fitting
if self.do_fit == True:
if self.do_fit:
logger.info("Fitting the data to the given model...")
logger.info("Fit model: " + self.fit_model)
logger.info("Binned fitting: " + str(self.binned))
Expand Down
4 changes: 2 additions & 2 deletions ptiming_ana/phaseogram/read_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def add_phases(self, pname):

def read_LSTfile(self, fname, df_type="short", filter_data=True):
if filter_data:
if self.src_dependent == False:
if not self.src_dependent:
df_or = pd.read_hdf(fname, key=dl2_params_lstcam_key)
if "pulsar_phase" not in df_or:
df_pulsar = pd.read_hdf(fname, key="phase_info")
Expand Down Expand Up @@ -252,7 +252,7 @@ def read_LSTfile(self, fname, df_type="short", filter_data=True):
else:
df = df_or

elif self.src_dependent == True:
elif self.src_dependent:
srcindep_df = pd.read_hdf(
fname, key=dl2_params_lstcam_key, float_precision=20
)
Expand Down

0 comments on commit 6b363e8

Please sign in to comment.