Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
297 commits
Select commit Hold shift + click to select a range
29ad639
Remove system_of_units_c
gonzaponte Mar 9, 2020
96eb925
Replace system_of_units_c imports with system_of_units
gonzaponte Mar 9, 2020
e658651
Remove mctrk_functions.py
gonzaponte Mar 10, 2020
21ac43d
Remove deprecated namedtuples
gonzaponte Mar 10, 2020
e13d338
Remove deprecated persistent data descriptors
gonzaponte Mar 10, 2020
b8e2956
Clean corpses of dead functions
gonzaponte Mar 10, 2020
705fd82
Remove useless line in waveform_generator
gonzaponte Mar 10, 2020
92e7ffe
Fix imports across the whole repo
gonzaponte Mar 10, 2020
9df27d2
Remove unused variables across the whole repo
gonzaponte Mar 10, 2020
4256f20
Remove unused exceptions
gonzaponte Mar 10, 2020
6903c42
Remove SensorParams class
gonzaponte Mar 10, 2020
6597e12
Replace import of SensorParams
gonzaponte Mar 10, 2020
18b78a0
Remove deprecated functions in tbl_functions
gonzaponte Mar 10, 2020
6e9fff4
Remove deprecated class Counters
gonzaponte Mar 10, 2020
a8712b3
Fix test_cwf_blr
gonzaponte Mar 10, 2020
337aedf
Rename file for consistency
gonzaponte Mar 10, 2020
13521bd
Move get_mc_info to mcinfo_io
gonzaponte Mar 10, 2020
e41c915
Fix get_mc_info imports
gonzaponte Mar 10, 2020
d66ca80
Rename hist_io to histogram_io
gonzaponte Mar 10, 2020
3114218
Replace hist_io imports with histogram_io
gonzaponte Mar 10, 2020
e067a11
Refactor test_compute_xy_position_depends_on_actual_run_number
gonzaponte Mar 10, 2020
f3cd893
Remove unused fixtures
gonzaponte Mar 10, 2020
764026a
Remove deprecated function
gonzaponte Mar 10, 2020
08508b3
Remove unused composite
gonzaponte Mar 10, 2020
3b59d3b
707 Clean up IC
carmenromo Apr 8, 2020
4a41eb9
Use IC io `load_dst` instead of pandas `read_hdf` to load PSFs
Aretno Apr 2, 2020
be2ef24
714 Use IC io `load_dst` instead of pandas `read_hdf` to load PSFs
mmkekic Apr 10, 2020
21d42e1
Tidy up .gitignore file
jmalbos Mar 20, 2020
429f698
711 Tidy up .gitignore file
gonzaponte Apr 10, 2020
8d2c931
Add documentation of how to prepare commits
gonzaponte Mar 5, 2020
aa05f82
701 Add documentation on how to prepare commits
mmkekic Apr 10, 2020
7b0bd7c
Add tests for columns_to_index kwarg in store_pandas_to_tables
mmkekic Apr 8, 2020
de9e42d
Add columns_to_index in store_pandas_as_tables
mmkekic Apr 10, 2020
3ddae97
Add docstrings for store_pandas_as_tables
mmkekic Apr 8, 2020
6ec4bf1
Add test to check load_dst converts from bytes
mmkekic Apr 8, 2020
f4a2b65
Change load_dst to decode byte type to strings
mmkekic Apr 8, 2020
8d75cee
Cosmetis of alingment in load_dst_io_test
mmkekic Apr 10, 2020
edeefb0
Add store_pandas_to_tables writer in indexation_test
mmkekic Apr 10, 2020
f990e01
Rename store_pandas_as_tables to df_writer
mmkekic Apr 10, 2020
7465ceb
Index columns in all esmeralda writers
mmkekic Apr 10, 2020
794c684
Index event column in beersheba deconv_writer
mmkekic Apr 10, 2020
15c87f3
716 Index dataframes tables
gonzaponte Apr 10, 2020
1876724
Updtes pdfs
carmenromo Apr 16, 2020
9f861d2
Add pmt and sipm gains to DB
carmenromo Apr 16, 2020
6592380
717 Update db
carmenromo Apr 16, 2020
08423b3
Replace IC function in testing_utils.py with pandas function
MiryamMV Mar 24, 2020
bb5369f
Add index reset to beersheba and esmeralda tests.
MiryamMV Apr 16, 2020
637fc00
712 Change assert
mmkekic Apr 17, 2020
85ceb22
Update NEXT100 DB with proper PDFs for SiPM noise
jmbenlloch Apr 11, 2019
bfc5d3d
Move common functions from irene to components
jmbenlloch May 12, 2020
881c12a
Refactor pmaps computing and writing
jmbenlloch May 12, 2020
a8be2d1
Move common functions from diomira to components
jmbenlloch Apr 11, 2019
f0955db
Add city Hypathia
jmbenlloch Mar 21, 2019
1e9bd4d
Add tests for Hypathia
jmbenlloch Mar 21, 2019
8f02102
Cosmetics
jmbenlloch May 14, 2020
6e6be42
Update simulate_sipm_response arguments
jmbenlloch May 14, 2020
9aa5ad7
More efficient version of check_empty_pmap
jmbenlloch May 14, 2020
835278b
Cosmetics
jmbenlloch May 14, 2020
82c7b5e
646 Hypathia: City to bypass diomira
andLaing May 18, 2020
99114a1
Remove old MC to dictionary readers
andLaing May 5, 2020
2249a2e
Add function to differentiate old and new file formats
andLaing May 5, 2020
7fc7f04
Modify load_mchits_df to be able to read all formats
andLaing May 5, 2020
db932d3
Add function to cast hits df to dictionary
andLaing May 5, 2020
e3a8cfb
Modify load_mcparticles_df to read all file formats
andLaing May 5, 2020
c0efc57
Add function to get correct sample binning from file
andLaing May 5, 2020
0b673c2
Modify load_mcsensor_response_df to work with both file formats
andLaing May 5, 2020
6d7e37e
Add function to check sensor types present
andLaing May 5, 2020
b51d806
Add Enum class for MC table types
andLaing May 5, 2020
d95c480
Add function to get the MC tables in file
andLaing May 5, 2020
49c1dbf
Add function to get list of events in file
andLaing May 5, 2020
4c9f193
Update imports for mcinfo_io
andLaing May 5, 2020
ad2f821
Add function to load the nexus configuration
andLaing May 5, 2020
28dc2b6
Add function to load the sensor positions table
andLaing May 5, 2020
ad1b2f8
Add function to load the MC generators table
andLaing May 5, 2020
c93ac1d
Add function to load the event mapping table
andLaing May 5, 2020
14d12da
Add function to read all MC tables into a dictionary
andLaing May 5, 2020
78483b3
Add a writer for the MC info to be copied to the output file
andLaing May 5, 2020
43c1a74
Modify mcinfo_io.copy_mc_info to use the new readers/writers
andLaing May 5, 2020
d2dba9b
mcinfo_io_test with tests for new MC readers
andLaing May 5, 2020
dae3c05
New test files for mcinfo_test
andLaing May 13, 2020
9184a3f
Adapt components.copy_mc_info for the new writer
andLaing May 5, 2020
f411298
Change fixture KrMC_true_hits to use DF based readers
andLaing Feb 28, 2020
2b68010
Patch test_voxels_with_no_hits for load_mchits_df
andLaing Feb 28, 2020
5629327
improve test_penthesilea_true_hits_are_correct
andLaing Mar 17, 2020
012b8c7
Change setup for test_voxels_with_no_hits to use cast function
andLaing Mar 18, 2020
74ce3b3
Add database relevant arguments for copy_mc_info to remaining cities
andLaing Mar 26, 2020
aac753f
Adapt diomira_test for new MC info copy
andLaing Mar 27, 2020
21656fb
Adapt irene_test to use new mc readers
andLaing Mar 27, 2020
42ab55a
Adapt penthesilea_test for new MC
andLaing Mar 27, 2020
f3e40c5
Show test_isidora_exact_result only fails because of MC output
andLaing Mar 28, 2020
a6f53f8
Adapt esmeralda_test for new MC
andLaing Mar 28, 2020
8e9ecf4
Adapt beersheba_test to use the modern copy_mc_info code
andLaing Apr 9, 2020
7a051b3
Remove obsolete mcinfo_io.mc_info_writer
andLaing May 5, 2020
7912f3e
Remove mcinfo_io.mc_info_writer specific tests
andLaing May 5, 2020
a0e3454
Remove mc_info_writer test from indexation_test.py
andLaing May 5, 2020
ab4c22e
Improve test for cast_todict comparison to old method
andLaing May 5, 2020
74dfb09
Fix clarifying comments for pandas gymnastics
andLaing May 6, 2020
d253632
Add exception for old format file in get_sensor_types
andLaing May 6, 2020
8c3c5ee
Improve load_mcconfiguration for all file types
andLaing May 8, 2020
7a22f34
Alter get_sensor_binning to use load_mcconfiguration
andLaing May 8, 2020
7761d8e
Added warning to load_mcsensor_positions for oldformat
andLaing May 8, 2020
f4bb031
Remove unnecessary index check and raise in read_mc_tables
andLaing May 12, 2020
f4ffac6
Alter test_copy_mc_info_which_events_out_of_range to new conditions
andLaing May 12, 2020
cd3449c
Remove unnecessary try except from mcinfo_io.copy_mc_info
andLaing May 12, 2020
389b68b
Improve error message in _get_list_of_events_new
andLaing May 12, 2020
6368f81
Add warning and empty df return to get_sensor_binning
andLaing May 12, 2020
ac8640f
Add warning to components.copy_mc_info in case of no MC
andLaing May 12, 2020
2babf44
Check warning in test_copy_mc_info_noMC
andLaing May 12, 2020
9cf35fa
Add old/new format files for 3 types of simulation
andLaing May 12, 2020
b1c5acc
Add test comparing old and new format for same simulation
andLaing May 12, 2020
6d77a01
Add missing column to old format mcparticles
andLaing May 12, 2020
776a148
Change Pmt binning name for old mcconfiguration
andLaing May 12, 2020
e9bbb54
Added protection so empty mc sensor positions columns same
andLaing May 13, 2020
4d2e0c0
Test comparing old and new format for same simulaitons
andLaing May 13, 2020
37b3263
Add function to check for presence of MC group
andLaing May 13, 2020
031bdc6
Check MC group present and give warning if not for copy_mc_info
andLaing May 13, 2020
657d600
Change esmeralda_test to use get_event_numbers_in_file
andLaing May 14, 2020
afffd8f
Replace uses of pandas.testing.assert_frame_equal with IC function
andLaing May 14, 2020
8b50df5
Remove unnecessary import from components.py
andLaing May 14, 2020
3e94e98
Remove unused imports from mcinfo_io
andLaing May 14, 2020
63a53fc
Add MCEventNotFound exception
andLaing May 14, 2020
d60f774
Use MCEventNotFound exception in components.copy_mc_info
andLaing May 14, 2020
34fefac
Change run number for test_empty_events_issue_81
andLaing May 19, 2020
51d9edc
Add str_col_length, columns_to_index keyword arguments in mc_writer
andLaing May 19, 2020
41ef169
Updated mcinfo_io_test names
andLaing May 19, 2020
b636c82
Reset index in load_mcsensor_response_dfold
andLaing May 19, 2020
a495685
Remove unnecessary copies from get_Sensor_binning
andLaing May 19, 2020
3114e8e
Add new file with fake MC group for exception tests
andLaing May 19, 2020
ec0387f
Add test to check KeyError raised if unrecognised MC table
andLaing May 19, 2020
5a7063c
Add tests for get_event_numbers_in_file
andLaing May 19, 2020
1437d3f
Add test for is_oldformat_file
andLaing May 19, 2020
ab03d3c
Add test warning raised without dabtabase in load_mcsensor_positions
andLaing May 19, 2020
07ef509
Add test for load_mcsensor_response_df return_raw=True
andLaing May 19, 2020
906c9f6
Add database arguments to cop_mc_info call in hypathia
andLaing May 19, 2020
5ea7df3
Remove MC table comparison from hypathia_test
andLaing May 19, 2020
22391fa
Remove unused imports from mcinfo_io_test
andLaing May 20, 2020
2b64ef6
Remove unused MCParticle class
andLaing May 20, 2020
17fc750
Remove unused MCParticleInfo class
andLaing May 20, 2020
a39abfc
Remove unused get_mc_info_safe
andLaing May 20, 2020
90009f9
Changed get_sensor_binning tests to use DataFrame comparison
andLaing May 21, 2020
d1aec0e
Move mc_particle_and_hits_nexus_data fixture to mcinfo_io_test
andLaing May 21, 2020
57aa97a
Move mc_sensors_nexus_data fixture to mcinfo_io_test
andLaing May 21, 2020
7997926
Change drop in get_sensor_binning to not use inplace
andLaing May 21, 2020
6b2241d
Add new test files for city exact results
andLaing May 22, 2020
bf37968
Use NEWMC files in cities exact result tests. All tables compared
andLaing May 22, 2020
0daeb46
Protec get_sensor_binning from merged files
andLaing May 22, 2020
db62205
693 Update mc readers
mmkekic May 25, 2020
4cb84ec
Update NEXT100 DB and related tests according to current design.
paolafer May 21, 2020
cd3b0c1
Update channel position table.
paolafer May 22, 2020
e04a842
719 Update NEXT100 DB and related tests
andLaing May 25, 2020
50ad0c8
Add buffer writer capable of writing nexus event as multiple events
andLaing May 28, 2020
d1e573f
Test for buffer writer
andLaing May 28, 2020
ad0a847
Improve docstrings for new functions
andLaing May 28, 2020
a3f1107
Add return info to buffer_writer docstring
andLaing Jun 3, 2020
5dfdf05
Move EventMap class from rwf_io to evm/nh5 and rename MCEventMap
andLaing Jun 3, 2020
182d078
Use tables_io.make_table to make nexus_map in buffer_writer
andLaing Jun 3, 2020
0e630e2
Improve names in MCEventMap
andLaing Jun 4, 2020
7727310
722 Integrated buffer writer
jmalbos Jun 5, 2020
80f669b
Update db
carmenromo Jun 11, 2020
8de4188
725 Update db
carmenromo Jun 11, 2020
9e32939
Install and initialize git lfs on Travis OSX
jacg Jun 22, 2020
88655da
728 Install and initialize git lfs on Travis OSX
jmbenlloch Jun 27, 2020
ea4006b
Update conda packages
mmkekic Jun 16, 2020
2d003d1
Remove nocov profiles since use_coverage is deprecated.
mmkekic Jun 16, 2020
94f68d1
Fix fixture usage in paolina_tests
mmkekic Jun 2, 2020
d72fcca
Change deprecated getfuncargvalue to getfixturevalue
mmkekic Jun 2, 2020
6b8ee5e
Accomodate _decode_str_columns to new pandas version
mmkekic Jun 2, 2020
a6d6de3
Convert np.ceil to int for np.linspace to work
mmkekic Jun 2, 2020
e659703
Use keyword elements for hypothesis strategies
mmkekic Jun 16, 2020
00c6854
Fix usage of hypothesis strategies
mmkekic Jun 16, 2020
7622568
Add pytest marks for slow and serial
mmkekic Jun 16, 2020
72da442
Use raw strings in regex searches
mmkekic Jun 16, 2020
a5a4fb8
Skip tests relying on scipy interpolation.
mmkekic Jun 16, 2020
dceec28
Change collection deprecationwarning message
mmkekic Jun 16, 2020
4559112
Ignore 'dataframe is empty' warning
mmkekic Jun 16, 2020
9b69eb4
Ignore UserWarnings in city on empty files
mmkekic Jun 16, 2020
1672946
Use isinstance instead of is in for enum members
mmkekic Jun 16, 2020
515a56c
723 Update env
gonzaponte Jul 2, 2020
b53f126
Add Flex100 to the list of available detectors
jmunozv Jul 3, 2020
d0bcbf1
729 Add Flex100 to the list of available detectors
jmbenlloch Jul 7, 2020
29b531c
Update values of `deconv_functions` tests after scipy version change
Aretno Jul 17, 2020
41c50a4
Update values of `deconv_functions` tests after scipy version change
Aretno Jul 17, 2020
f3d3234
733 Update beersheba related tests after package updates
carmenromo Jul 17, 2020
d099075
Add single pe test file
andLaing Jun 18, 2020
b4ecb27
Test to show loss of single pe signal in pmt simulation
andLaing Jun 12, 2020
2f14c82
Change fee.ADC_TO_PES to 16.241
andLaing Jun 18, 2020
195b0dd
Add round to return in diomira.simulate_pmt_response
andLaing Jun 18, 2020
7b33772
Add functions to run very slow tests with commandline option
andLaing Jun 18, 2020
7149793
New comparison file for test_diomira_exact_result
andLaing Jun 18, 2020
d540180
Change daq_decimate to avoid loss of charge
andLaing Jul 7, 2020
f5ca33b
Temporarily mark test_spe_to_adc skip
andLaing Jul 7, 2020
a262b9a
Add test to check that losses low in basic simulation
andLaing Jul 22, 2020
62958eb
726 Change rounding in PMT simulation
mmkekic Jul 24, 2020
1c4fd60
Modify 'load_dst' and 'load_dsts' to accept an event list.
Aretno Jul 27, 2020
7c77b06
736 Modify 'load_dst' and 'load_dsts' to accept an event list
mmkekic Aug 7, 2020
b3080c6
Update url of miniconda repository
jmalbos Aug 31, 2020
773c703
738 Update url of miniconda repository
jerenner Sep 1, 2020
df39147
739 Update Flex100DB to fix SiPM numbering
jmunozv Sep 3, 2020
67b43de
Upload gains for the new dice board
carmenromo Sep 7, 2020
6a102eb
740 Upload DEMO++ DB
carmenromo Sep 7, 2020
edb82d5
Upload demo++ database
carmenromo Sep 8, 2020
83f1b36
741 Upload demo++ database
carmenromo Sep 8, 2020
a9b83e3
Add test to check non-exact pitch divisor as deconvolution binning.
Aretno Sep 14, 2020
dcd0fe5
Change variable grid to fixed detector grid and variable range
Aretno Sep 14, 2020
a69036a
Adapt demonstrator test to the new code changes
Aretno Sep 14, 2020
dde5c6f
Fix docstring
Aretno Sep 15, 2020
096bf1a
735 Fix non-integer sensor position in beersheba
mmkekic Sep 15, 2020
0c8bc91
Add detsim folder and __init__.py file
andLaing Sep 15, 2020
0b756b0
Add detsim.buffer_functions
andLaing Sep 15, 2020
6824a35
Add full sim file as fixture to general conftest.py
andLaing Sep 15, 2020
b1ba611
Add new test file binned_simwfs.h5
andLaing Sep 15, 2020
e26e5f2
Add detsim.conftest.py for detsim specific fixtures
andLaing Sep 15, 2020
9dbb003
Add tests for detsim.buffer_functions
andLaing Sep 15, 2020
a86a75b
Add detsim.sensor_utils.py
andLaing Sep 15, 2020
2ccb8dc
Add tests for detsim.sensor_utils
andLaing Sep 15, 2020
6bc7363
Add components for MC waveform binning and trigger search
andLaing Sep 15, 2020
6b9b047
737 Bufferization functions
carmenromo Sep 16, 2020
89f34cf
New source for MC sensor response
andLaing May 25, 2020
715e097
Tests for mcsensors_from_file
andLaing May 25, 2020
7df6a8a
721 Source for nexus full simulation
jmalbos Sep 21, 2020
50a850e
Upload DB
carmenromo Sep 25, 2020
9050ae4
Upload gains and pdfs for SiPMs in demo++
carmenromo Sep 28, 2020
ea767e0
743 Upload DEMO++ DB
carmenromo Sep 28, 2020
5beba01
Upload DB with the lastest calibrations in NEW
carmenromo Sep 29, 2020
8180c70
744 Upload DB with the lastest calibrations in NEW
jmbenlloch Sep 29, 2020
f2567cf
745 Update NEXT100 local db after fixing SiPM positions
jmalbos Oct 7, 2020
bf96038
Upload DB
carmenromo Oct 22, 2020
5d0139a
746 Include dice board ratios in DEMOPP database
carmenromo Oct 22, 2020
8bfe866
Update demo db
carmenromo Oct 26, 2020
daf379e
Fix max run value
carmenromo Oct 26, 2020
bd7d5d3
747 Update demo DB
carmenromo Oct 26, 2020
7816250
Increase max run in DEMOPPDB for channel position and mapping
carmenromo Oct 27, 2020
ad91493
Undo change in PMT 2 gain with min run zero
carmenromo Oct 27, 2020
5b8de26
748 Update DEMOPPDB
carmenromo Oct 27, 2020
ecc267f
Upload max run for all PMT tables
carmenromo Oct 27, 2020
87fb7dd
750 Update DEMOPPDB 2.0
carmenromo Oct 27, 2020
2f4b56b
Add selectioncity module
gondiaz Jan 27, 2020
220d53e
Cosmetics
gondiaz Jan 27, 2020
59c9235
Update selectioncity
gondiaz Jan 28, 2020
b2ea5ce
Add selectioncity_tests
gondiaz Jan 28, 2020
c1291f6
Add fixtures
gondiaz Jan 28, 2020
2d75b10
Change parametrize by fixture with params
gondiaz Jan 28, 2020
cf17edb
Upload test rwfs and pmaps files for selectioncity
gondiaz Jan 28, 2020
2cb3ac0
Add selectioncity module
gondiaz Jan 27, 2020
7b1c745
Cosmetics
gondiaz Jan 27, 2020
567a301
Update selectioncity
gondiaz Jan 28, 2020
fd91b15
Add selectioncity_tests
gondiaz Jan 28, 2020
f4498b5
Add fixtures
gondiaz Jan 28, 2020
e5d93f0
Change parametrize by fixture with params
gondiaz Jan 28, 2020
c297152
Modifies for selection of CHITS
Dec 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
# Byte-compiled / optimized
__pycache__/
*.py[cod]

*.pyc
*.o
*.so
# C extensions
*.c
.cache
*.egg-info
*.*~
environment?.?.yml
*.so

# Distribution / packaging
build/
*.egg-info/
environment-*.yml
miniconda.sh

# Unit test / coverage reports
.hypothesis/

# Jupyter Notebook
.ipynb_checkpoints

# Backup files
*~

# macOS
.DS_Store
doc/.DS_Store
doc/build
invisible_cities/cities/.ipynb_checkpoints
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,11 @@ install:

script:
- HYPOTHESIS_PROFILE=travis-ci bash manage.sh run_tests_par


before_install:
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew install git-lfs; fi
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then git lfs install; fi

before_script:
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then git lfs pull; fi
2 changes: 0 additions & 2 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
settings.register_profile("travis-ci" , settings(max_examples = 1000, deadline=300))
settings.register_profile("hard" , settings(max_examples = 1000))
settings.register_profile("dev" , settings(max_examples = 10))
settings.register_profile("hard_nocov", settings(max_examples = 1000, use_coverage=False))
settings.register_profile("dev_nocov" , settings(max_examples = 10, use_coverage=False))
settings.register_profile("debug" , settings(max_examples = 10,
verbosity=Verbosity.verbose))
settings.load_profile(os.getenv(u'HYPOTHESIS_PROFILE', 'dev'))
48 changes: 48 additions & 0 deletions doc/commits.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
How to create a good commit history
===================================

Commit structure
-----------------

- Focus on a specific change. Don't try to change everything at once.
If the plan is to implement a series of things, do them one by one.

- Do not mix changes concerning different features in one commit.
For instance, do not mix cosmetical changes with other, more relevant ones.

- Commit frequently and in an incremental manner.
Do not be afraid of making too many commits, they can be combined afterwards
(this is known as squashing in git).
Besides, the history can be easily cleaned when the changes are small and independent of each other.


Commit style
--------------

- Just follow https://chris.beams.io/posts/git-commit/

This is a summary of a good commit message.
But, please at least take a look to the details in the link above.


| The seven rules of a great Git commit message
|
| 1. Separate subject from body with a blank line
| 2. Limit the subject line to 50 characters
| 3. Capitalize the subject line
| 4. Do not end the subject line with a period
| 5. Use the imperative mood in the subject line
| 6. Wrap the body at 72 characters
| 7. Use the body to explain what and why vs. how

Commits after PR review
-----------------------

- Remember that these guidelines apply also to changes requested during a review process.
Don't make commits like ``Changes requested by the reviewer``.

- Follow the same guidelines listed above and,
if you want to refer to the discussion happening in the PR,
do it using the second part of the commit message.
You may also refer to the PR by using ``#PR_NUMBER`` or
by posting a link to a specific comment in the discussion.
100 changes: 58 additions & 42 deletions invisible_cities/cities/beersheba.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@

from typing import Tuple
from typing import List
from typing import Callable

from enum import auto

from . components import city
from . components import collect
from . components import copy_mc_info
from . components import print_every
from . components import cdst_from_files

Expand All @@ -38,22 +39,24 @@
from .. dataflow.dataflow import push
from .. dataflow.dataflow import pipe

from .. database.load_db import DataSiPM

from .. reco.deconv_functions import find_nearest
from .. reco.deconv_functions import cut_and_redistribute_df
from .. reco.deconv_functions import drop_isolated_sensors
from .. reco.deconv_functions import deconvolve
from .. reco.deconv_functions import richardson_lucy
from .. reco.deconv_functions import InterpolationMethod

from .. io. mcinfo_io import mc_info_writer
from .. io.run_and_event_io import run_and_event_writer
from .. io. dst_io import _store_pandas_as_tables
from .. io. dst_io import df_writer
from .. io. dst_io import load_dst

from .. evm.event_model import HitEnergy

from .. types.ic_types import AutoNameEnumBase

from .. core.system_of_units_c import units
from .. core import system_of_units as units


class CutType (AutoNameEnumBase):
Expand All @@ -65,7 +68,8 @@ class DeconvolutionMode(AutoNameEnumBase):
separate = auto()


def deconvolve_signal(psf_fname : str,
def deconvolve_signal(det_db : pd.DataFrame,
psf_fname : str,
e_cut : float,
n_iterations : int,
iteration_tol : float,
Expand All @@ -85,6 +89,7 @@ def deconvolve_signal(psf_fname : str,

Parameters
----------
det_db : Detector database.
psf_fname : Point-spread function.
e_cut : Cut in relative value to the max voxel over the deconvolution output.
n_iterations : Number of Lucy-Richardson iterations
Expand All @@ -111,16 +116,19 @@ def deconvolve_signal(psf_fname : str,
bin_size = np.asarray(bin_size )
diffusion = np.asarray(diffusion )

psfs = pd.read_hdf(psf_fname)
deconvolution = deconvolve(n_iterations, iteration_tol, sample_width, bin_size, inter_method)
psfs = load_dst(psf_fname, 'PSF', 'PSFs')
det_grid = [np.arange(det_db[var].min() + bs/2, det_db[var].max() - bs/2 + np.finfo(np.float32).eps, bs)
for var, bs in zip(dimensions, bin_size)]
deconvolution = deconvolve(n_iterations, iteration_tol,
sample_width, det_grid , inter_method)

if energy_type not in HitEnergy :
if not isinstance(energy_type , HitEnergy ):
raise ValueError(f'energy_type {energy_type} is not a valid energy type.')
if inter_method not in InterpolationMethod:
if not isinstance(inter_method, InterpolationMethod):
raise ValueError(f'inter_method {inter_method} is not a valid interpolation method.')
if cut_type not in CutType :
if not isinstance(cut_type , CutType ):
raise ValueError(f'cut_type {cut_type} is not a valid cut type.')
if deconv_mode not in DeconvolutionMode :
if not isinstance(deconv_mode , DeconvolutionMode ):
raise ValueError(f'deconv_mode {deconv_mode} is not a valid deconvolution mode.')

def deconvolve_hits(df, z):
Expand Down Expand Up @@ -294,17 +302,18 @@ def deconv_writer(h5out, compression='ZLIB4'):
For a given open table returns a writer for deconvolution hits dataframe
"""
def write_deconv(df):
return _store_pandas_as_tables(h5out = h5out ,
df = df ,
compression = compression ,
group_name = 'DECO' ,
table_name = 'Events' ,
descriptive_string = 'Deconvolved hits')
return df_writer(h5out = h5out ,
df = df ,
compression = compression ,
group_name = 'DECO' ,
table_name = 'Events' ,
descriptive_string = 'Deconvolved hits',
columns_to_index = ['event'] )
return write_deconv


@city
def beersheba(files_in, file_out, compression, event_range, print_mod, run_number,
def beersheba(files_in, file_out, compression, event_range, print_mod, detector_db, run_number,
deconv_params = dict()):
"""
The city corrects Penthesilea hits energy and extracts topology information.
Expand Down Expand Up @@ -395,36 +404,43 @@ def beersheba(files_in, file_out, compression, event_range, print_mod, run_numbe
filter_events_no_hits = fl.map(check_nonempty_dataframe,
args = 'cdst',
out = 'cdst_passed_no_hits')
deconvolve_events = fl.map(deconvolve_signal(**deconv_params),
deconvolve_events = fl.map(deconvolve_signal(DataSiPM(detector_db, run_number), **deconv_params),
args = 'cdst',
out = 'deconv_dst')

event_count_in = fl.spy_count()
event_count_out = fl.spy_count()
events_passed_no_hits = fl.count_filter(bool, args = "cdst_passed_no_hits")

evtnum_collect = collect()

with tb.open_file(file_out, "w", filters = tbl.filters(compression)) as h5out:
# Define writers
write_event_info = fl.sink(run_and_event_writer(h5out), args=("run_number", "event_number", "timestamp"))
write_mc_ = mc_info_writer(h5out) if run_number <= 0 else (lambda *_: None)

write_mc = fl.sink( write_mc_, args = ("mc", "event_number"))
write_deconv = fl.sink( deconv_writer(h5out=h5out), args = "deconv_dst" )
write_summary = fl.sink( summary_writer(h5out=h5out), args = "summary" )
return push(source = cdst_from_files(files_in),
pipe = pipe(fl.slice(*event_range, close_all=True) ,
print_every(print_mod) ,
event_count_in.spy ,
cut_sensors ,
drop_sensors ,
filter_events_no_hits ,
events_passed_no_hits .filter ,
deconvolve_events ,
event_count_out.spy ,
fl.fork(write_mc ,
write_deconv ,
write_summary ,
write_event_info)) ,
result = dict(events_in = event_count_in .future,
events_out = event_count_out .future,
events_pass = events_passed_no_hits.future))
write_event_info = fl.sink(run_and_event_writer (h5out), args = ("run_number", "event_number", "timestamp"))
write_deconv = fl.sink( deconv_writer(h5out=h5out), args = "deconv_dst")
write_summary = fl.sink( summary_writer(h5out=h5out), args = "summary" )
result = push(source = cdst_from_files(files_in),
pipe = pipe(fl.slice(*event_range, close_all=True) ,
print_every(print_mod) ,
event_count_in.spy ,
cut_sensors ,
drop_sensors ,
filter_events_no_hits ,
events_passed_no_hits .filter ,
deconvolve_events ,
event_count_out.spy ,
fl.branch("event_number" ,
evtnum_collect.sink) ,
fl.fork(write_deconv ,
write_summary ,
write_event_info)) ,
result = dict(events_in = event_count_in .future,
events_out = event_count_out .future,
evtnum_list = evtnum_collect .future,
events_pass = events_passed_no_hits.future))

if run_number <= 0:
copy_mc_info(files_in, h5out, result.evtnum_list,
detector_db, run_number)

return result
Loading