Skip to content

Commit

Permalink
PEP8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-richard committed May 16, 2023
1 parent e944082 commit 6761c09
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 27 deletions.
8 changes: 4 additions & 4 deletions pyrfu/mms/load_brst_segments.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,22 @@ def load_brst_segments(tint, data_path: str = None, download: bool = True):
pkg_path = os.path.dirname(os.path.abspath(__file__))

# Read the current version of the MMS configuration file
with open(os.path.join(pkg_path, "config.json"), "r") as fs:
with open(os.path.join(pkg_path, "config.json"), "r", encoding="utf-8") as fs:
config = json.load(fs)

data_path = os.path.normpath(config["local_data_dir"])
else:
data_path = os.path.normpath(data_path)

# Define path of the brst segment file to save
file_path = os.path.join(data_path, URL.split("/")[-1])
file_path = os.path.join(data_path, URL.split("/", maxsplit=100)[-1])

if download:
# Get url content
response = requests.get(URL)
response = requests.get(URL, timeout=10)

# Write content of the brst segment file to the local file
with open(file_path, "wb") as fs:
with open(file_path, "wb", encoding="utf-8") as fs:
fs.write(response.content)

# Read brst segment content
Expand Down
12 changes: 2 additions & 10 deletions pyrfu/mms/read_feeps_sector_masks_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,8 @@ def read_feeps_sector_masks_csv(tint):
[os.path.dirname(os.path.abspath(__file__)), "sun", file_name],
)

csv_file = open(csv_file, "r")

csv_reader = csv.reader(csv_file)

csv_data = []

for line in csv_reader:
csv_data.append([float(x) for x in line])

csv_file.close()
with open(csv_file, "r", encoding="utf-8") as csv_file:
csv_data = [[float(x) for x in line] for line in csv.reader(csv_file)]

csv_data = np.array(csv_data)

Expand Down
20 changes: 10 additions & 10 deletions pyrfu/mms/reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,16 +223,16 @@ def reduce(vdf, xyz, dim: str = "1d", base: str = "pol", **kwargs):
else:
pass

options = dict(
xyz=xyz_ts[i_t, ...],
n_mc=n_mc,
weight=weight,
v_lim=v_lim,
a_lim=a_lim,
projection_dim=dim,
projection_base=base,
speed_grid_edges=speed_grid_edges,
)
options = {
"xyz": xyz_ts[i_t, ...],
"n_mc": n_mc,
"weight": weight,
"v_lim": v_lim,
"a_lim": a_lim,
"projection_dim": dim,
"projection_base": base,
"speed_grid_edges": speed_grid_edges,
}

tmpst = int_sph_dist(f_3d, speed, phi, theta, speed_grid, **options)

Expand Down
6 changes: 3 additions & 3 deletions pyrfu/mms/remove_edist_background.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ def remove_edist_background(vdf, n_sec: float = 0.0, n_art: float = -1.0):

# Check path
# Guess data path from CDF attributes
data_path = str(vdf.attrs["CDF"]).split(f"mms{mms_id}/fpi")[0]
data_path = str(vdf.attrs["CDF"]).split(f"mms{mms_id}/fpi", maxsplit=1)[0]

# Check if path exists if not use the default
if not os.path.exists(data_path):
pkg_path = os.path.dirname(os.path.abspath(__file__))

# Read the current version of the MMS configuration file
with open(os.path.join(pkg_path, "config.json"), "r") as fs:
with open(os.path.join(pkg_path, "config.json"), "r", encoding="utf-8") as fs:
config = json.load(fs)

data_path = os.path.normpath(config["local_data_dir"])
Expand All @@ -118,7 +118,7 @@ def remove_edist_background(vdf, n_sec: float = 0.0, n_art: float = -1.0):
else:
n_photo = photoe_scle

for i in range(len(vdf.time.data)):
for i, _ in enumerate(vdf.time.data):
istartdelphi_count = startdelphi_count.data[i]
iebgdist = int(np.fix(istartdelphi_count / 16))

Expand Down

0 comments on commit 6761c09

Please sign in to comment.