Skip to content

Separate TelescopeModel and SiteModel for sim_telarray configuration writer #1489

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

Merged
merged 42 commits into from
Apr 9, 2025

Conversation

GernotMaier
Copy link
Contributor

@GernotMaier GernotMaier commented Apr 4, 2025

TelescopeModel and SiteModel have not been separated in the ModelParameter and SimtelConfigWriter routines - site parameters have been added simply to the telescope model. This had some side effects, like that checks for site parameters where necessary when writing telescope parameters.

This PR refactors the code and introduces a clear separation of TelescopeModel and SiteModel. Unfortunately, this required quite some changes, but I think the code is now easier to read and definitely more consistent.

Notes:

  • ModelParameter.get_config_file has been removed and replaced by get_config_file (a property) and write_sim_telarray_config_file (this hopefully clarifies from where we call the config file writer).
  • there are a couple of checks e.g. for array_triggers parameter as part of TelescopeModel in the code. These will be fixed in a follow up PR.

@GernotMaier GernotMaier self-assigned this Apr 4, 2025

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

Copy link
Contributor

@orelgueta orelgueta left a comment

Choose a reason for hiding this comment

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

Very nice. Simplifies the structure, some of the code and makes things clearer. Minor comments.

)

@property
def config_file_directory(self):
"""Directory for configure files. Configure, if necessary."""
if self._config_file_directory is None:
self._set_config_file_directory_and_name()
return self._config_file_directory
return self._config_file_directory or self._set_config_file_directory_and_name()
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't this make the code above it checking if None redundant? I suggest applying the same lazy init to the config_file_path while we are at it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Fixed it.

This comment has been minimized.

This comment has been minimized.

1 similar comment
Copy link

Passed

Analysis Details

0 Issues

  • Bug 0 Bugs
  • Vulnerability 0 Vulnerabilities
  • Code Smell 0 Code Smells

Coverage and Duplications

  • Coverage 100.00% Coverage (96.30% Estimated after merge)
  • Duplications 0.00% Duplicated Code (0.00% Estimated after merge)

Project ID: gammasim_simtools_AY_ssha9WiFxsX-2oy_w

View in SonarQube

@GernotMaier
Copy link
Contributor Author

@orelgueta - thanks for the review! Please have another look, I think I've followed all your suggestions.

if self._config_file_directory is None:
self._set_config_file_directory_and_name()
return self._config_file_directory or self._set_config_file_directory_and_name()
return self._config_file_directory
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought the opposite, i.e., that

return self._config_file_directory or self._set_config_file_directory_and_name()

would cover both cases and you won't need

if self._config_file_directory is None:
            self._set_config_file_directory_and_name()

But it doesn't matter, we can keep it like this.

@GernotMaier GernotMaier merged commit 3a381fc into main Apr 9, 2025
14 checks passed
@GernotMaier GernotMaier deleted the separate-sim_telarray-config-writer branch April 9, 2025 15:47
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.

Add functionality to select model parameters for certain simulation software types.
3 participants