This HTML automatically generated with rman for NEMO
Table of Contents

Name

ccdmath - map arithmetic using function expressions

Synopsis

ccdmath in=[image1[,image2,...]] out=image fie=expression

Description

ccdmath combines maps through some simple operations to make a new map. It also handles a few arithmetic functions, such as sqrt, exp, log10. See fie(3NEMO) for a full definition of the available functions and operations. Input maps are referred to by %n, where n is the ordinal number of the input maps (1 being the first one), in the function expression fie. For example %1+%2 would add the first two maps.

The program can also be used in creation mode: when no input files are given, parameters %x, %y and %z in fie= can be used to refer to the X, Y and Z pixel coordinates in the map to be created, (0,0,0) in pixel coordinates w.r.t. reference pixel. %w and %r can be used for 2D and 3D radius w.r.t. reference pixel, again in pixel coordinates.

Parameters

The following parameters are recognized in any order if the keyword is also given:
in=in-file(s)
list of input file name(s), each in image(5NEMO) format. In case of multiple files, the list must be space or comma separated. If no files are given, the program is in creation mode.
out=out-file
output file, will be in Image(5NEMO) format. The image header (WCS etc.) will be inherited from the first map on the input list. [no default]
fie=expression
Expression how to manipulate the input maps or create output map. Input maps are referred to by %n or $n, in creation mode position is referred to by %x and %y [no default].
size=nx,ny,nz
Size of the output map in case program is in creation mode [default: 10,10,1].
crpix=r1,r2,r3
(New) values for the reference pixel. Note these are in FITS notation, i.e. (1,1,1) is the lower left of the first plane in a cube. Recall that (nx+1)/2 is the central pixel in coordinate X, not nx/2! By default the WCS is transferred from the first input image to the output image, however, by using all 3 keywords crpix=,crval=,cdelt= the WCS of the output image can be overwritten. [Default: 1,1,1 for image creation].
crval=r1,r2,r3
(New) values for the reference pixel. [Default: 0,0,0 for image creation].
cdelt=r1,r2,r3
(New) values for the pixel separation. [Default: 1,1,1 for image creation].
seed=integer
seed for the random number generator (default: a value 0, which will be converted into a unique new value using UNIX’s clock time, in seconds since once-upon-a-time-in-the-seventies).
replicate=t|f
Normally each input image needs to be of the same shape. Setting replicate=t will allow the 3rd axis of a 2D map to be replicated in order for the fie= expression to be parsed. Default: false

Example

Create a ’difference’ map from two input maps:
   % ccdmath inmap1,inmap2 outmap "abs(%1-%2)"
create the maximum of two maps:
   % ccdmath inmap1,inmap2 outmap "ifgt(%1,%2,%1,%2)"
create the difference of two maps if either of the two is not zero:
   % ccdmath inmap1,inmap2 outmap "ifne(%1,0,%1-%2,ifne(%2,0,%1-%2,0))"
create a map from scratch:
  % ccdmath out=newmap fie="exp(-((%x-50)/25)**2-((%y-50)/25)**2)" size=100,100
create a (2 plane 4x3 image) cube from scratch:
  % ccdmath "" cube432 "%x+10*%y+100*%z" 4,3,2
create a new WCS for an existing cube, with reference value (0,0,0) in the center of the cube, assuming you know the size of the cube (nx,ny,nz) and pixel sizes (dx,dy,dz):
  % ccdmath cube0 cube1 %1 crpix=$nx/2+0.5,$ny/2+0.5,$nz/2+0.5 crval=0,0,0
cdelt=$dx,$dy,$dz
and creating an annulus:
  %  ccdmath "" map0 "ifgt(%w,20,1,iflt(%w,10,1,0))" size=512 crpix=256,256
Rescaling a map to a linear-log, retaining linear near 0, and logarithmic in signal/noise for large values from the mean:
  set s = 0.19
  cddmath map0 map0s "sign(%1)*$s*log(1+abs(%1)/$s)"
A test cube234.fits with value x + 10y + 100z can be made as follows:
  ccdmath out=- fie=%x+10*%y+100*%z size=2,3,4 | ccdfits - cube234.fits

Timing

Performance on Rigel (SUN 3/160, 16Mhz):


100 * 100    rang: 5.8"    +: 3.4"      sqrt: 2.6"
200 * 200    rang: 23.2    +: 13.0"    sqrt: 8.7"
300 * 300    rang: 51.8"    +: 31.3"    sqrt: 23.8"
512 * 512    rang: 152.7"    +: 88.4"    sqrt: 64.2"

For some historic amusement, this 512^2 rang benchmark measured in 1989 took 153s. On a 2021 laptop this same benchmark took 0.81/64". Scaling this it means 12,000 times faster, in 32 years of evolution of hardware. This was a 4.2GHz i5-1135G7. For hackcode1(1NEMO) this was a factor of 26,000, see bench(5NEMO) .

See Also

fie(3NEMO) , image(5NEMO) , tsf(1NEMO) , ccdgen(1NEMO) , ccdsky(1NEMO)

Author

Peter Teuben

Files


src/image/trans      ccdmath.c ccdmath.1

Update History


 1-Jul-87    V1.0: Created    PJT
 6-jul-87    V1.1: order keywords changed for future enhancements    PJT
 1-jun-88    V2.0: new filestruct, although code is same             PJT
18-dec-88    V2.1: new keyword structure, fie() used.             PJT
22-jan-89    V2.3: can make map from scratch using %x, %y and %z    PJT
1-mar-03    V3.0: set/change the WCS                PJT
19-jun-03    V3.1: allow %w and %r, and use offset from crpix    PJT
25-aug-04    V3.2: fixed error in setting crpix (off by 2!)        PJT
25-dec-2020    V3.3: add replicate=    PJT


Table of Contents