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

Containers for waveforms and charge extraction #29

Merged
merged 28 commits into from
Jan 26, 2023

Conversation

guillaumegrolleron
Copy link
Contributor

@guillaumegrolleron guillaumegrolleron commented Jan 18, 2023

-Implementation of containers to store waveforms from ctapipe EventSource in a numpy array mindset.
-Charges can be extract from this WaveformsContainer and store in a ChargeContainer. Charge computation can be done with any ever implemented ImageExctractor from ctapipe or with user defined extractors.
-Charges and waveforms can be read and written in a fits format

-some features for data management such as
GRID access, local access, ELOG reading (work in progress)
-some features for data management such as
GRID access, local access, ELOG reading (work in progress)
-try to vetorize Federica charge computation method
to perform wfs and charge extraction fits.fz file one by one
-possibility to write file by file
allaws shape of camera (1855) and not
number of used pixels in run
to avoid np.uint16 limit reached bug when computing charge histogram
computation np.int16 -> np.uint16
expected_pixels_id now
-change histo HG and LG computation in charge.py to avoid broken pixels
 instance
 -updates user script ggrolleron (load wfs+compute charge)
Copy link
Collaborator

@jlenain jlenain left a comment

Choose a reason for hiding this comment

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

Hi @guillaumegrolleron !
Many thanks for this very useful PR !
I have suggested a couple of minor changes, mainly to ease the use of these classes by other users, and to further avoid hardcoding the low/hig gain indices in some places.

nectarchain/calibration/container/charge.py Outdated Show resolved Hide resolved
nectarchain/calibration/container/charge.py Outdated Show resolved Hide resolved
nectarchain/calibration/container/charge.py Show resolved Hide resolved
nectarchain/calibration/container/charge.py Outdated Show resolved Hide resolved
nectarchain/calibration/container/charge.py Outdated Show resolved Hide resolved

@staticmethod
def load_run(run_number : int,max_events : int = None, run_file = None) :
"""Static method to load from $NECTARCAMDATA directory data for specified run with max_events
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it documented somewhere that a $NECTARCAMDATA environment variable needs to be set ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I forgot to document that, is it fine if I explain in the README.md of nectarchain how to set this environment variable ? I'm not sure of the best policy

Copy link
Collaborator

Choose a reason for hiding this comment

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

For the time being, it may not be wise to document it at the module root level. I think for instance the dqm uses another environment variable for the same purpose. Or just leave it as it, with an explanation in the docstring.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok I see, I will follow the dqm method

import os

import logging
logging.basicConfig(format='%(asctime)s %(name)s %(levelname)s %(message)s',level=logging.INFO,filename = f"{os.environ.get('NECTARCHAIN_LOG')}/{Path(__file__).stem}_{os.getpid()}_load_wfs_charge.log")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Document that a $NECTARCHAIN_LOG environment variable is expected ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is not a mandatory variable, but I defined it in the README



if __name__ == '__main__':
SPE_run_number = [2633,2634,3784]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess at some point such arguments could be passed by the user instead of being hardcoded.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed it is better, I did it

-add README for calibration module
(with definition of environment variables)
Copy link
Collaborator

@jlenain jlenain left a comment

Choose a reason for hiding this comment

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

Many thanks for the changes, @guillaumegrolleron !
Are there other modifications you would like to add, or could we merge ?

@guillaumegrolleron
Copy link
Contributor Author

There are no more modifications, you can merge @jlenain ! Thanks for review

@jlenain jlenain merged commit 5a7751a into cta-observatory:master Jan 26, 2023
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