-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpsfphot_old_(06-04-12).cl
2934 lines (2676 loc) · 127 KB
/
psfphot_old_(06-04-12).cl
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
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
################################################################################
#
# ===========================================================
# PROCEDURE TO PERFORM POINT SPREAD FUNCTION (PSF) PHOTOMETRY
# ===========================================================
#
# To run properly this procedure must be executed inside the package:
# 'noao.digiphot.daophot'
#
# This script follows the 'A user's guide to stellar CCD photometry
# with IRAF' by Massey & Davis (1992).
#
#
# by Gabriel Perren 2009
################################################################################
procedure psfphot (image, datamax)
file image {prompt = "Input image name"}
#real sky_mean {prompt = "Sky mean value [MEAN]"}
#real sky_std {prompt = "Sky standard desviation value [STDDEV]"}
#real fwhm {prompt = "Typical FWHM for stellar image"}
#real psf_rad {prompt = "(4xFWHM+1 aprox) Radius of bigger PSF star in the frame"}
#real aperture1 {prompt = "(FWHM aprox) Aperture photometry radius [pixels]"}
real datamax {prompt = "Maximum good data value?"}
bool interactive {prompt = "Run under interactive mode?"}
struct *file_var {mode="h", prompt = "Internal file name variable"}
struct *file_var2 {mode="h", prompt = "Internal file name variable"}
struct *flist {mode="h", prompt = "Internal file name variable"}
begin
string imname, imname2
bool filelist_check, check, dopsf, psf_done, no_neighbours, right_sustraction
bool first_psf, first_nstarsubstar, use_psf, star_search, auxi, newstars, doapert
bool sigma_warning, apert_warning, nopsfstar, pstselect, thresh_change, tvmark, pstauto
bool core_psf, rem_psf, better_psf, better_psf2, do_pstselect, apert_null, dao_perf
real dmax, fitrad, psfrad, nstarpsfrad, sigma, gain, rdnoise, sstd, value
real fannulus, sannulu, fdannulu, datamin, sigma_old
real apstd, aperture
real smean, thresh
real min, max, xmin, xmax, ymin, ymax
real avg, mag1, mag2, delta_m, maxnpsf, psfnumber
string m1, m2, null, expression
real diff, oldfitrad, oldthresh, oldpsfrad, olddmax
int k, i, l, n, m, o, p, var1, var2
struct line, line2
imname = image
dmax = datamax
inter=interactive
# ------------------------------------------------------------------------------------
# Package loaded control
if (! defpac ("daophot")) {
print ('\n This script must be loaded inside the package noao/digiphot/daophot')
bye()
}
else {
}
# ------------------------------------------------------------------------------------
# delete ((imname//'.parameters'),verify=no,>>&"/dev/null")
# ------------------------------------------------------------------------------------
# Check image name (if input file has an '@', treat as a list of files iterating through the script)
# ------------------------------------------------------------------------------------
filelist_check = no
if (substr (imname, 1, 1) == "@") {
filelist_check = yes
k = strlen(imname)
imname2 = substr (imname, 2, k)
cp (imname2, 'fitfileslist')
file_var2 = 'fitfileslist'
while (fscan (file_var2,line2) != EOF) {
imname = line2
goto runscript # THESE GOTO STATEMENTS ACCOUNT FOR THE FACT THAT THE INPUT
print ('') # FILE MIGHT BE A LIST OF FILES, ie: @filename
rerun: # IF SO, THEN RUN THE SCRIPT FOR EACH FILE AND THEN EXIT
print ('\n New iteration with file: '//imname) #ELSE, RUN THE SCRIPT FOT THE SINGLE FILE INPUT.
print ('')
}
}
else {
print ('\n Not a list of files: single file')
print (' Running script')
}
if (filelist_check) {
delete ('fitfileslist')
if (sigma_warning == no && apert_warning == no) {
print ('\n ----------------------------------------------------- ')
print (' Script "casleopsf" finished correctly. ')
}
else if (sigma_warning == no && apert_warning == yes) {
print ('\n ----------------------------------------------------- ')
print (' Script "casleopsf" finished with a WARNING: ')
print ('\n WARNING: Not enough stars to compute an aperture correction')
}
else if (sigma_warning == yes && apert_warning == no) {
print ('\n ----------------------------------------------------- ')
print (' Script "casleopsf" finished with a WARNING: ')
print ('\n WARNING: sigma and sstd [SSTDEV] values differed significantly')
print (' sigma = '//sigma_old//' ; sstd = '//sstd)
}
else {
print ('\n ----------------------------------------------------- ')
print (' Script "casleopsf" finished with two WARNINGS: ')
print ('\n WARNING: sigma and sstd [SSTDEV] values differed significantly')
print (' sigma = '//sigma_old//' ; sstd = '//sstd)
print ('\n WARNING: Not enough stars to compute an aperture correction')
}
print ('\n After processing ALL THE CLUSTERs FRAMES:')
print ('\n Move on to the next script: "daom"')
print ('\n Remember this last script must be executed inside the package:')
print ('\n noao/digiphot/photcal ')
print (' ----------------------------------------------------- ')
bye
}
runscript:
print ('\n###########################################', >> (imname//'.parameters'))
date >> (imname//'.parameters')
print ('\nPSF Phot script has started', >> (imname//'.parameters'))
k = strlen(imname)
if (substr (imname, k-4, k) == ".fits") {
print ('\n Image file name: '//imname)
print (' Is this the image name PLUS the \'.fits\' extension? (y/n)')
print (' default = yes')
check = yes
scan (check)
if (check) {
imname = substr (imname, 1, k-5)
print ('\n Renaming file from '//imname//'.fits to '//imname//'.fit')
copy (imname//'.fits', imname//'.fit')
delete (imname//'.fits')
print ('\n\'.fits\' file renamed to \'.fit\' file', >> (imname//'.parameters'))
print ('\n Image name: '//imname)
print ('Image name: ', imname, >> (imname//'.parameters'))
}
else {
print ('\n Unknown \'image name\' error.')
print (' Closing.')
bye()
}
}
else {
if (substr (imname, k-3, k) == ".fit") {
print ('\n Image file name: '//imname)
print (' Is this the image name PLUS the \'.fit\' extension? (y/n)')
print (' default = yes')
check = yes
scan (check)
if (check) {
imname = substr (imname, 1, k-4)
print ('\n Image name: '//imname)
print ('nImage name: ', imname, >> (imname//'.parameters'))
}
else {
print ('\n Unknown \'image name\' error.')
print (' Closing.')
bye()
}
}
else {
print ('\n Image name: '//imname)
print ('\nImage name: ', imname, >> (imname//'.parameters'))
}
}
# ------------------------------------------------------------------------------------
# End of 'Check image name'
# ------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------
# Input 'GAIN', 'RDNOISE' and 'apert_standard' values
# ------------------------------------------------------------------------------------
# Acquire the values of "gain" and "rdnoise" from the file 'gain_rdnoise'
# previously created by "casleored" script. If such file does not exists, input the values.
#
files ('*gain_rdnoise', > 'temp.grd')
file_var = 'temp.grd'
n=0
while (fscan (file_var,line) != EOF) {
n = n + 1
}
if (n == 0) {
print ('\n No "gain_rdnoise" file.')
hselect.mode = "hl"
hselect.images = imname
hselect.fields = "GAIN"
hselect.expr = yes
hselect > "tempget" # Get value from header
file_var = 'tempget'
while (fscan (file_var,gain) != EOF)
del ("tempget")
hselect.mode = "hl"
hselect.images = imname
hselect.fields = "RDNOISE"
hselect.expr = yes
hselect > "tempget" # Get value from header
file_var = 'tempget'
while (fscan (file_var,rdnoise) != EOF)
del ("tempget")
print ('\n GAIN = '//gain)
print (' RDNOISE = '//rdnoise)
print ('\n Accept GAIN and RDNOISE values read from header? (y/n)')
print (' default = yes')
check=yes
scan (check)
if (check) { # Do nothing
}
else {
print ('\n Input GAIN value')
scan (gain)
print (' Input RDNOISE value')
scan (rdnoise)
}
print ('Gain = ', gain, >> (imname//'.parameters'))
print ('Rdnoise = ', rdnoise, >> (imname//'.parameters'))
print (gain, rdnoise, >> 'gain_rdnoise')
}
else {
file_var = 'gain_rdnoise'
while (fscan (file_var, gain, rdnoise) != EOF)
print ('Gain = ', gain, >> (imname//'.parameters'))
print ('Rdnoise = ', rdnoise, >> (imname//'.parameters'))
}
del ('temp.grd')
# Acquire of the "aperture" value used for the standards stars from the file 'apert_standard'
# previously created by "casleored2" script. If such file does not exists, input the value.
#
files ('*apert_standard', > 'temp.apert')
file_var = 'temp.apert'
m=0
while (fscan (file_var,line) != EOF) {
m = m + 1
}
if (m == 0) {
print ('\n No "apert_standard" file.')
print ('\n Input aperture used for standard stars [pixels]')
scan (apstd)
print ('Inputed aperture used for standard stars [pixels] = ', apstd, >> (imname//'.parameters'))
print (apstd, >> 'apert_standard')
}
else {
file_var = 'apert_standard'
while (fscan (file_var, apstd) != EOF)
print ('Aperture used for standard stars [pixels] (from file) = ', apstd, >> (imname//'.parameters'))
}
del ('temp.apert')
# ------------------------------------------------------------------------------------
# End of 'Input 'GAIN', 'RDNOISE' and 'apert_standard' values'
# ------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------
# Get mean FWHM, SKY MEAN and SKY STANDARD DEVIATION value from several stars
# ------------------------------------------------------------------------------------
print ('\n Read values from file obtained with \'getdata\' script')
print (' (else input values manually)? (y/n)')
print (' default = yes')
check = yes
scan (check)
if (check) {
# ------------------------------------------------------------------------------------
# Search for 'imname//'_data'' file
#
auxi=no
while (auxi==no) {
o=0
# Search for "imname//'_data'"
# ------------------------------------------------------------------------------------
files ('*'//imname//'_data', > 'tempfile')
flist = 'tempfile'
while (fscan (flist,line) != EOF) {
o = o + 1
}
del ("tempfile")
# ------------------------------------------------------------------------------------
if (o!=1) {
print('')
print (' ****************************')
print (' Missing "'//imname//'_data" file.')
print (' ****************************')
print ('\n Continue and input values manually (else exit)? (y/n)')
scan (check)
if (check) {
print ('\n Input FWHM, SSTDEV and SKY MEAN values')
print ('\n Input FWHM value')
scan (fitrad)
print ('\n Input SSTDEV value')
scan (sstd)
print ('\n Input SKY MEAN value')
scan (smean)
auxi = yes
}
else {
bye()
}
}
else {
if (o==1) {
print ('')
print ('"'//imname//'_data" file found.')
auxi=yes
i = 1
file_var = imname//'_data'
while (fscan (file_var, value, null) != EOF) {
if (i == 1) {
fitrad = value
print ('\n FWHM = '//fitrad)
}
else {
if (i == 2) {
sstd = value
print ('\n SSTDEV = '//sstd)
}
else {
smean = value
print ('\n Sky Mean = '//smean)
}
}
i = i+1
}
print ('\n Accept values read from file (else input values manually)? (y/n)')
print (' default = yes')
check = yes
scan (check)
if (check) {
}
else {
print ('\n Input FWHM, SSTDEV and SKY MEAN values')
print ('\n Input FWHM value')
scan (fitrad)
print ('\n Input SSTDEV value')
scan (sstd)
print ('\n Input SKY MEAN value')
scan (smean)
}
}
else {
print (' Unknown error. Check code.')
bye()
}
}
} # This bracket closes the 'auxi' 'while'
} # This bracket closes the 'if'
else {
print ('\n Input FWHM, SSTDEV and SKY MEAN values')
print ('\n Input FWHM value')
scan (fitrad)
print ('\n Input SSTDEV value')
scan (sstd)
print ('\n Input SKY MEAN value')
scan (smean)
}
# ------------------------------------------------------------------------------------
# End of 'Get mean FWHM, SKY MEAN and SKY STANDARD DEVIATION value from several stars'
# ------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------
# Input 'psfrad' and 'aperture' values
# ------------------------------------------------------------------------------------
psfrad = 4*fitrad+1 # According to 'A Reference Guide to the IRAF-DAOPHOT Package'
aperture = fitrad # by L. Davis (page 31)
if (inter) {
print ('\n Accept radius of bigger PSF star in the frame')
print (' (\'psfrad\') value as: '//psfrad//' (4xFWHM + 1)')
print (' (else input another \'psfrad\' value)? (y/n)')
print (' default = yes')
check = yes
scan (check)
if (check) { # Do nothing
}
else {
print ('\n Input new \'psfrad\' value:')
scan (psfrad)
}
print ('\n Accept aperture photometry radius [pixels]')
print (' (\'aperture\') value as: '//aperture//' (0+FWHM)')
print (' (else input another \'aperture\' value)? (y/n)')
print (' default = yes')
check = yes
scan (check)
if (check) { # Do nothing
}
else {
print ('\n Input new \'aperture\' value:')
scan (aperture)
print (' New aperture value: aperture = ', aperture, >> (imname//'.parameters'))
}
}
# ------------------------------------------------------------------------------------
# End of 'Input 'psfrad' and 'aperture' values'
# ------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------
# Input parameters
# -------------------------------------------------------------------------------------------
print ('\nParameters used during the PSF procedure', >> (imname//'.parameters'))
print ('', >> (imname//'.parameters'))
print ('Image name = ', imname, >> (imname//'.parameters'))
print ('Sky mean value = ', smean, >> (imname//'.parameters'))
print ('Sky standard desviation value [SSTDEV] = ', sstd, >> (imname//'.parameters'))
print ('Maximum good data value = ', dmax, >> (imname//'.parameters'))
print ('Typical FWHM for stellar images = ', fitrad, >> (imname//'.parameters'))
print ('Radius of bigger PSF star in the frame = ', psfrad, >> (imname//'.parameters'))
print ('Aperture photometry radius [pixels] = ', aperture, >> (imname//'.parameters'))
# -------------------------------------------------------------------------------------------
# End of 'Input parameters'
# -------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Parameters input, Daofind and Phot tasks
# ------------------------------------------------------------------------------
if (smean*gain + rdnoise*rdnoise < 0) {
print ('\n smean*gain + rdnoise*rdnoise < 0')
print (' Inputing sigma = 0.')
sigma_old = 0
sigma = 0
print ('\nWARNING: smean*gain + rdnoise*rdnoise < 0', >> (imname//'.parameters'))
print ('Using sigma=0', >> (imname//'.parameters'))
print ('\nWARNING: smean*gain + rdnoise*rdnoise')
print ('Using sigma=0')
}
else {
sigma = sqrt(smean*gain + rdnoise*rdnoise)/gain
}
sigma_warning = no
diff = sigma - sstd
if ((diff <= -sstd*0.25) || (diff >= sstd*0.25)) { # A difference of less than abs(25%) is acceptable (totally arbitrary criteria)
# Page 27 of 'A Reference Guide to the IRAF-DAOPHOT Package'
# by L. Davis, recommends to check for this difference.
print ('\n WARNING: sigma and sstd [SSTDEV] values differ significantly')
print (' sigma = '//sigma//' ; sstd = '//sstd)
print (' difference = '//diff)
print (' ', >> (imname//'.parameters'))
print (' WARNING: sigma and sstd [SSTDEV] values differ significantly = ', diff, >> (imname//'.parameters'))
print (' sigma = '//sigma//' ; sstd = '//sstd, >> (imname//'.parameters'))
print (' ', >> (imname//'.parameters'))
sigma_warning = yes
if (inter) {
print ('\n Continue (else exit)? (y/n)')
print (' default = yes')
check = yes
scan (check)
if (check) { # Do nothing
}
else {
bye
}
}
}
unlearn datapars
unlearn daopars
print (' ----------------------------------------------------- ')
print (' Datapars and daopars tasks ')
print (' Basic image parameters ')
if (sigma == 0.) {
sigma = sstd
print ('Using SSTDEV to calculate the Threshold', >> (imname//'.parameters'))
print ('\n Using SSTDEV to calculate the Threshold (since sigma = 0)')
}
else {
print ('\n Use \'sigma\'= '//sigma//' value to calculate the threshold as:')
print (' threshold = 3.5*sigma = '//3.5*sigma//' or else use')
print (' \'SSTDEV\'= '//sstd//' value:')
print (' threshold = 3.5*STDDEV = '//3.5*sstd)
print ('\n Input y/n (yes = sigma ; no = STDDEV)')
check=yes
scan (check)
if (check) { # Do nothing
}
else {
sigma = sstd
print ('Using STDDEV to calculate the Threshold', >> (imname//'.parameters'))
}
}
findpars.threshold = 3.5*sigma
print (' Threshold = '//3.5*sigma)
print ('Threshold = ', (3.5*sigma), >> (imname//'.parameters'))
datapars.emission = yes
datapars.fwhmpsf = fitrad
datapars.sigma = sstd
# According to a 'A user's guide to stellar CCD photometry with IRAF' by Massey & Davis
# (page 41): '...set datamin in datapars to some value like (sky value) - 3*sigma
# According ro IRAF's datapar help: '...DAOPHOT users should either leave datamin set to
# INDEF or set it to a number between 5-7 sigma below the sky background value'
#
# So we set this value to smean-4.5*sigma
print ('\n Datamin = smean-4.5*sigma = '//smean-4.5*sigma)
print ('\n Accept datamin value? (y/n)')
print (' default = yes')
check=yes
scan (check)
if (check) {
print ('Datamin = ', (smean-4.5*sigma), >> (imname//'.parameters'))
datamin = smean-4.5*sigma
datapars.datamin = datamin
}
else {
print ('\n Input new datamin value:')
scan (datamin)
print ('Datamin = ', datamin, >> (imname//'.parameters'))
datapars.datamin = datamin
}
datapars.datamax = dmax
daopars.psfrad = psfrad
daopars.fitrad = fitrad # = FWHM
print (' Minimum data value = ' // datamin )
print (' Maximum data value = ' // dmax )
print (' Fitrad = ' // fitrad // ' pixels ')
print (' Psfrad = ' // psfrad // ' pixels ')
print (' ----------------------------------------------------- ')
if (inter) {
print ('\n Accept the following data to be inputed in \'datapars\' ')
print (' (else don\'t overwrite these values and use values already')
print (' stored in \'datapars\' task)? (y/n)')
print (' default = yes')
print ('\n datapars.noise = "poisson"')
print (' datapars.ccdread = "RDNOISE"')
print (' datapars.gain = "GAIN"')
print (' datapars.exposur = "EXPTIME"')
print (' datapars.filter = "FILTERS"')
check = yes
scan (check)
if (check) {
datapars.noise = "poisson"
datapars.ccdread = "RDNOISE"
datapars.gain = "GAIN"
datapars.exposur = "EXPTIME"
datapars.filter = "FILTERS"
}
else {
print ('\n Use stored values in \'datapars\' task (else exit, change')
print (' these values, and re-run the script)? (y/n)')
print (' default = yes')
check = yes
scan (check)
if (check) { # Do nothing
}
else {
bye()
}
}
}
else {
datapars.noise = "poisson"
datapars.ccdread = "RDNOISE"
datapars.gain = "GAIN"
datapars.exposur = "EXPTIME"
datapars.filter = "FILTERS"
}
psf_done=no
while (psf_done == no) { # THIS WHILE CLOSES AFTER THE CHECKING OF THE
# .coo.1, .als.1 and .als.2 (if it exists) FILES
star_search = no
thresh = 3.5*sigma
thresh_change = no
while (star_search == no) {
dao_perf=yes
while (dao_perf) {
if (thresh_change == no) {
print ('\n Perform NEW Daofind (else use EXISTING '//imname//'.coo.1 file)? (y/n)')
print (' (if answer = yes, this will DELETE any \'.coo.1\' file)')
print (' default = no')
check = no
scan (check)
}
else {
check = yes
}
if (check) {
o=0
# Search for "imname.coo.1"
# ------------------------------------------------------------------------------------
files ('*'//imname//'.coo.1', > 'tempfile')
flist = 'tempfile'
while (fscan (flist,line) != EOF) {
o = o + 1
}
del ("tempfile")
# ------------------------------------------------------------------------------------
if (o!=1) {
dao_perf=no # File doesn't exist. Move on.
}
else {
if (o==1) {
print ('\n DELETE '//imname//'.coo.1 file? (y/n)')
scan (check)
if (check) {
delete (imname//'.coo.1',verify=no,>>&"/dev/null")
dao_perf=no
}
else {
dao_perf=yes
}
}
else {
print (' Unknown error. Try again.')
dao_perf=yes
}
}
}
else {
dao_perf=no
# ------------------------------------------------------------------------------------
# Search for 'imname.coo.1' file
# ------------------------------------------------------------------------------------
auxi=no
while (auxi==no) {
o=0
# Search for "imname.coo.1"
# ------------------------------------------------------------------------------------
files ('*'//imname//'.coo.1', > 'tempfile')
flist = 'tempfile'
while (fscan (flist,line) != EOF) {
o = o + 1
}
del ("tempfile")
# ------------------------------------------------------------------------------------
if (o!=1) {
print ('\n ***********************************')
print (' Missing '//imname//'.coo.1 file.')
print (' ***********************************')
print ('\n Search for '//imname//'.coo.1 file again (else run')
print (' \'Daofind\' task to create one)? (y/n)')
print (' default = yes')
check = yes
scan (check)
if (check) {
auxi=no
}
else {
auxi=yes
check = yes # Move on to 'Daofind' task
}
}
else {
if (o==1) {
print ('\n '//imname//'.coo.1 file found.')
auxi=yes
check = no # Do not perform 'Daofind' task
}
else {
print (' Unknown error. Try again.')
dao_perf=yes
}
}
}
# ------------------------------------------------------------------------------------
# End of 'Search for 'imname.coo.1' file'
# ------------------------------------------------------------------------------------
}
} # This bracket closes the 'dao_perf' 'while'
if (check) {
print ('------------', >> (imname//'.parameters'))
print ('Daofind task', >> (imname//'.parameters'))
print ('------------', >> (imname//'.parameters'))
print ('\n ----------------------------------------------------- ')
print (' Daofind task: ')
print (' Search for stars ')
print (' Threshold value: ' // thresh)
print (' ----------------------------------------------------- ')
daofind.verif = no
daofind.verb = yes
daofind.interactive = no
daofind ((imname), (imname//'.coo.1'))
}
file_var = (imname//'.coo.1')
m=0
while (fscan (file_var,line) != EOF) {
m = m + 1
}
print ('\n Number of stars found = '//(m-41))
print ('Number of stars found = ', (m-41), >> (imname//'.parameters'))
print (' Threshold = '//thresh)
print ('\n Star search done.')
print ('\n Press \'y\' key to display stars found.')
print ('\n Else press \'n\' key to DELETE the '//imname//'.coo.1 file,')
print (' select a new \'threshold\' value and perform a new \'Daofind\' run.')
print (' default = yes')
check = yes
scan (check)
if (check) {
tvmark=yes
while (tvmark==yes) {
print ('\n ----------------------------------------------------- ')
print (' Display task: ')
print (' Original Image: ' // imname )
print (' ----------------------------------------------------- ')
display ((imname), 1)
print ('\n ----------------------------------------------------- ')
print (' Tvmark ')
print (' -red point = detected star ')
print (' Add or remove stars in necessary ')
print ('\n -the "a" key to add an undetected star ')
print (' -the "d" key to remove a detected star ')
print (' -the "q" key to exit interactive tvmark ')
print (' ----------------------------------------------------- ')
tvmark.interactive = no
tvmark.mark = 'point'
tvmark.font = "raster"
tvmark.txsize = 2
tvmark.color = 204
tvmark.number = no
tvmark.label = no
tvmark (1, (imname // '.coo.1'))
# The first tvmark marks the stars in the image, found by 'daofind'
# The second one (below this), performs the 'interactive' tvmark.
# If I try to make the first tvmark 'interactive', then
# it doesn't mark the stars, this way the found star are marked
tvmark.interactive = yes
tvmark.number = yes
tvmark.toleran = 4
tvmark (1, (imname // '.coo.1'))
auxi=no
while (auxi == no) {
print ('\n Now, do you want to...:')
print ('\n [1]: Move on to \'phot\' task')
print ('\n [2]: Repeat \'tvmark\' over this \'.coo.1\' file')
print ('\n [3]: Remove all objects inside a rectangular section and')
print (' then re-load \'tvmark\' ')
print ('\n [4]: Repeat \'daofind\' with a different \'threshold\'')
print (' (this means DELETING the actual \'.coo.1\' file)')
print ('\n [5]: Save actual \'.coo.1\' file and exit scritp.')
var2=2
scan (var2)
if (var2==1) {
auxi=yes
tvmark=no
star_search = yes
print('\n Moving on to \'phot\' task.')
}
else {
if (var2==2) {
auxi=yes
tvmark=yes
print('\n Repeating \'tvmark\' over \'.coo.1\' file.')
}
else {
if (var2==3) {
print ('\n Input xmin, ymin, xmax and ymax values like shown below')
print ('')
print (' _______________________[xmax,ymax]')
print (' | |')
print (' | |')
print (' | |')
print (' |_______________________|')
print (' [xmin,ymin]')
print ('\n Input minimum x value')
scan (xmin)
print ('\n Input minimum y value')
scan (ymin)
print ('\n Input maximum x value')
scan (xmax)
print ('\n Input maximum y value')
scan (ymax)
expression = "XCENTER < "//xmin
expression = expression // " "// '|| XCENTER > '//xmax
expression = expression // " "// '|| YCENTER < '//ymin
expression = expression // " "// '|| YCENTER > '//ymax
print ('\n Expression: '//expression)
rename.field = 'all'
rename (imname//'.coo.1', imname//'_original')
pselect.infiles = imname//'_original'
pselect.outfiles = imname//'.coo.1'
pselect.expr = expression
pselect.mode = "hl"
pselect
delete (imname//'_original')
auxi=yes
tvmark=yes
print('\n Repeating \'tvmark\' over \'.coo.1\' file.')
}
else {
if (var2==4) {
print ('\n DELETE '//imname//'.coo.1 file, change \'threshold\' value')
print (' and repeat \'Daofind\'? (y/n)')
print (' default = yes')
scan (check)
if (check) {
auxi=yes
tvmark=no
thresh_change = yes
print ('\n Actual threshold = ' //thresh)
print (' Input new threshold value')
print ('\n (A higher threshold means less stars)')
scan (thresh)
findpars.threshold = thresh
print ('New Findpars.threshold = ', thresh, >> (imname//'.parameters'))
del (imname// '.coo.1')
}
else {
auxi=no
}
}
else {
if (var2==5) {
print ('\n Halt script')
bye()
}
else {
print (' Invalid choice. Try again.')
auxi=no
}
}
}
}
} # This bracket closes the 'if (var2==1)' 'else'
} # This bracket closes the 'while (auxi == no)' 'while'
} # This bracket closes the 'tvmark' 'while'
} # This bracket closes the 'if (check)' 'if' after 'Star search done'
else {
star_search = no
print ('\n DELETE '//imname//'.coo.1 file, change \'threshold\' value')
print (' and repeat \'Daofind\' (else exit script)? (y/n)')
print (' default = yes')
check=yes
scan (check)
if (check) {
print ('\n Actual threshold = ' //thresh)
print (' Input new threshold value')
print ('\n (A higher threshold means less stars)')
thresh_change = yes
scan (thresh)
findpars.threshold = thresh
print ('New Findpars.threshold = ', thresh, >> (imname//'.parameters'))
del (imname// '.coo.1')
}
else {
print ('****************************', >> (imname//'.parameters'))
print ('Exited script after Daofind', >> (imname//'.parameters'))
bye()
}
}
} # This bracket closes the 'star_search' 'while'
print ('\n ----------------------------------------------------- ')
print (' Phot task (first run) ')
print (' Aperture = '//aperture )
print (' ----------------------------------------------------- ')
# print ('\n Recenter stars marked by tvmark?')
# print (' (Useful when using .coo. files from other frames)')
# print (' default = no')
# check = no
# scan (check)
# if (check) {
#
# apphot
#
# unlearn centerpars
# unlearn fitskypars
# unlearn photpars
# unlearn psf
# fitskypars.salgorithm = "mode" # From Massey-Davis guide to stellar CCD photometry
# centerpars.calgorithm = "centroid"
# centerpars.cbox = 2.5*fitrad
# fannulus = 4*fitrad
# fdannulu = 3.25*fitrad
# fitskypars.annulus = fannulus
# fitskypars.dannulus = fdannulu
#
# phot.interactive = no
# phot.radplots = no
# phot.update = yes
# phot.verbose = yes
# phot.verify = no
# photpars.apertures = aperture
# phot ((imname), "default", "default")
#
# daophot
#
# }
# else {
unlearn centerpars
unlearn fitskypars
unlearn photpars
unlearn psf
fitskypars.salgorithm = "mode" # From Massey-Davis guide to stellar CCD photometry
centerpars.calgorithm = "none"
# According to 'A Reference Guide to the IRAF-DAOPHOT Package'
# by L. Davis (page 31): cbox = 2xFWHM (or 5, wichever is greater)
# annulus = 4xFWHM
# dannulu = 2.5-4.0xFWHM
# According to IRAF help: a reasonable value for 'cbox' is 2.5-4.0 * FWHM
# According to 'A User's Guide to Stellar CCD Photometry with IRAF'
# by Massey-Davis (page 47): cbox = 5 (approx 2.0-3.0xFWHM)
# annulus = 10 (approx 3.0-4.0xFWHM)
# dannulu = 10 (approx 3.0-4.0xFWHM)
centerpars.cbox = 2.5*fitrad
fannulus = 4*fitrad
fdannulu = 3.25*fitrad
fitskypars.annulus = fannulus
fitskypars.dannulus = fdannulu
print ('\n Fitskypars.annulus = '//fannulus//' (4*fitrad)')
print (' Fitskypars.dannulus = '//fdannulu//' (3.25*fitrad)')
if (inter) {
print ('\n Accept \'annulus\' and \'dannulu\' values (else')
print (' input new values)? (y/n)')
print (' default = yes')
check = yes
scan (check)
if (check) {
print ('Fitskypars.annulus = ', fannulus, >> (imname//'.parameters'))
print ('Fitskypars.dannulu = ', fdannulu, >> (imname//'.parameters'))
}
else {
print (' Input new \'annulus\' value')
scan (fannulus)
print (' Input new \'dannulus\' value')
scan (fdannulu)
fitskypars.annulus = fannulus
fitskypars.dannulus = fdannulu
print ('Fitskypars.annulus = ', fannulus, >> (imname//'.parameters'))
print ('Fitskypars.dannulus = ', fdannulu, >> (imname//'.parameters'))
}
}
else {
print ('Fitskypars.annulus = ', fannulus, >> (imname//'.parameters'))
print ('Fitskypars.dannulus = ', fdannulu, >> (imname//'.parameters'))
}
phot.interactive = no
phot.radplots = no
phot.update = yes
phot.verbose = yes
phot.verify = no
photpars.apertures = aperture
phot ((imname), "default", "default")