Support #1909
npred return error: TypeError: in method 'GModelSky_npred', argument 4 of type 'GObservation const &'
Status: | Closed | Start date: | 01/18/2017 | |
---|---|---|---|---|
Priority: | Normal | Due date: | ||
Assigned To: | Knödlseder Jürgen | % Done: | 100% | |
Category: | - | |||
Target version: | - | |||
Duration: |
Description
Dear all,
I am using gammalib 1.1.0 and ctools 1.1.0
I am tryng to extract the npred from the models as a function of energy after fitting some data.
models = like.obs().models()
for k,m in enumerate(models):
obsEng = ebounds.elogmean(i)
source[i] = m.npred(obsEng, obsTime, obs)
....
but I have an error, in the documentation npred function have 3 paramaters, but here it is said that I need another parameter.
File "/Users/grod/DPA/External/gamma/gammalib-1.1.0/lib/python2.7/site-packages/gammalib/model.py", line 704, in npred
return _model.GModelSky_npred(self, obsEng, obsTime, obs)
TypeError: in method 'GModelSky_npred', argument 4 of type 'GObservation const &'
What I am doing wrong?
Thanks in advance!
Gonzalo.
Recurrence
No recurrence.
History
#1 Updated by Knödlseder Jürgen almost 8 years ago
- Status changed from New to In Progress
- Assigned To set to Knödlseder Jürgen
- % Done changed from 0 to 10
The difference in the number of arguments comes from the fact that a Python method always has as first argument the class object itself (argument self
). Hence a method with 3 arguments has in fact 4 arguments internally, but when you call the method, you don’t have to specify the first argument, so your number of arguments is correct.
The problem in your case may come from the type of the obs
argument. From your code snippet I don’t know what type it has. It should be of type GObservation
(or any derived type, such as GCTAObservation
).
What is the type of obs
in your case?
#2 Updated by Rodriguez Fernandez Gonzalo almost 8 years ago
- Assigned To deleted (
Knödlseder Jürgen) - % Done changed from 10 to 0
That’s the problem!
I’ve made a mistake, I was using a GObservations object as the last argument!,
Now I just put the correct GCTAObservation object and It is working!
Thanks!
Gonzalo.
#3 Updated by Knödlseder Jürgen almost 8 years ago
- Status changed from In Progress to Closed
- Assigned To set to Knödlseder Jürgen
- % Done changed from 0 to 100
Good to see that it’s solved.