Feature #1263
High level analysis scripts
Status: | Closed | Start date: | 07/10/2014 | |
---|---|---|---|---|
Priority: | Normal | Due date: | ||
Assigned To: | Sanchez David | % Done: | 100% | |
Category: | - | |||
Target version: | 1.0.0 | |||
Duration: |
Description
Provide uniform high level analysis scripts for common tasks as e.g. spectral points calculation or residual maps. This will start by expanding the obsutils.py script. For later stages the structure of this scripting should be well thought through, it might become the interface to ctools most users use.
Recurrence
No recurrence.
History
#1 Updated by Sanchez David over 10 years ago
Buehler Rolf wrote:
Provide uniform high level analysis scripts for common tasks as e.g. spectral points calculation or residual maps. This will start by expanding the obsutils.py script. For later stages the structure of this scripting should be well thought through, it might become the interface to ctools most users use.
to feed the discussion, I think we need a collection of script/classes
- a set of classes/scripts that run the entire analysis (based on configuration files?)
- an ascii reader/writer
- a set of classes that plot the spectrum+point+ul+residual (in plotutils.py or spectrumutils.py)
- a set of classes that plot maps (maybe in the same class than the spectrum one)
- a way to plot LC?
- a way of computing UL (without dependencies)
I am currently working on the plotting tools and I used the tools that Michael Mayer sent us. I thinks the ascii format should be such that the reader knows the units and it convert to the desired units
#2 Updated by Knödlseder Jürgen over 10 years ago
Sanchez David wrote:
Buehler Rolf wrote:
- an ascii reader/writer
The is the GCsv
class for column separated value ASCII files. Can you check whether this satisfies the needs, or is something else needed?
#3 Updated by Knödlseder Jürgen over 10 years ago
obsutils.py
, now we also have plotutils.py
. Here some proposal to start the discussion:
obsutils.py
- Observation definition
- Event simulation
- Standard ctools analysis workflows
plotutils.py
- Stuff needed to display data and results
- Depends on matplotlib (no further dependency required)
specutils.py
- Utilities for spectral analysis, including definition of node functions, splitting runs in energy bins, etc.
timeutils.py
- Utilities for temporal analysis, including light curves, GRB analysis
#4 Updated by Knödlseder Jürgen over 10 years ago
- Target version set to 3rd coding sprint
#5 Updated by Sanchez David over 10 years ago
Knödlseder Jürgen wrote:
We have to think how to organize the scripts into modules. So far there isobsutils.py
, now we also haveplotutils.py
. Here some proposal to start the discussion:
obsutils.py
- Observation definition
- Event simulation
- Standard ctools analysis workflows
plotutils.py
- Stuff needed to display data and results
- Depends on matplotlib (no further dependency required)
specutils.py
- Utilities for spectral analysis, including definition of node functions, splitting runs in energy bins, etc.
timeutils.py
- Utilities for temporal analysis, including light curves, GRB analysis
I have started working on it and I have a tool that plot SEDs. The rest will follow.
#6 Updated by Sanchez David over 10 years ago
Knödlseder Jürgen wrote:
Sanchez David wrote:
Buehler Rolf wrote:
- an ascii reader/writer
The is the
GCsv
class for column separated value ASCII files. Can you check whether this satisfies the needs, or is something else needed?
Can this class create a file? I did not see a “write” function
#7 Updated by Knödlseder Jürgen over 10 years ago
Sanchez David wrote:
Knödlseder Jürgen wrote:
Sanchez David wrote:
Buehler Rolf wrote:
- an ascii reader/writer
The is the
GCsv
class for column separated value ASCII files. Can you check whether this satisfies the needs, or is something else needed?Can this class create a file? I did not see a “write” function
I guess not for the moment, but it should of course be able of doing that. For the moment I simply use it for reading Fermi FileFunctions. The class is definitely not very developed. You may create an issue for that.
#8 Updated by Sanchez David over 10 years ago
Knödlseder Jürgen wrote:
Sanchez David wrote:
Knödlseder Jürgen wrote:
Sanchez David wrote:
Buehler Rolf wrote:
- an ascii reader/writer
The is the
GCsv
class for column separated value ASCII files. Can you check whether this satisfies the needs, or is something else needed?Can this class create a file? I did not see a “write” function
I guess not for the moment, but it should of course be able of doing that. For the moment I simply use it for reading Fermi FileFunctions. The class is definitely not very developed. You may create an issue for that.
We will have a look so
#9 Updated by Buehler Rolf over 10 years ago
- File dicdata.py added
- File spectrum.json added
I think to be independent of modules we could pass the data around in the high level analysis scripts as python dictionaries and if needed write/read with json.
The general form of the dictionaries for final data as lightcurves or spectra could e.g. be of the form:
dict = {“parameter1":{“value":[..],“eu_value":[..],“ed_value”:[..], “unit”:[..]}, “parameter2”,...}
(once we agree on a format it should be fixed somewhere)
We could provide additional files (without support) as the ones I attach which can read/plot/manipulate these dictionaries and do rely on external modules, as e.g. astropy. This e.g. allows one to save into any ascii format one needs to process the data later.
#10 Updated by Buehler Rolf over 10 years ago
I forgot to mention, this is also the format in which obsutils.specpoint right now returns spectra. The example file above was then written out with json:
spec = obsutils.specpoints(obssim,“CrabNebula",obsutils.getlogbins())
json.dump(spec,open(“spectrum.json",“w"),indent=4)
#11 Updated by Sanchez David over 10 years ago
- File plotting.py added
- File analysisutils.py added
- File runctlike.py added
Buehler Rolf wrote:
I forgot to mention, this is also the format in which obsutils.specpoint right now returns spectra. The example file above was then written out with json:
spec = obsutils.specpoints(obssim,“CrabNebula",obsutils.getlogbins())
json.dump(spec,open(“spectrum.json",“w"),indent=4)
Hi Rolf
I was about to commit my tool that plot spectra and make bin in E. I’ll change it to add your class and will commit it soon. I have created a branch
btw, I found strange values of TS (sometimes -600 or so) We need to have a look.
for the record I upload the .py I have now
cheers
david
#12 Updated by Sanchez David over 10 years ago
I have created a new branch ( if git did what i told me) with a first commit
#13 Updated by Knödlseder Jürgen over 10 years ago
Sanchez David wrote:
I have created a new branch ( if git did what i told me) with a first commit
Do you have some stuff to be merged in? If yes, please tell me what branch.
#14 Updated by Sanchez David about 10 years ago
I think there is still stuff to check
#15 Updated by Knödlseder Jürgen about 10 years ago
- Target version changed from 3rd coding sprint to 1.0.0
#16 Updated by Sanchez David about 10 years ago
- File analysisutils.py added
- File plotutils.py added
Hi,
I have finally finished a first version of the high level analysis tools. I am not sure I have push them on git so I uploaded them here (sorry)
features : * Make LC * Make bin in energy * Make butterfly
Let me know how I can upload it on git on if you found bugs or missing feature.
#17 Updated by Knödlseder Jürgen about 10 years ago
- Status changed from New to In Progress
- Assigned To set to Sanchez David
- % Done changed from 0 to 80
Looks good. It needs a little bit more documentation so that it becomes clear what the various functions or classes are doing. Also some usage example in the example
folder would be nice to better understand what’s behind the code.
In any case, I merged the scripts into the devel
branch, so if you do some further modifications I recommend that you create a new fresh branch from devel
using
git checkout -b 1263-high-level-scripts-continued
#18 Updated by Mayer Michael about 10 years ago
I also had look at the code and find it very nice to have these functions.
Concerning the light curve, the spectrum and upper limit computation: I would be in favour to have this as individual tools (or cscripts) in ctools. This would be more aligned with the ctools-philosophy. The high-level analysis-tools would then call these classes.
- ctupperlimit (C++)
- cslightcurve (python)
- csspectrum (python, see also #1335)
We can call ctupperlimit within the two csscripts to also get an upper limit in each time - or energy bin.
#19 Updated by Mayer Michael about 10 years ago
Note in the meantime, we also added ctbutterfly
(see #1051)
#20 Updated by Knödlseder Jürgen about 10 years ago
Indeed, the overall philosophy is: if you have an atomic task, create a ctool or cscript, if you combine atomic tasks together, or need a nice envelope for a given task, write a Python script.
#21 Updated by Knödlseder Jürgen about 10 years ago
Mayer Michael wrote:
I would therefore propose to add the following tools:Concerning the names, could we get them a little more compacts, e.g.:
- ctupperlimit (C++)
- cslightcurve (python)
- csspectrum (python, see also #1335)
ctlimit
orctulimit
cslightcrv
csspec
#22 Updated by Sanchez David about 10 years ago
HI
I’ll take charge of this
thanks
David
#23 Updated by Mayer Michael about 10 years ago
#24 Updated by Sanchez David about 10 years ago
#25 Updated by Sanchez David about 10 years ago
Well, for LC and bin in energy, I have some concerns. User will want to use CPU farm and make 1 point (of the LC or the spectra) per job no? This is what I do for Fermi analysis.
I am having a look at ctbutterfly and see if I should change my scripts
#26 Updated by Mayer Michael about 10 years ago
Well, for LC and bin in energy, I have some concerns. User will want to use CPU farm and make 1 point (of the LC or the spectra) per job no? This is what I do for Fermi analysis.
I agree! The user needs flexibility to launch individual jobs. We could implement a similar logic as in cttsmap
, where we added the parameters binmin
and binmax
. With these parameters the user can specify which range should be computed in the current job.
#27 Updated by Sanchez David about 10 years ago
So I think the new tools should me made in such way that they are calling a tool/script per bin/points (the same for all jobs). In the future, submition to clusters might also be supported (no?)
#28 Updated by Sanchez David about 10 years ago
I had a look a ctbutterfly. It makes the same as my function in plotutils.py
As suggested by Jurgen, I will create a new branch and update the script to use it and also to use the new script (csspec, etc..) when ready.
#29 Updated by Mayer Michael about 10 years ago
So I think the new tools should me made in such way that they are calling a tool/script per bin/points (the same for all jobs). In the future, submition to clusters might also be supported (no?)
Since every batch farm works differently, a support for that is (as far as I know) not foreseen in gammalib. However, we could provide easy functionality that the user can specify a part of spectra/maps (individual bins), which should be calculated in the job. Accordingly, the user can submit the same csspec
job, just with different binmin
, binmax
parameters. (Of course you would have to merge afterwards, see, e.g. $CTOOLS/scripts/tsmerge.py
)
I had a look a ctbutterfly. It makes the same as my function in plotutils.py
Yes, it is very much inspired by the python script I uploaded a while ago. Of course, there are still some things to improve (#1051).
As suggested by Jurgen, I will create a new branch and update the script to use it and also to use the new script (csspec, etc..) when ready.
Excellent, sounds like a good plan. In my view, we could start with ctulimit
, which can then be used in csspec
and cslightcrv
.
#30 Updated by Knödlseder Jürgen almost 10 years ago
Sanchez David wrote:
Well, for LC and bin in energy, I have some concerns. User will want to use CPU farm and make 1 point (of the LC or the spectra) per job no? This is what I do for Fermi analysis.
A nice alternative to this is the use of OpenMP, which does the parallelization itself and adapts it to the available resources. We had a discussion with Michael on this when he wrote the tsmap
tool. Given the fact that processors will get more and more cores in the future, we should really integrate more OpenMP capabilities into the ctools
so that the parallelization is transparent to the user. Nevertheless, we still may keep the possibility to perform “external parallelization”.
#31 Updated by Sanchez David almost 10 years ago
I was wondering if we could not create a unique tool 'csanalysis’ that run a fit from fits files or GObservation containers. this tools can then be called by the high level analysis tool to create enerby bin or time bin.
what do you think?
I have created a new branch also 1263-high-level-scripts-continued
#32 Updated by Mayer Michael almost 10 years ago
I don’t quite understand what this tool should do exactly. The name csanalysis
seems very generic to me. Do you intend this tool to only run ctlike
and csspec
afterwards? Or should it give also light curves, maps etc... anything a user can possibly want?
#33 Updated by Sanchez David almost 10 years ago
This need to be updated zith the new parameter name and new tools. working on it
#34 Updated by Knödlseder Jürgen over 9 years ago
Remove analysisutils.py
and plotutils.py
from the distribution for now. More thinking is needed to define the strategy for common high-level tools.
#35 Updated by Knödlseder Jürgen over 9 years ago
- Status changed from In Progress to Closed
- % Done changed from 80 to 100
Remove scripts.