Table of Contents

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

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.

**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

% 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,100create a (2 plane 4x3 image) cube from scratch:

% ccdmath "" cube432 "%x+10*%y+100*%z" 4,3,2create 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,$dzand creating an annulus:

% ccdmath "" map0 "ifgt(%w,20,1,iflt(%w,10,1,0))" size=512 crpix=256,256Rescaling 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

ccdmath out=- fie=%x+10*%y+100*%z size=2,3,4 | ccdfits - cube234.fits

100 * 100rang: 5.8"+: 3.4"sqrt: 2.6" 200 * 200rang: 23.2+: 13.0"sqrt: 8.7" 300 * 300rang: 51.8"+: 31.3"sqrt: 23.8" 512 * 512rang: 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)*
.

src/image/transccdmath.c ccdmath.1

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