### CHPIX

Replaces the values of selected pixels in an NDF

#### Description:

This application replaces selected elements of an NDF  array component with specified values.

Two methods are available for obtaining the regions and replacement values, selected through Parameter MODE:

• from the parameter system (see Parameters SECTION and NEWVAL). The task loops until there are no more elements to change, indicated by a null value in response to a prompt. For non-interactive processing, supply the value of Parameter NEWVAL on the command line.

• The second approach uses a text file, that is especially beneficial where there are too many section and value pairs to enter manually. The file should contain two space-separated columns; the first column is the NDF section to replace, and the second supplies the value to insert into the section (see Parameter FILE).

#### Usage:

chpix in out section newval [comp]

#### Parameters:

The name of the NDF array component to be modified. The options are: "Data", "Error", "Quality" or "Variance". "Error" is the alternative to "Variance" and causes the square of the supplied replacement value to be stored in the output VARIANCE array. ["Data"]
Name of a text file containing the sections and replacement values. It is only accessed if Parameter MODE is given the value "File". Each line should contain an NDF section of a region (see Parameter SECTION), then one or more spaces, followed by the replacement value. The value is either numeric or "Bad", the latter requests that the bad value be inserted into the section. The file may contain comment lines with the first character # or !.
NDF structure containing the array component to be modified.
The mode in which the sections and replacement values are to be obtained. The supplied string can be one of the following values.
• "Interface" — sections and values are obtained via Parameters SECTION and NEWVAL respectively.

• "File" — sections and values are obtained from a text file specified by Parameter FILE.

["Interface"]
Value to substitute in the output array element or elements. The range of allowed values depends on the data type of the array being modified. NEWVAL="Bad" instructs that the bad value appropriate for the array data type be substituted. Placing NEWVAL on the command line permits only one section to be replaced. If there are multiple replacements, a null value (!) terminates the loop. If the section being modified contains only a single pixel, then the original value of that pixel is used as the suggested default value.
##### OUT = NDF (Write)
Output NDF structure containing the modified version of the array component.
The elements to change. This is defined as an NDF section, so that ranges can be defined along any axis, and be given as pixel indices or axis (data) co-ordinates. So for example "3,4,5" would select the pixel at (3,4,5); "3:5," would replace all elements in Columns 3 to 5; ",4" replaces Line 4. See Section 9 for details. A null value (!) terminates the loop during multiple replacements.
Title for the output NDF structure. A null value (!) propagates the title from the input NDF to the output NDF. [!]

#### Results Parameters

##### OLDVAL = LITERAL (Write)
If the section being modified contains only a single pixel, then the original value of that pixel is written out to this output parameter.

#### Examples:

chpix rawspec spectrum 55 100
Assigns the value 100 to the pixel at index 55 within the one-dimensional NDF called rawspec, creating the output NDF called spectrum.
chpix rawspec spectrum 10:19 0 error
Assigns the value 0 to the error values at indices 10 to 19 within the one-dimensional NDF called rawspec, creating the output NDF called spectrum. The rawspec dataset must have a variance compoenent.
chpix in=rawimage out=galaxy section="$\sim$20,100:109" newval=bad
Assigns the bad value to the pixels in the section $\sim$20,100:109 within the two-dimensional NDF called rawimage, creating the output NDF called galaxy. This section is the central 20 pixels along the first axis, and pixels 110 to 199 along the second.
chpix in=zzcha out=zzcha_c section="45,21," newval=-1
Assigns value $-$1 to the pixels at index (45, 21) within all planes of the three-dimensional NDF called zzcha, creating the output NDF called zzcha_c.
his reads the text file called badbaseline.txt to obtain the editing commands to be applied to the NDF called harpcube to form the NDF harpmasked.