diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-07-08 20:46:52 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-07-08 20:46:52 -0400 |
commit | fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch) | |
tree | bdda434976bc09c864f2e4fa6f16ba1952b1e555 /noao/imred/ccdred/ccdtest | |
download | iraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz |
Initial commit
Diffstat (limited to 'noao/imred/ccdred/ccdtest')
-rw-r--r-- | noao/imred/ccdred/ccdtest/artobs.cl | 109 | ||||
-rw-r--r-- | noao/imred/ccdred/ccdtest/artobs.hlp | 127 | ||||
-rw-r--r-- | noao/imred/ccdred/ccdtest/badpix.dat | 4 | ||||
-rw-r--r-- | noao/imred/ccdred/ccdtest/ccdtest.cl | 10 | ||||
-rw-r--r-- | noao/imred/ccdred/ccdtest/ccdtest.hd | 6 | ||||
-rw-r--r-- | noao/imred/ccdred/ccdtest/ccdtest.men | 4 | ||||
-rw-r--r-- | noao/imred/ccdred/ccdtest/demo.cl | 1 | ||||
-rw-r--r-- | noao/imred/ccdred/ccdtest/demo.dat | 182 | ||||
-rw-r--r-- | noao/imred/ccdred/ccdtest/demo.hlp | 27 | ||||
-rw-r--r-- | noao/imred/ccdred/ccdtest/demo.par | 1 | ||||
-rw-r--r-- | noao/imred/ccdred/ccdtest/mkimage.hlp | 87 | ||||
-rw-r--r-- | noao/imred/ccdred/ccdtest/mkimage.par | 10 | ||||
-rw-r--r-- | noao/imred/ccdred/ccdtest/mkpkg | 10 | ||||
-rw-r--r-- | noao/imred/ccdred/ccdtest/subsection.cl | 53 | ||||
-rw-r--r-- | noao/imred/ccdred/ccdtest/subsection.hlp | 73 | ||||
-rw-r--r-- | noao/imred/ccdred/ccdtest/t_mkimage.x | 204 |
16 files changed, 908 insertions, 0 deletions
diff --git a/noao/imred/ccdred/ccdtest/artobs.cl b/noao/imred/ccdred/ccdtest/artobs.cl new file mode 100644 index 00000000..b64294a6 --- /dev/null +++ b/noao/imred/ccdred/ccdtest/artobs.cl @@ -0,0 +1,109 @@ +# ARTOBS -- Make a CCD observation + +procedure artobs (image, exptime, ccdtype) + +string image {prompt="Image name"} +real exptime {prompt="Exposure time"} +string ccdtype {prompt="CCD type"} + +int ncols=132 {prompt="Number of columns"} +int nlines=100 {prompt="Number of lines"} +string filter="" {prompt="Filter"} +string datasec="[1:100,1:100]" {prompt="Data section"} +string trimsec="[3:98,3:98]" {prompt="Trim section"} +string biassec="[103:130,*]" {prompt="Bias section"} + +file imdata="" {prompt="Image data"} +real skyrate=0. {prompt="Sky count rate"} +file badpix="" {prompt="Bad pixel regions"} +real biasval=500. {prompt="Bias value"} +real badval=500. {prompt="Bad pixel value"} +real zeroval=100. {prompt="Zero level value"} +real darkrate=1. {prompt="Dark count rate"} +real zeroslope=0.01 {prompt="Slope of zero level"} +real darkslope=0.002 {prompt="Slope of dark count rate"} +real flatslope=0.0003 {prompt="Flat field slope"} +real sigma=5. {prompt="Gaussian sigma"} +int seed=0 {prompt="Random number seed"} +bool overwrite=no {prompt="Overwrite existing image?"} + +begin + int c1, c2, l1, l2 + real exp, value, valslope + string im, type, s + + im = image + exp = exptime + type = ccdtype + + if (access (im//".imh") == yes) + im = im // ".imh" + if (access (im//".hhh") == yes) + im = im // ".hhh" + if (access (im) == yes) { + if (overwrite == yes) + imdelete (im, verify=no) + else + return + } + + # Create the image. + s = str (ncols) // " " // str (nlines) + mkimage (im, "make", 0., 2, s, pixtype="short", slope=0., sigma=sigma, + seed=seed) + + # Add a data image. + if (access (imdata//".imh") == yes) + imdata = imdata // ".imh" + if (access (imdata//".hhh") == yes) + imdata = imdata // ".hhh" + if (access (imdata) == yes) + imcopy (imdata//datasec, im//datasec, verbose=no) + + # Add sky. + value = exp * skyrate + if (value != 0.) + mkimage (im//datasec, "add", value, slope=0., sigma=0.) + + # Add flat field response. + if (flatslope != 0.) + mkimage (im//datasec, "mul", 1., slope=flatslope, sigma=0.) + + # Add zero level and dark count. + value = zeroval + exp * darkrate + valslope = zeroslope + exp * darkslope + if ((value != 0.) && (valslope != 0.)) + mkimage (im//datasec, "add", value, slope=valslope, sigma=0.) + + # Add bias. + if (biasval != 0.) + mkimage (im, "add", biasval, slope=0., sigma=sigma, seed=0) + + # Set bad pixels. + if (access (badpix)) { + list = badpix + while (fscan (list, c1, c2, l1, l2) != EOF) { + if (nscan() != 4) + next + c1 = max (1, c1) + c2 = min (ncols, c2) + l1 = max (1, l1) + l2 = min (nlines, l2) + s = "["//c1//":"//c2//","//l1//":"//l2//"]" + mkimage (im//s, "replace", badval, slope=0., sigma=0.) + } + } + + # Set image header + ccdhedit (im, "exptime", exp, type="real") + if (type != "") + ccdhedit (im, "imagetyp", type, type="string") + if (datasec != "") + ccdhedit (im, "datasec", datasec, type="string") + if (trimsec != "") + ccdhedit (im, "trimsec", trimsec, type="string") + if (biassec != "") + ccdhedit (im, "biassec", biassec, type="string") + if (filter != "") + ccdhedit (im, "subset", filter, type="string") +end diff --git a/noao/imred/ccdred/ccdtest/artobs.hlp b/noao/imred/ccdred/ccdtest/artobs.hlp new file mode 100644 index 00000000..02f2cf0f --- /dev/null +++ b/noao/imred/ccdred/ccdtest/artobs.hlp @@ -0,0 +1,127 @@ +.help artobs Oct87 noao.imred.ccdred.ccdtest +.ih +NAME +artobs -- Make a demonstration CCD observation +.ih +USAGE +artobs image exptime ccdtype +.ih +PARAMETERS +.ls image +Observation to be created. +.le +.ls exptime +Exposure time of observation. +.le +.ls ccdtype +CCD image type of observation. This type is one of the standard types +for the CCDRED package. +.le +.ls ncols = 132, nlines = 100 +The number of columns and lines in the full image created including +bias section. +.le +.ls filter = "" +Filter string for the observation. +.le +.ls datasec = "[1:100,1:100]" +Data section of the observation. +.le +.ls trimsec = "[3:98,3:98]" +Trim section for later processing. +.le +.ls biassec = "[103:130,*]" +Prescan or overscan bias section. +.le +.ls imdata = "" +Image to be used as source of observation if specified. The image must +be at least as large as the data section. +.le +.ls skyrate = 0. +Sky counting rate. The total sky value will be scaled by the exposure time. +.le +.ls badpix = "" +Bad pixel region file in the standard CCDRED bad pixel file format. +.le +.ls biasval = 500. +Mean bias value of the entire image. +.le +.ls badval = 500. +Bad pixel value placed at the specified bad pixel regions. +.le +.ls zeroval = 100. +Zero level of the data section. +.le +.ls darkrate = 1. +Dark count rate. The total dark count will be scaled by the exposure time +.le +.ls zeroslope = 0.01 +Slope of the zero level per pixel. +.le +.ls darkslope = 0.002 +Slope of the dark count rate per pixel. This is also scaled by the exposure +time. +.le +.ls flatslope = 3.0000000000000E-4 +The mean flat field response is 1 with a slope given by this value. +.le +.ls sigma = 5. +Gaussian noise sigma per pixel. +.le +.ls seed = 0 +Random number seed. If zero new values are used for every observation. +.le +.ls overwrite = no +Overwrite an existing image? If no a new observation is not created. +There is no warning message. +.le +.ih +DESCRIPTION +This script task generates artificial CCD observations which include +bad pixels, bias and zero levels, dark counts, flat field response +variations and sky brightness levels. Optionally, image data from +a reference image may be included. This task is designed to be used +with the \fBccdred\fR package and includes appropriate image header +information. + +First the task checks whether the requested image exists. If it does +exist and the overwrite flag is no then a new observations is not created. +If the overwrite flag is set then the old image is deleted and a new +observation is created. + +An empty image of the specified size and of pixel data type short is +first created. If a noise sigma is specified it is added to the entire +image. If a reference image is specified then image section given by +the \fIdatasec\fR parameter is copied into the data section of the +observation. Next a sky level, specified by the \fIskyrate\fR +parameter times the exposure time, is added to the data section. +The flat field response with a mean of one and a slope given by the +\fIflatslope\fR parameter is multiplied into the data section. If +a dark count rate and/or a zero level is specified then these effects +are added to the data section. Then the specified bias level +is added to the entire image; i.e. including the bias section. +Finally, the pixels specified in the bad pixel region file, if one +is specified, are set to the bad pixel value. + +The CCD reduction parameters for the data section, the trim section, +the bias section, exposure time, the CCD image type, and the filter +are added to the image header (if they are specified) using \fBccdhedit\fR +to apply any keyword translation. +.ih +EXAMPLES +1. To create some test CCD images first set the task parameters such as +number of columns and lines, data, bias, and trim sections, and data +values. The images are then created as follows: + + cl> artobs.filter = "V" # Set the filter + cl> artobs zero 0. zero # Zero level image + cl> artobs dark 1000. dark skyrate=0. # Dark count image + cl> artobs flat 1. flat skyrate=1000. # Flat field image + cl> artobs obj 10. object # Object image + +Note that the CCD image type is not used explicitly so that for a +dark count image you must set the sky count rate to zero. +.ih +SEE ALSO +mkimage, subsection, demo +.endhelp diff --git a/noao/imred/ccdred/ccdtest/badpix.dat b/noao/imred/ccdred/ccdtest/badpix.dat new file mode 100644 index 00000000..92b13aa9 --- /dev/null +++ b/noao/imred/ccdred/ccdtest/badpix.dat @@ -0,0 +1,4 @@ +10 10 1 1000 +20 20 1 20 +30 30 50 100 +1 1000 50 50 diff --git a/noao/imred/ccdred/ccdtest/ccdtest.cl b/noao/imred/ccdred/ccdtest/ccdtest.cl new file mode 100644 index 00000000..eb3f8b68 --- /dev/null +++ b/noao/imred/ccdred/ccdtest/ccdtest.cl @@ -0,0 +1,10 @@ +#{ CCDTEST -- CCDRED Test package + +package ccdtest + +task mkimage = ccdtest$x_ccdred.e +task artobs = ccdtest$artobs.cl +task subsection = ccdtest$subsection.cl +task demo = ccdtest$demo.cl + +clbye() diff --git a/noao/imred/ccdred/ccdtest/ccdtest.hd b/noao/imred/ccdred/ccdtest/ccdtest.hd new file mode 100644 index 00000000..4218f9b0 --- /dev/null +++ b/noao/imred/ccdred/ccdtest/ccdtest.hd @@ -0,0 +1,6 @@ +# Help directory for the CCDTEST package. + +demo hlp=demo.hlp, src=demo.cl +mkimage hlp=mkimage.hlp, src=t_mkimage.x +artobs hlp=artobs.hlp, src=artobs.cl +subsection hlp=subsection.hlp, src=subsection.cl diff --git a/noao/imred/ccdred/ccdtest/ccdtest.men b/noao/imred/ccdred/ccdtest/ccdtest.men new file mode 100644 index 00000000..f2b3909d --- /dev/null +++ b/noao/imred/ccdred/ccdtest/ccdtest.men @@ -0,0 +1,4 @@ + artobs - Create an artificial CCD observation + demo - Run a demonstration of the CCD reduction package + mkimage - Make or modify an image with simple values + subsection - Create an artificial subsection CCD observation diff --git a/noao/imred/ccdred/ccdtest/demo.cl b/noao/imred/ccdred/ccdtest/demo.cl new file mode 100644 index 00000000..213500c4 --- /dev/null +++ b/noao/imred/ccdred/ccdtest/demo.cl @@ -0,0 +1 @@ +stty (playback=demofile, verify=yes) diff --git a/noao/imred/ccdred/ccdtest/demo.dat b/noao/imred/ccdred/ccdtest/demo.dat new file mode 100644 index 00000000..733a319b --- /dev/null +++ b/noao/imred/ccdred/ccdtest/demo.dat @@ -0,0 +1,182 @@ +\O=NOAO/IRAF V2.5 valdes@lyra Mon 15:42:35 12-Oct-87 +\T=vt640 +\G=vt640 +clear\n\{%V-%!200\} +\n\{%10000 + CCD REDUCTION DEMONSTRATION + + In this demonstration we are going to make some (artificial) CCD + observations which we will reduce using the CCDRED package. The + dome is opening and we are ready to begin observing...\} +\n\{%V-\} +unlearn\sccdred;unlearn\sccdtest\n\{ # Initialize parameters and data...\} +imdelete\s%B%%*.*\sv-\n\{%V-\} +imrename\sB*.*\s%B%%*.*\sv-\n\{%V-\} +imdelete\sZero*.*,Flat*.*\n\{%V-\} +delete\sDemo*\sv-\n\{%V-\} +\n\{%V-\} +setinstrument\sdemo\sreview-\n\{ # Set instrument parameters...\} +lpar\sartobs\n\{ # List observing parameters...\} +artobs\sobs001\s0.\szero\n\{%15000 # Observe zero level images...\} +artobs\sobs002\s0.\szero\n\{%V-\} +artobs\sobs003\s0.\szero\n\{%V-\} +artobs\sobs004\s0.\szero\n\{%V-\} +artobs\sobs005\s0.\szero\n\{%V-\} +\n\{%V-\} +artobs.skyrate=0\n\{ # Observe a long dark count...\} +artobs\sobs006\s1000.\sdark\n\{%V-\} +\n\{%V-\} +artobs.filter="V"\n\{ # Observe V flat fields...\} +artobs.skyrate=2000\n\{%V-\} +artobs\sobs007\s1.\sflat\n\{%V-\} +artobs\sobs008\s1.\sflat\n\{%V-\} +artobs\sobs009\s1.\sflat\n\{%V-\} +artobs\sobs010\s1.\sflat\n\{%V-\} +artobs\sobs011\s2.\sflat\n\{%V-\} +artobs\sobs012\s2.\sflat\n\{%V-\} +\n\{%V-\} +artobs.filter="B"\n\{ # Observe B flat fields...\} +artobs.skyrate=1000\n\{%V-\} +artobs\sobs013\s1.\sflat\n\{%V-\} +artobs\sobs014\s2.\sflat\n\{%V-\} +artobs\sobs015\s3.\sflat\n\{%V-\} +artobs\sobs016\s3.\sflat\n\{%V-\} +artobs\sobs017\s3.\sflat\n\{%V-\} +artobs\sobs018\s3.\sflat\n\{%V-\} +\n\{%V-\} +artobs.filter="V"\n\{ # Observe objects...\} +artobs.skyrate=100\n\{%V-\} +artobs\sobs019\s10.\sobject\simdata=dev$pix\n\{%V-\} +artobs\sobs020\s20.\sobject\simdata=dev$pix\n\{%V-\} +artobs.filter="B"\n\{%V-\} +artobs\sobs021\s30.\sobject\simdata=dev$pix\n\{%V-\} +artobs\sobs022\s40.\sobject\simdata=dev$pix\n\{%V-\} +\n\{%V-\} +lpar\ssubsection\n\{ # Subsection readout parameters...\} +subsection\sobs023\sobs019\n\{%5000 # Readout a subsection of the CCD...\} +dir\n\{ # Check directory of observations...\} +clear\n\{%10000 # Continue...\} +\n\{%15000 + INSTRUMENT SETUP + + Because there are a variety of instruments, observatories, and data + formats there are many parameters. To set all of these conveniently + there is a task which reads setup files prepared by the observing + staff. The setup task: + 1. Defines an instrument header translation file which + translates the image header parameters to something + the CCDRED package understands. This is an important + feature of the package. + 2. It runs a setup script which sets parameters and performs + other functions desired by the observing staff. + 3. The user is then given the opportunity to modify the + package and processing parameters...\} +\n\{%V-\} +setinstrument\smode=m\n\{ # Set demo instrument parameters...\} +demo\r +\{%5000\}^Z +\{%5000\}^Z +\{%5000\}\r +\r +\r +\r +\r +\r +\r +\r +\r +\r +\r +\r +\r +\r +\r +\r +\r +\r +\r +Zero\r +\r +Flat*.*\r +^Z +clear\n\{%5000 # Continue...\} +\n\{%20000 + IMAGE HEADERS + + The CCDRED package uses image header information if present. This + includes the type of data (object, flat field, etc.), exposure + time, region of image containing the data, processing status, and + more. To make this more general there is a instrument header + translation file to translate image header keywords to the standard + names used by the package. In this example the image header + keywords are identical to the package except that the image type is + CCDTYPE, the exposure time is INTEG and the subset parameter is + FILTER. Let's look at the image header using the the standard + image header lister and the special one in the CCDRED package. + This special lister provides additional information about image + types and processing status...\} + +\n\{%V-\} +imheader\sobs023\sl+\n\{ # List object image header...\} +ccdlist\sobs*.*\n\{%5000 # List short CCD status...\} +ccdlist\sobs023\sl+\n\{%5000 # List long CCD status...\} +clear\n\{%5000 # Continue...\} +\n\{%20000 + COMBINE CALIBRATION IMAGES + + In order to reduce calibration noise and eliminate cosmic ray events + we combine many zero level and flat field calibration images. The + combining task provides many options. We will combine the images by + scaling each image to the same exposure time, rejecting the highest + pixel at each image point, and taking a weighted average of the + remainder. Flat field images must be combined separately for each + filter. We will simply specify all the images and the task automatically + selects the appropriate images to combine! ...\} +\n\{%V-\} +zerocombine\smode=m\n\{ # Combine zero level images...\} +obs*.*\r +\{%5000\}^Z +flatcombine\smode=m\n\{ # Combine flat field images...\} +obs*.*\r +\{%5000\}^Z +clear\n\{%5000 # Continue...\} +\n\{%15000 + PROCESS OBSERVATIONS + + We are now ready to process our observations. The processing steps we + have selected are to replace bad pixels by interpolation, fit and + subtract a readout bias given by an overscan strip, subtract the zero + level calibration image, scale and subtract a dark count calibration, + divide by a flat field, trim the image of the overscan strip and border + columns and lines. The task which does this is "ccdproc". The task is + expert at reducing CCD observations easily and efficiently. It checks + the image types, applies the proper filter flat field, applies the + proper part of the calibration images to subsection readouts, does only + the processing steps selected if not done previously, and automatically + processes the calibration images as needed. As before we simply specify + all the images and the task selects the appropriate images to process + including finding the one dark count image "obs006". Watch the log + messages to see what the task is doing...\} +\n\{%V-\} +ccdproc\sobs*.*\n\{ # Process object images...\} +\n\{%V-\} +\{%V-\}q0,+,\r +NO\n\{%V-\} +\n\{%10000 + That's it! We're done. Now lets check the results. The "ccdlist" + listing will show the processing status and the images are now smaller + and of pixel datatype real. The CCDSEC parameter identifies the relation + of the image to the actual CCD pixels of the detector...\} +\n\{%V-\} +ccdlist\sobs*.*\sccdtype=object\n\{ # List short CCD status...\} +ccdlist\sobs023\sl+\n\{%5000 # List long CCD status...\} +imhead\sobs023\sl+\n\{%5000 # List object image header...\} +dir\n\{%5000 # Check the data directory...\} +\n\{%V- + We specified that the original images be saved by using the prefix B. + We are also left with a text log file, a metacode file containing the + fits to the overscan regions, and a file which maps the filter subset + strings to short identifiers used in CCDLIST and when creating the + combined images "FlatV" and "FlatB". You may look through these files, + or use GKIMOSAIC to examine the metacode file, now if you want. +\} diff --git a/noao/imred/ccdred/ccdtest/demo.hlp b/noao/imred/ccdred/ccdtest/demo.hlp new file mode 100644 index 00000000..c03d5efb --- /dev/null +++ b/noao/imred/ccdred/ccdtest/demo.hlp @@ -0,0 +1,27 @@ +.help demo Oct87 noao.imred.ccdred.ccdtest +.ih +NAME +demo -- Run a demonstration of the CCD reduction package +.ih +USAGE +demo +.ih +PARAMETERS +.ls demofile = "ccdtest$demo.dat" +Demonstration playback file. +.le +.ih +DESCRIPTION +This script task runs a demonstration playback. The playback file +is specified by a hidden parameter. Normally this default playback file +is used. The default demonstration will use the task \fBtv.display\fR if it +is loaded to show you the CCD frames being processed. +.ih +EXAMPLES +1. To run a demonstration of the \fBccdred\fR package: + + cl> demo +.ih +SEE ALSO +stty +.endhelp diff --git a/noao/imred/ccdred/ccdtest/demo.par b/noao/imred/ccdred/ccdtest/demo.par new file mode 100644 index 00000000..70bee0f3 --- /dev/null +++ b/noao/imred/ccdred/ccdtest/demo.par @@ -0,0 +1 @@ +demofile,s,h,"ccdtest$demo.dat",,,Demonstration playback file diff --git a/noao/imred/ccdred/ccdtest/mkimage.hlp b/noao/imred/ccdred/ccdtest/mkimage.hlp new file mode 100644 index 00000000..2be4ab5b --- /dev/null +++ b/noao/imred/ccdred/ccdtest/mkimage.hlp @@ -0,0 +1,87 @@ +.help mkimage Oct87 noao.imred.ccdred.ccdtest +.ih +NAME +mkimage -- Make or modify and image with simple values +.ih +USAGE +mkimage image option value [ndim dims] +.ih +PARAMETERS +.ls image +Image to create or modify. +.le +.ls option +Editing option which is one of the following: +.ls make +Make a new image of the specified size, dimensionality, pixel type, and values. +.le +.ls replace +Replace pixel values in the image. +.le +.ls add +Add to the pixel values in the image. +.le +.ls multiply +Multiply the pixel values in the image. +.le +.le +.ls value +Mean pixel value to be used. +.le +.ls ndim +Number of dimensions when creating a new image. +.le +.ls dims +Image dimensions given as a white space separated string (see the examples). +.le +.ls pixtype = "real" +Pixel datatype when creating an image. The types are "real", "short", +"integer", "long", and "double". +.le +.ls slope = 0. +Slope of pixel values per pixel. +.le +.ls sigma = 0. +Gaussian noise of pixel values if not zero. +.le +.ls seed = 0 +Seed for random numbers. If zero then the first time the task is +called a seed of 1 is used and all subsequent calls while the task is in +the process cache continue with new random numbers. +.le +.ih +DESCRIPTION +An image is created or modified using simple values. This task is intended +for test and demonstration purposes. A image may be created of a specified +size, dimensionality, and pixel datatype. The pixel values used in creating +or editing an image consist of a sloped plane (which repeats for dimensions +greater than 2) with pseudo-Gaussian noise. The sloped plane is defined such +that: + + pix[i,j] = value + slope * ((ncols + nlines) / 2 - 1) + slope * (i + j) + +where i and j are the pixel indices (starting with 1) and ncols and nlines +are the number of columns and lines. The interpretation of "value" is that +it is the mean of the plane. The Gaussian noise is only approximately random +for purposes of speed! +.ih +EXAMPLES +1. To create an 2 dimensional real image of size 100 x 200 with all zero +values: + + cl> mkimage name make 0 2 "100 200" + +Note that the dimension string is quoted because of the blank separated +values. + +2. To add noise with a sigma of 5: + + cl> mkimage name add 0 sigma=5 + +2. To replace a region of the image with the value 10: + + cl> mkimage name[10:20,30:40] replace 10 +.ih +SEE ALSO +artobs, subsection +.endhelp diff --git a/noao/imred/ccdred/ccdtest/mkimage.par b/noao/imred/ccdred/ccdtest/mkimage.par new file mode 100644 index 00000000..148bf7ea --- /dev/null +++ b/noao/imred/ccdred/ccdtest/mkimage.par @@ -0,0 +1,10 @@ +image,s,a,,,,Image to make or modify +option,s,a,,"make|replace|add|multiply",,Editing option +value,r,a,,,,Mean pixel value +slope,r,h,0.,,,Slope of pixel values +sigma,r,h,0.,0.,,Noise sigma +seed,i,h,0,0,,Seed for noise generator + +ndim,i,a,,1,7,Number of dimensions +dims,s,a,,,,Image dimensions +pixtype,s,h,"real","short|real",,Pixel datatype diff --git a/noao/imred/ccdred/ccdtest/mkpkg b/noao/imred/ccdred/ccdtest/mkpkg new file mode 100644 index 00000000..79fcb59c --- /dev/null +++ b/noao/imred/ccdred/ccdtest/mkpkg @@ -0,0 +1,10 @@ +# Make CCDTEST Package. + +$checkout libpkg.a .. +$update libpkg.a +$checkin libpkg.a .. +$exit + +libpkg.a: + t_mkimage.x <imhdr.h> + ; diff --git a/noao/imred/ccdred/ccdtest/subsection.cl b/noao/imred/ccdred/ccdtest/subsection.cl new file mode 100644 index 00000000..60522c8b --- /dev/null +++ b/noao/imred/ccdred/ccdtest/subsection.cl @@ -0,0 +1,53 @@ +# SUBSECTION -- Make a subsection CCD observation + +procedure subsection (subimage, image) + +string subimage {prompt="Subsection image name"} +string image {prompt="Full image name"} + +int ncols=82 {prompt="Number of columns"} +int nlines=50 {prompt="Number of lines"} +string ccdsec="[26:75,26:75]" {prompt="CCD section"} +string datasec="[1:50,1:50]" {prompt="Data section"} +string trimsec="" {prompt="Trim section"} +string biassec="[51:82,1:50]" {prompt="Bias section"} +bool overwrite=no {prompt="Overwrite existing image?"} + +begin + string im, imdata, s + real biasval, sigma + + im = subimage + imdata = image + biasval = artobs.biasval + sigma = artobs.sigma + + if (access (im//".imh") == yes) + im = im // ".imh" + if (access (im//".hhh") == yes) + im = im // ".hhh" + if (access (im) == yes) { + if (overwrite == yes) + imdelete (im, verify=no) + else + return + } + + # Create the image. + s = "[1:" // str (ncols) // ",1:" // str(nlines) // "]" + imcopy (imdata//s, im, verbose=no) + + # Copy subsection image. + imcopy (imdata//ccdsec, im//datasec, verbose=no) + + # Add bias. + if (biasval != 0.) + mkimage (im//biassec, "replace", biasval, slope=0., sigma=sigma, + seed=0) + + # Set image header + ccdhedit (im, "ccdsec", ccdsec, type="string") + ccdhedit (im, "datasec", datasec, type="string") + ccdhedit (im, "trimsec", trimsec, type="string") + ccdhedit (im, "biassec", biassec, type="string") +end diff --git a/noao/imred/ccdred/ccdtest/subsection.hlp b/noao/imred/ccdred/ccdtest/subsection.hlp new file mode 100644 index 00000000..a2779500 --- /dev/null +++ b/noao/imred/ccdred/ccdtest/subsection.hlp @@ -0,0 +1,73 @@ +.help subsection Oct87 noao.imred.ccdred.ccdtest +.ih +NAME +subsection -- Make a subsection readout CCD image +.ih +USAGE +subsection subimage image +.ih +PARAMETERS +.ls subimage +Subsection image to be created. +.le +.ls image +Full image from which to take the subsection readout. +.le +.ls ncols = 82, nlines = 50 +Number of image columns and lines in the full subsection image including +bias regions. +.le +.ls ccdsec="[26:75,26:75]" +CCD section of the subsection. This is the image section of the full +image to be used. +.le +.ls datasec = "[1:50,1:50]" +Data section of the image. +.le +.ls trimsec = "" +Trim section for later processing. +.le +.ls biassec="[51:82,1:50]" +Prescan or overscan bias section. +.le +.ls overwrite = no +Overwrite an existing image? If no a new observation is not created. +There is no warning message. +.le +.ih +DESCRIPTION +This script task generates artificial CCD subsection observations +which include bad pixels, bias and zero levels, dark counts, flat +field response variations and sky brightness levels. It creates an +subsection image which includes a bias section from a previously +created image (created by the task \fBartobs\fR). This task is +designed to be used with the \fBccdred\fR package and includes +appropriate image header information. + +First the task checks whether the requested image exists. If it does +exist and the overwrite flag is no then a new observations is not created. +If the overwrite flag is set then the old image is deleted and a new +observation is created. + +The image section give by the parameter \fIccdsec\fR of the reference +image is copied to the new image. It is assumed the reference image +contains any desired zero level, bias, flat field, and dark count +effects. The bias section is then added with a bias value given by +\fBartobs.biasval\fR with noise given by \fBartobs.sigma\fR. + +Also the image header parameters from the reference image are +copied and the data, bias, trim, and ccd section parameters are +updated. +.ih +EXAMPLES +1. To create some test CCD images first create full frame observations with +the task \fBartobs\fR. Then set the subsection parameters +for the size of the subsection observation, the data section, trim section, +bias section, and the CCD section of the subsection observation. + + cl> artobs obj 5 object filter=V + cl> subsection obj1 object +.ih +SEE ALSO +mkimage, artobs, demo +.endhelp diff --git a/noao/imred/ccdred/ccdtest/t_mkimage.x b/noao/imred/ccdred/ccdtest/t_mkimage.x new file mode 100644 index 00000000..ff0d5f26 --- /dev/null +++ b/noao/imred/ccdred/ccdtest/t_mkimage.x @@ -0,0 +1,204 @@ +include <imhdr.h> + +define OPTIONS "|make|replace|add|multiply|" +define MAKE 1 # Create a new image +define REPLACE 2 # Replace pixels +define ADD 3 # Add to pixels +define MULTIPLY 4 # Multiply pixels + +# T_MKIMAGE -- Make or edit an image with simple values. +# An image may be created of a specified size, dimensionality, and pixel +# datatype. The image may also be edited to replace, add, or multiply +# by specified values. The values may be a combination of a sloped plane +# (repeated for dimensions greater than 2) and Gaussian noise. +# The editing may be confined to sections of the image by use of image +# sections in the input image. This task is a simple tool for +# specialized uses in test applications. +# +# The sloped plane is defined such that: +# +# pix[i,j] = value + slope * ((ncols + nlines) / 2 - 1) + slope * (i + j) +# +# The interpretation of value is that it is the mean of the plane. +# +# The Gaussian noise is only approximately random for purposes of speed! + +procedure t_mkimage () + +char image[SZ_FNAME] # Image to edit +char option[7] # Edit option +real value # Edit value +real slope # Slope +real sigma # Gaussian noise sigma +long seed # Random number seed + +int i, op, ncols, nlines +long vin[IM_MAXDIM], vout[IM_MAXDIM] +pointer sp, rannums, im, buf, bufin, bufout + +int clgwrd(), clgeti(), clscan(), nscan() imgnlr(), impnlr() +char clgetc() +real clgetr() +long clgetl() +pointer immap() + +data seed/1/ + +begin + call smark (sp) + call clgstr ("image", image, SZ_FNAME) + op = clgwrd ("option", option, 7, OPTIONS) + value = clgetr ("value") + slope = clgetr ("slope") + sigma = clgetr ("sigma") + if (clgetl ("seed") > 0) + seed = clgetl ("seed") + + call amovkl (long (1), vin, IM_MAXDIM) + call amovkl (long (1), vout, IM_MAXDIM) + switch (op) { + case MAKE: + im = immap (image, NEW_IMAGE, 0) + IM_NDIM(im) = clgeti ("ndim") + i = clscan ("dims") + do i = 1, IM_NDIM(im) + call gargi (IM_LEN(im, i)) + if (nscan() != IM_NDIM(im)) + call error (0, "Bad dimension string") + switch (clgetc ("pixtype")) { + case 's': + IM_PIXTYPE(im) = TY_SHORT + case 'i': + IM_PIXTYPE(im) = TY_INT + case 'l': + IM_PIXTYPE(im) = TY_LONG + case 'r': + IM_PIXTYPE(im) = TY_REAL + case 'd': + IM_PIXTYPE(im) = TY_DOUBLE + default: + call error (0, "Bad pixel type") + } + + ncols = IM_LEN(im,1) + nlines = IM_LEN(im,2) + call salloc (rannums, 2 * ncols, TY_REAL) + call mksigma (sigma, seed, Memr[rannums], 2*ncols) + + while (impnlr (im, bufout, vout) != EOF) + call mkline (value, slope, sigma, seed, Memr[rannums], + Memr[bufout], vout[2] - 1, ncols, nlines) + case REPLACE: + im = immap (image, READ_WRITE, 0) + + ncols = IM_LEN(im,1) + nlines = IM_LEN(im,2) + call salloc (rannums, 2 * ncols, TY_REAL) + call mksigma (sigma, seed, Memr[rannums], 2*ncols) + + while (impnlr (im, bufout, vout) != EOF) + call mkline (value, slope, sigma, seed, Memr[rannums], + Memr[bufout], vout[2] - 1, ncols, nlines) + case ADD: + im = immap (image, READ_WRITE, 0) + + ncols = IM_LEN(im,1) + nlines = IM_LEN(im,2) + call salloc (buf, ncols, TY_REAL) + call salloc (rannums, 2 * ncols, TY_REAL) + call mksigma (sigma, seed, Memr[rannums], 2*ncols) + + while (imgnlr (im, bufin, vin) != EOF) { + i = impnlr (im, bufout, vout) + call mkline (value, slope, sigma, seed, Memr[rannums], + Memr[buf], vout[2] - 1, ncols, nlines) + call aaddr (Memr[bufin], Memr[buf], Memr[bufout], ncols) + } + case MULTIPLY: + im = immap (image, READ_WRITE, 0) + + ncols = IM_LEN(im,1) + nlines = IM_LEN(im,2) + call salloc (buf, ncols, TY_REAL) + call salloc (rannums, 2 * ncols, TY_REAL) + call mksigma (sigma, seed, Memr[rannums], 2*ncols) + + while (imgnlr (im, bufin, vin) != EOF) { + i = impnlr (im, bufout, vout) + call mkline (value, slope, sigma, seed, Memr[rannums], + Memr[buf], vout[2] - 1, ncols, nlines) + call amulr (Memr[bufin], Memr[buf], Memr[bufout], ncols) + } + } + + call imunmap (im) + call sfree (sp) +end + + +# MKLINE -- Make a line of data. A slope of zero is a special case. +# The Gaussian random numbers are taken from the sequence of stored +# values with starting point chosen randomly in the interval 1 to ncols. +# This is not very random but is much more efficient. + +procedure mkline (value, slope, sigma, seed, rannums, data, line, ncols, nlines) + +real value # Mean value +real slope # Slope in mean +real sigma # Sigma about mean +long seed # Random number seed +real rannums[ARB] # Random numbers +real data[ncols] # Data for line +int line # Line number +int ncols # Number of columns +int nlines # Number of lines + +int i +real a, urand() + +begin + if (slope == 0.) + call amovkr (value, data, ncols) + else { + a = value + slope * (line - (ncols + nlines) / 2. - 1) + do i = 1, ncols + data[i] = a + slope * i + } + if (sigma > 0.) { + i = (ncols - 1) * urand (seed) + 1 + call aaddr (rannums[i], data, data, ncols) + } +end + + +# MKSIGMA -- A sequence of random numbers of the specified sigma and +# starting seed is generated. The random number generator is modeled after +# that in Numerical Recipes by Press, Flannery, Teukolsky, and Vetterling. + +procedure mksigma (sigma, seed, rannums, nnums) + +real sigma # Sigma for random numbers +long seed # Seed for random numbers +real rannums[nnums] # Random numbers +int nnums # Number of random numbers + +int i +real v1, v2, r, fac, urand() + +begin + if (sigma > 0.) { + for (i=1; i<=nnums; i=i+1) { + repeat { + v1 = 2 * urand (seed) - 1. + v2 = 2 * urand (seed) - 1. + r = v1 ** 2 + v2 ** 2 + } until ((r > 0) && (r < 1)) + fac = sqrt (-2. * log (r) / r) * sigma + rannums[i] = v1 * fac + if (i == nnums) + break + i = i + 1 + rannums[i] = v2 * fac + } + } +end |