From CNSHD555442
3/8/2006 10:52:18 AM mcleskey
Request from pweilbacher@aip.de
To: help@stsci.edu
Cc:
Dear STScI helpdesk,
I am slowly getting used to calling IRAF routines in Python scripts, but
I cannot figure out myself what is going on with the combine task.
I originally wanted to try to call it like this:
In [1]: import pyraf
In [2]: import pyraf.iraf as iraf
[...]
In [10]: iraf.combine(file1+"[*,*,"+str(i)+"],"+file2+"_mrl[*,*,"+str(i)+"],"+file3+"_mrl[*,*,"+str(i)+"]",
....: file123+"[*,*,"+str(i)+"]",
....: plfile=filebpm+"[*,*,"+str(i)+"]",
....: sigma=filesig+"[*,*,"+str(i)+"]",
....: combine="average", reject="sigclip", lsigma=8, hsigma=1.4, nkeep=0,
....: offsets="none", masktype="badvalue", maskvalue=1, blank=-500)
---------------------------------------------------------------------------
exceptions.KeyError Traceback (most recent call last)
/home/peter/Data/<console>
/usr/local/lib/python/PyRAF/pyraf/iraftask.py in __call__(self, *args, **kw)
650
651 def __call__(self,*args,**kw):
--> 652 return apply(self.run,args,kw)
653
654 def __repr__(self):
/usr/local/lib/python/PyRAF/pyraf/iraftask.py in run(self, *args, **kw)
252 # set parameters
253 kw['_setMode'] = 1
--> 254 apply(self.setParList,args,kw)
255
256 if iraf.Verbose>1:
/usr/local/lib/python/PyRAF/pyraf/iraftask.py in setParList(self, *args, **kw)
364 p.get().setParList()
365 # set the parameters
--> 366 apply(newParList.setParList, args, kw)
367 if _setMode:
368 # set mode of automatic parameters
/usr/local/lib/python/PyRAF/pyraf/irafpar.py in setParList(self, *args, **kw)
2130 i = key.find('.')
2131 if i<=0:
-> 2132 raise e
2133 param = (self.getParObject(key[:i]).name, key[i+1:])
2134 if fullkw.has_key(param):
KeyError: "Error in parameter 'plfile' for task combine\n'Key plfile not found'"
But as you can see this does not seem to be the task combine from
package ccdred, because it does not have the plfile parameter.
Then I tried to selectively import only those IRAF packages that I
really need, so that I get the correct combine task. But this doesn't
work, either, as you can see here:
In [1]: import pyraf
In [2]: from pyraf.iraf import images, imutil, immatch, noao, imred, ccdred
In [3]: ccdred.combine("file1,file2", "fileout")
---------------------------------------------------------------------------
pyraf.irafglobals.IrafError Traceback (most recent call last)
/home/peter/Data/<console>
/usr/local/lib/python/PyRAF/pyraf/iraftask.py in __call__(self, *args, **kw)
650
651 def __call__(self,*args,**kw):
--> 652 return apply(self.run,args,kw)
653
654 def __repr__(self):
/usr/local/lib/python/PyRAF/pyraf/iraftask.py in run(self, *args, **kw)
233 """Execute this task with the specified arguments"""
234
--> 235 self.initTask(force=1)
236
237 # Special _save keyword turns on parameter-saving.
/usr/local/lib/python/PyRAF/pyraf/iraftask.py in initTask(self, force)
89 if self._filename and not self._fullpath: self._initFullpath()
90 if self._currentParList is None:
---> 91 self._initParpath()
92 self._initParList()
93
/usr/local/lib/python/PyRAF/pyraf/iraftask.py in _initParpath(self)
891 self._defaultParpath = os.path.join(basedir,self._name + ".par")
892 if not os.path.exists(iraf.Expand(self._defaultParpath, noerror=1)):
--> 893 self._noParFile()
894 self._defaultParpath = ""
895
/usr/local/lib/python/PyRAF/pyraf/iraftask.py in _noParFile(self)
901 # Here I raise an exception, but subclasses (e.g., CL tasks)
902 # can do something different.
--> 903 raise iraf.IrafError("Cannot find .par file for task " + self._name)
904
905 def _initParList(self):
IrafError: Cannot find .par file for task combine
I don't understand how it cannot find the .par file, I can call this
task from the PyRAF or IRAF/cl commandline without any problem.
>From the Python shell I also cannot call
pyraf.iraf.epar(ccdred.combine) or pyraf.iraf.lpar(ccdred.combine),
then I get the same error message about missing .par file.
I am probably still missing some basic understanding of how PyRAF and
IRAF commands under Python work, so any hints would be appreciated.
Thanks in advance,
Peter.
3/8/2006 12:35:00 PM helenem
helenem changed platform to STSDAS
3/8/2006 5:18:42 PM perry
Hi Peter
> KeyError: "Error in parameter 'plfile' for task combine\n'Key plfile not found'"
>
> But as you can see this does not seem to be the task combine from
> package ccdred, because it does not have the plfile parameter.
Actually, I believe that task does have that parameter.
You say that you are able to run the same command in PyRAF successfully? Could you convert your example to a simpler one that doesn't have a lot of variable substitutions for the command string so I can better try to understand what is going wrong? If simple enough I can try to run it here under the same conditions to track down what the problem is.
Thanks, Perry Greenfield
perry changed status to Assignment Accepted
perry mailed the current call log entry to pweilbacher@aip.de
perry assigned call to perry
3/9/2006 4:37:19 AM mcleskey
Reply from pweilbacher@aip.de
Subject: Re: CNSHD557262 Re: IRAF combine task under Python (PyRAF)
To: Help@stsci.edu
Cc:
On Wed, 8 Mar 2006, Help@stsci.edu wrote:
> If you need to respond to this message please do so by replying to this message or create a new message with call number CNSHD557262 included in the subject line.
>
> Current Call log entry :
>
> > KeyError: "Error in parameter 'plfile' for task combine\n'Key plfile not found'"
> >
> > But as you can see this does not seem to be the task combine from
> > package ccdred, because it does not have the plfile parameter.
>
> Actually, I believe that task does have that parameter.
>
> You say that you are able to run the same command in PyRAF
> successfully? Could you convert your example to a simpler one that
> doesn't have a lot of variable substitutions for the command string so
> I can better try to understand what is going wrong? If simple enough I
> can try to run it here under the same conditions to track down what
> the problem is.
Hi Perry,
sorry, should have known that this was not a good idea... Really any combine call
with plfile= arguments shows the "problem", like this
import pyraf
import pyraf.iraf as iraf
iraf.combine("FOV1,FOV2,FOV3","FOV123",plfile="FOV123_bpm")
(you can try with the files from http://www.aip.de/People/PWeilbacher/FOV.tar.gz).
But I found out now that it is the mscred package that is interfering.
If I remove it from my login.cl but leave imred and ccdred in, the above
command works from Python.
The question that remains is: could I explicitely call the combine task
from noao.imred.ccdred from Python, even if mscred is loaded? All of
these commands
iraf.ccdred.combine("LowResCube1_FOV,LowResCube2_FOV.fits,LowResCube3_FOV","FOV123",plfile="FOV_bpm")
iraf.noao.imred.ccdred.combine("LowResCube1_FOV,LowResCube2_FOV.fits,LowResCube3_FOV","FOV123",plfile="FOV_bpm")
from pyraf.iraf import ccdred
ccdred.combine("LowResCube1_FOV,LowResCube2_FOV.fits,LowResCube3_FOV","FOV123",plfile="FOV_bpm")
just give
IrafError: Cannot find .par file for task combine
even though Python itself seems to recognize them as valid calls.
Cheers,
Peter.
3/9/2006 10:27:57 AM mcleskey
Reply from perry@stsci.edu
Subject: Re: Reply from pweilbacher for CNSHD557262 submitted by pweilbacher regarding IRAF combine task under Python (PyRAF)
To: "<support@stsci.edu>" <support@stsci.edu>, pweilbacher@aip.de
Cc:
>
> Hi Perry,
>
> sorry, should have known that this was not a good idea... Really
> any combine call
> with plfile= arguments shows the "problem", like this
> import pyraf
> import pyraf.iraf as iraf
> iraf.combine("FOV1,FOV2,FOV3","FOV123",plfile="FOV123_bpm")
> (you can try with the files from
> http://www.aip.de/People/PWeilbacher/FOV.tar.gz).
>
> But I found out now that it is the mscred package that is
> interfering.
> If I remove it from my login.cl but leave imred and ccdred in, the
> above
> command works from Python.
>
>
> The question that remains is: could I explicitely call the combine
> task
> from noao.imred.ccdred from Python, even if mscred is loaded? All of
> these commands
>
> iraf.ccdred.combine("LowResCube1_FOV,LowResCube2_FOV.fits,LowResCube3_F
> OV","FOV123",plfile="FOV_bpm")
>
> iraf.noao.imred.ccdred.combine("LowResCube1_FOV,LowResCube2_FOV.fits,Lo
> wResCube3_FOV","FOV123",plfile="FOV_bpm")
> from pyraf.iraf import ccdred
>
> ccdred.combine("LowResCube1_FOV,LowResCube2_FOV.fits,LowResCube3_FOV","
> FOV123",plfile="FOV_bpm")
>
> just give
> IrafError: Cannot find .par file for task combine
>
> even though Python itself seems to recognize them as valid calls.
>
>
> Cheers,
> Peter.
>
>
Thanks for providing the data and giving more specific information. I'm
not sure the problem is with the imports or something else. When I try
the following from ipython
import pyraf
from pyraf import iraf
from iraf import mscred
from iraf import imred
from iraf imoprt ccdred
iraf.noao.imred.ccdred.combine("FOV1, FOV2, FOV3", "FOV123",
plfile="FOV123_bpm")
works without any error messages as does:
iraf.combine("FOV1, FOV2, FOV3", "FOV123", plfile="FOV123_bpm")
though
iraf.mscred.combine("FOV1, FOV2, FOV3", "FOV123", plfile="FOV123_bpm")
fails as you describe.
If you do what I did, do you still have problems?
Thanks, Perry
3/9/2006 10:42:02 AM mcleskey
Reply from pweilbacher@aip.de
Subject: Re: Reply from pweilbacher for CNSHD557262 submitted by pweilbacher regarding IRAF combine task under Python (PyRAF)
To: Perry Greenfield <perry@stsci.edu>
Cc: "<support@stsci.edu>" <support@stsci.edu>
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
--562897975-1650477495-1141918862=:11086
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
Hi Perry,
below your commands I paste the output (in short) that I get.
> Thanks for providing the data and giving more specific information. I'm not
> sure the problem is with the imports or something else. When I try the
> following from ipython
>
> import pyraf
> from pyraf import iraf
> from iraf import mscred
> from iraf import imred
> from iraf imoprt ccdred
> iraf.noao.imred.ccdred.combine("FOV1, FOV2, FOV3", "FOV123", plfile="FOV123_bpm")
IrafError: Cannot find .par file for task combine
> works without any error messages as does:
> iraf.combine("FOV1, FOV2, FOV3", "FOV123", plfile="FOV123_bpm")
KeyError: "Error in parameter 'plfile' for task combine\n'Key plfile not found'"
> though
> iraf.mscred.combine("FOV1, FOV2, FOV3", "FOV123", plfile="FOV123_bpm")
KeyError: "Error in parameter 'plfile' for task combine\n'Key plfile not found'"
> fails as you describe.
>
> If you do what I did, do you still have problems?
Yes, see above. I also attach the full output in case you can tell any
more from that. Let me know if you have an idea, how to find the
difference between our setups.
Cheers,
Peter.
3/9/2006 10:50:02 AM mcleskey
Reply from perry@stsci.edu
Subject: Re: Reply from pweilbacher for CNSHD557262 submitted by pweilbacher regarding IRAF combine task under Python (PyRAF)
To: Peter Weilbacher <pweilbacher@aip.de>
Cc: "<support@stsci.edu>" <support@stsci.edu>
Interesting. What do you get if you type (after imports):
iraf.noao.imred.ccdred.combine._filename
Thanks, Perry
3/9/2006 10:54:12 AM mcleskey
Reply from pweilbacher@aip.de
Subject: Re: Reply from pweilbacher for CNSHD557262 submitted by pweilbacher regarding IRAF combine task under Python (PyRAF)
To: Perry Greenfield <perry@stsci.edu>
Cc: "<support@stsci.edu>" <support@stsci.edu>
On Thu, 9 Mar 2006, Perry Greenfield wrote:
>
> Interesting. What do you get if you type (after imports):
>
> iraf.noao.imred.ccdred.combine._filename
'ccdred$x_ccdred.e'
Peter.
3/9/2006 11:08:14 AM mcleskey
Reply from perry@stsci.edu
Subject: Re: Reply from pweilbacher for CNSHD557262 submitted by pweilbacher regarding IRAF combine task under Python (PyRAF)
To: Peter Weilbacher <pweilbacher@aip.de>
Cc: "<support@stsci.edu>" <support@stsci.edu>
On Mar 9, 2006, at 10:53 AM, Peter Weilbacher wrote:
> 'ccdred$x_ccdred.e'
>
> Peter.
>
That's what it is supposed to be. This was done after restoring your
automatic loading of mscred in your login.cl file, or not? If yes, does
this problem go away again (even if you do the import of mscred from
the command line) if you change the login.cl file to remove its
automatic loading. If yes, can you essentially make the login.cl file
vanilla (minimal difference from the default values (or are you using
loginuser.cl?) to see if the problem goes away? That could help me
track it down to some environmental issue.
Thanks, Perry
3/9/2006 11:36:15 AM mcleskey
Reply from pweilbacher@aip.de
Subject: Re: Reply from pweilbacher for CNSHD557262 submitted by pweilbacher regarding IRAF combine task under Python (PyRAF)
To: Perry Greenfield <perry@stsci.edu>
Cc: "<support@stsci.edu>" <support@stsci.edu>
On Thu, 9 Mar 2006, Perry Greenfield wrote:
>
> On Mar 9, 2006, at 10:53 AM, Peter Weilbacher wrote:
>
>> 'ccdred$x_ccdred.e'
>>
>> Peter.
>>
>
> That's what it is supposed to be. This was done after restoring your
> automatic loading of mscred in your login.cl file, or not? If yes, does this
> problem go away again (even if you do the import of mscred from the command
> line) if you change the login.cl file to remove its automatic loading. If
> yes, can you essentially make the login.cl file vanilla (minimal difference
> from the default values (or are you using loginuser.cl?) to see if the
> problem goes away? That could help me track it down to some environmental
> issue.
Yes, I am using loginuser.cl, the contents of it are listed at the
bottom. As you can see, mscred is currently not preloaded while ccdred
is. If I hash-comment all lines in loginuser.cl everything works as it
should. If I hash-comment only ccdred and mscred I get
import pyraf
from pyraf import iraf
from iraf import mscred
from iraf import imred
from iraf import ccdred
iraf.noao.imred.ccdred.combine._filename
'ccdred$xx_ccdred.e'
iraf.mscred.combine._filename
'combine$x_combine.e'
iraf.combine("FOV1, FOV2, FOV3", "FOV123", plfile="FOV123_bpm")
IrafError: Cannot find executable for task combine
Tried /usr/local/iraf/iraf/noao/bin.suse/xx_ccdred.e, /usr/local/iraf/iraf/../extern/mscred/src/ccdred/xx_ccdred.e
Obviously, x_ccdred.e turns into xx_ccdred.e. Not sure if that's
supposed to be like that.
Peter.
.#
.# Peter's loginuser.cl
.#
task $peter.pkg = "home$iraf/peter.cl"
task $pad.pkg = "home$iraf/pad.cl"
imred
ccdred
.# mscred
digiphot
apphot
onedspec
twodspec
apextract
longslit
stsdas
toolbox
imgtools
headers
tables
ttools
color
peter
3/9/2006 3:56:01 PM mcleskey
Reply from perry@stsci.edu
Subject: Re: Reply from pweilbacher for CNSHD557262 submitted by pweilbacher regarding IRAF combine task under Python (PyRAF)
To: <support@stsci.edu>
Cc:
OK, I'm going to log this as a bug. I have some guesses as to what is
happening (presumably there is some confusion about which parameter
file is supposed to be used, and I will have to track that down). I
can't promise I can fix this quickly but it does look like a real
problem. Thanks for reporting this and taking the time to help me
isolate the issue.
Perry
On Mar 9, 2006, at 11:37 AM, <support@stsci.edu> wrote:
> Reply from pweilbacher for CNSHD557262 submitted by pweilbacher
> regarding IRAF combine task under Python (PyRAF)
>
> Current Call log entry :
>
>
> Reply from pweilbacher@aip.de
>
> Subject: Re: Reply from pweilbacher for CNSHD557262 submitted by
> pweilbacher regarding IRAF combine task under Python (PyRAF)
> To: Perry Greenfield <perry@stsci.edu>
> Cc: "<support@stsci.edu>" <support@stsci.edu>
>
> On Thu, 9 Mar 2006, Perry Greenfield wrote:
>
>>
>> On Mar 9, 2006, at 10:53 AM, Peter Weilbacher wrote:
>>
>>> 'ccdred$x_ccdred.e'
>>>
>>> Peter.
>>>
>>
>> That's what it is supposed to be. This was done after restoring your
>> automatic loading of mscred in your login.cl file, or not? If yes,
>> does this
>> problem go away again (even if you do the import of mscred from the
>> command
>> line) if you change the login.cl file to remove its automatic
>> loading. If
>> yes, can you essentially make the login.cl file vanilla (minimal
>> difference
>> from the default values (or are you using loginuser.cl?) to see if the
>> problem goes away? That could help me track it down to some
>> environmental
>> issue.
>
> Yes, I am using loginuser.cl, the contents of it are listed at the
> bottom. As you can see, mscred is currently not preloaded while
> ccdred
> is. If I hash-comment all lines in loginuser.cl everything works as
> it
> should. If I hash-comment only ccdred and mscred I get
> import pyraf
> from pyraf import iraf
> from iraf import mscred
> from iraf import imred
> from iraf import ccdred
>
> iraf.noao.imred.ccdred.combine._filename
> 'ccdred$xx_ccdred.e'
>
> iraf.mscred.combine._filename
> 'combine$x_combine.e'
>
> iraf.combine("FOV1, FOV2, FOV3", "FOV123", plfile="FOV123_bpm")
> IrafError: Cannot find executable for task combine
> Tried /usr/local/iraf/iraf/noao/bin.suse/xx_ccdred.e,
> /usr/local/iraf/iraf/../extern/mscred/src/ccdred/xx_ccdred.e
>
> Obviously, x_ccdred.e turns into xx_ccdred.e. Not sure if that's
> supposed to be like that.
>
> Peter.
>
>
> .#
> .# Peter's loginuser.cl
> .#
>
> task $peter.pkg = "home$iraf/peter.cl"
> task $pad.pkg = "home$iraf/pad.cl"
>
> imred
> ccdred
> .# mscred
> digiphot
> apphot
>
> onedspec
> twodspec
> apextract
> longslit
>
> stsdas
> toolbox
> imgtools
> headers
> tables
> ttools
>
> color
>
> peter
>
>