Skip to content

Commit

Permalink
fixed linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nmahesh1412 committed Oct 16, 2024
1 parent c2aba45 commit 1278f41
Showing 1 changed file with 10 additions and 23 deletions.
33 changes: 10 additions & 23 deletions src/pyuvdata/uvbeam/feko_beam.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# -*- mode: python; coding: utf-8 -*-
# Copyright (c) 2018 Radio Astronomy Software Group
# Licensed under the 2-clause BSD License
"""Class for reading beam FEKO files."""

import os
import re
import warnings

Check warning on line 6 in src/pyuvdata/uvbeam/feko_beam.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/uvbeam/feko_beam.py#L5-L6

Added lines #L5 - L6 were not covered by tests

import numpy as np

Check warning on line 8 in src/pyuvdata/uvbeam/feko_beam.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/uvbeam/feko_beam.py#L8

Added line #L8 was not covered by tests
Expand All @@ -28,7 +26,6 @@ def nametopol(self, fname):
"""
Get name of the y file from the main filename.
Parameters
----------
fname : str
Expand Down Expand Up @@ -120,9 +117,7 @@ def read_feko_beam(
fix_auto_power : bool
For power beams, if auto polarization beams with imaginary values are found,
fix those values so that they are real-only in data_array.
"""

basename = os.path.basename(filename)
self.filename = [basename]
self._filename.form = (1,)

Check warning on line 123 in src/pyuvdata/uvbeam/feko_beam.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/uvbeam/feko_beam.py#L121-L123

Added lines #L121 - L123 were not covered by tests
Expand Down Expand Up @@ -175,32 +170,27 @@ def read_feko_beam(
self.pixel_coordinate_system = "az_za"
self._set_cs_params()

Check warning on line 171 in src/pyuvdata/uvbeam/feko_beam.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/uvbeam/feko_beam.py#L167-L171

Added lines #L167 - L171 were not covered by tests

out_file = open(filename, "r")
line = out_file.readlines()[9].strip() # Get the line with column names
out_file.close()
column_names = line.split('"')[1::2]
with open(filename) as out_file:
line = out_file.readlines()[9].strip() # Get the line with column names
column_names = line.split('"')[1::2]

Check warning on line 175 in src/pyuvdata/uvbeam/feko_beam.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/uvbeam/feko_beam.py#L173-L175

Added lines #L173 - L175 were not covered by tests

theta_col = np.where(np.array(column_names) == "Theta")[0][0]
phi_col = np.where(np.array(column_names) == "Phi")[0][0]

Check warning on line 178 in src/pyuvdata/uvbeam/feko_beam.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/uvbeam/feko_beam.py#L177-L178

Added lines #L177 - L178 were not covered by tests

with open(filename, "r") as fh:
data_chunks = fh.read()[
1:
].split(
with open(filename) as fh:
data_chunks = fh.read()[1:].split(

Check warning on line 181 in src/pyuvdata/uvbeam/feko_beam.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/uvbeam/feko_beam.py#L180-L181

Added lines #L180 - L181 were not covered by tests
"\n\n"
) ## avoiding the first row since there is a blank row at the start of every file
) ## avoiding the row=1; there is a blank row at the start of every file
data_all = [

Check warning on line 184 in src/pyuvdata/uvbeam/feko_beam.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/uvbeam/feko_beam.py#L184

Added line #L184 was not covered by tests
i.splitlines()[9:] for i in data_chunks
] ## skips the 9 lines of text in each chunk

if beam_type == "efield":
filename2 = self.nametopol(filename)
with open(filename2, "r") as fh:
data_chunks = fh.read()[
1:
].split(
with open(filename2) as fh:
data_chunks = fh.read()[1:].split(

Check warning on line 191 in src/pyuvdata/uvbeam/feko_beam.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/uvbeam/feko_beam.py#L188-L191

Added lines #L188 - L191 were not covered by tests
"\n\n"
) ## avoiding the first row since there is a blank row at the start of every file
) ## avoiding the row=1;there is a blank row at the start of every file
data_all2 = [

Check warning on line 194 in src/pyuvdata/uvbeam/feko_beam.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/uvbeam/feko_beam.py#L194

Added line #L194 was not covered by tests
i.splitlines()[9:] for i in data_chunks
] ## skips the 9 lines of text in each chunk
Expand Down Expand Up @@ -259,7 +249,6 @@ def read_feko_beam(
raise ValueError(

Check warning on line 249 in src/pyuvdata/uvbeam/feko_beam.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/uvbeam/feko_beam.py#L249

Added line #L249 was not covered by tests
"Data does not appear to be regularly gridded in azimuth angle"
)
delta_phi = phi_axis[1] - phi_axis[0]
self.axis1_array = phi_axis
self.Naxes1 = self.axis1_array.size
self.axis2_array = theta_axis
Expand Down Expand Up @@ -368,9 +357,7 @@ def read_feko_beam(

if frequency is None:
warnings.warn(

Check warning on line 359 in src/pyuvdata/uvbeam/feko_beam.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/uvbeam/feko_beam.py#L358-L359

Added lines #L358 - L359 were not covered by tests
"No frequency provided. Detected frequency is: " "{freqs} Hz".format(
freqs=self.freq_array
)
f"No frequency provided. Detected frequency is: {self.freq_array} Hz"
)

if use_future_array_shapes:
Expand Down

0 comments on commit 1278f41

Please sign in to comment.