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

Add tools for PSF creation. #668

Merged
merged 24 commits into from
Mar 11, 2020
Merged

Add tools for PSF creation. #668

merged 24 commits into from
Mar 11, 2020

Conversation

Aretno
Copy link
Collaborator

@Aretno Aretno commented Sep 18, 2019

Functions and tests for PSF creation starting from penthesilea Kr hits (1 hit = 1 sipm).

For the PSF, empty bins surrounding the charged SiPMs are added (as zero's are also relevant). The PSF is calculated using the relative position between SiPMs and barycenter. In the case of the Z dimension, the relative positions is between the slice position and the barycenter in the Z dimension.

Copy link
Collaborator

@gonzaponte gonzaponte left a comment

Choose a reason for hiding this comment

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

As for the other PR, this is not a complete review, I'm just trying to provide an outsider's (pedantic) view of this.

Also for this PR, review the naming of variables. In this one, you mix lower_case with camelCase and CamelCase. The last one is particularly problematic because it clashes with the actual naming convention we use: lower_case for variables, CamelCase for classes/types.

Overall there is only one "major" (for a very loose definition of major) concern and one function I don't quite understand. The rest are minor details.

@jjgomezcadenas
Copy link
Collaborator

jjgomezcadenas commented Nov 17, 2019 via email

@jacg
Copy link
Collaborator

jacg commented Nov 17, 2019

Hereby I declare that if IC moves to Haskell it WON’T be my fault....

:-)

Haskell for IC (or HEP) would be a disaster. There are too many complexities, too much experimentation in the language (no serious work is done without using a number of language extensions which range from "why the hell isn't this in the standard" to "here be dragons"), the error messages are (all too often) impenetrable. And the build system situation is deep tragedy. You should not ask people whose primary interest is not programming, to do serious work in Haskell.

OTOH, within Haskell there are many things which would be absolutely marvellous for HEP. If you could get those without the complications and distractions, then it would be a huge boon. This has been done for front-end web development with Elm. Elm is a simplified Haskell derivative that compiles to JavaScript and has outstandingly clear and helpful error messages and a build story that won't drive you insane. It gives web developers many of the advantages of Haskell without any of the problems. A language like that, but with a different set of power-vs-simplicity tradeoffs, a set more appropriate for HEP, could do wonders.

I'm not aware of a viable candidate, so I'm afraid that (amongst many other disadvantages) we'll have to keep using Python's shitty type annotations instead of a robust, informative and expressive static type system built into the language; and continue to distinguish pure from impure code without the help of the type system and thus have to rely on @gonzaponte's review comments to remind us that

  • the distinction exists
  • we are making it, by conventions which
    • most of us are probably not actively aware of
    • aren't reliable

(We'll also have to continue to compose our components (functions!) using a very clunky syntax. I tried to mitigate this by giving you dataflow, but it's still extremely sad compared to how it could look if we had Haskell syntax for this purpose, but that's another story.)

@Aretno Aretno force-pushed the PSF_creator branch 2 times, most recently from e90cb12 to 430491c Compare December 17, 2019 11:48
@Aretno
Copy link
Collaborator Author

Aretno commented Jan 24, 2020

Notebook explaining the contents of the PR: https://github.com/Aretno/Notebooks/blob/master/Tools%20for%20PSF%20creation%20auxiliar%20Notebook.ipynb

Also, I modified the code to make it a bit more compact but no big changes were made.

Copy link
Collaborator

@gonzaponte gonzaponte left a comment

Choose a reason for hiding this comment

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

Second round, almost there. Check for unused variables and imports with pyflakes.

def psf_writer(hdf5_file, **kwargs):
psf_table = make_table(hdf5_file,
group = "PSF",
name = "PSFs",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe a better name for either the group or the node? /PSF/PSFs seems a bit redundant.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Any suggestions? I don't really care much.

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 have much better ideas...

Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems to be irrelevant as the file contains only this info and it is loaded through pd.read_hdf

Copy link
Collaborator

@gonzaponte gonzaponte left a comment

Choose a reason for hiding this comment

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

I think after these cosmetical changes we are good to go.

def psf_writer(hdf5_file, **kwargs):
psf_table = make_table(hdf5_file,
group = "PSF",
name = "PSFs",
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems to be irrelevant as the file contains only this info and it is loaded through pd.read_hdf

@Aretno Aretno changed the title Tools for PSF creation. Add tools for PSF creation. Mar 9, 2020
Copy link
Collaborator

@gonzaponte gonzaponte left a comment

Choose a reason for hiding this comment

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

This PR adds the relevant functions for PSFs, an input needed for the future city Beersheba (#666). The code adds the functions to create the PSF and the functions for IO operations. All of that is nicely implemented, well tested and with some nice protections against bad inputs.

The author has also provided a notebook with a demonstration of the code:
https://github.com/Aretno/Notebooks/blob/master/Tools%20for%20PSF%20creation%20auxiliar%20Notebook.ipynb

Great work!

@carmenromo carmenromo merged commit 44b8018 into next-exp:master Mar 11, 2020
andLaing pushed a commit to andLaing/IC that referenced this pull request May 13, 2020
next-exp#668

[author: Aretno]

Functions and tests for PSF creation starting from penthesilea Kr
hits (1 hit = 1 sipm).

For the PSF, empty bins surrounding the charged SiPMs are added (as
zero's are also relevant). The PSF is calculated using the relative
position between SiPMs and barycenter. In the case of the Z dimension,
the relative positions is between the slice position and the
barycenter in the Z dimension.

[reviewer: gonzaponte]

This PR adds the relevant functions for PSFs, an input needed for the
future city Beersheba (next-exp#666). The code adds the functions to create
the PSF and the functions for IO operations. All of that is nicely
implemented, well tested and with some nice protections against bad
inputs.

The author has also provided a notebook with a demonstration of the code:
https://github.com/Aretno/Notebooks/blob/master/Tools%20for%20PSF%20creation%20auxiliar%20Notebook.ipynb

Great work!
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.

5 participants