Package pyraf :: Module iraffunctions
[hide private]
[frames] | no frames]

Module iraffunctions

source code

module iraffunctions.py -- IRAF emulation tasks and functions

This is not usually used directly -- the relevant public classes and functions get included in iraf.py. The implementations are kept here to avoid possible problems with name conflicts in iraf.py (which is the home for all the IRAF task and package names.) Private routines have names beginning with '_' and do not get imported by the iraf module.

The exception is that iraffunctions can be used directly for modules that must be compiled and executed early, before the pyraf module initialization is complete.

$Id: iraffunctions.py 1319 2010-12-03 21:38:07Z sontag $

R. White, 2000 January 20

Functions [hide private]
 
setVerbose(value=1, **kw)
Set verbosity level when running tasks.
source code
 
_writeError(msg)
Write a message to stderr
source code
 
Init(doprint=1, hush=0, savefile=None)
Basic initialization of IRAF environment
source code
 
_getIrafEnv(file='/usr/local/bin/cl', vars=('IRAFARCH', 'iraf'))
Returns dictionary of environment vars defined in cl startup file
source code
 
saveToFile(savefile, **kw)
Save IRAF environment to pickle file
source code
 
restoreFromFile(savefile, doprint=1, **kw)
Initialize IRAF environment from pickled save file (or file handle)
source code
 
_addPkg(pkg)
Add an IRAF package to the packages list
source code
 
_addTask(task, pkgname=None)
Add an IRAF task to the tasks list
source code
 
handleRedirAndSaveKwds(target)
This decorator is used to consolidate repeated code used in command-line functions, concerning standard pipe redirection.
source code
 
handleRedirAndSaveKwdsPlus(target)
This decorator is used to consolidate repeated code used in command-line functions, concerning standard pipe redirection.
source code
 
addLoaded(pkg)
Add an IRAF package to the loaded pkgs list
source code
 
load(pkgname, args=(), kw=None, doprint=1, hush=0, save=1)
Load an IRAF package by name
source code
 
run(taskname, args=(), kw=None, save=1)
Run an IRAF task by name
source code
 
getAllTasks(taskname)
Returns list of names of all IRAF tasks that may match taskname
source code
 
getAllPkgs(pkgname)
Returns list of names of all IRAF pkgs that may match pkgname
source code
 
getTask(taskname, found=0)
Find an IRAF task by name using minimum match
source code
 
getPkg(pkgname, found=0)
Find an IRAF package by name using minimum match
source code
 
getTaskList()
Returns list of names of all defined IRAF tasks
source code
 
getTaskObjects()
Returns list of all defined IrafTask objects
source code
 
getPkgList()
Returns list of names of all defined IRAF packages
source code
 
getLoadedList()
Returns list of names of all loaded IRAF packages
source code
 
getVarDict()
Returns dictionary all IRAF variables
source code
 
getVarList()
Returns list of names of all IRAF variables
source code
 
listAll(*args, **kw)
List IRAF packages, tasks, and variables
source code
 
listPkgs(*args, **kw)
List IRAF packages
source code
 
listLoaded(*args, **kw)
List loaded IRAF packages
source code
 
listTasks(*args, **kw)
List IRAF tasks, optionally specifying a list of packages to include
source code
 
listCurrent(*args, **kw)
List IRAF tasks in current package (equivalent to '?' in the cl) If parameter n is specified, lists n most recent packages.
source code
 
listVars(*args, **kw)
List IRAF variables
source code
 
gripes(*args, **kw)
Hide the system call - direct the user to support
source code
 
gripe(*args, **kw)
Hide the system call - direct the user to support
source code
 
which(*args, **kw)
Emulate the which function in IRAF.
source code
 
whereis(*args, **kw)
Emulate the whereis function in IRAF.
source code
 
clParGet(paramname, pkg=None, native=1, mode=None, prompt=1)
Return value of IRAF parameter
source code
 
envget(var, default=None)
Get value of IRAF or OS environment variable
source code
 
mktemp(root)
Make a temporary filename starting with root
source code
 
isNullFile(s)
Returns true if this is the CL null file
source code
 
substr(s, first, last)
Return sub-string using IRAF 1-based indexing
source code
 
strlen(s)
Return length of string
source code
 
isindef(s)
Returns true if argument is INDEF
source code
 
stridx(test, s)
Return index of first occurrence of any of the characters in 'test' that are in 's' using IRAF 1-based indexing
source code
 
strldx(test, s)
Return index of last occurrence of any of the characters in 'test' that are in 's' using IRAF 1-based indexing
source code
 
strlwr(s)
Return string converted to lower case
source code
 
strupr(s)
Return string converted to upper case
source code
 
strstr(str1, str2)
Search for first occurrence of 'str1' in 'str2', returns index of the start of 'str1' or zero if not found.
source code
 
strlstr(str1, str2)
Search for last occurrence of 'str1' in 'str2', returns index of the start of 'str1' or zero if not found.
source code
 
trim(str, trimchars=None)
Trim any of the chars in 'trimchars' (default = whitesspace) from both ends of 'str'.
source code
 
triml(str, trimchars=None)
Trim any of the chars in 'trimchars' (default = whitesspace) from the left side of 'str'.
source code
 
trimr(str, trimchars=None)
Trim any of the chars in 'trimchars' (default = whitesspace) from the right side of 'str'.
source code
 
frac(x)
Return fractional part of x
source code
 
real(x)
Return real/float representation of x
source code
 
integer(x)
Return integer representation of x
source code
 
mod(a, b)
Return a modulo b
source code
 
nint(x)
Return nearest integer of x
source code
 
radix(value, base=10, length=0)
Convert integer value to string expressed using given base
source code
 
rad(value)
Convert arg in degrees to radians
source code
 
deg(value)
Convert arg in radians to degrees
source code
 
sin(value)
Trigonometric sine function.
source code
 
asin(value)
Trigonometric arc sine function.
source code
 
cos(value)
Trigonometric cosine function.
source code
 
acos(value)
Trigonometric arc cosine function.
source code
 
tan(value)
Trigonometric tangent function.
source code
 
atan2(x, y)
Trigonometric 2-argument arctangent function.
source code
 
dsin(value)
Trigonometric sine function.
source code
 
dasin(value)
Trigonometric arc sine function.
source code
 
dcos(value)
Trigonometric cosine function.
source code
 
dacos(value)
Trigonometric arc cosine function.
source code
 
dtan(value)
Trigonometric tangent function.
source code
 
datan2(x, y)
Trigonometric 2-argument arctangent function.
source code
 
exp(value)
Exponential function
source code
 
log(value)
Natural log function
source code
 
log10(value)
Base 10 log function
source code
 
sqrt(value)
Square root function
source code
 
absvalue(value)
Absolute value function
source code
 
minimum(*args)
Minimum of list of arguments
source code
 
maximum(*args)
Maximum of list of arguments
source code
 
hypot(x, y)
Return the Euclidean distance, sqrt(x*x + y*y).
source code
 
sign(value)
Sign of argument (-1 or 1)
source code
 
clNot(value)
Bitwise boolean NOT of an integer
source code
 
clAnd(x, y)
Bitwise boolean AND of two integers
source code
 
clOr(x, y)
Bitwise boolean OR of two integers
source code
 
clXor(x, y)
Bitwise eXclusive OR of two integers
source code
 
osfn(filename)
Convert IRAF virtual path name to OS pathname
source code
 
clSexagesimal(d, m, s=0)
Convert d:m:s value to float
source code
 
clDms(x, digits=1, seconds=1)
Convert float to d:m:s.s
source code
 
defpar(paramname)
Returns true if parameter is defined
source code
 
access(filename)
Returns true if file exists
source code
 
fp_equal(x, y)
Floating point compare to within machine precision.
source code
 
_fp_norm(x)
Normalize a floating point number x to the value normx, in the range [1-10).
source code
 
_denode(filename)
Remove IRAF "node!" specification from filename
source code
 
_imextn()
Returns list of image types and extensions
source code
 
_checkext(ext, extlist)
Returns image type if ext is in extlist, else returns None
source code
 
_searchext(root, extlist)
Returns image type if file root.ext is found (ext from extlist)
source code
 
imaccess(filename)
Returns true if image matching name exists and is readable
source code
 
defvar(varname)
Returns true if CL variable is defined
source code
 
deftask(taskname)
Returns true if CL task is defined
source code
 
defpac(pkgname)
Returns true if CL package is defined and loaded
source code
 
curpack()
Returns name of current CL package
source code
 
curPkgbinary()
Returns name pkgbinary directory for current CL package
source code
 
bool2str(value)
Convert IRAF boolean value to a string
source code
 
boolean(value)
Convert Python native types (string, int, float) to IRAF boolean
source code
 
fscan(locals, line, *namelist, **kw)
fscan function sets parameters from a string or list parameter
source code
 
fscanf(locals, line, format, *namelist, **kw)
fscanf function sets parameters from a string/list parameter with format
source code
 
_weirdEOF(locals, namelist) source code
 
_isStruct(locals, name, checklegal=0)
Returns true if the variable `name' is of type struct
source code
 
scan(locals, *namelist, **kw)
Scan function sets parameters from line read from stdin
source code
 
scanf(locals, format, *namelist, **kw)
Formatted scan function sets parameters from line read from stdin
source code
 
nscan()
Return number of items read in last scan function
source code
 
set(*args, **kw)
Set IRAF environment variables
source code
 
reset(*args, **kw)
Set IRAF environment variables
source code
 
show(*args, **kw)
Print value of IRAF or OS environment variables
source code
 
unset(*args, **kw)
Unset IRAF environment variables.
source code
 
time(*args, **kw)
Print current time and date
source code
 
sleep(*args, **kw)
Sleep for specified time
source code
 
beep(**kw)
Beep to terminal (even if output is redirected)
source code
 
clOscmd(s, **kw)
Execute a system-dependent command in the shell, returning status
source code
 
stty(*args, **kw)
IRAF stty command (mainly not implemented)
source code
 
eparam(*args, **kw)
Edit parameters for tasks.
source code
 
tparam(*args, **kw)
Edit parameters for tasks.
source code
 
lparam(*args, **kw)
List parameters for tasks
source code
 
dparam(*args, **kw)
Dump parameters for task in executable form
source code
 
update(*args, **kw)
Update task parameters on disk
source code
 
unlearn(*args, **kw)
Unlearn task parameters -- restore to defaults
source code
 
teal(*args, **kw)
Call the TEAL GUI but use simple-auto-close mode (like EPAR) by setting returnDict=False.
source code
 
edit(*args, **kw)
Edit text files
source code
 
clear(*args, **kw)
Clear screen if output is terminal
source code
 
flprcache(*args, **kw)
Flush process cache.
source code
 
prcacheOff(*args, **kw)
Disable process cache.
source code
 
prcacheOn(*args, **kw)
Re-enable process cache.
source code
 
prcache(*args, **kw)
Print process cache.
source code
 
gflush(*args, **kw)
Flush any buffered graphics output.
source code
 
pyexecute(*args, **kw)
Execute python code in filename (which may include IRAF path).
source code
 
history(*args, **kw)
Print history.
source code
 
ehistory(*args, **kw)
Dummy history function
source code
 
clNoBackground(*args, **kw)
Dummy background function
source code
 
wait(*args, **kw)
Dummy background function
source code
 
kill(*args, **kw)
Dummy background function
source code
 
service(*args, **kw)
Dummy background function
source code
 
jobs(*args, **kw)
Dummy background function
source code
 
clDummy(*args, **kw)
Dummy do-nothing function
source code
 
language(*args, **kw)
Dummy do-nothing function
source code
 
cache(*args, **kw)
Dummy do-nothing function
source code
 
clbye(*args, **kw)
Dummy do-nothing function
source code
 
logout(*args, **kw)
Dummy do-nothing function
source code
 
keep(*args, **kw)
Dummy do-nothing function
source code
 
bye(*args, **kw)
Dummy do-nothing function
source code
 
_notImplemented(cmd)
Dummy unimplemented function
source code
 
putlog(*args, **kw) source code
 
clAllocate(*args, **kw) source code
 
clDeallocate(*args, **kw) source code
 
clDevstatus(*args, **kw) source code
 
fprint(*args, **kw)
Error unimplemented function
source code
 
pkgHelp(*args, **kw)
Give help on package (equivalent to CL '? [taskname]')
source code
 
allPkgHelp(*args, **kw)
Give help on all packages (equivalent to CL '??')
source code
 
_clProcedure(*args, **kw)
Core function for the CL task
source code
 
clProcedure(input=None, mode='', DOLLARnargs=0, **kw)
Run CL commands from a file (cl < input) -- OBSOLETE
source code
 
hidetask(*args, **kw)
Hide the CL task in package listings
source code
 
task(*args, **kw)
Define IRAF tasks
source code
 
redefine(*args, **kw)
Redefine an existing task
source code
 
package(pkgname=None, bin=None, PkgName='', PkgBinary='', **kw)
Define IRAF package, returning tuple with new package name and binary
source code
 
clPrint(*args, **kw)
CL print command -- emulates CL spacing and uses redirection keywords
source code
 
_quietConv(w, d, c, args, i)
Format codes that are quietly converted to %s
source code
 
_boolConv(w, d, c, args, i)
Boolean gets converted to upper case before printing
source code
 
_badConv(w, d, c, args, i)
Format codes that are converted to %s with warning
source code
 
_hConv(w, d, c, args, i)
Handle %h %m %H %M dd:mm:ss.s formats
source code
 
_rConv(w, d, c, args, i)
Handle W.DrN general radix format
source code
 
_wConv(w, d, c, args, i)
Handle %w format, which is supposed to generate spaces
source code
 
printf(*args, **kw)
Formatted print function
source code
 
pwd(*args, **kw)
Print working directory
source code
 
chdir(*args, **kw)
Change working directory
source code
 
cd(*args, **kw)
Change working directory
source code
 
back(*args, **kw)
Go back to previous working directory
source code
 
error(errno=0, errmsg='', task='error', _save=False, suppress=True)
Print error message
source code
 
errno(_save=None)
Returns status from last call to error()
source code
 
errcode(_save=None)
Returns status from last call to error()
source code
 
errmsg(_save=None)
Returns message from last call to error()
source code
 
errtask(_save=None)
Returns task from last call to error()
source code
 
clCompatibilityMode(verbose=0, _save=0)
Start up full CL-compatibility mode
source code
 
clArray(array_size, datatype, name='<anonymous>', mode='h', min=None, max=None, enum=None, prompt=None, init_value=None, strict=0)
Create an IrafPar object that can be used as a CL array
source code
 
clExecute(s, locals=None, mode='proc', local_vars_dict={}, local_vars_list=[], verbose=0, **kw)
Execute a single cl statement
source code
 
clLineToPython(line)
Returns the Python code corresponding to a single cl statement.
source code
 
Expand(instring, noerror=0)
Expand a string with embedded IRAF variables (IRAF virtual filename)
source code
 
_expand1(instring, noerror)
Expand a string with embedded IRAF variables (IRAF virtual filename)
source code
 
IrafTaskFactory(prefix='', taskname=None, suffix='', value=None, pkgname=None, pkgbinary=None, redefine=0, function=None)
Returns a new or existing IrafTask, IrafPset, or IrafPkg object
source code
 
IrafPsetFactory(prefix, taskname, suffix, value, pkgname, pkgbinary, redefine=0)
Returns a new or existing IrafPset object
source code
 
IrafPkgFactory(prefix, taskname, suffix, value, pkgname, pkgbinary, redefine=0)
Returns a new or existing IrafPkg object
source code
 
redirProcess(kw)
Process Stdout, Stdin, Stderr keywords used for redirection
source code
 
redirApply(redirKW)
Modify _sys.stdin, stdout, stderr using the redirKW dictionary
source code
 
redirReset(resetList, closeFHList)
Restore _sys.stdin, stdout, stderr to their original values
source code
Variables [hide private]
  BITS_PER_LONG = 64
  FP_EPSILON = 2.2204460492503131e-16
  _varDict = {'arch': '.redhat', 'artdata': 'noao$artdata/', 'as...
  _tasks = {'clpackage._logout': <IrafCLTask _logout (home$logou...
  _mmtasks = {'wcslab': 'tv.wcslab', 'noao': 'clpackage.noao', '...
  _pkgs = {'noao': <IrafPkg noao (noao$noao.cl) Pkg: clpackage B...
  _loaded = {'clpackage': 0, 'dataio': 12, 'images': 4, 'imcoord...
  loadedPath = [<IrafPkg clpackage (hlib$clpackage.cl) Pkg: clpa...
  cl = <IrafPythonTask cl (cl$cl.par) Pkg: clpackage Bin: bin$ H...
  _unsavedVarsDict = {'BITS_PER_LONG': 1, 'EOF': 1, 'FP_EPSILON'...
  _tmpfileCounter = 0
  _NullFileList = ['dev$null', '/dev/null']
  _NullPath = None
  _radixDigits = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '...
  _denode_pat = re.compile(r'[^/]*!')
  _nscan = 0
  _sttyArgs = {'baud': 9600, 'reset': no, 'all': no, 'ncols': 80...
  _clearString = '\x1b[H\x1b[2J'
  _re_taskname = re.compile(r'(?:(?P<taskprefix>\$?)(?P<taskname...
  _reFormat = re.compile(r'%(?P<w>-?\d*)(?P<d>(?:\.\d*)?)(?P<c>[...
  _fDispatch = {}
  _backDir = None
  _exitCommands = {'.exit': 1, 'exit': 1, 'logout': 1, 'quit': 1}
  _clExecuteCount = 0
  __re_var_match = re.compile(r'(?P<varname>[^\$]*)\$')
  __re_var_paren = re.compile(r'\((?P<varname>[^\(\)]*)\)')
  __package__ = 'pyraf'
  clpkg = <IrafPkg clpackage (hlib$clpackage.cl) Pkg: clpackage ...

Imports: IrafPkg, Verbose, no, epsilon, IrafTask, userWorkingHome, IrafError, userIrafHome, yes, INDEF, EOF, SubprocessError, iraf, gki, irafecl, sscanf, cPickle, _sys, _os, _string, _re, _math, _struct, _types, _time, _fnmatch, _glob, _tempfile, _linecache, _StringIO, _pickle, _numpy, _minmatch, _teal, _subproc, _wutil, _irafnames, _irafutils, _irafinst, _iraftask, _irafpar, _irafexecute, _cl2py, help


Function Details [hide private]

setVerbose(value=1, **kw)

source code 

Set verbosity level when running tasks. Level 0 (default) prints almost nothing. Level 1 prints warnings. Level 2 prints info on progress. This accepts **kw so it can be used on the PyRAF command-line. This cannot avail itself of the decorator which wraps redirProcess since it needs to be defined here up front.

saveToFile(savefile, **kw)

source code 

Save IRAF environment to pickle file

savefile may be a filename or a file handle. Set clobber keyword (or CL environment variable) to overwrite an existing file.

handleRedirAndSaveKwds(target)

source code 

This decorator is used to consolidate repeated code used in command-line functions, concerning standard pipe redirection. Typical 'target' functions will: take 0 or more positional arguments, take NO keyword args (except redir's & _save), and return nothing.

handleRedirAndSaveKwdsPlus(target)

source code 

This decorator is used to consolidate repeated code used in command-line functions, concerning standard pipe redirection. Typical 'target' functions will: take 0 or more positional arguments, take AT LEAST ONE keyword arg (not including redir's & _save), and return nothing.

getTask(taskname, found=0)

source code 

Find an IRAF task by name using minimum match

Returns an IrafTask object. Name may be either fully qualified (package.taskname) or just the taskname. taskname is also allowed to be an IrafTask object, in which case it is simply returned. Does minimum match to allow abbreviated names. If found is set, returns None when task is not found; default is to raise exception if task is not found.

getPkg(pkgname, found=0)

source code 

Find an IRAF package by name using minimum match

Returns an IrafPkg object. pkgname is also allowed to be an IrafPkg object, in which case it is simply returned. If found is set, returns None when package is not found; default is to raise exception if package is not found.

listAll(*args, **kw)

source code 

List IRAF packages, tasks, and variables

Decorators:
  • @handleRedirAndSaveKwds

listPkgs(*args, **kw)

source code 

List IRAF packages

Decorators:
  • @handleRedirAndSaveKwds

listLoaded(*args, **kw)

source code 

List loaded IRAF packages

Decorators:
  • @handleRedirAndSaveKwds

listTasks(*args, **kw)

source code 

List IRAF tasks, optionally specifying a list of packages to include

Package(s) may be specified by name or by IrafPkg objects.

Decorators:
  • @handleRedirAndSaveKwdsPlus

listCurrent(*args, **kw)

source code 

List IRAF tasks in current package (equivalent to '?' in the cl) If parameter n is specified, lists n most recent packages.

Decorators:
  • @handleRedirAndSaveKwds

listVars(*args, **kw)

source code 

List IRAF variables

Decorators:
  • @handleRedirAndSaveKwdsPlus

gripes(*args, **kw)

source code 

Hide the system call - direct the user to support

Decorators:
  • @handleRedirAndSaveKwds

gripe(*args, **kw)

source code 

Hide the system call - direct the user to support

Decorators:
  • @handleRedirAndSaveKwds

which(*args, **kw)

source code 

Emulate the which function in IRAF.

Decorators:
  • @handleRedirAndSaveKwds

whereis(*args, **kw)

source code 

Emulate the whereis function in IRAF.

Decorators:
  • @handleRedirAndSaveKwds

clParGet(paramname, pkg=None, native=1, mode=None, prompt=1)

source code 

Return value of IRAF parameter

Parameter can be a cl task parameter, a package parameter for any loaded package, or a fully qualified (task.param) parameter from any known task.

strstr(str1, str2)

source code 

Search for first occurrence of 'str1' in 'str2', returns index of the start of 'str1' or zero if not found. IRAF 1-based indexing

strlstr(str1, str2)

source code 

Search for last occurrence of 'str1' in 'str2', returns index of the start of 'str1' or zero if not found. IRAF 1-based indexing

radix(value, base=10, length=0)

source code 

Convert integer value to string expressed using given base

If length is given, field is padded with leading zeros to reach length. Note that if value is negative, this routine returns the actual bit-pattern of the twos-complement integer (even for base 10) rather than a signed value. This is consistent with IRAF's behavior.

sin(value)

source code 

Trigonometric sine function. Input in radians.

asin(value)

source code 

Trigonometric arc sine function. Result in radians.

cos(value)

source code 

Trigonometric cosine function. Input in radians.

acos(value)

source code 

Trigonometric arc cosine function. Result in radians.

tan(value)

source code 

Trigonometric tangent function. Input in radians.

atan2(x, y)

source code 

Trigonometric 2-argument arctangent function. Result in radians.

dsin(value)

source code 

Trigonometric sine function. Input in degrees.

dasin(value)

source code 

Trigonometric arc sine function. Result in degrees.

dcos(value)

source code 

Trigonometric cosine function. Input in degrees.

dacos(value)

source code 

Trigonometric arc cosine function. Result in degrees.

dtan(value)

source code 

Trigonometric tangent function. Input in degrees.

datan2(x, y)

source code 

Trigonometric 2-argument arctangent function. Result in degrees.

clDms(x, digits=1, seconds=1)

source code 

Convert float to d:m:s.s

Number of decimal places on seconds is set by digits. If seconds is false, prints just d:m.m (omits seconds).

fp_equal(x, y)

source code 

Floating point compare to within machine precision. This logic is taken directly from IRAF's fp_equald function.

_fp_norm(x)

source code 

Normalize a floating point number x to the value normx, in the range [1-10). expon is returned such that: x = normx * (10.0 ** expon) This logic is taken directly from IRAF's fp_normd function.

_imextn()

source code 

Returns list of image types and extensions

The return value is (ktype, globlist) where ktype is the image kernel (oif, fxf, etc.) and globlist is a list of glob-style patterns that match extensions.

_checkext(ext, extlist)

source code 

Returns image type if ext is in extlist, else returns None

Assumes ext starts with a '.' (as returned by os.path.split) and that null extensions can't match.

boolean(value)

source code 

Convert Python native types (string, int, float) to IRAF boolean

Accepts integer/float values 0,1 or string 'yes','no' Also allows INDEF as value

fscan(locals, line, *namelist, **kw)

source code 

fscan function sets parameters from a string or list parameter

Uses local dictionary (passed as first argument) to set variables specified by list of following names. (This is a bit messy, but it is by far the cleanest approach I've thought of. I'm literally using call-by-name for these variables.)

Accepts an additional keyword argument strconv with names of conversion functions for each argument in namelist.

Returns number of arguments set to new values, which may be fewer than the number of variables if an unexpected character is encountered in 'line'. If there are too few space-delimited arguments on the input line, it does not set all the arguments. Returns EOF on end-of-file.

fscanf(locals, line, format, *namelist, **kw)

source code 

fscanf function sets parameters from a string/list parameter with format

Implementation is similar to fscan but is a bit simpler because special struct handling is not needed. Does not allow strconv keyword.

Returns number of arguments set to new values, which may be fewer than the number of variables if an unexpected character is encountered in 'line'. If there are too few space-delimited arguments on the input line, it does not set all the arguments. Returns EOF on end-of-file.

_isStruct(locals, name, checklegal=0)

source code 

Returns true if the variable `name' is of type struct

If checklegal is true, returns true only if variable is struct and does not currently have a legal value.

scan(locals, *namelist, **kw)

source code 

Scan function sets parameters from line read from stdin

This can be used either as a function or as a task (it accepts redirection and the _save keyword.)

scanf(locals, format, *namelist, **kw)

source code 

Formatted scan function sets parameters from line read from stdin

This can be used either as a function or as a task (it accepts redirection and the _save keyword.)

set(*args, **kw)

source code 

Set IRAF environment variables

Decorators:
  • @handleRedirAndSaveKwdsPlus

reset(*args, **kw)

source code 

Set IRAF environment variables

Decorators:
  • @handleRedirAndSaveKwdsPlus

show(*args, **kw)

source code 

Print value of IRAF or OS environment variables

Decorators:
  • @handleRedirAndSaveKwds

unset(*args, **kw)

source code 

Unset IRAF environment variables. This is not a standard IRAF task, but it is obviously useful. It makes the resulting variables undefined. It silently ignores variables that are not defined. It does not change the os environment variables.

Decorators:
  • @handleRedirAndSaveKwds

time(*args, **kw)

source code 

Print current time and date

Decorators:
  • @handleRedirAndSaveKwds

sleep(*args, **kw)

source code 

Sleep for specified time

Decorators:
  • @handleRedirAndSaveKwds

stty(*args, **kw)

source code 

IRAF stty command (mainly not implemented)

Decorators:
  • @handleRedirAndSaveKwdsPlus

eparam(*args, **kw)

source code 

Edit parameters for tasks. Starts up epar GUI.

Decorators:
  • @handleRedirAndSaveKwds

tparam(*args, **kw)

source code 

Edit parameters for tasks. Starts up epar GUI.

Decorators:
  • @handleRedirAndSaveKwds

lparam(*args, **kw)

source code 

List parameters for tasks

Decorators:
  • @handleRedirAndSaveKwds

dparam(*args, **kw)

source code 

Dump parameters for task in executable form

Decorators:
  • @handleRedirAndSaveKwdsPlus

update(*args, **kw)

source code 

Update task parameters on disk

Decorators:
  • @handleRedirAndSaveKwds

unlearn(*args, **kw)

source code 

Unlearn task parameters -- restore to defaults

Decorators:
  • @handleRedirAndSaveKwds

teal(*args, **kw)

source code 

Call the TEAL GUI but use simple-auto-close mode (like EPAR) by setting returnDict=False. This call will return nothing.

Decorators:
  • @handleRedirAndSaveKwdsPlus

edit(*args, **kw)

source code 

Edit text files

Decorators:
  • @handleRedirAndSaveKwds

clear(*args, **kw)

source code 

Clear screen if output is terminal

Decorators:
  • @handleRedirAndSaveKwds

flprcache(*args, **kw)

source code 

Flush process cache. Takes optional list of tasknames.

Decorators:
  • @handleRedirAndSaveKwds

prcacheOff(*args, **kw)

source code 

Disable process cache. No process cache will be employed for the rest of this session.

Decorators:
  • @handleRedirAndSaveKwds

prcacheOn(*args, **kw)

source code 

Re-enable process cache. A process cache will again be employed for the rest of this session. This may be useful after prcacheOff().

Decorators:
  • @handleRedirAndSaveKwds

prcache(*args, **kw)

source code 

Print process cache. If args are given, locks tasks into cache.

Decorators:
  • @handleRedirAndSaveKwds

gflush(*args, **kw)

source code 

Flush any buffered graphics output.

Decorators:
  • @handleRedirAndSaveKwds

pyexecute(*args, **kw)

source code 

Execute python code in filename (which may include IRAF path). This is callable from within CL scripts. There is a corresponding pyexecute.cl task that runs outside the PyRAF environment and just prints a warning.

Decorators:
  • @handleRedirAndSaveKwdsPlus

history(*args, **kw)

source code 

Print history. Does not replicate the IRAF behavior of changing default number of lines to print. (That seems fairly useless to me.)

Decorators:
  • @handleRedirAndSaveKwds

ehistory(*args, **kw)

source code 

Dummy history function

Decorators:
  • @handleRedirAndSaveKwds

clNoBackground(*args, **kw)

source code 

Dummy background function

Decorators:
  • @handleRedirAndSaveKwdsPlus

wait(*args, **kw)

source code 

Dummy background function

Decorators:
  • @handleRedirAndSaveKwdsPlus

kill(*args, **kw)

source code 

Dummy background function

Decorators:
  • @handleRedirAndSaveKwdsPlus

service(*args, **kw)

source code 

Dummy background function

Decorators:
  • @handleRedirAndSaveKwdsPlus

jobs(*args, **kw)

source code 

Dummy background function

Decorators:
  • @handleRedirAndSaveKwdsPlus

putlog(*args, **kw)

source code 
Decorators:
  • @handleRedirAndSaveKwdsPlus

clAllocate(*args, **kw)

source code 
Decorators:
  • @handleRedirAndSaveKwdsPlus

clDeallocate(*args, **kw)

source code 
Decorators:
  • @handleRedirAndSaveKwdsPlus

clDevstatus(*args, **kw)

source code 
Decorators:
  • @handleRedirAndSaveKwdsPlus

pkgHelp(*args, **kw)

source code 

Give help on package (equivalent to CL '? [taskname]')

Decorators:
  • @handleRedirAndSaveKwds

allPkgHelp(*args, **kw)

source code 

Give help on all packages (equivalent to CL '??')

Decorators:
  • @handleRedirAndSaveKwds

_clProcedure(*args, **kw)

source code 

Core function for the CL task

Gets passed to IrafPythonTask as function argument. Note I/O redirection has already been set up before calling this.

clProcedure(input=None, mode='', DOLLARnargs=0, **kw)

source code 

Run CL commands from a file (cl < input) -- OBSOLETE

This is obsolete, replaced by the IrafPythonTask version of the cl, using above _clProcedure function. It is being retained only for backward compatibility since translated versions of CL scripts could use it. New versions will not use it. Also, this cannot use handleRedirAndSaveKwds.

hidetask(*args, **kw)

source code 

Hide the CL task in package listings

Decorators:
  • @handleRedirAndSaveKwds

task(*args, **kw)

source code 

Define IRAF tasks

Decorators:
  • @handleRedirAndSaveKwdsPlus

package(pkgname=None, bin=None, PkgName='', PkgBinary='', **kw)

source code 

Define IRAF package, returning tuple with new package name and binary

PkgName, PkgBinary are old default values. If Stdout=1 is specified, returns output as string array (normal task behavior) instead of returning PkgName, PkgBinary. This inconsistency is necessary to replicate the inconsistent behavior of the package command in IRAF.

clPrint(*args, **kw)

source code 

CL print command -- emulates CL spacing and uses redirection keywords

Decorators:
  • @handleRedirAndSaveKwds

printf(*args, **kw)

source code 

Formatted print function

Decorators:
  • @handleRedirAndSaveKwds

pwd(*args, **kw)

source code 

Print working directory

Decorators:
  • @handleRedirAndSaveKwds

chdir(*args, **kw)

source code 

Change working directory

Decorators:
  • @handleRedirAndSaveKwds

cd(*args, **kw)

source code 

Change working directory

Decorators:
  • @handleRedirAndSaveKwds

back(*args, **kw)

source code 

Go back to previous working directory

Decorators:
  • @handleRedirAndSaveKwds

Expand(instring, noerror=0)

source code 

Expand a string with embedded IRAF variables (IRAF virtual filename)

Allows comma-separated lists. Also uses os.path.expanduser to replace '~' symbols. Set noerror flag to silently replace undefined variables with just the variable name or null (so Expand('abc$def') = 'abcdef' and Expand('(abc)def') = 'def'). This is the IRAF behavior, though it is confusing and hides errors.

IrafTaskFactory(prefix='', taskname=None, suffix='', value=None, pkgname=None, pkgbinary=None, redefine=0, function=None)

source code 

Returns a new or existing IrafTask, IrafPset, or IrafPkg object

Type of returned object depends on value of suffix and value.

Returns a new object unless this task or package is already defined. In that case if the old task appears consistent with the new task, a reference to the old task is returned. Otherwise a warning is printed and a reference to a new task is returned.

If redefine keyword is set, the behavior is the same except a warning is printed if it does *not* exist.

IrafPsetFactory(prefix, taskname, suffix, value, pkgname, pkgbinary, redefine=0)

source code 

Returns a new or existing IrafPset object

Returns a new object unless this task is already defined. In that case if the old task appears consistent with the new task, a reference to the old task is returned. Otherwise a warning is printed and a reference to a new task is returned.

If redefine keyword is set, the behavior is the same except a warning is printed if it does *not* exist.

IrafPkgFactory(prefix, taskname, suffix, value, pkgname, pkgbinary, redefine=0)

source code 

Returns a new or existing IrafPkg object

Returns a new object unless this package is already defined, in which case a warning is printed and a reference to the existing task is returned. Redefine parameter currently ignored.

Returns a new object unless this package is already defined. In that case if the old package appears consistent with the new package, a reference to the old package is returned. Else if the old package has already been loaded, a warning is printed and the redefinition is ignored. Otherwise a warning is printed and a reference to a new package is returned.

If redefine keyword is set, the behavior is the same except a warning is printed if it does *not* exist.

redirProcess(kw)

source code 

Process Stdout, Stdin, Stderr keywords used for redirection

Removes the redirection keywords from kw Returns (redirKW, closeFHList) which are a dictionary of the filehandles for stdin, stdout, stderr and a list of filehandles to close after execution.

Image and Stdplot redirection not handled (but it isn't clear that these are ever used anyway)

redirApply(redirKW)

source code 

Modify _sys.stdin, stdout, stderr using the redirKW dictionary

Returns a list of the original filehandles so they can be restored (by redirReset)

redirReset(resetList, closeFHList)

source code 

Restore _sys.stdin, stdout, stderr to their original values

Also closes the filehandles in closeFHList. If a tuple with a StringIO pipe is included in closeFHList, that means the value should be returned as the return value of the function. Returns an array of lines (without newlines.)


Variables Details [hide private]

_varDict

Value:
{'arch': '.redhat',
 'artdata': 'noao$artdata/',
 'as': 'host$as/',
 'astcat': 'noao$astcat/',
 'astrometry': 'noao$astrometry/',
 'astutil': 'noao$astutil/',
 'bin': 'iraf$bin(arch)/',
 'boot': 'host$boot/',
...

_tasks

Value:
{'clpackage._logout': <IrafCLTask _logout (home$logout.cl) Pkg: clpack\
age Bin: bin$ Hidden No parfile>,
 'clpackage.apropos': <IrafCLTask apropos (stsdas$apropos.cl) Pkg: clp\
ackage Bin: bin$>,
 'clpackage.cl': <IrafPythonTask cl (cl$cl.par) Pkg: clpackage Bin: bi\
n$ Hidden>,
 'clpackage.clpackage': <IrafPkg clpackage (hlib$clpackage.cl) Pkg: cl\
package Bin: bin$>,
...

_mmtasks

Value:
{'wcslab': 'tv.wcslab', 'noao': 'clpackage.noao', 'xregister': 'immatc\
h.xregister', 'help': 'system.help', 'diskspace': 'system.diskspace', \
'less': 'user.less', 'xyxymatch': 'immatch.xyxymatch', 'ndwfsget': 'cl\
package.ndwfsget', 'lcase': 'utilities.lcase', 'crtpict': 'plot.crtpic\
t', 'blkrep': 'imgeom.blkrep', 'dbx': 'user.dbx', 'gdb': 'user.gdb', '\
reblock': 'dataio.reblock', 'gmisc': 'clpackage.gmisc', 'mtlocal': 'no\
ao.mtlocal', 'touch': 'system.touch', 'chpixtype': 'imutil.chpixtype',\
 'imexamine': 'tv.imexamine', 'ccget': 'imcoords.ccget', 'pcols': 'plo\
...

_pkgs

Value:
{'noao': <IrafPkg noao (noao$noao.cl) Pkg: clpackage Bin: bin$>, 'colo\
r': <IrafPkg color (color$color.cl) Pkg: clpackage Bin: bin$>, 'imfilt\
er': <IrafPkg imfilter (imfilter$imfilter.cl) Pkg: images Bin: bin$>, \
'dataio': <IrafPkg dataio (dataio$dataio.cl) Pkg: clpackage Bin: bin$>\
, 'astrometry': <IrafPkg astrometry (astrometry$astrometry.cl) Pkg: no\
ao Bin: noaobin$>, 'obsolete': <IrafPkg obsolete (obsolete$obsolete.cl\
) Pkg: clpackage Bin: bin$>, 'gemini': <IrafPkg gemini (gemini$gemini.\
cl) Pkg: clpackage Bin: bin$>, 'gmisc': <IrafPkg gmisc (gmisc$gmisc.cl\
...

_loaded

Value:
{'clpackage': 0,
 'dataio': 12,
 'images': 4,
 'imcoords': 5,
 'imfilter': 6,
 'imfit': 7,
 'imgeom': 8,
 'immatch': 9,
...

loadedPath

Value:
[<IrafPkg clpackage (hlib$clpackage.cl) Pkg: clpackage Bin: bin$>,
 <IrafPkg system (system$system.cl) Pkg: clpackage Bin: bin$>,
 <IrafPkg lists (lists$lists.cl) Pkg: clpackage Bin: bin$>,
 <IrafPkg system (system$system.cl) Pkg: clpackage Bin: bin$>,
 <IrafPkg clpackage (hlib$clpackage.cl) Pkg: clpackage Bin: bin$>,
 <IrafPkg user (home$login.cl) Pkg: clpackage Bin: bin$>,
 <IrafPkg clpackage (hlib$clpackage.cl) Pkg: clpackage Bin: bin$>,
 <IrafPkg user (home$login.cl) Pkg: clpackage Bin: bin$>,
...

cl

Value:
<IrafPythonTask cl (cl$cl.par) Pkg: clpackage Bin: bin$ Hidden>

_unsavedVarsDict

Value:
{'BITS_PER_LONG': 1,
 'EOF': 1,
 'FP_EPSILON': 1,
 'IrafError': 1,
 'IrafPkg': 1,
 'IrafTask': 1,
 'SubprocessError': 1,
 '_NullFileList': 1,
...

_radixDigits

Value:
['0',
 '1',
 '2',
 '3',
 '4',
 '5',
 '6',
 '7',
...

_sttyArgs

Value:
{'baud': 9600, 'reset': no, 'all': no, 'ncols': 80, 'show': no, 'verif\
y': no, 'clear': no, 'playback': None, 'ucaseout': no, 'terminal': Non\
e, 'delay': 500, 'logout': None, 'ucasein': no, 'login': None, 'logio'\
: None, 'nlines': 24, 'resize': no}

_re_taskname

Value:
re.compile(r'(?:(?P<taskprefix>\$?)(?P<taskname>[a-zA-Z_][a-zA-Z0-9_]*\
)(?P<tasksuffix>\.(?:pkg|tb))?,?[ \t]*)')

_reFormat

Value:
re.compile(r'%(?P<w>-?\d*)(?P<d>(?:\.\d*)?)(?P<c>[a-zHM])')

clpkg

Value:
<IrafPkg clpackage (hlib$clpackage.cl) Pkg: clpackage Bin: bin$>