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

Update MAGIC-LST scripts to ctapipe v0.12.0 #6

Merged
merged 12 commits into from
Jan 14, 2022

Conversation

YoshikiOhtani
Copy link
Collaborator

@YoshikiOhtani YoshikiOhtani commented Jan 12, 2022

Here the combined analysis scripts are updated to be used in the ctapipe v0.12.0 environment.

Yoshiki Ohtani and others added 7 commits January 5, 2022 06:32
Replace get_key_if_exists with dict.get
…tory/magic-cta-pipe into dev-yoshiki

Conflicts:
	lst1_magic/magic_data_cal_to_dl1.py
	magicctapipe/scripts/lst1_magic_real/check_coincidence_overview.py
	magicctapipe/scripts/lst1_magic_real/check_pointing_directions.py
	magicctapipe/scripts/lst1_magic_real/get_common_obs_info.py
	magicctapipe/scripts/lst1_magic_real/lst1_magic_dl1_to_dl2.py
	magicctapipe/scripts/lst1_magic_real/lst1_magic_event_coincidence.py
	magicctapipe/scripts/lst1_magic_real/lst1_magic_mc_dl0_to_dl1.py
	magicctapipe/scripts/lst1_magic_real/lst1_magic_stereo_reco.py
	magicctapipe/scripts/lst1_magic_real/lst1_magic_train_rfs.py
	magicctapipe/scripts/lst1_magic_real/notebooks/check_data_quality.ipynb
	magicctapipe/scripts/lst1_magic_real/notebooks/check_sensitivity_from_data.ipynb
	magicctapipe/scripts/lst1_magic_real/notebooks/check_spectrum.ipynb
	magicctapipe/utils/merge_hdf_files.py
	magicctapipe/utils/my_functions.py
	utils/__init__.py
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@@ -43,41 +73,82 @@ event_coincidence:


stereo_reco:
subarray: '/fefs/home/yoshiki.ohtani/software/magic-cta-pipe/lst1_magic/data/subarray_lst1_magic.pkl'
quality_cuts: (intensity > 50) & (width > 0)
subarray: '/home/yoshiki.ohtani/software/magic-cta-pipe/magicctapipe/scripts/lst1_magic_real/data/subarray_lst1_magic.pickle'
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 that is better to save the subarray information together with the DL1 file(s) produced by the event coincidence script. If you have the SubarrayDescription object (as saved in the pickle file), you can define it in the event coincidence script and use the SubarrayDescription.to_hdf method to write it into the HDF5 file (if I understood correctly, saving the subarray in the HDF5 file should be done before saving anything else).
This would avoid having to specify the path to the pickle file, and instead reading everything from the file at once.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hm, OK, I think I can define the subarray object inside the stereo reconstruction script. I'm implementing this solution now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

By the way saving the subarray after saving others, for example event dl1 parameters works without any problems. Probably it was updated?

magic_stereo = Field(-1, 'True if M1 and M2 are triggered')


class SimInfoContainer(Container):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not using the SimulationConfigContainer from ctapipe instead of defining a new one? SimulationConfigContainer has more members, so you will not use them all, but I think we should try to use already defined things (especially if already in ctapipe)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, now I see that you extract source.simulation_config, which indeed is a SimulationConfigContainer, and then fill the custom container. Since the simulation configuration is not a big container (anyway just one per run), I would write directly source.simulation_config into the HDF5 file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for your comment, and indeed I agree with you, I will change it.

if stereo_params.az < 0:
stereo_params.az = stereo_params.az + u.Quantity(2*np.pi, u.rad)
stereo_params.az += u.Quantity(360, u.deg)
Copy link
Collaborator

Choose a reason for hiding this comment

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

here the indentation is wrong, should be one tab less

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks I modified it

setup.py Outdated
@@ -22,11 +22,11 @@
install_requires=[
'astropy>=4.0.5,<5',
'ctapipe~=0.12.0',
'ctapipe_io_magic~=0.3.0',
'ctapipe_io_magic',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Was this an issue for you? Anyway this will be changed when we will merge into master and I will make a new version of ctapipe_io_magic (v0.4.0, which I will create from the current master branch, the one working with ctapipe v0.12)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes there was an issue for some reason, anyway the version 0.3.0 is for ctapipe v0.8.0 and so I modified it. Would be great if you create v0.4.0, and then I will modify it again.

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 can do it now. I will check if I need to update a bit the README.md and then create tag and release.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, it took a bit, but now ctapipe_io_magic was tagged with version 0.4.0. Also, it can be installed with pip without cloning the repo, since now I uploaded the module in PyPI.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks! Ah so it means now one doesn't need to clone both ctapipe and ctapipe_io_magic, and instead just need to create an environment, clone only magic-cta-pipe and type pip install .?

Copy link
Collaborator

Choose a reason for hiding this comment

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

To have everything working as you say, indeed we would need to create an environment.yml file, which will install ctapipe 0.12 (and dependencies), ctapipe_io_magic 0.4.0 (and dependencies) and finally magic-cta-pipe

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I see, is it possible for you to create an environment.yml file? I think it would be better and easy way for the students to install the pipeline if they need to do it by themself (in the local machine, another computer, etc)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sure, I can do it. I will do a commit in the update-ctapipe-v0.12 branch.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks a lot!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Done!

Copy link
Collaborator

@aleberti aleberti left a comment

Choose a reason for hiding this comment

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

Ok, I think I checked everything, and put my comments, and some you already replied. So at that point I will check them again. Thanks for updating the scripts!

@YoshikiOhtani
Copy link
Collaborator Author

YoshikiOhtani commented Jan 13, 2022

OK so I think I updated all the points that Alessio mentioned and pushed the commits, but have not yet tested them. I will test them tomorrow (already today in Japan :)) and will let you know once it is done. Then if there are not any further comments I think we can merge it.

@YoshikiOhtani
Copy link
Collaborator Author

Sorry for taking time but I found some mistakes in the scripts about the subarray descriptions, and so I modified them. I also updated the script for merging HDF files. I tested the script and confirmed that now it works fine.

@YoshikiOhtani
Copy link
Collaborator Author

@aleberti, if it is fine for you, could you merge this branch to update-ctapipe-v0.12, and merge update-ctapipe-v0.12 to master, please? And probably create a new tag (v0.1.0 ?) for the current version?

@aleberti
Copy link
Collaborator

Sure, give me some time and I do it :)

@aleberti aleberti merged commit 75f5e84 into update-ctapipe-v0.12 Jan 14, 2022
@YoshikiOhtani
Copy link
Collaborator Author

Thanks a lot! I will delete my branch then…

@YoshikiOhtani YoshikiOhtani deleted the dev-yoshiki branch January 14, 2022 16:18
@aleberti
Copy link
Collaborator

Sure, in any case I have to do a second tag, because I need to add some files to build the package to upload it to PyPI.

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.

3 participants