DPUSER - The Next Generation: Examples
Author: Thomas Ott

# Examples

In this section, a few examples how to use of DPUSER are given. This very often is the fastest way to learn how a software package works.

### Printing the ASCII character set

Assign the ASCII character set to a string variable and print it out

> `ascii = "" // create empty string variable`
> `for (i = 32; i <= 255; i++) ascii += char(i) // assign values`
> `print ascii // display on screen`

### Getting information on files

Create a list of files and show their sizes

> `list = findfile("*.cpp") // find all C++ files`
> `size = longarray(nelements(list)) // create matrix for file sizes`
> `for (i = 1; i <= nelements(list); i++ {`
> `size[i] = filesize(list[i]) // assign values and print out`
> `print "file " + list[i] + " has a size of " + size[i] / 1024 + " kB"`
> `}`

### Reducing speckle data

This example shows how a standard speckle data reduction could look like.

> `dark = cubeavg('darkcube.fits') // create dark frame`
> `sky = cubeavg('sky.fits') // sky`
> `dpl = dpixcreate(sky, 5) // dead pixel list`
> `dpl[128,*] = 1 // assume 128th row is dead`
> `flat = dpixapply(sky - dark, dpl) // create flat field`
> `flat = median(flat) / flat // take inverse of flat field`
> `lxp = dpixapply(cubeavg('object.cube') - sky, dpl)`
> `// long exposure`
> `'object.lxp' = lxp // write lxp to disk`
> `x = xmax(lxp)`
> `y = ymax(lxp) // find position of maximum`
> `naxis1 = naxis1(lxp)`
> `naxis2 = naxis2(lxp) // set up global variables`
> `mask = circle(x, y, 20) // create mask for ssa`
> `'object.ssa' = ssa('object.cube', x, y, sky, flat, dpl, mask)`
> `// do ssa and write to disk`
> `x = naxis1 / 2 + 1`
> `y = naxis2 / 2 + 1 // center of the array`
> `psf = norm(center('object.ssa') * cosbell(x, y, 5, 20))`
> `// Point Spread Function`
> `'object.wien' = wien('object.ssa', psf) // deconvolve`

This standard reduction works fine if the object is dominated by one bright source. For faint sources or many objects of comparable brightness in the field of view, a more sophisticated reduction is necessary. See the help on ssa for more information.