-
Notifications
You must be signed in to change notification settings - Fork 0
/
PSFavr8.f
2074 lines (2074 loc) · 80.5 KB
/
PSFavr8.f
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
c PSFavr8: average PSFs for cryo/postcryo and rotate
c
c Supports Option 0 and Option 1
c
c Focal-Plane PSF file names:
c
c w1-psf-cryo-wpro.fits
c w1-psf-postcryo-wpro.fits
c w1-psfunc-cryo-wpro.fits
c w1-psfunc-postcryo-wpro.fits
c w2-psf-cryo-wpro.fits
c w2-psf-postcryo-wpro.fits
c w2-psfunc-cryo-wpro.fits
c w2-psfunc-postcryo-wpro.fits
c
c WPhotpmc PSF file names (in Asce and Desc tile subdirs):
c
c unWISE-w1-psf-wpro-01x01-01x01.fits
c unWISE-w1-psfunc-wpro-01x01-01x01.fits
c unWISE-w2-psf-wpro-01x01-01x01.fits
c unWISE-w2-psfunc-wpro-01x01-01x01.fits
c unWISE-w3-psf-wpro-01x01-01x01.fits (if generated)
c unWISE-w3-psfunc-wpro-01x01-01x01.fits (if generated)
c unWISE-w4-psf-wpro-01x01-01x01.fits (if generated)
c unWISE-w4-psfunc-wpro-01x01-01x01.fits (if generated)
c
c ICORE PSF file names (in tile directory):
c
c unwise-w1-psf-awaic-01x01-01x01.fits
c unwise-w2-psf-awaic-01x01-01x01.fits
c
c vsn 1.0 B70725 initial version, cloned from PSFavr8.f
c vsn 1.1 B70804 fixed cryo/postcryo averging for case of no cryo or
c postcryo for given asce or desc.
c vsn 1.2 B70830 changes error-exit stop statements to call exit(64)
c vsn 1.3 B70914 cloned from PSFavr8sd; added option 0 support
c vsn 1.4 B70916 added optional scale factors for psfuncs
c vsn 1.5 B71004 made -sc1 and -sp1 defaults 1.65
c vsn 1.6 B71012 changed psfunc scaling from input to output; no more
c -sc1 -sc2 -sp1 -sp2, now s01 s02 s11 s22 for option-0
c W1 and W2 resp., and option-1 W1 and W2 resp.
c vsn 1.6 B71015 added comments about -h and -mh to tutorial
c vsn 1.6 B71020 added handling for PA zero crossings by allowing up
c 3600 histogram cells and jumping past those with
c zero counts
c vsn 1.6 B71025 added missing CTYPE# lines to awaic headers
c vsn 1.6 B71030 changed CTYPE# from "sin" to "tan" (WISE to unWISE)
c vsn 1.6 B71122 changed MJD0 from start of hibernation to end of
c 4-band cryo
c vsn 1.6 B71128 made MJD0 a command-line parameter
c vsn 1.6 B71207 eliminates "-w" because it is not needed; left in
c Slash variable for convenience, '/' default
c vsn 1.61 B80111 added psfunc scale factor to FITS header
c vsn 1.62 B80128 set default psfunc scale factors back to 1.0
c B80226 changed "end of cryo" to "end of cryo PSF"
c vsn 1.63 B80306 delete FITS files with output names that already exist
c
c=======================================================================
c
Integer*4 IArgC, LNBlnk, FileID, nOSc, nEpoch,
+ NPlanes, NRows, NCols, I, J, N, IStat,
+ ImRPixR, NArgs, NArg, NPix, status, n1ang, n2ang,
+ naxes(2), nOvrSamp, nAngsw1ac, nAngsw1dc, nAngsw2ac,
+ nAngsw2dc, nAngsw1ap, nAngsw1dp, nAngsw2ap,
+ nAngsw2dp, ndir, nHmax, nW1acryo, nW1apostcryo,
+ nW2acryo, nW2apostcryo, nW1dcryo, nW1dpostcryo,
+ nW2dcryo, nW2dpostcryo
Character*200 InFNam, OutFNam, CanPath,
+ OutPath, w1paNam, w2paNam
Character*80 hdrline(100), record
Character*65 EpochStr
Character*11 Vsn, TmpStr, Flag
Character*9 TmpStr9
Character*8 cdate, ctime, TileNam
Character*2 TmpStr2
Character*1 Slash
Logical*4 dbg, GotIN, GotOut, w3, w4, da, ge,
+ GotAng1, GotAng2
c ! Focal-Plane PSFs
Real*4 w1psfc(641,641), w1psfuncc(641,641), ! W1 cryo
+ w1psfp(641,641), w1psfuncp(641,641), ! W1 postcryo
+ w2psfc(641,641), w2psfuncc(641,641), ! W2 cryo
+ w2psfp(641,641), w2psfuncp(641,641), ! W2 postcryo
+ wgt(641,641)
c ! Output wpro PSFs
Real*4 w1psfca(641,641), w1psfuncca(641,641), ! W1 cryo asce
+ w1psfcd(641,641), w1psfunccd(641,641), ! W1 cryo desc
+ w2psfca(641,641), w2psfuncca(641,641), ! W2 cryo asce
+ w2psfcd(641,641), w2psfunccd(641,641), ! W2 cryo desc
+ w1psfpa(641,641), w1psfuncpa(641,641), ! W1 postcryo asce
+ w1psfpd(641,641), w1psfuncpd(641,641), ! W1 postcryo desc
+ w2psfpa(641,641), w2psfuncpa(641,641), ! W2 postcryo asce
+ w2psfpd(641,641), w2psfuncpd(641,641) ! W2 postcryo desc
c
c NOTE: W1 cryo & postcryo will be epoch-averaged and only one output
c unless W3 = T, in which case W1 cryo will be output as W3, and
c W1 postcryo will be output as W1 with no epoch averaging.
c
c W2 cryo & postcryo will be epoch-averaged and only one output
c unless W4 = T, in which case W2 cryo will be output as W4, and
c W2 postcryo will be output as W2 with no epoch averaging.
c
c When cryo and post-cryo are averaged, they are averaged into the
c cryo array, and that is used for output.
c
c ! Output awaic PSFs
Real*4 w1psfawaic(27,27), w2psfawaic(27,27) ! W1 & W2
c ! Option 0 PSFs
Real*4 w1psfopt0(641,641), w2psfopt0(641,641),! W1 & W2
+ w1psfuncopt0(641,641), w2psfuncopt0(641,641)
c
Real*4, allocatable :: w1angsac(:), w2angsac(:), ! ascending cryo
+ w1angsdc(:), w2angsdc(:), ! descending cryo
+ w1angsap(:), w2angsap(:), ! ascending postcryo
+ w1angsdp(:), w2angsdp(:) ! descending postcryo
Real*8 Ang1acMin, Ang1acMax, Ang2acMin, PixSum,
+ Ang2acMax, Ang1dcMin, Ang1dcMax, Ang2dcMin,
+ Ang2dcMax, Ang1apMin, Ang1apMax, Ang2apMin,
+ Ang2apMax, Ang1dpMin, Ang1dpMax, Ang2dpMin,
+ Ang2dpMax, wgt1, wgt2, MJD, MJD0, w1ang, w2ang,
+ f1ac, f1dc, f1ap, f1dp, f2ac, f2dc, f2ap, f2dp,
+ MJD1, MJD2
real*4 dH1ac, dH1dc, Dh2ac, dH2dc,
+ dH1ap, dH1dp, Dh2ap, dH2dp,
+ nullval, dH, xlo, xhi, ylo, yhi,
+ s01, s02, s11, s12
logical*4 anynull
c
common /vdt/ cdate,ctime,vsn
c
Data Vsn/'1.63 B80306'/, nOvrSamp/11/, nHmax/3600/, dH/0.1/,
+ GotIn,GotOut,GotAng1,GotAng2/4*.false./, da/.false./,
+ dbg/.false./, Slash/'/'/, TileNam/'NotGiven'/,
+ Ang1acMin,Ang2acMin,Ang1dcMin,Ang2dcMin/4*99999.9/,
+ Ang1acMax,Ang2acMax,Ang1dcMax,Ang2dcMax/4*-99999.9/,
+ Ang1apMin,Ang2apMin,Ang1dpMin,Ang2dpMin/4*99999.9/,
+ Ang1apMax,Ang2apMax,Ang1dpMax,Ang2dpMax/4*-99999.9/,
+ w3/.false./, w4/.false./, ge/.false./, MJD2/-9.9/,
+ nW1acryo,nW1apostcryo,nW2acryo,nW2apostcryo/4*0/,
+ nW1dcryo,nW1dpostcryo,nW2dcryo,nW2dpostcryo/4*0/,
+ nEpoch/-1/, s01/1.0/, s02/1.0/, s11/1.0/, s12/1.0/
c
c Data MJD0/55469.278/ ! JD = 2455468.5, September 29, 2010
c ! end of 3-band cryo
c Data MJD0/55994.0/ ! JD = 2455468.5, February 1, 2011
c ! start of hibernation
c Data MJD0/55414.932/ ! JD = 2455414.441, August 6, 2010
c ! end of 4-band cryo
Data MJD0/55480.0/ ! JD = 2455480.0, October 11, 2010
c Peter's Preference
c end of cryo PSF
c
c=======================================================================
c
NArgs = IArgC()
If (NArgs .lt. 1) then
print *,'PSFavr8 vsn ', Vsn
print *
print *,'Usage: PSFavr8 <flags specifications>'
print *
print *,'Where the REQUIRED flags and specifications are:'
print *,' -i pathname for the focal-plane PSFs'
print *,' -o directory name for output PSF files'
print *,' (must have "Asce" and "Desc" subdirectories)'
print *,' -a1 W1 filename for rotation angles'
print *,' -a2 W2 filename for rotation angles'
print *
print *,'The OPTIONAL flags and specifications are:'
print *,' -t tile name (e.g., 1124p045)'
print *,' -s01 scale factor for W1 option-0 psfunc (1.0)'
print *,' -s02 scale factor for W2 option-0 psfunc (1.0)'
print *,' -s11 scale factor for W1 option-1 psfunc (1.0)'
print *,' -s12 scale factor for W2 option-1 psfunc (1.0)'
print *,' -w3 output W1 cryo PSF as W3'
print *,' (no cryo/postcryo averaging)'
print *,' -w4 output W2 cryo PSF as W4'
print *,' (no cryo/postcryo averaging)'
print *,' -os oversampling factor for interpolation (11)'
print *,' -e generate a tile epoch text file'
print *,' -h histogram resolution for angles (0.1 deg)'
print *,' -mh maximum number of histogram cells (3600)'
print *,' -d turn on debug prints'
print *,' -da dump angle histograms to stdout'
print *,' -m MJD separating cryo and post-cryo (55480.0)'
c print *,' -w testing on a Windows machine' ! don't need this after all
print *
print *,'If the -h and -mh values cannot span the angle range,'
print *,'the histogram resolution (-h) will be increased as'
print *,'needed to do so.'
stop
end if
c
c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
c
NArg = 0
5 NArg = NArg + 1
call GetArg(NArg,Flag)
call UpCase(Flag)
c ! input path for focal-plane PSFs
If (Flag .eq. '-I') then
call NextNarg(NArg,Nargs)
call GetArg(NArg,CanPath)
if (CanPath(LNBlnk(CanPath):LNBlnk(CanPath)) .ne. Slash)
+ CanPath = CanPath(1:LNBlnk(CanPath))//Slash
GotIn = .true.
c ! Turn debug prints on
else if (Flag .eq. '-D') then
dbg = .true.
print *,'Debug prints enabled'
c ! Dump angle histograms
else if (Flag .eq. '-DA') then
da = .true.
print *,'Angle histograms will be dumped to sdtout'
c
else if (Flag .eq. '-E') then ! Generate tile epoch text file
ge = .true.
print *,'Tile epoch text file will be generated'
c ! output filename stem
else if (Flag .eq. '-O') then
call NextNarg(NArg,Nargs)
call GetArg(NArg,OutPath)
if (OutPath(LNBlnk(OutPath):LNBlnk(OutPath)) .ne. Slash)
+ OutPath = OutPath(1:LNBlnk(OutPath))//Slash
GotOut = .true.
c ! W1 rotation angles
else if (Flag .eq. '-T') then
call NextNarg(NArg,Nargs)
call GetArg(NArg,TileNam)
if (dbg) print *,'TileNam = ', TileNam
c
else if (Flag .eq. '-A1') then ! W1 rotation angles
call NextNarg(NArg,Nargs)
call GetArg(NArg,w1paNam)
if (dbg) print *,'w1paNam = ', w1paNam(1:lnblnk(w1paNam))
GotAng1 = .true.
if (Access(w1paNam(1:lnblnk(w1paNam)),' ') .ne. 0) then
print *,'File not found: ',w1paNam(1:lnblnk(w1paNam))
call exit(64)
end if
c ! W2 rotation angles
else if (Flag .eq. '-A2') then
call NextNarg(NArg,Nargs)
call GetArg(NArg,w2paNam)
if (dbg) print *,'w2paNam = ', w2paNam(1:lnblnk(w2paNam))
GotAng2 = .true.
if (Access(w2paNam(1:lnblnk(w2paNam)),' ') .ne. 0) then
print *,'File not found: ',w2paNam(1:lnblnk(w2paNam))
call exit(64)
end if
c ! Oversampling factor
else if (Flag .eq. '-OS') then
call NextNarg(NArg,Nargs)
call GetArg(NArg,TmpStr)
read (TmpStr, *, err=3000) nOvrSamp
if (dbg) print *,'Oversampling factor = ',nOvrSamp
if (mod(nOvrSamp,2) .eq. 0) then
nOvrSamp = nOvrSamp + 1
print *,'Oversampling factor must be odd; changed to ',nOvrSamp
end if
c ! W1 option-0 psfunc scale factor
else if (Flag .eq. '-S01') then
call NextNarg(NArg,Nargs)
call GetArg(NArg,TmpStr)
read (TmpStr, *, err=3000) s01
if (dbg) print *,'W1 option-0 psfunc scale factor = ',s01
c
else if (Flag .eq. '-S02') then ! W2 option-0 psfunc scale factor
call NextNarg(NArg,Nargs)
call GetArg(NArg,TmpStr)
read (TmpStr, *, err=3000) s02
if (dbg) print *,'W2 option-0 psfunc scale factor = ',s02
c
else if (Flag .eq. '-S11') then ! W1 option-1 psfunc scale factor
call NextNarg(NArg,Nargs)
call GetArg(NArg,TmpStr)
read (TmpStr, *, err=3000) s11
if (dbg) print *,'W1 option-1 psfunc scale factor = ',s11
c
else if (Flag .eq. '-S12') then ! W2 option-1 psfunc scale factor
call NextNarg(NArg,Nargs)
call GetArg(NArg,TmpStr)
read (TmpStr, *, err=3000) s12
if (dbg) print *,'W2 option-1 psfunc scale factor = ',s12
c
else if (Flag .eq. '-H') then ! Histogram resolution
call NextNarg(NArg,Nargs)
call GetArg(NArg,TmpStr)
read (TmpStr, *, err=3000) dH
if (dbg) print *,'Histogram resolution = ',dH
if (dH .le. 0.0) then
print *,'Histogram resolution must be > 0'
call exit(64)
end if
c
else if (Flag .eq. '-M') then ! MJD0
call NextNarg(NArg,Nargs)
call GetArg(NArg,TmpStr)
read (TmpStr, *, err=3000) MJD0
if (dbg) print *,'MJD0 = ',MJD0
c
else if (Flag .eq. '-MH') then ! Max # Histogram cells
call NextNarg(NArg,Nargs)
call GetArg(NArg,TmpStr)
read (TmpStr, *, err=3000) nHmax
if (dbg) print *,'Max # Histogram cells = ',nHmax
if (nHmax .le. 0) then
print *,'Max # Histogram cells must be > 0'
call exit(64)
end if
c ! W1 cryo as W3
else if (Flag .eq. '-W3') then
w3 = .true.
if (dbg) print *,'w3 = T'
c ! W1 cryo as W3
else if (Flag .eq. '-W4') then
w4 = .true.
if (dbg) print *,'w4 = T'
c ! Windows directory backslashes
c else if (Flag .eq. '-W') then ! Windows DOS wil accept forward
c Slash = '\' ! slash in file names
c if (dbg) print *,'Window test; "slash" character = "\"'
end if
c
If (NArg .lt. NArgs) Go to 5
call signon('PSFavr8')
c
c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
c ! Verify input
If (.not.GotIn) then
print *,'ERROR: Input path to focal-plane PSFs not specified'
call exit(64)
end if
c
If (.not.GotOut) then
print *,'ERROR: Output filename stem not specified'
call exit(64)
end if
c
If (.not.GotAng1) then
print *,'ERROR: W1 Rotation angle filename not specified'
call exit(64)
end if
c
If (.not.GotAng2) then
print *,'ERROR: W2 Rotation angle filename not specified'
call exit(64)
end if
c
c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
c ! Set up tile epoch text file
if (ge) open (12, file = TileNam//'-epochs.txt')
c
c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
c ! Set up rotation angles for W1
open (10, file = w1paNam)
n1ang = 0
10 read (10,*, end=15,err=3001) ndir, w1ang, MJD
if (ge) then
if (MJD-MJD2 .gt. 9.9) then ! NOTE: this will probably not
if (nEpoch .ge. 0) then ! work near a pole
write(TmpStr9,'(F9.2)') MJD2
EpochStr = EpochStr(1:lnblnk(EpochStr))//Tmpstr9
write (12,*) EpochStr
end if
nEpoch = nEpoch + 1
write(TmpStr2,'(I2)') nEpoch
write(TmpStr9,'(F9.2)') MJD
if (ndir .eq. 1) then
EpochStr = 'Epoch '//TmpStr2//': Ascending'
else
EpochStr = 'Epoch '//TmpStr2//': Descending'
end if
if (MJD .lt. MJD0) then
EpochStr = EpochStr(1:lnblnk(EpochStr))
+ //' Cryo, MJD Range ='//TmpStr9//' to'
else
EpochStr = EpochStr(1:lnblnk(EpochStr))
+ //' Post-Cryo, MJD Range ='//TmpStr9//' to'
end if
end if
MJD2 = MJD
end if
n1ang = n1ang + 1
if (ndir .eq. 1) then ! 1 --> ascending scan
if (MJD .lt. MJD0) then ! cryo
nW1acryo = nW1acryo + 1
if (w1ang .gt. Ang1acMax) Ang1acMax = w1ang
if (w1ang .lt. Ang1acMin) Ang1acMin = w1ang
else ! postcryo
nW1apostcryo = nW1apostcryo + 1
if (w1ang .gt. Ang1apMax) Ang1apMax = w1ang
if (w1ang .lt. Ang1apMin) Ang1apMin = w1ang
end if
end if
if (ndir .eq. 0) then ! 0 --> descending scan
if (MJD .lt. MJD0) then ! cryo
nW1dcryo = nW1dcryo + 1
if (w1ang .gt. Ang1dcMax) Ang1dcMax = w1ang
if (w1ang .lt. Ang1dcMin) Ang1dcMin = w1ang
else ! postcryo
nW1dpostcryo = nW1dpostcryo + 1
if (w1ang .gt. Ang1dpMax) Ang1dpMax = w1ang
if (w1ang .lt. Ang1dpMin) Ang1dpMin = w1ang
end if
end if
go to 10
c
15 rewind(10)
c ! Gen Epoch File if requested
if (ge) then
if (nEpoch .ge. 0) then
write(TmpStr9,'(F9.2)') MJD2
EpochStr = EpochStr(1:lnblnk(EpochStr))//Tmpstr9
write (12,*) EpochStr
end if
end if
c ! Allocate W1 angle arrays
dH1ac = dH
nAngsw1ac = NInt((Ang1acMax - Ang1acMin)/dH1ac)
if (nAngsw1ac .lt. 1) nAngsw1ac = 1
if (nAngsw1ac .gt. nHmax) then
nAngsw1ac = nHmax
print *,'WARNING: adjusting angle histogram for W1 ac'
end if
dH1ac = (Ang1acMax - Ang1acMin)/float(nAngsw1ac)
allocate(w1angsac(nAngsw1ac))
if (.not.allocated(w1angsac)) then
print *,'ERROR: allocation of w1angsac failed'
print *,' no. elements =',nAngsw1ac
call exit(64)
end if
c
dH1ap = dH
nAngsw1ap = NInt((Ang1apMax - Ang1apMin)/dH1ap)
if (nAngsw1ap .lt. 1) nAngsw1ap = 1
if (nAngsw1ap .gt. nHmax) then
nAngsw1ap = nHmax
print *,'WARNING: adjusting angle histogram for W1 ap'
end if
dH1ap = (Ang1apMax - Ang1apMin)/float(nAngsw1ap)
allocate(w1angsap(nAngsw1ap))
if (.not.allocated(w1angsap)) then
print *,'ERROR: allocation of w1angsap failed'
print *,' no. elements =',nAngsw1ap
call exit(64)
end if
c
dH1dc = dH
nAngsw1dc = NInt((Ang1dcMax - Ang1dcMin)/dH1dc)
if (nAngsw1dc .lt. 1) nAngsw1dc = 1
if (nAngsw1dc .gt. nHmax) then
nAngsw1dc = nHmax
print *,'WARNING: adjusting angle histogram for W1 dc'
end if
dH1dc = (Ang1dcMax - Ang1dcMin)/float(nAngsw1dc)
allocate(w1angsdc(nAngsw1dc))
if (.not.allocated(w1angsdc)) then
print *,'ERROR: allocation of w1angsdc failed'
print *,' no. elements =',nAngsw1dc
call exit(64)
end if
c
dH1dp = dH
nAngsw1dp = NInt((Ang1dpMax - Ang1dpMin)/dH1dp)
if (nAngsw1dp .lt. 1) nAngsw1dp = 1
if (nAngsw1dp .gt. nHmax) then
nAngsw1dp = nHmax
print *,'WARNING: adjusting angle histogram for W1 dp'
end if
dH1dp = (Ang1dpMax - Ang1dpMin)/float(nAngsw1dp)
allocate(w1angsdp(nAngsw1dp))
if (.not.allocated(w1angsdp)) then
print *,'ERROR: allocation of w1angsdp failed'
print *,' no. elements =',nAngsw1dp
call exit(64)
end if
c
w1angsac = 0.0
w1angsap = 0.0
w1angsdc = 0.0
w1angsdp = 0.0
c
do 20 I = 1, n1ang
read(10, *, err=3001) ndir, w1ang, MJD
if (ndir .eq. 1) then
if (MJD .lt. MJD0) then
n = NInt((w1ang - Ang1acMin)/dH1ac + 0.5)
if (n .lt. 1) n = 1
if (n .gt. nAngsw1ac) n = nAngsw1ac
w1angsac(n) = w1angsac(n) + 1.0
else
n = NInt((w1ang - Ang1apMin)/dH1ap + 0.5)
if (n .lt. 1) n = 1
if (n .gt. nAngsw1ap) n = nAngsw1ap
w1angsap(n) = w1angsap(n) + 1.0
end if
end if
if (ndir .eq. 0) then
if (MJD .lt. MJD0) then
n = NInt((w1ang - Ang1dcMin)/dH1dc + 0.5)
if (n .lt. 1) n = 1
if (n .gt. nAngsw1dc) n = nAngsw1dc
w1angsdc(n) = w1angsdc(n) + 1.0
else
n = NInt((w1ang - Ang1dpMin)/dH1dp + 0.5)
if (n .lt. 1) n = 1
if (n .gt. nAngsw1dp) n = nAngsw1dp
w1angsdp(n) = w1angsdp(n) + 1.0
end if
end if
20 continue
close(10)
call ChkPAX(w1angsac,nAngsw1ac,dH1ac)
call ChkPAX(w1angsdc,nAngsw1dc,dH1dc)
call ChkPAX(w1angsap,nAngsw1ap,dH1ap)
call ChkPAX(w1angsdp,nAngsw1dp,dH1dp)
c
if (da) then
print *
print *,'W1 Cryo Ascending angle histogram (bin# Angle Count):'
do 22 n = 1, nAngsw1ac
w1ang = (float(n) - 0.5)* dH1ac + Ang1acMin
if ((w1angsac(n) .gt. 0.0) .or. (n .eq. 1))
+ write (6, '(I4,2F10.2)') n, w1ang, w1angsac(n)
22 continue
print *
print *,'W1 Cryo Descending angle histogram (bin# Angle Count):'
do 24 n = 1, nAngsw1dc
w1ang = (float(n) - 0.5)* dH1dc + Ang1dcMin
if ((w1angsdc(n) .gt. 0.0) .or. (n .eq. 1))
+ write (6, '(I4,2F10.2)') n, w1ang, w1angsdc(n)
24 continue
print *
print *,'W1 Post-Cryo Ascending angle histogram (bin# Angle Count):'
do 26 n = 1, nAngsw1ap
w1ang = (float(n) - 0.5)* dH1ap + Ang1apMin
if ((w1angsap(n) .gt. 0.0) .or. (n .eq. 1))
+ write (6, '(I4,2F10.2)') n, w1ang, w1angsap(n)
26 continue
print *
print *,'W1 Post-Cryo Descending angle histogram (bin# Angle Count):'
do 28 n = 1, nAngsw1dp
w1ang = (float(n) - 0.5)* dH1dp + Ang1dpMin
if ((w1angsdp(n) .gt. 0.0) .or. (n .eq. 1))
+ write (6, '(I4,2F10.2)') n, w1ang, w1angsdp(n)
28 continue
end if
c
if (n1ang .gt. 0) then
f1ac = dfloat(nW1acryo)/dfloat(n1ang)
f1dc = dfloat(nW1dcryo)/dfloat(n1ang)
f1ap = dfloat(nW1apostcryo)/dfloat(n1ang)
f1dp = dfloat(nW1dpostcryo)/dfloat(n1ang)
else
f1ac = 0.0d0
f1dc = 0.0d0
f1ap = 0.0d0
f1dp = 0.0d0
end if
if (dbg) then
print *,'n1ang: ',n1ang
print *,'nW1acryo, f1ac: ', nW1acryo, f1ac
print *,'nW1dcryo, f1dc: ', nW1dcryo, f1dc
print *,'nW1apostcryo, f1ap: ', nW1apostcryo, f1ap
print *,'nW1dpostcryo, f1dp: ', nW1dpostcryo, f1dp
end if
c
c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
c ! Set up rotation angles for W2
open (10, file = w2paNam)
n2ang = 0
30 read (10,*, end=35,err=3002) ndir, w2ang, MJD
n2ang = n2ang + 1
if (ndir .eq. 1) then ! 1 --> ascending scan
if (MJD .lt. MJD0) then ! cryo
nW2acryo = nW2acryo + 1
if (w2ang .gt. Ang2acMax) Ang2acMax = w2ang
if (w2ang .lt. Ang2acMin) Ang2acMin = w2ang
else ! postcryo
nW2apostcryo = nW2apostcryo + 1
if (w2ang .gt. Ang2apMax) Ang2apMax = w2ang
if (w2ang .lt. Ang2apMin) Ang2apMin = w2ang
end if
end if
if (ndir .eq. 0) then ! 0 --> descending scan
if (MJD .lt. MJD0) then ! cryo
nW2dcryo = nW2dcryo + 1
if (w2ang .gt. Ang2dcMax) Ang2dcMax = w2ang
if (w2ang .lt. Ang2dcMin) Ang2dcMin = w2ang
else ! postcryo
nW2dpostcryo = nW2dpostcryo + 1
if (w2ang .gt. Ang2dpMax) Ang2dpMax = w2ang
if (w2ang .lt. Ang2dpMin) Ang2dpMin = w2ang
end if
end if
go to 30
c
35 rewind(10)
dH2ac = dH
nAngsw2ac = NInt((Ang2acMax - Ang2acMin)/dH2ac)
if (nAngsw2ac .lt. 1) nAngsw2ac = 1
if (nAngsw2ac .gt. nHmax) then
nAngsw2ac = nHmax
print *,'WARNING: adjusting angle histogram for W2 ac'
end if
dH2ac = (Ang2acMax - Ang2acMin)/float(nAngsw2ac)
allocate(w2angsac(nAngsw2ac))
if (.not.allocated(w2angsac)) then
print *,'ERROR: allocation of w2angsac failed'
print *,' no. elements =',nAngsw2ac
call exit(64)
end if
c
dH2ap = dH
nAngsw2ap = NInt((Ang2apMax - Ang2apMin)/dH2ap)
if (nAngsw2ap .lt. 1) nAngsw2ap = 1
if (nAngsw2ap .gt. nHmax) then
nAngsw2ap = nHmax
print *,'WARNING: adjusting angle histogram for W2 ap'
end if
dH2ap = (Ang2apMax - Ang2apMin)/float(nAngsw2ap)
allocate(w2angsap(nAngsw2ap))
if (.not.allocated(w2angsap)) then
print *,'ERROR: allocation of w2angsap failed'
print *,' no. elements =',nAngsw2ap
call exit(64)
end if
c
dH2dc = dH
nAngsw2dc = NInt((Ang2dcMax - Ang2dcMin)/dH2dc)
if (nAngsw2dc .lt. 1) nAngsw2dc = 1
if (nAngsw2dc .gt. nHmax) then
nAngsw2dc = nHmax
print *,'WARNING: adjusting angle histogram for W2 dc'
end if
dH2dc = (Ang2dcMax - Ang2dcMin)/float(nAngsw2dc)
allocate(w2angsdc(nAngsw2dc))
if (.not.allocated(w2angsdc)) then
print *,'ERROR: allocation of w2angsdc failed'
print *,' no. elements =',nAngsw2dc
call exit(64)
end if
c
dH2dp = dH
nAngsw2dp = NInt((Ang2dpMax - Ang2dpMin)/dH2dp)
if (nAngsw2dp .lt. 1) nAngsw2dp = 1
if (nAngsw2dp .gt. nHmax) then
nAngsw2dp = nHmax
print *,'WARNING: adjusting angle histogram for W2 dp'
end if
dH2dp = (Ang2dpMax - Ang2dpMin)/float(nAngsw2dp)
allocate(w2angsdp(nAngsw2dp))
if (.not.allocated(w2angsdp)) then
print *,'ERROR: allocation of w2angsdp failed'
print *,' no. elements =',nAngsw2dp
call exit(64)
end if
c
w2angsac = 0.0
w2angsap = 0.0
w2angsdc = 0.0
w2angsdp = 0.0
c
do 40 I = 1, n2ang
read(10, *, err=3002) ndir, w2ang, MJD
if (ndir .eq. 1) then
if (MJD .lt. MJD0) then
n = NInt((w2ang - Ang2acMin)/dH2ac + 0.5)
if (n .lt. 1) n = 1
if (n .gt. nAngsw2ac) n = nAngsw2ac
w2angsac(n) = w2angsac(n) + 1.0
else
n = NInt((w2ang - Ang2apMin)/dH2ap + 0.5)
if (n .lt. 1) n = 1
if (n .gt. nAngsw2ap) n = nAngsw2ap
w2angsap(n) = w2angsap(n) + 1.0
end if
end if
if (ndir .eq. 0) then
if (MJD .lt. MJD0) then
n = NInt((w2ang - Ang2dcMin)/dH2dc + 0.5)
if (n .lt. 1) n = 1
if (n .gt. nAngsw2dc) n = nAngsw2dc
w2angsdc(n) = w2angsdc(n) + 1.0
else
n = NInt((w2ang - Ang2dpMin)/dH2dp + 0.5)
if (n .lt. 1) n = 1
if (n .gt. nAngsw2dp) n = nAngsw2dp
w2angsdp(n) = w2angsdp(n) + 1.0
end if
end if
40 continue
close(10)
call ChkPAX(w2angsac,nAngsw2ac,dH2ac)
call ChkPAX(w2angsdc,nAngsw2dc,dH2dc)
call ChkPAX(w2angsap,nAngsw2ap,dH2ap)
call ChkPAX(w2angsdp,nAngsw2dp,dH2dp)
c
if (da) then
print *
print *,'W2 Cryo Ascending angle histogram (bin# Angle Count):'
do 42 n = 1, nAngsw2ac
w2ang = (float(n) - 0.5)* dH2ac + Ang2acMin
if ((w2angsac(n) .gt. 0.0) .or. (n .eq. 1))
+ write (6, '(I4,2F10.2)') n, w2ang, w2angsac(n)
42 continue
print *
print *,'W2 Cryo Descending angle histogram (bin# Angle Count):'
do 44 n = 1, nAngsw2dc
w2ang = (float(n) - 0.5)* dH2dc + Ang2dcMin
if ((w2angsdc(n) .gt. 0.0) .or. (n .eq. 1))
+ write (6, '(I4,2F10.2)') n, w2ang, w2angsdc(n)
44 continue
print *
print *,'W2 Post-Cryo Ascending angle histogram (bin# Angle Count):'
do 46 n = 1, nAngsw2ap
w2ang = (float(n) - 0.5)* dH2ap + Ang2apMin
if ((w2angsap(n) .gt. 0.0) .or. (n .eq. 1))
+ write (6, '(I4,2F10.2)') n, w2ang, w2angsap(n)
46 continue
print *
print *,'W2 Post-Cryo Descending angle histogram (bin# Angle Count):'
do 48 n = 1, nAngsw2dp
w2ang = (float(n) - 0.5)* dH2dp + Ang2dpMin
if ((w2angsdp(n) .gt. 0.0) .or. (n .eq. 1))
+ write (6, '(I4,2F10.2)') n, w2ang, w2angsdp(n)
48 continue
end if
c
if (n2ang .gt. 0) then
f2ac = dfloat(nW2acryo)/dfloat(n2ang)
f2dc = dfloat(nW2dcryo)/dfloat(n2ang)
f2ap = dfloat(nW2apostcryo)/dfloat(n2ang)
f2dp = dfloat(nW2dpostcryo)/dfloat(n2ang)
else
f2ac = 0.0d0
f2dc = 0.0d0
f2ap = 0.0d0
f2dp = 0.0d0
end if
if (dbg) then
print *,'n2ang: ',n2ang
print *,'nW2acryo, f2ac: ', nW2acryo, f2ac
print *,'nW2dcryo, f2dc: ', nW2dcryo, f2dc
print *,'nW2apostcryo, f2ap: ', nW2apostcryo, f2ap
print *,'nW2dpostcryo, f2dp: ', nW2dpostcryo, f2dp
end if
c
c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
c ! Read in all 8 PSF files
c
InFnam = CanPath(1:LNBlnk(CanPath))//'w1-psf-cryo-wpro.fits'
c
Call GetNAX(InFNam,NCols,NRows,NPlanes,1,xlo,xhi,ylo,yhi,FileID)
if (dbg) print *,'GetNAX returned NCols,NRows,NPlanes,FileID:',
+ NCols,NRows,NPlanes,FileID ! dbg
if (dbg) print *,InFNam(1:lnblnk(InFNam))
if (dbg) print *,'xlo,xhi,ylo,yhi: ', xlo, xhi, ylo, yhi
if ((Ncols .ne. 641) .or. (NRows .ne. 641) .or. (NPlanes .ne.1))
+then
print *,'ERROR: NCols, NRows, NPlanes = ',
+ Ncols,', ',NRows,', ',NPlanes
print *,' in file: ',InFNam(1:lnblnk(InFNam))
print *,' should be 641 by 641'
call exit(64)
end if
c
NPix = NCols*NRows
naxes(1) = NCols
naxes(2) = NRows
c
status = 0
call ftgpve(FileID,1,1,NPix,nullval,w1psfc,anynull,status)
if (dbg) print *,'ftgpve returned ',NPix,' pixels' ! dbg
c
C The FITS file must always be closed before exiting the program.
C Any unit numbers allocated with FTGIOU must be freed with FTFIOU.
call ftclos(FileID, status)
call ftfiou(FileID, status)
c
c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
c
InFnam = CanPath(1:LNBlnk(CanPath))//'w1-psfunc-cryo-wpro.fits'
c
Call GetNAX(InFNam,NCols,NRows,NPlanes,1,xlo,xhi,ylo,yhi,FileID)
if (dbg) print *,'GetNAX returned NCols,NRows,NPlanes,FileID:',
+ NCols,NRows,NPlanes,FileID ! dbg
if (dbg) print *,InFNam(1:lnblnk(InFNam))
if (dbg) print *,'xlo,xhi,ylo,yhi: ', xlo, xhi, ylo, yhi
if ((Ncols .ne. 641) .or. (NRows .ne. 641) .or. (NPlanes .ne.1))
+then
print *,'ERROR: NCols, NRows, NPlanes = ',
+ Ncols,', ',NRows,', ',NPlanes
print *,' in file: ',InFNam(1:lnblnk(InFNam))
print *,' should be 641 by 641'
call exit(64)
end if
c
status = 0
call ftgpve(FileID,1,1,NPix,nullval,w1psfuncc,anynull,status)
if (dbg) print *,'ftgpve returned ',NPix,' pixels' ! dbg
c
C The FITS file must always be closed before exiting the program.
C Any unit numbers allocated with FTGIOU must be freed with FTFIOU.
call ftclos(FileID, status)
call ftfiou(FileID, status)
c
c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
c
InFnam = CanPath(1:LNBlnk(CanPath))//'w1-psf-postcryo-wpro.fits'
c
Call GetNAX(InFNam,NCols,NRows,NPlanes,1,xlo,xhi,ylo,yhi,FileID)
if (dbg) print *,'GetNAX returned NCols,NRows,NPlanes,FileID:',
+ NCols,NRows,NPlanes,FileID ! dbg
if (dbg) print *,InFNam(1:lnblnk(InFNam))
if (dbg) print *,'xlo,xhi,ylo,yhi: ', xlo, xhi, ylo, yhi
if ((Ncols .ne. 641) .or. (NRows .ne. 641) .or. (NPlanes .ne.1))
+then
print *,'ERROR: NCols, NRows, NPlanes = ',
+ Ncols,', ',NRows,', ',NPlanes
print *,' in file: ',InFNam(1:lnblnk(InFNam))
print *,' should be 641 by 641'
call exit(64)
end if
c
status = 0
call ftgpve(FileID,1,1,NPix,nullval,w1psfp,anynull,status)
if (dbg) print *,'ftgpve returned ',NPix,' pixels' ! dbg
c
C The FITS file must always be closed before exiting the program.
C Any unit numbers allocated with FTGIOU must be freed with FTFIOU.
call ftclos(FileID, status)
call ftfiou(FileID, status)
c
c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
c
InFnam = CanPath(1:LNBlnk(CanPath))//'w1-psfunc-postcryo-wpro.fits'
c
Call GetNAX(InFNam,NCols,NRows,NPlanes,1,xlo,xhi,ylo,yhi,FileID)
if (dbg) print *,'GetNAX returned NCols,NRows,NPlanes,FileID:',
+ NCols,NRows,NPlanes,FileID ! dbg
if (dbg) print *,InFNam(1:lnblnk(InFNam))
if (dbg) print *,'xlo,xhi,ylo,yhi: ', xlo, xhi, ylo, yhi
if ((Ncols .ne. 641) .or. (NRows .ne. 641) .or. (NPlanes .ne.1))
+then
print *,'ERROR: NCols, NRows, NPlanes = ',
+ Ncols,', ',NRows,', ',NPlanes
print *,' in file: ',InFNam(1:lnblnk(InFNam))
print *,' should be 641 by 641'
call exit(64)
end if
c
status = 0
call ftgpve(FileID,1,1,NPix,nullval,w1psfuncp,anynull,status)
if (dbg) print *,'ftgpve returned ',NPix,' pixels' ! dbg
c
C The FITS file must always be closed before exiting the program.
C Any unit numbers allocated with FTGIOU must be freed with FTFIOU.
call ftclos(FileID, status)
call ftfiou(FileID, status)
c
c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
c
InFnam = CanPath(1:LNBlnk(CanPath))//'w2-psf-cryo-wpro.fits'
c
Call GetNAX(InFNam,NCols,NRows,NPlanes,1,xlo,xhi,ylo,yhi,FileID)
if (dbg) print *,'GetNAX returned NCols,NRows,NPlanes,FileID:',
+ NCols,NRows,NPlanes,FileID ! dbg
if (dbg) print *,InFNam(1:lnblnk(InFNam))
if (dbg) print *,'xlo,xhi,ylo,yhi: ', xlo, xhi, ylo, yhi
if ((Ncols .ne. 641) .or. (NRows .ne. 641) .or. (NPlanes .ne.1))
+then
print *,'ERROR: NCols, NRows, NPlanes = ',
+ Ncols,', ',NRows,', ',NPlanes
print *,' in file: ',InFNam(1:lnblnk(InFNam))
print *,' should be 641 by 641'
call exit(64)
end if
c
status = 0
call ftgpve(FileID,1,1,NPix,nullval,w2psfc,anynull,status)
if (dbg) print *,'ftgpve returned ',NPix,' pixels' ! dbg
c
C The FITS file must always be closed before exiting the program.
C Any unit numbers allocated with FTGIOU must be freed with FTFIOU.
call ftclos(FileID, status)
call ftfiou(FileID, status)
c
c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
c
InFnam = CanPath(1:LNBlnk(CanPath))//'w2-psfunc-cryo-wpro.fits'
c
Call GetNAX(InFNam,NCols,NRows,NPlanes,1,xlo,xhi,ylo,yhi,FileID)
if (dbg) print *,'GetNAX returned NCols,NRows,NPlanes,FileID:',
+ NCols,NRows,NPlanes,FileID ! dbg
if (dbg) print *,InFNam(1:lnblnk(InFNam))
if (dbg) print *,'xlo,xhi,ylo,yhi: ', xlo, xhi, ylo, yhi
if ((Ncols .ne. 641) .or. (NRows .ne. 641) .or. (NPlanes .ne.1))
+then
print *,'ERROR: NCols, NRows, NPlanes = ',
+ Ncols,', ',NRows,', ',NPlanes
print *,' in file: ',InFNam(1:lnblnk(InFNam))
print *,' should be 641 by 641'
call exit(64)
end if
c
status = 0
call ftgpve(FileID,1,1,NPix,nullval,w2psfuncc,anynull,status)
if (dbg) print *,'ftgpve returned ',NPix,' pixels' ! dbg
c
C The FITS file must always be closed before exiting the program.
C Any unit numbers allocated with FTGIOU must be freed with FTFIOU.
call ftclos(FileID, status)
call ftfiou(FileID, status)
c
c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
c
InFnam = CanPath(1:LNBlnk(CanPath))//'w2-psf-postcryo-wpro.fits'
c
Call GetNAX(InFNam,NCols,NRows,NPlanes,1,xlo,xhi,ylo,yhi,FileID)
if (dbg) print *,'GetNAX returned NCols,NRows,NPlanes,FileID:',
+ NCols,NRows,NPlanes,FileID ! dbg
if (dbg) print *,InFNam(1:lnblnk(InFNam))
if (dbg) print *,'xlo,xhi,ylo,yhi: ', xlo, xhi, ylo, yhi
if ((Ncols .ne. 641) .or. (NRows .ne. 641) .or. (NPlanes .ne.1))
+then
print *,'ERROR: NCols, NRows, NPlanes = ',
+ Ncols,', ',NRows,', ',NPlanes
print *,' in file: ',InFNam(1:lnblnk(InFNam))
print *,' should be 641 by 641'
call exit(64)
end if
c
status = 0
call ftgpve(FileID,1,1,NPix,nullval,w2psfp,anynull,status)
if (dbg) print *,'ftgpve returned ',NPix,' pixels' ! dbg
c
C The FITS file must always be closed before exiting the program.
C Any unit numbers allocated with FTGIOU must be freed with FTFIOU.
call ftclos(FileID, status)
call ftfiou(FileID, status)
c
c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
c
InFnam = CanPath(1:LNBlnk(CanPath))//'w2-psfunc-postcryo-wpro.fits'
c
Call GetNAX(InFNam,NCols,NRows,NPlanes,1,xlo,xhi,ylo,yhi,FileID)
if (dbg) print *,'GetNAX returned NCols,NRows,NPlanes,FileID:',
+ NCols,NRows,NPlanes,FileID ! dbg
if (dbg) print *,InFNam(1:lnblnk(InFNam))
if (dbg) print *,'xlo,xhi,ylo,yhi: ', xlo, xhi, ylo, yhi
if ((Ncols .ne. 641) .or. (NRows .ne. 641) .or. (NPlanes .ne.1))
+then
print *,'ERROR: NCols, NRows, NPlanes = ',
+ Ncols,', ',NRows,', ',NPlanes
print *,' in file: ',InFNam(1:lnblnk(InFNam))
print *,' should be 641 by 641'
call exit(64)
end if
c
status = 0
call ftgpve(FileID,1,1,NPix,nullval,w2psfuncp,anynull,status)
if (dbg) print *,'ftgpve returned ',NPix,' pixels' ! dbg
c
C The FITS file must always be closed before exiting the program.
C Any unit numbers allocated with FTGIOU must be freed with FTFIOU.
call ftclos(FileID, status)
call ftfiou(FileID, status)
c
w1psfopt0 = 0.0
w2psfopt0 = 0.0
w1psfuncopt0 = 0.0
w2psfuncopt0 = 0.0
c
c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
c ! W1 ascending
c
call Rot8(w1psfc,w1psfuncc,nAngsw1ac,dH1ac,w1angsac,nOvrSamp,
+ Ang1acMin,w1psfca,w1psfuncca,wgt)
call Rot8(w1psfp,w1psfuncp,nAngsw1ap,dH1ap,w1angsap,nOvrSamp,
+ Ang1apMin,w1psfpa,w1psfuncpa,wgt)
w1psfopt0 = w1psfopt0 + f1ac*w1psfca + f1ap*w1psfpa
w1psfuncopt0 = w1psfuncopt0 + f1ac*w1psfuncca + f1ap*w1psfuncpa
c
hdrline(1) = 'EXTEND = T /'
+ //' TAPE MAY HAVE STANDARD FITS EXTENSIONS'
hdrline(2) = 'CDELT2 = 9.54861E-05 /'
hdrline(3) = 'CRPIX1 = 321.000 /'
hdrline(4) = 'CRPIX2 = 321.000 /'
hdrline(5) = 'XLO = 1.000 /'
hdrline(6) = 'YLO = 1.000 /'
hdrline(7) = 'XHI = 2048.000 /'
hdrline(8) = 'YHI = 2048.000 /'
write(hdrline(9), '(''NOVRSAMP= '',I10,'' /'')')
+ nOvrSamp
hdrline(12) = 'TILE = '''//TileNam//''''
hdrline(14) = 'PSFTYPE = ''W1'''
c
OutFNam = OutPath(1:LNBlnk(OutPath))
+ //'Asce'//Slash//'unWISE-w1-psf-wpro-01x01-01x01.fits'