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

Major update of Telescope class #631

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open

Major update of Telescope class #631

wants to merge 29 commits into from

Conversation

anawas
Copy link
Collaborator

@anawas anawas commented Nov 7, 2024

Baseline functions of the Telescope class (e.g. max_baseline or get_stations_wgs84) now have the same output for OSKAR and RASCIL backends. Thus, the two code examples in issue #629 now work as expected. The main work was done in Telescope::constructor() function.

Other things that have been changed or adapted:

  • Renamed function get_baselines_wgs84 to get_stations_wgs84 because it always returned coordinates of stations, not baselines
  • Replaced numpy.loadtxt() with more robust class method __read_layout_txt() (in Telescope::_get_station_info)
  • Added some tests cases to test_telescope_baselines.py
  • Fixed some typos and added few lines of comments.

Copy link
Collaborator

@Lukas113 Lukas113 left a comment

Choose a reason for hiding this comment

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

LGTM

Some comments to address.

The failing CI-pipeline is not related to this PR, thus the test is ignored for this review.

f"""CSV has {dataframe.shape[1] - cls.SOURCES_COLS + 1}
too many rows. The extra rows will be cut off."""
f"CSV has {dataframe.shape[1] - cls.SOURCES_COLS + 1} "
f"rows too many. The extra rows will be cut off."
Copy link
Collaborator

Choose a reason for hiding this comment

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

line 829 doesn't need to be an f-string.

new_latitude = lat + (east_relative / r_earth) * (180 / np.pi)
new_longitude = long + (north_relative / r_earth) * (180 / np.pi) / np.cos(
long * np.pi / 180
r_earth = 6378100 # from astropy (astropy.constants.R_earth.value)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nice!

:rtype: karabo.simulation.telescope.Telecope
:raises: ValueError if instr_name is not a valid RASCIL telescope
"""
config: Configuration = create_named_configuration(instr_name)
Copy link
Collaborator

Choose a reason for hiding this comment

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

does specifying the dtype Configuation do anything? If not (I assume because the function should return just this type), I think removing would be a better idea. Not sure what the implication of this is in case the function is changing it's return type for each use-case.


# there are only stations in the rascil files no antennas
# we add a dummy antenna
telescope.add_antenna_to_station(i, 0.1, 0.1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't understand why both horizontal x & y need to be 0.1. Can you elaborate?

@@ -485,7 +536,7 @@ def write_to_disk(self, dir_name: DirPathType, *, overwrite: bool = False) -> No
): # for OSKAR & `overwrite` security purpose
err_msg = f"{dir_name=} has to end with a `.tm`, but doesn't."
raise RuntimeError(err_msg)
with write_dir(dir=dir_name, overwrite=overwrite) as wd:
with write_dir(dir=dir_name, overwrite=True) as wd:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is an accident? If not, what's the motivation behind ignoring the fun-arg?

Comment on lines +45 to +50
# @pytest.mark.parametrize("site_name, num_stations", rascil_telesecopes_to_test)
# def test_num_of_baselines(site_name, num_stations):
# site: Telescope =
# Telescope.constructor(site_name, backend=SimulatorBackend.RASCIL)
# num_baselines = num_stations * (num_stations-1) // 2
# assert len(site.get_baselines_wgs84()) == num_baselines
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why out-commented? If not needed, I think just removing it would be better?

assert len(baseline_wgs) == 134


def test_telescope_baseline_length(rascil_telescope):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think adding type-hint here would be an improvement. In case someone does a refactoring on get_stations_wgs84, it would be catched automatically. Otherwise you'll just see the fail in the failing CI-pipeline.

Copy link

codecov bot commented Nov 8, 2024

Codecov Report

Attention: Patch coverage is 97.91667% with 1 line in your changes missing coverage. Please review.

Project coverage is 70.97%. Comparing base (645161b) to head (b4c77f7).

Files with missing lines Patch % Lines
karabo/simulation/telescope.py 97.77% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #631      +/-   ##
==========================================
+ Coverage   70.76%   70.97%   +0.21%     
==========================================
  Files          55       55              
  Lines        5879     5905      +26     
==========================================
+ Hits         4160     4191      +31     
+ Misses       1719     1714       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants