Conversation
invisible_cities/cities/icaro.py
Outdated
| @city | ||
| def icaro(files_in, file_out, compression, detector_db, run_number, | ||
| bootstrap, quality_ranges, band_sel_params, map_params, krevol_params): | ||
| def icaro(files_in, file_out, compression, event_range, print_mod, |
There was a problem hiding this comment.
Why do you introduce event_range and print_mod? If I'm not wrong, the aim is that all the events are run in one interaction of the pipe. Therefore, those variables don't make sense in that context.
There was a problem hiding this comment.
Below there is:
fl.slice(*event_range, close_all=True),
print_every(print_mod) ,so I added them to the list of arguments (as I saw in other cities). If we remove them, we should also change those lines I guess.
There was a problem hiding this comment.
In that regard, I think that the best example for the concept I mean is Eutropia, that is also taking the whole range of events as a whole and doing a single iteration. Do you agree, @gonzaponte?
There was a problem hiding this comment.
IIRC the city needs the parameter event_range. That's probably why Eutropia takes it even though it doesn't use it (Although skimming through the code I didn't see why it is needed). But yes, in this case, we don't want to iterate over single events so the Eutropia example is a good one.
There was a problem hiding this comment.
Ok, I removed those lines and the print_mod argument for now.
invisible_cities/cities/icaro.py
Outdated
| def icaro(files_in, file_out, compression, event_range, print_mod, | ||
| detector_db, run_number, bootstrap, quality_ranges, | ||
| band_sel_params, map_params, | ||
| r_fid, nStimeprofile, x_range, y_range): |
There was a problem hiding this comment.
Just to check, shouldn't we group the variables in dicts in the config file? I think this is easier to read but not strongly opinionated.
There was a problem hiding this comment.
Not sure, I just took a look at other cities and I saw that it was done this way. You mean grouping r_fid and nStimeprofile in a krevol_params dictionary and then call the function like this:
add_krevol(**krevol_params)?
There was a problem hiding this comment.
Yes, something of that sort, but again, it's something we can discuss in the meeting, not a big deal for me.
There was a problem hiding this comment.
I would only use dictionaries as arguments whenever there are large groups of parameters that impact a specific part of the flow. For instance, if your arguments affect only the time evolution and they are quite a few, I would group them into a dictionary, otherwise, I would leave them as individual arguments.
There is no clear cut though, so waiting for the city to be more advanced will give us a better perspective.
62ffe43 to
00323e2
Compare
00323e2 to
966db40
Compare
|
Some general comments on my first draft: The idea was to have the map core, the function in charge of performing the fits for each bin and return an object that we could use. I created a krmap_components file in which I put almost everything, because I dind't want to flood the city file with hundreds of lines of code, making it worse in terms of readability...
|
gonzaponte
left a comment
There was a problem hiding this comment.
I didn't look at anything in detail, but at first glance looks ok. I think we can safely assume that there is symmetry in x-y and remove all those bits dealing with potentially different x- and y-bins. The most important thing is to look into changing the format of KrMap. If you feel like there are potential problems with that we can discuss it.
| from invisible_cities.core.core_functions import in_range, shift_to_bin_centers | ||
|
|
||
|
|
||
| class KrMap(): |
There was a problem hiding this comment.
I'm more inclined to use a dataclass
@dataclass
class KrMap:
x_bins : np.ndarray, #1D
y_bins : np.ndarray, #1D
data : pd.DataFrame
with an appropriate init method. I have the feeling that it will make everything easier. If you find that some other part of the code will be more difficult to implement, let me know and we will discuss.
There was a problem hiding this comment.
I'll look into this now! I'll tell you if I struggle with anything.
There was a problem hiding this comment.
I have a question here, maybe due to my limited knowledge, but why are we creating a new KrMap class instead of using the ASectorMap class that already exists and was used in ICAROS?
There was a problem hiding this comment.
I hope we will end up with a similar dataclass, but refactored into something better. As I see it, the field MapInfo in ASectorMap should be unraveled into attributes, and the fields of type pd.DataFrame should be combined into a single pd.DataFrame.
There was a problem hiding this comment.
Ok, I see, ASectorMap is already defined in reco/corrections.py but as far as I can see it's never used in the codebase. We should decide if we want to expand that, or create a new dataclass (KrMap?) and delete the unused ASectorMap. If we want to keep KrMap, I believe it needs a chi2 attribute as well.
There was a problem hiding this comment.
I haven't looked too much into the whole organization of the code, but I believe we are discarding all the data model form icaros.
If we want to keep KrMap, I believe it needs a chi2 attribute as well.
This can be a column of the dataframe help by KrMap
| def get_XY_bins(n_bins : int, | ||
| XYrange : Tuple[float, float] = (-490, 490)): |
There was a problem hiding this comment.
do we really need this function? seems a bit trivial.
There was a problem hiding this comment.
It is... I initially added it in order to have customizable range of the map, in case someone wanted it that way, but it's true that maybe it could be inserted into other function. In any case, I guess the XYrange parameter would have to appear before, in the kr selection part, so here it would not be necessary to have the DB values (or hardcoded values, as they are now), just the parameter used before.
| bin_centers : list | ||
| List contaning np.arrays with the center of the bins |
| binsizes_x = bins_x[1:] - bins_x[:-1] # Compute bin sizes | ||
| binsizes_y = bins_y[1:] - bins_y[:-1] |
| from .. types.ic_types import MasksContainer | ||
|
|
||
| from . components import city | ||
| from . components import print_numberofevents |
There was a problem hiding this comment.
print_numberofevents, quality_check and kr_selection are not defined in components.py, so the code gives ImportError
There was a problem hiding this comment.
I left the rest of the city as it was before my commits, I only included the imports that I needed for my part and the compute_map function, but did not modify anything else, so it should be OK when the different parts of the code are included... Right now here it's the skeleton that Brais drafted and some of those imports are not done yet (It's not that they are not in components.py because they are somewhere else, I guess they are nowhere right now).
invisible_cities/cities/icaro.py
Outdated
| from . components import dst_from_files | ||
| from . components import quality_check | ||
| from . components import kr_selection | ||
| from . components import map_builder |
There was a problem hiding this comment.
map_builder and add_krevol are defined in icaro.py and not in components (I followed the convention that if a function is used only in the module it stays in the module itself)
This PR aims to serve as a first step towards the joint efforts of the Kr Calibration Team towards the standardization and update of the procedure for the Kr maps production, validation and posterior usage. It proposes a first draft of the city to focus the efforts and set the guidelines.
The city will read Kr kdsts and perform a series of quality selections and data checks, then a set of fits to extract both the energy and lifetime map and last, a computation of the evolution of the relevant parameters through the run.