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

Simplify file naming in names.py #835

Merged
merged 6 commits into from
Mar 26, 2024
Merged

Conversation

GernotMaier
Copy link
Contributor

This PR addresses issue #798:

  • file name retrieval in names.py for output files from especially camera_efficiency and ray tracing is very repetitive. Improved this a bit, but a condensation into a single function is hardly possible. I've simplified as much as possible.
  • introduced consistent naming patterns (e.g., should a value in a file name has a unit or not (yes, it always should))

@GernotMaier GernotMaier self-assigned this Mar 16, 2024
@GernotMaier GernotMaier linked an issue Mar 16, 2024 that may be closed by this pull request
@GernotMaier GernotMaier changed the base branch from main to dev-simulation-model-elements-naming March 16, 2024 16:25
@GernotMaier GernotMaier marked this pull request as ready for review March 18, 2024 08:08
@GernotMaier GernotMaier changed the base branch from dev-simulation-model-elements-naming to main March 21, 2024 14:29
Copy link
Collaborator

@tobiaskleiner tobiaskleiner left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. It looks good in general and improves readability of the code a lot. I have added few minor comments.

@@ -193,7 +183,7 @@ def analyze(self, export=True, force=False):
"""
self._logger.info("Analyzing CameraEfficiency")

if self._file_results.exists() and not force:
if self._file["results"].exists() and not force:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Better to use if "results" in self._file for dict. Also codecov complains about missing test. Maybe you can add tests? Also for the following two lines 225 and 303.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done (your first point).

I am not adding tests - all what I have changed is this one line which triggered codecov. No new logic has been introduced.

Both camera_efficiency and ray_tracing modules need a good review. I had a quick look, and it is not straight forward to add tests to those rather long functions. I do think this requires far more attention than adding a quick test to make codecov happy.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok I agree. This would then probably go in a seperate PR. If you agree we can open an issue to adress this.

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 and no. We have all the tools like pycoverage and codecov to tell us the missing tests. Do we need to open additionally issues on that? I am really not sure.

this_mirror if self.config.single_mirror_mode else None,
self.label,
"photons",
photons_file_name = names.generate_file_name(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Line not covered by test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See comment above, same thing.


Parameters
----------
file_type: str
Type of file (e.g., config, output, plot)
key: str
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be named suffix. Description is not matching.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exactly. Changed it.

@@ -12,7 +12,7 @@

def test_reading_simtel_file(args_dict, io_handler):
test_file = io_handler.get_input_data_file(
file_name="photons-North-LSTN-01-d10.0-za20.0-off0.000_validate_optics.lis.gz",
file_name="photons-North-LSTN-01-d10.0km-za20.0deg-off0.000deg_validate_optics.lis.gz",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we use here 0.000deg for 0 offset, but above 000deg for 0 azimuth angle?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is motivated by:

  • zenith and offset angle needs to be set on a sub-degree accuracy
  • azimuth not - it is probably impossible to see a difference between a shower coming from 180 or 185 deg.

I am generally not a friend of putting metadata in the file name. This information should be in a metdata header. We should fix this at some point in the future.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes this makes sense, but do we really need milli degree accuracy for offset? Agree to put this in the metadata in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We actually have simulated at 0.125 deg offset at some point, so this is not completely wrong.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok thanks, everything is clear then. Going to mark it as approved.

)
== "camera-efficiency-table-North-MST-FlashCam-D-za040deg_azm000deg_test.ecsv"
== "camera-efficiency-table-North-MSTN-za40.0deg_azm000deg_test.ecsv"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Related to previous comment, also seen later a couple of times.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same reply - I've commented on zenith vs azimuth accuracy. Let me know if this makes sense, easy to change it to azm000.0deg, but I don't think it makes sense (and python is horrible in getting the accuracy right)

@GernotMaier
Copy link
Contributor Author

@tobiaskleiner - thanks for the comments and suggestions! Added them or commented on the issues. Let me know if this is ok.

Copy link
Collaborator

@tobiaskleiner tobiaskleiner left a comment

Choose a reason for hiding this comment

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

Good to merge.

@GernotMaier
Copy link
Contributor Author

@tobiaskleiner - thank you!

@GernotMaier GernotMaier merged commit 2d2bf7e into main Mar 26, 2024
12 of 13 checks passed
@GernotMaier GernotMaier deleted the simplify-config-file-naming branch March 26, 2024 10:20
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.

Cumbersome file name extraction in names.py
2 participants