aboutsummaryrefslogtreecommitdiff
path: root/noao/digiphot/daophot/doc/psf.hlp
blob: 5613a8b258730d18d16965ae9c47686d9236b0fc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
.help psf May00  noao.digiphot.daophot
.ih
NAME
psf -- build the point spread function for an image
.ih
USAGE
psf image photfile pstfile psfimage opstfile groupfile
.ih
PARAMETERS
.ls image
The images for which the PSF model is to be built.
.le
.ls photfile
The list of input photometry files. The number of photometry files must
be equal to the number of input images. If photfile is "default", "dir$default",
or a directory specification  PSF searches for a file called dir$image.mag.# 
where # is the highest available version number for the file. Photfile is
normally the output of the PHOT task but may also be the  output of the PSF,
PEAK, NSTAR and ALLSTAR tasks. Photfile may be an APPHOT/DAOPHOT text database
or an STSDAS binary table.
.le
.ls pstfile
The list of input psf star photometry files. The ids of the psf stars in these
files must be the same as their ids in \fIphotfile\fR. The number of psf
star files must be zero or equal to the number of input images. If pstfile
is "default", "dir$default" or a directory specification, PSF searches for
a file called image.pst.? where ? is the highest existing version number.
Pstfile is usually the output of the DAOPHOT PSTSELECT task but may also be
the appropriately edited output psf file produced by PSF itself, or the output
of the GROUP, NSTAR, PEAK or ALLSTAR tasks.  Photfile may be an APPHOT/DAOPHOT
text database or an STSDAS table.
.le
.ls psfimage
The output PSF model image names or directory. The must be one PSF image name
for every input image. If psfimage is "default", "dir$default", or a directory
specification, then PSF creates an image called image.psf.? where ? is the next
available version number.
.le
.ls opstfile
The output psf star files containing lists of the stars actually used to
compute the PSF model. There must be one output psf star file for every input
image. If opstfile is "default", "dir$default", or a directory specification
then PSF creates a file called image.pst.? where ? is the next available
version number. If the DAOPHOT package parameter \fItext\fR is "yes" then an
APPHOT/DAOPHOT text database is written, otherwise an STSDAS binary table is
written.
.le
.ls groupfile
The output psf star group files listing the PSF stars and their neighbors that
were used to create the PSF models. There must be one output group file for
every input image. If groupfile is "default", "dir$default", or a directory
specification then PSF creates a file called image.psg.? where ? is the
next available version number. If the DAOPHOT package parameter \fItext\fR is
"yes" then an APPHOT/DAOPHOT text database is written, otherwise an STSDAS
table database is written.
.le
.ls plotfile = ""
The name of the output file containing mesh, contour, or profile plots of the
selected PSF stars. If plotfile is undefined no plot file is created,
otherwise a mesh, contour, or profile plot is written to this file for each PSF
star selected. Plotfile is opened in append mode and may become very large.
.le
.ls datapars = ""
The name of the file containing the data dependent parameters. The parameters
\fIscale\fR, \fIdatamin\fR, and \fIdatamax\fR are located here. If datapars
is undefined then the default parameter set in uparm directory is used.
.le
.ls daopars = ""
The name of the file containing the daophot fitting parameters. The parameters
\fIpsfrad\fR and \fIfitrad\fR are located here. If \fIdaopars\fR is undefined
then the default parameter set in uparm directory is used.
.le
.ls matchbyid = yes
Match the stars in the psf star list(s) if any to the stars in the input
photometry files using id numbers (matchbyid = yes) or x and y positions
(matchbyid = no).
.le
.ls interactive = yes
Fit the PSF interactively ? If interactive = yes and \fIicommands\fR is
undefined, PSF reads selects the initial list of PSF stars from \fIpstfile\fR
and waits for commands from the user. If interactive = no and \fIicommands\fR
is undefined, PSF reads in the candidate PSF stars from \fIpstfile\fR, computes
 the PSF, and writes it to \fIpsfimage\fR without input from the user. If
\fIicommands\fR is defined, then interactive = no, and commands are read from
the image cursor command file.
.le
.ls mkstars = no
Mark the selected or deleted psf stars on the image display ?
.le
.ls showplots = yes
Show plots of the selected PSF stars? After each star is selected
interactively by the user, a mesh, contour, or profile plot of the data
subraster around the candidate star is displayed. At this point the user
can accept or reject the star. In interactive mode the user can set showplots
to "yes" or "no".  In non-interactive mode showplots is always "no".
.le
.ls plottype = "mesh"
The default type of plot displayed when selecting PSF stars. The choices
are "mesh", "contour", or "radial".
.le
.ls icommands = ""
The image display cursor or the name of the image cursor command file.
.le
.ls gcommands = ""
The graphics cursor or the name of the graphics cursor command file.
.le
.ls wcsin = ")_.wcsin", wcsout = ")_.wcsout"
The coordinate system of the input coordinates read from \fIphotfile\fR and
\fIpstfile\fR, and of the output coordinates written to \fIpsfimage\fR,
\fIopstfile\fR, \fIgroupfile\fR respectively. The image header coordinate
system is used to transform from the input coordinate system to the "logical"
pixel coordinate system used internally, and from the internal "logical" pixel
coordinate system to the output coordinate system. The input coordinate system
options are "logical", tv", "physical", and "world". The output coordinate
system options are "logical", "tv", and "physical". The image cursor coordinate
system is assumed to be the "tv" system.
.ls logical
Logical coordinates are pixel coordinates relative to the current image.
The  logical coordinate system is the coordinate system used by the image
input/output routines to access the image data on disk. In the logical
coordinate system the coordinates of the first pixel of a  2D image, e.g.
dev$ypix  and a 2D image section, e.g. dev$ypix[200:300,200:300] are
always (1,1).
.le
.ls tv
Tv coordinates are the pixel coordinates used by the display servers. Tv
coordinates  include  the effects of any input image section, but do not
include the effects of previous linear transformations. If the input
image name does not include an image section, then tv coordinates are
identical to logical coordinates.  If the input image name does include a
section, and the input image has not been linearly transformed or copied from
a parent image, tv coordinates are identical to physical coordinates.
In the tv coordinate system the coordinates of the first pixel of a
2D image, e.g. dev$ypix and a 2D image section, e.g. dev$ypix[200:300,200:300]
are (1,1) and (200,200) respectively.
.le
.ls physical
Physical coordinates are pixel coordinates invariant  with respect to linear
transformations of the physical image data.  For example, if the current image
was created by extracting a section of another image,  the  physical
coordinates of an object in the current image will be equal to the physical
coordinates of the same object in the parent image,  although the logical
coordinates will be different.  In the physical coordinate system the
coordinates of the first pixel of a 2D image, e.g. dev$ypix and a 2D
image section, e.g. dev$ypix[200:300,200:300] are (1,1) and (200,200)
respectively.
.le
.ls world
World coordinates are image coordinates in any units which are invariant
with respect to linear transformations of the physical image data. For
example, the ra and dec of an object will always be the same no matter
how the image is linearly transformed. The units of input world coordinates
must be the same as those expected by the image header wcs, e. g.
degrees and degrees for celestial coordinate systems.
.le
The wcsin and wcsout parameters default to the values of the package
parameters of the same name. The default values of the package parameters
wcsin and wcsout are "logical" and "logical" respectively.
.le
.ls cache = ")_.cache"
Cache the image pixels in memory. Cache may be set to the value of the apphot
package parameter (the default), "yes", or "no". By default caching is
disabled.
.le
.ls verify = ")_.verify"
Verify the critical PSF task parameters? Verify can be set to the DAOPHOT
package parameter value (the default), "yes", or "no".
.le
.ls update = ")_.update"
Update the PSF task parameters if \fIverify\fR is "yes"? Update can be
set to the default daophot package parameter value, "yes", or "no".
.le
.ls verbose = ")_.verbose"
Print messages about the progress of the task ? Verbose can be set to the
DAOPHOT package parameter value (the default), "yes", or "no".
.le
.ls graphics = ")_.graphics"
The default graphics device. Graphics can be set to the default DAOPHOT package
parameter value, "yes", or "no".
.le
.ls display = ")_.display"
The  default  image  display  device.  Display can be set to the DAOPHOT
package parameter value (the default), "yes", or "no". By default graphics
overlay is disabled.  Setting display to one of "imdr", "imdg", "imdb", or
"imdy" enables graphics overlay with the IMD graphics kernel. 
.le

.ih
DESCRIPTION

The PSF task builds the point spread function for the IRAF image \fIimage\fR
using stars selected, from the input photometry file \fIphotfile\fR with the
image cursor, and/or by their ids stored in the psf star file \fIpstfile\fR,
and writes the PSF model out to the IRAF image \fIpsfimage\fR, the final
PSF star list to \fIopstfile\fR, and group membership information for the
selected PSF stars to \fIgroupfile\fR. If the DAOPHOT package parameter
\fItext\fR is "yes", then \fIgroupfile\fR is an APPHOT/DAOPHOT text database,
otherwise it is an STSDAS binary table.

The coordinates read from \fIphotfile\fR and \fIpstfile\fR are assumed to be
in coordinate system defined by \fIwcsin\fR. The options are "logical", "tv",
"physical", and "world" and the transformation from the input coordinate
system to the internal "logical" system is defined by the image coordinate
system. The simplest default is the "logical" pixel system. Users working on
with image sections but importing pixel coordinate lists generated from the
parent image must use the "tv" or "physical" input coordinate systems.

The coordinates written to \fIpsfimage\fR, \fIpstfile\fR and \fIgroupfile\fR
are in the coordinate system defined by \fIwcsout\fR with the exception
of the psf model center coordinates PSFX and PSFY which are always in the
logical system of the input image. The options are "logical", "tv", and
"physical". The simplest default is the "logical" system.  Users wishing to
correlate the output coordinates of objects measured in image sections or
mosaic pieces with coordinates in the parent image must use the "tv"
or "physical" coordinate systems.

Suitable PSF stars are normally selected interactively using the image display
and image cursor and matched with the stars in \fIphotfile\fR using the cursor
position and a tolerance specified by the \fImatchrad\fR parameter in the
DAOPARS task. A star must be in the photometry file before it can be used as
a PSF star. If a match is found, PSF checks that the candidate star is not too
close to the edge of the image and that it contains no bad pixels as defined
by \fIdatamin\fR and \fIdatamax\fR in the DATAPARS task. After selection a
mesh, contour, or profile plot of the data subraster around the candidate star
is displayed in the graphics window, PSF enters graphics cursor command mode
and the user is given the option to accept or reject the star.  If the user
accepts the star it is added to the PSF star list.  Commands in the graphics
cursor menu permit the user to manipulate the floor and ceiling levels of the
contour plot and the viewing angles for the mesh plot interactively.

Users who know which stars they wish to use as PSF stars ahead of time or
who are without access to an image display can also select PSF stars by id
number, after which mesh, contour, or radial profile plots will be displayed in
the graphics window in the usual way.

If the user does not wish to see any plots of the PSF stars or interact with
the fitting process, the image cursor may be redirected to a text
file containing cursor commands \fIicommands\fR which specify the PSF stars
to be used in the fit. If \fIplotfile\fR is defined contour, mesh, or profile
plots of the selected psf stars can be saved in a metacode plot file for later
examination.

In interactive mode the PSF star may be initialized by setting \fIpstfile\fR
to a file created by the PSTSELECT task. If \fIshowplot\fR = "yes" the user is
asked to accept or delete each star in the input psf star list.  Other stars
may also be added or deleted from this list at any time with the image cursor.
If \fIinteractive\fR=no or \fIicommands\fR is defined, the PSF stars are read
in from \fIpstfile\fR, and the PSF model is computed and saved without
input from the user.

If \fIcache\fR is yes and the host machine physical memory and working set size
are large enough, the input image pixels are cached in memory. If caching
is enabled and PSF is run interactively the first data access will appear
to take a long time as the entire image must be read in before the data
is actually read. All subsequent measurements will be very fast because PSF
is accessing memory not disk. The point of caching is to speed up random
image access by making the internal image i/o buffers the same size as the
image itself. However if the input object lists are sorted in row order and
sparse caching may actually worsen not improve the execution time. Also at
present there is no point in enabling caching for images that are less than
or equal to 524288 bytes, i.e. the size of the test image dev$ypix, as the
default image i/o buffer is exactly that size. However if the size of dev$ypix
is doubled by converting it to a real image with the chpixtype task then the
effect of caching in interactive is can be quite noticeable if measurements
of objects in the top and bottom halves of the image are alternated.

The output PSF image \fIpsfimage\fR  is normally a 2D  image containing the
image header parameters, "XPSF", "YPSF", "PSFMAG" and "PSFRAD" which define the
centroid, magnitude and size of the PSF model, the parameters "FUNCTION",
"PSFHEIGH", "NPARS", and "PAR#" which define the analytic component of the PSF,
and a single look-up table of residuals from the analytic fit subsampled by a
factor of 2 with respect to the parent image.

If the DAOPARS parameter \fIvarorder\fR = -1, the PSF is fit by the analytic
function and \fIpsfimage\fR has no pixel file.

If the DAOPARS parameter \fIvarorder\fR = 1 or 2, then two or five additional
lookup tables are computed and \fIpsfimage\fR is a 3D image with 3 or 6 planes
respectively. The first two additional look-up tables contain the first
derivatives of the PSF wrt the x and y positions in the image (varorder = 1),
and the next three contains the second derivatives with respect to x ** 2, xy,
and y ** 2 (varorder = 2).

The positions and magnitudes of each of the stars contributing to the PSF model
are also stored in the PSF image header.

\fIGroupfile\fR contains a list of the PSF stars, their nearest neighbors, and
friends of the neighbors. A neighbor is defined to be any star within a
distance of 1.5 * \fIpsfrad\fR / \fIscale\fR + 2.0 * \fIfitrad\fR /
\fIscale\fR + 1 pixels of the PSF star. Friends of the neighbors are defined
to be any stars within 2.0 * \fIfitrad\fR / \fIscale\fR + 1.0 of a neighbor
star. \fIFitrad\fR and \fIpsfrad\fR are respectively the fitting radius and psf
radius parameters in the DAOPARS task. \fIScale\fR is the scale factor defined
in the DATAPARS task.

.ih 
CURSOR COMMANDS

The following cursor commands are available once the image cursor has
been activated.

.nf
	Keystroke Commands 

?	Print help
p	Print photometry for star nearest the cursor
l	List the current psf stars
a	Add star nearest cursor to psf star list
f	Fit the psf
r	Review the fit for all the psf stars
s	Subtract fitted psf from psf star nearest cursor
d	Delete psf star nearest cursor from psf star list
w	Write the psf to the psf image
z	Rebuild the psf from scratch
q	Quit task

	Colon Commands

:p [n]	Print photometry for star n
:a [n]	Add star n to psf star list
:d [n]	Delete star n from psf star list
:s [n]  Subtract fitted psf from psf star n   

	Colon Parameter Editing Commands

# Data dependent parameters which affect the psf computation 

:scale	   [value]	Show/set the image scale (units / pixel)
:fwhmpsf   [value]	Show/set the fwhm of psf (scale units)
:datamin   [value]	Show/set the minimum good data value (counts)
:datamax   [value]	Show/set the maximum good data value (counts)
:matchrad  [value]	Show/set matching radius (scale units)

# Psf computation parameters

:psfimage   [name,name]	Show/set the psf image and groupfile
:function   [string]	Show/set the analytic psf function
:varorder   [integer]	Show/set order of psf function variability
:nclean	    [integer]	Show/set number of cleaning iterations
:saturated  [y/n]	Show/set the use saturated star flag
:psfrad	    [value]	Show/set the psf radius (scale units)
:fitrad	    [value]	Show/set the fitting radius (scale units)


The following cursor commands are available once a star has been selected 
and the graphics cursor has been activated.

	Interactive Graphics Keystroke Commands

?    	Print help
p	Print the photometry for this star
t	Print the plot parameters and data minimum and maximum
a	Accept star and proceed
d	Reject star and select another with image cursor
m	Plot the default mesh plot for this star
n	Increase vertical angle by 15 degrees (mesh plot only)
s	Decrease vertical angle by 15 degrees (mesh plot only)
w	Decrease horizontal angle by 15 degrees (mesh plot only)
e	Increase horizontal angle by 15 degrees (mesh plot only)
c	Plot the default contour plot for this star
r	Plot the radial profile for this star


	Colon Graphics Commands

:m [val] [val]	Set the mesh plot vertical and horizontal viewing angles
:v [val]        Set the mesh plot vertical viewing angle
:h [val]        Set the mesh plot horizontal viewing angle
:c [val] [val]  Set the contour plot floor and ceiling levels
:l [value]	Set the contour plot floor level
:u [value]	Set the contour plot ceiling level
.fi

.ih
ALGORITHMS
The PSF is determined from the actual observed brightness values as a function
of x and y 
for one or more stars in the frame and stored as a two-component model.
The first component is an analytic function which approximates
the light distribution in the cores of the PSF stars. There are
currently 6 choices for the analytic component of the model:
"gauss", "moffat15", "moffat25", "lorentz", "penny1", and "penny2".
The parameters of the analytic component of the psf model are stored
in the psf image header parameters "FUNCTION", "PSFHEIGH", "NPARS",
and "PARN". The magnitude, size, and centroid of the PSF are stored
in the image header parameters "PSFMAG", "PSFRAD", 
"XPSF", "and "YPSF". If \fImatchbyid\fR is "no" or there is no input psf star list "PSFMAG" is
set to the magnitude of the first PSF star in the input photometry file. If \fImatchbyid\fR
is "yes", and there is an input psf star list "PSFMAG" is set to the magnitude of the first psf star
in the psf star list. "XPSF" and "YPSF" are the center of the image.
If \fIvarorder\fR >= 0,
the residuals from this fit are stored as a lookup
table with twice the sampling interval of the original image.
This lookup table is used as additive corrections from the integrated
analytic function to actual observed empirical PSF.
The parameters of the analytic function are computed by fitting
all the stars weighted by their signal-to-noise.
so that the signal-to-noise ratio in
the PSF does not deteriorate as fainter stars are added in. The more
crowded the field the more PSF stars are required to lower the noise
generated by neighbor subtraction.

If the \fIvarorder\fR parameter in the DAOPARS task is set to 1 or 2, two
or five additional lookup
tables containing the first derivatives of the PSF in x and y 
and the second order derivatives of the image with respect to
x ** 2, x * y, and y ** 2 are also written.
This model
permits the PSF fitting process to take account of smooth linear
or quadratic changes in the PSF across the frame caused for example by a tilt in
the detector with respect to the optical axis or low order optical
aberrations.
Users of this option should ensure that the PSF varies in a systematic
way across the frame and that the chosen PSF stars span the entire
region of interest in the frame. To avoid mistaking
neighbor stars for variations in the PSF it is recommended that the
first few iterations of PSF be run with a constant PSF. Only after
neighbor stars have been subtracted reasonably cleanly should
the variable PSF option be enabled.

The brightness of any hypothetical pixel at any arbitrary point within
the PSF is computed as follows. The analytic function 
is integrated over the area of the pixel, a correction is determined
by bicubic interpolation within the lookup table and added to the
integral. Since the values in the table of residuals differ by smaller
amounts between adjacent grid points than the original brightness data
would have, the errors in the interpolation are much less than they would
have been if one  had tried to interpolate directly within the original
data.

.ih
GUIDE TO COMPUTING A PSF IN A CROWDED FIELD

The following is a rough guide to the methodology of computing the
PSF in a crowded field. The procedure outlined below assumes
that the user can either make use of the IRAF display facilities or
has access to a local display program. At a minimum the display program
should be able to display an image, read back the coordinates of objects in the
image, and mark objects in the image.

The crowded field PSF fitting procedure makes use of many of the
DAOPHOT tasks. Details on the setup and operation of each task can be found
in the appropriate manual pages.

.ls [1]
RUN THE DAOFIND and PHOT TASKS ON THE IMAGE OF INTEREST.
.le
.ls [2]
EXAMINE THE IMAGE. Load the image on the display with the IRAF display task.
Using the display itself, the DAOEDIT task, or the IRAF IMEXAMINE task, estimate the radius
at which
the stellar light distribution disappears into the noise for the
brightest candidate PSF star. Call this parameter \fIpsfrad\fR and record it.
Mark the objects detected by DAOFIND with dots on the image display using the
IRAF TVMARK
task. Users at sites with display devices not currently supported by
IRAF should substitute their local versions of DISPLAY and TVMARK.
.le
.ls [3]
SELECT CANDIDATE PSF STARS.
Good PSF stars should have no neighbors
within the fitting radius stored in the DAOPARS task parameter \fIfitrad\fR.
In addition all stars within 1.5 times the psf radius,
(stored in the DAOPARS task parameter
\fIpsfrad\fR), should be significantly fainter than the candidate star.
There should be no bad columns, bad rows or blemishes
near the candidate star. A sufficient number of stars should be
selected in order to reduce the increased noise resulting from the
neighbor subtraction process. Users of the variable PSF option should
take care that the list of PSF stars span the area of interest on the
image. Twenty-five to thirty stars is not unreasonable in this case.

The task PSTSELECT can be used to preselect candidate PSF stars.
These candidate PSF stars can be marked on the image display using the
PDUMP, and TVMARK tasks. Be sure to mark the PSF stars in another
color from the stars found by DAOFIND. Stars can be added to or
subtracted from this list interactively when PSF is run.
.le
.ls [4]
EXAMINE THE PSF STARS FOR NEIGHBORS MISSED BY DAOFIND AND ADD THESE TO
THE PHOT FILE.
Examine the vicinity of the PSF stars on the display checking for neighbor
stars which do not have dots on them indicating that they were
missed by DAOFIND.
If IRAF supports the local display device simply run PHOT interactively
selecting the missing stars with the image cursor.
Be sure to use the same set of PHOT parameters used in step [1] with
the exception of the CENTERPARS
task parameter \fIcalgorithm\fR which should be temporarily set to "centroid".
If IRAF does not support the
local display generate a list of the approximate coordinates of the
missing stars.
Run PHOT in batch mode with this coordinate list as input and with the
parameters set as described above.
Create a new PHOT file by using PCONCAT to add the new PHOT output to the
PHOT output from [1] and renumber using PRENUMBER. Do not resort.
.le
.ls [5]
ESTIMATE OF THE PSF.
Run PSF using the combined PHOT output from [4] and
the list of candidate stars from [3].
Write out the PSF image (extension .psf.#) and the psf group file
(extension .psg.#). The PSF image is the current estimate of the PSF.
.le
.ls [6]
FIT ALL THE STARS IN EACH PSF STAR GROUP IN THE ORIGINAL IMAGE.
Run NSTAR on the image using the output group file (extension .psg.#)
of [5] as the input photometry list. To help prevent the bumps in the initial
PSF from interfering with the profile fits in NSTAR, it may
be necessary to temporarily set the psf radius,
\fIpsfrad\fR in the DAOPARS task,
to about one pixel greater than the separation of the nearest neighbor
to a PSF star.
The fitting radius, \fIfitrad\fR in the
DAOPARS task, should be sufficiently large to include enough
pixels for a good fit but not so large as to include any neighbors
inside the fitting radius.
.le
.ls [7]
SUBTRACT ALL THE FITTED STARS FROM THE ORIGINAL IMAGE.
Run SUBSTAR to subtract the NSTAR results from the original image.
Use the IRAF DISPLAY task or the local display program to display
the subtracted image. If you decreased the value of \fIpsfrad\fR
in [6] use this smaller value when you subtract as well.
.le
.ls [8]
CHECK FOR PREVIOUSLY INVISIBLE FAINT COMPANIONS.
Check to see whether the PSF stars and neighbors subtracted
cleanly or whether there are faint companions that were not previously
visible before.
.le
.ls [9]
APPEND THESE COMPANIONS TO THE PHOT FILE.
Run PHOT on the faint companions in the subtracted image
and append the results to the PHOT file created in [4] using PCONCAT.
Renumber the stars using PRENUMBER.
.le
.ls [10]
SUBTRACT ALL THE PSF NEIGHBOR STARS FROM THE ORIGINAL IMAGE.
Edit the nstar output file (extension .nst.#) removing all the PSF stars
from the file. The PSF stars is the first one in each group. In the
near future this will be done with the PEXAMINE task but at the
moment the text editor can be used for text databases and the TTOOLS
package task TEDIT can be used for tables. PSELECT can also be used
to remove stars with specific id numbers. Run SUBSTAR using the edited
nstar output file as input.
.le
.ls [11]
RECOMPUTE THE PSF.
Run PSF on the subtracted image from [10] using the PHOT file from [9]
as the input stellar photometry file.
Temporarily set the minimum good data value, the \fIdatamin\fR parameter
in the DATAPARS task to a large negative number, to avoid the
enhanced noise where the
stars were subtracted from triggering the bad pixel detector in PSF.
A new psf (extension .psf.#) and new psf group file (extension .psg.#)
will be created. Be sure to increase the \fIpsfrad\fR value to the
original large value found in [2].
.le
.ls [12]
RERUN NSTAR.
Rerun NSTAR on the original image with the newly created group file
(extension .psg.#) as the input stellar photometry file and the newly
computed PSF image (extension .psf.#).
It should not be necessary to reduce the psf radius as in [6]
but the fitting radius should be left at a generous number.
.le
.ls [13]
REPEAT STEPS [7-12] UNTIL THE PSF FIT IS ACCEPTABLE.
If any neighbors are still visible iterate on this process by repeating
steps [7] to [12] until the neighbors completely disappear. The main
point to remember is that each time through the loop the PSF is obtained
from an image in which the neighbors but not the PSF stars have been 
subtracted out while NSTAR and SUBSTAR should be run on the original
picture with all the stars still in it.
.le

.ih
EXAMPLES

1. Compute the PSF for the image dev$ypix. Select stars using the display and
the image cursor and show plots of the data and the residuals from the fit
for each star. Good stars for making the PSF model can be found at (442,410),
(348,189), and (379,67).

.nf
    da> daofind dev$ypix default fwhmpsf=2.5 sigma=5.0 threshold=20.0

        ... answer verify prompts

        ... find stars in the image

        ... answer will appear in ypix.coo.1

    da> phot dev$ypix default default annulus=10. dannulus=5.       \
        apertures = 5.0

        ... answer verify prompts

        ... do aperture photometry on the detected stars

        ... answer will appear in ypix.mag.1

    da> display dev$ypix 1

	... display the image

    da> psf dev$ypix default "" default default default psfrad=9.0 \
        fitrad=3.0 mkstars=yes display=imdr

	... verify the critical parameters

	... move the image cursor to a candidate star and hit the a key,
	    a plot of the stellar data appears

	... type ? for a listing of the graphics cursor menu

	... type a to accept the star, d to reject it

	... move to the next candidate stars and repeat the previous
            steps

	... type l to list all the psf stars

	... type f to fit the psf

	... move cursor to first psf star and type s to see residuals,
            repeat for all the psf stars

	... type w to save the PSF model

	... type q to quit, and q again to confirm

	... the output will appear in ypix.psf.1.imh, ypix.pst.1 and
            ypix.psg.1
.fi


2. Run PSF non-interactively using the photometry file and psf star file
created in the previous example.

.nf
	da> psf dev$ypix default default default default default \
            psfrad=9.0 fitrad=3.0 interactive- plotfile=psf.plots

        ... the output will appear in ypix.psf.2, ypix.psg.2, and
	    ypix.pst.2

        da> gkidir psf.plots

        ... list the plots created by psf 

        da> gkiextract psf.plots 1 | stdgraph

        ... display the surface plots of the first psf star

	da> seepsf ypix.psf.2 ypixpsf

	... convert the sampled PSF look-up table to a PSF image
.fi


3. Setup and run PSF interactively without using the image display cursor.
Use the photometry file created in example 1. Before running PSF in this
manner the user should have a list of the candidate PSF star ids.

.nf
	da> show stdimcur

	... store the default value

	da> set stdimcur = text

	... define the image cursor to be the standard input

	da> epar psf

	... edit the psf parameters

	... move to the datapars line and type :e edit the data dependent
	    parameters, type :q to quit the datapars menu

	... move to the daopars line and type :e edit the daophot fitting
  	    parameters, type :q to quit the daopars menu

	... finish editing the psf parameters

	da> psf dev$ypix default "" default default default \
	    plottype=radial

	... verify critical parameters

	... type :a # where # stands for the id number of the star,
	    a plot of the stellar data appears

	... type a to accept the star, d to reject it

	... repeat for all the PSF stars

	... type l to list the psf stars

	... type f to fit the PSF

	... type :s # where # stands for the id of the psf star, a plot
	    of the model residuals appears

	... type w to save the PSF

	... type q to quit PSF and q again to confirm the quit

	... the output will appear in ypix.psf.3, ypix.pst.3, ypix.psg.3

	da> set stdimcur = stdimage

	... reset the image cursor
.fi


4. Run PSF in non-interactive mode using an image cursor  command file of
instructions called icmds.

.nf
	da> type icmds 
	    :a 106
	    :a 24
	    :a 16
	    :a 68
	    f
	    w
	    q

	da> psf dev$ypix default "" default default default  \
	    icommands=icmds

	... verify the critical parameters

	... the PSF will be constructed from stars 106, 24, 16, 68
	    in the input photometry file

	... the output will appear in ypix.psf.4, ypix.pst.4, ypix.psg.4

.fi


.ih
TIME REQUIREMENTS
.ih
BUGS
.ih
SEE ALSO
datapars,daopars,pstselect,seepsf
.endhelp