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.
% 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 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
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) .
src/image/trans ccdmath.c ccdmath.1
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