-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmimosa_atti.f90
4938 lines (4022 loc) · 133 KB
/
mimosa_atti.f90
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
!|
!********************
Module ATTI_DEFS
!|*******************
!|MODULE ATTI_DEFS
!|*******************
!| CONTAINS GLOBAL DECLARATIONS FOR ATTITUDE CALCULATIONS
!|
!| important variables:
!|---------------------
!| point_max - MAXIMAL POINTING NUMBER
!Integer,parameter::point_max=3000
Real (KIND=8),Parameter :: axes_precision = 1.0d-3
Real (KIND=8),Parameter :: zero_double = 1.0d-15
!| err - ERROR NUMBER
!| 1 = INVALID NUMBER OF POINTINGS
!| 10+DATA_TYPE = OUTSIDE RANGE FOR THE GIVEN DATA_TYPE
!| 15 = INVALID DATA_TYPE
!| 20+DATA_TYPE = INVALID AXIS DIRECTION
Integer :: err
! IF IOView = 1 then image created will be as seen from outside of the sphere
! IF IOViev = -1 then image created will be as seen from inside of the sphere
Integer,Save:: IOView=1
! Image and Carte tangent point displacement with respect
! to the array centre
Real(kind=4),save::ImaTanPointDisX=0.0,ImaTanPointDisY=0.0,&
MapTanPointDisX=0.0,MapTanPointDisY=0.0
!| point_num - NUMBER OF POINTINGS
Integer,Save:: point_num
!| point_rot_mat - ARRAY OF ROTATION MATRICES FOR EACH POINTING
!Real(KIND=8),Dimension(point_max,3,3)::point_rot_mat
Real(KIND=8),Dimension(:,:,:),pointer ::point_rot_mat
!| pointing_table - AUXILIARY ARRAY FOR COMMUNICATION WITH ibis_atti_lib
!Real(KIND=4),Dimension(point_max,3)::pointing_table
!SPR 4357 - change below
Real(KIND=8),Dimension(:,:),pointer::pointing_table
!| array containing exclusion zones in the image
Logical,Dimension(:,:),pointer:: FilterImage
!| Data_Type - INPUT DATA TYPE
!| 1 : Xtel(ra dec) , theta - clockwise angle between
!| the Nord direction and Ztel
!| 2 : Xtel(ra dec) , Ztel(ra dec)
!| 3 : Xtel(x,y,z) , Ztel(x,y,z) in Equatorial System
!| 4 : xXtel(l2,b2) , Ztel(l2,b2) in Galactic System
!| ...........................................
Integer,Save :: Data_Type
!| pixel_ratio - RATIO MASK_PIXEL_DIM/DISTANCE_MASK_TO_DETECTOR
!| ........................................................
Real (KIND=8),Save :: pixel_ratio,pixel_ang_size
! EQUATORIAL COORDINATES OF Xtel AND Ztel AXES
!........................................................
Real(kind=8) , Dimension(3) ::Xtel_eq,Ztel_eq
! Galactic COORDINATES OF Xtel AND Ztel AXES
!........................................................
Real(kind=8) ::l2Xtel,b2Xtel,l2Ztel,b2Ztel
! GALACTIC SYSTEM TYPE
! 1 : B1950.0 FK4
! 2 : J2000.0 FK5
!........................
Integer,Save :: gal_sys_Type
! ALPHA , DELTA (IN DEG. AND RAD.) OF Xtel and Ztel AXES
!.........................................................
Real (KIND=8) :: alphaXtel_deg,deltaXtel_deg
Real (KIND=8) :: alphaXtel_rad,deltaXtel_rad
Real (KIND=8) :: alphaZtel_deg,deltaZtel_deg
Real (KIND=8) :: alphaZtel_rad,deltaZtel_rad
! ANTICLOCKWISE DIRECTION ANGLE (IN DEG. AND RAD.) BETWEEN
! NORD DIRECTION ( IN FIELD OF VIEW) AND +Ztel AXIS
!..........................................................
Real (KIND=8) :: theta_deg,theta_rad
! ROTATION MATRIX BETWEEN EQUATORIAL AND TELESCOPE SYSTEM
!.........................................................
Real (KIND=8) , Dimension(3,3) :: rot_mat
! THE NORD DIRECTION IN THE TANGENT PLANE
Real(kind=8) , Dimension(3) :: Z_nord_dir
Real(kind=8) :: alphaZnord,deltaZnord
!| message_level - MESSAGE LEVEL
!| 0 - NO MESSAGES FROM LIBRARY ROUTINES
!| 1 - DIAGNOSTIC MASSAGES
!|.......................................
Integer ,Save:: message_level=1
!| Interface_Type - INTERFACE TYPE
!| 0 - LABO INPUT FILE
!| 1 - ISDC INTERFACE
!|......................................
Integer ,Save:: Interface_Type=0
! AUXILIARY VARIABLES
!.....................................................
Real(kind=8) , Dimension(3) :: vector,vector1,vector2
Real (KIND=8),Save :: dpi,d360_rad,d270_rad,d180_rad,d90_rad
Real (KIND=8),Save :: deg_to_rad,rad_to_deg,x_tol
Real(KIND=4) ,Save :: spi,s360_rad,s270_rad,s180_rad,s90_rad
! SPR 4357 - change below
Real (KIND=8),Save :: sdeg_to_rad,srad_to_deg
Real (KIND=8) :: yz_radius,d_one,norm
! SLA FUNCTIONS INTERFACE
!.....................................
INTERFACE
! SLA FUNCTIONS DECLARATIONS
Function sla_drange(a)
Real (kind=8) :: a,sla_drange
End Function sla_drange
Function sla_dranrm(a)
Real (kind=8) :: a,sla_dranrm
End Function sla_dranrm
Function sla_dsep(a,b,c,d)
Real (kind=8) :: a,b,c,d,sla_dsep
End Function sla_dsep
Function sla_dbear(a,b,c,d)
Real (kind=8) :: a,b,c,d,sla_dbear
End Function sla_dbear
END INTERFACE
!********************
End Module ATTI_DEFS
!********************
!********************
MODULE ATTI_INTERNAL
!|****************************************************
!|MODULE ATTI_INTERNAL - CONTAINS AUXILIARY PROCEDURES
!| You can use it with the statement
!| USE MODULE ATTI_INTERNAL
!|*****************************************************
CONTAINS
!| A. TAN projection : (alpha,delta) in deg. ==> tangent plane coordinates
!| Versions:
!| 1. DOUBLE PRECISION OF CALL LIST PARAMEMETRS
!| 2. SINGLE PRECISION " " " "
!| 3. POINTING NUMBER VERIFICATION AND ROTATION MATRIX SEARCHING
!|
!| D_CONVN_ADYZ: 1
!| S_CONV_ADYZ : 2+3
!| S_CONVN_ADYZ :2
!|
!....................................................................
Subroutine D_CONVN_ADYZ(alpha_deg,delta_deg,y,z,rot_matrix,pixel,status)
!....................................................................
Use ATTI_DEFS
Implicit None
! INPUT VARIABLES
Real(kind=8) :: alpha_deg,delta_deg ! RA DEC COORD. IN deg
Real(kind=8),Dimension(3,3),Intent(in) :: rot_matrix ! rotation matrix
REAL(kind=8),Intent(in)::pixel
! OUTPUT VARIABLES
Real(kind=8),Intent(out) :: y,z ! TANGENT PLANE COORD.
Integer ,Intent(out) :: status
! status = 1 when x< 0
! The arrival direction is below the detector plane.
! In this case the direction cosines are conserved but
! the resulting point (y,z) is placed outside the radius
! yz_radius.To recover the original position do
! n= dsqrt(y**2+z**2)
! y = y*yz_radius/n
! z = z*yz_radius/n
! status = 2 when x near 0
! This means a very great direction angle with respect to
! the line-of-sight-axis X
! status = 0 otherwise
! AUXILIARY VARIABLES
Real(kind=8) :: a_rad,d_rad,n1
! NO VERIFICATION OF POINTING NUMBER
! ROTATION MATRIX GIVEN IN rot_matrix
STATUS = 0
If((alpha_deg .Lt.0.0d0).or.( alpha_deg .Gt. 360.0d0)) Then
If(message_level ==1) Print *,' ATTENTION RA < 0 !!'
alpha_deg = mod(alpha_deg+360.0d0,360.0d0)
Endif
If(Abs(delta_deg).Gt.90.0d0) Then
If(message_level ==1) Print *,' ATTENTION abs(DEC) > 90 !!'
delta_deg = mod(delta_deg,90.0d0)
Endif
a_rad = alpha_deg*deg_to_rad
d_rad = delta_deg*deg_to_rad
! transformation (a,d) --> (x,y,z) in Equatorial System
Call sla_dcs2c(a_rad,d_rad,vector)
! rotation (x,y,z) Equat. --> (x,y,z) Telescope
Call sla_dmxv(rot_matrix,vector,vector1)
!normalisation
Call sla_dvn(vector1,vector,norm)
! NORMALISATION FACTOR
! transformation to pixel units
n1 = vector(1)
If(n1.Le.0.d0)Then
! ARRIVAL DIRECTION BELOW THE DETECTOR PLANE
STATUS = 1
n1 = (1.d0+10.0d-10 -n1**2) / yz_radius
Else
If(vector(1).Le.x_tol) Then
! TOO BIG ARRIVAL ANGLE
STATUS = 2
Endif
Endif
n1=n1*pixel
vector = vector/n1
! reflection of Y axis
y = IOView*vector(2)
z = vector(3)
!!$if(abs(y) > 1000)then
!!$ print *,vector
!!$endif
!...........................
End Subroutine D_CONVN_ADYZ
!...........................
!....................................................................
Subroutine S_CONVN_ADYZ(alpha_deg,delta_deg,y,z,rot_matrix,pixel,status)
!....................................................................
Use ATTI_DEFS
Implicit None
! INPUT VARIABLES
Real(kind=4),Intent(in) :: alpha_deg,delta_deg ! RA DEC COORD. IN deg
Real(kind=8),Dimension(3,3),Intent(in)::rot_matrix ! ROTATION MATRIX
REAL(kind=4),Intent(in)::pixel
! OUTPUT VARIABLES
Real(kind=4),Intent(out) :: y,z ! TANGENT PLANE COORD.
Integer ,Intent(out) :: status
! status = 1 when x< 0
! The arrival direction is below the detector plane.
! In this case the direction cosines are conserved but
! the resulting point (y,z) is placed outside the radius
! yz_radius.To recover the original position do
! n= dsqrt(y**2+z**2)
! y = y*yz_radius/n
! z = z*yz_radius/n
! status = 2 when x near 0
! This means a very great direction angle with respect to
! the line-of-sight-axis X
! status = 0 otherwise
! AUXILIARY VARIABLES
Real(kind=8) ::a,d, a_rad,d_rad,n1
STATUS = 0
a=alpha_deg
d=delta_deg
If((a.Lt.0.0d0).or.(alpha_deg .Gt. 360.0d0)) Then
If(message_level ==1) Print *,' ATTENTION RA not in (0,360)'
a = mod(a,360.0d0)
Endif
If(Abs(d).Gt.90) Then
If(message_level ==1) Print *,' ATTENTION abs(DEC) > 90 !!'
d = mod(d,90.0d0)
Endif
a_rad = a*deg_to_rad
d_rad = d*deg_to_rad
! transformation (a,d) --> (x,y,z) in Equatorial System
Call sla_dcs2c(a_rad,d_rad,vector)
! rotation (x,y,z) Equat. --> (x,y,z) Telescope
Call sla_dmxv(rot_matrix,vector,vector1)
! NORMALISATION FACTOR
! transformation to pixel units
n1 = vector1(1)
If(n1.Le.0.d0)Then
! ARRIVAL DIRECTION BELOW THE DETECTOR PLANE
STATUS = 1
n1 = (1.d0+10.0d-10 -n1**2) / yz_radius
Else
If(vector1(1).Le.x_tol) Then
! TOO BIG ARRIVAL ANGLE
STATUS = 2
Endif
Endif
n1=n1*pixel
vector1 = vector1/n1
! reflection of Y axis
! RETOUR TO THE SINGLE PRECISION
y = IOView*vector1(2)
z = vector1(3)
!..........................
End Subroutine S_CONVN_ADYZ
!..........................
!........................................................
Subroutine D_CONV_LB_AD(l_deg,b_deg,alpha_deg,delta_deg)
!........................................................
Use ATTI_DEFS
Implicit None
!INPUT/OUTPUT VARIABLES
Real(kind=8)::l_deg,b_deg,alpha_deg,delta_deg
!LOCAL VARIABLES
Real(kind=8):: l_rad,b_rad,cosdltsinalf,sindlt,dlt,alf
l_rad = l_deg*deg_to_rad
b_rad = b_deg*deg_to_rad
call sla_galeq(l_rad,b_rad,alf,dlt)
alpha_deg=alf*rad_to_deg
delta_deg=dlt*rad_to_deg
!...........................
END Subroutine D_CONV_LB_AD
!...........................
!........................................................
Subroutine D_CONV_AD_LB(alpha_deg,delta_deg,l_deg,b_deg)
!........................................................
Use ATTI_DEFS
Implicit None
!INPUT/OUTPUT VARIABLES
Real(kind=8)::alpha_deg,delta_deg,l_deg,b_deg
!LOCAL VARIABLES
Real(kind=8):: dlt,alf,cosbsinl,sinb,b,l
dlt = delta_deg*deg_to_rad
alf = alpha_deg*deg_to_rad
call sla_eqgal(alf,dlt,l,b)
l_deg = l*rad_to_deg
b_deg = b*rad_to_deg
!...........................
END Subroutine D_CONV_AD_LB
!...........................
!........................................................
Subroutine S_CONV_LB_AD(l_deg,b_deg,alpha_deg,delta_deg)
!........................................................
Use ATTI_DEFS
Implicit None
!INPUT/OUTPUT VARIABLES
Real(kind=4)::l_deg,b_deg,alpha_deg,delta_deg
!LOCAL VARIABLES
Real(kind=8):: l_rad,b_rad,cosdltsinalf,sindlt,dlt,alf
l_rad = dble(l_deg)*deg_to_rad
b_rad = dble(b_deg)*deg_to_rad
call sla_galeq(l_rad,b_rad,alf,dlt)
alpha_deg=real(alf)*rad_to_deg
delta_deg=real(dlt)*rad_to_deg
!...........................
END Subroutine S_CONV_LB_AD
!...........................
!........................................................
Subroutine S_CONV_AD_LB(alpha_deg,delta_deg,l_deg,b_deg)
!........................................................
Use ATTI_DEFS
Implicit None
!INPUT/OUTPUT VARIABLES
Real(kind=4)::alpha_deg,delta_deg,l_deg,b_deg
!LOCAL VARIABLES
Real(kind=8):: dlt,alf,cosbsinl,sinb,b,l
dlt = dble(delta_deg)*deg_to_rad
alf = dble(alpha_deg)*deg_to_rad
call sla_eqgal(alf,dlt,l,b)
l_deg = real(l)*rad_to_deg
b_deg = real(b)*rad_to_deg
!...........................
END Subroutine S_CONV_AD_LB
!...........................
!| B. TAN back-projection : tangent plane coordinates ==> (alpha,delta) in deg.
!| Versions:
!| 1. DOUBLE PRECISION OF CALL LIST PARAMEMETRS
!| 2. SINGLE PRECISION " " " "
!|
!| D_CONVN_YZAD: 1
!| S_CONVN_YZAD :2
!|
!................................................................
Subroutine D_CONVN_YZAD(y,z,alpha_deg,delta_deg,rot_matrix,pixel)
!................................................................
Use ATTI_DEFS
Implicit None
! INPUT VARIABLES
Real(kind=8),Intent(in) :: y,z ! COORD. IN TANGENT PLANE
Real(kind=8),Dimension(3,3),Intent(in)::rot_matrix ! ROTATION MATRIX
REAL(kind=8),Intent(in)::pixel !pixel size
!OUTPUT VARIABLES
Real(kind=8),Intent(out) :: alpha_deg,delta_deg ! RA DEC (deg)
! AUXILIARY VARIABLES
Real(kind=8) :: a_rad,d_rad
! TRANSFORMATION TO A VECTOR OF THE DIRECTION IN THE SATELLITE SYSTEM
vector(1) = 1
vector(2) = IOView*(y*pixel)
vector(3) = (z*pixel)
! BACK PROJECTION TO EQUATORIAL SYSTEM
Call sla_dimxv(rot_matrix,vector,vector1)
Call sla_dvn(vector1,vector2,norm)
! (a,d) --> (x,y,z)
Call sla_dcc2s(vector2,a_rad,d_rad)
! normalisation
a_rad = sla_dranrm(a_rad)
d_rad = sla_drange(d_rad)
alpha_deg = a_rad*rad_to_deg
delta_deg = d_rad*rad_to_deg
alpha_deg = MOD(alpha_deg+360.d0,360.0d0)
!..........................
END SUBROUTINE D_CONVN_YZAD
!...........................
!.............................................................
SUBROUTINE S_CONVN_YZAD(y,z,alpha_deg,delta_deg,rot_matrix,pixel)
!.............................................................
Use ATTI_DEFS
Implicit None
! INPUT VARIABLES
Real(kind=4),Intent(in) :: y,z ! COORD. IN TANGENT PLANE
Real(kind=8),Dimension(3,3),Intent(in)::rot_matrix ! ROTATION MATRIX
REAL(kind=4),Intent(in)::pixel
!OUTPUT VARIABLES
Real(kind=4),Intent(out) :: alpha_deg,delta_deg ! RA DEC (deg)
! AUXILIARY VARIABLES
Real(kind=8) :: a_rad,d_rad
! TRANSFORMATION TO A VECTOR OF THE DIRECTION IN THE SATELLITE SYSTEM
vector(1) = 1
vector(2) = IOView*(y*pixel)
vector(3) = (z*pixel)
! BACK PROJECTION TO EQUATORIAL SYSTEM
Call sla_dimxv(rot_matrix,vector,vector1)
! (a,d) --> (x,y,z)
Call sla_dcc2s(vector1,a_rad,d_rad)
! normalisation
a_rad = sla_dranrm(a_rad)
d_rad = sla_drange(d_rad)
alpha_deg = a_rad*rad_to_deg
delta_deg = d_rad*rad_to_deg
alpha_deg = MOD(alpha_deg+360.d0,360.0d0)
!...........................
END SUBROUTINE S_CONVN_YZAD
!...........................
!|C. Cartesian projection/back-projection
!| Versions:
!| 1. DOUBLE PRECISION OF CALL LIST PARAMEMETRS
!| 2. SINGLE PRECISION " " " "
!|
!| D_CAR_ADYZ : 1
!| S_CAR_ADYZ : 2
!| D_CAR_YZAD : 1
!|
!...........................................................
SUBROUTINE D_CAR_ADYZ(alpha,delta,xn,yn,aref,dref,pixel_ang)
!...........................................................
Use ATTI_DEFS
Implicit None
!INPUT VARIABLES
Real(kind=8),Intent(in)::alpha,delta,aref,dref
REAL(kind=8),Intent(in)::pixel_ang !pixel ang size
!OUTPUT VARIABLES
Real(kind=8),Intent(out)::xn,yn
!Local variables
Real(kind=8) :: adiff,a,ar,zref
adiff = alpha-aref
xn =adiff
zref = mod(aref+180.0d0,360.0d0)
if(aref==180.0d0)zref=360.0d0
if((aref.ge.0).and.(aref.le.180.0d0))then
!situation 1
if(alpha .gt.zref)then
xn = adiff-360.0d0
endif
else
!situation 2
if(alpha.le.zref)then
xn = 360.0d0+adiff
endif
endif
xn = IOView*xn
xn = xn/pixel_ang
yn =( delta-dref)/(pixel_ang)
!........................
END SUBROUTINE D_CAR_ADYZ
!........................
!...................................................
SUBROUTINE D_CAR_YZAD(xn,yn,alpha,delta,aref,dref,pixel_ang)
!...................................................
Use ATTI_DEFS
Implicit None
!INPUT VARIABLES
Real(kind=8),Intent(in)::xn,yn,aref,dref
REAL(kind=8),Intent(in)::pixel_ang !pixelANGULAR size
!OUTPUT VARIABLES
Real(kind=8),Intent(out)::alpha,delta
alpha = Mod(IOView*xn*pixel_ang+aref+360.0d0,360.0d0)
!alpha =xn*pixel_ang+aref
delta = yn*pixel_ang+dref
!........................
END SUBROUTINE D_CAR_YZAD
!........................
!...................................................
SUBROUTINE S_CAR_ADYZ(alpha,delta,xn,yn,aref,dref,pixel_ang)
!...................................................
Use ATTI_DEFS
Implicit None
!INPUT VARIABLES
Real(kind=4),Intent(in)::alpha,delta,aref,dref
REAL(kind=4),Intent(in)::pixel_ang
!OUTPUT VARIABLES
Real(kind=4),Intent(out)::xn,yn
!Local variables
Real(kind=4) :: adiff,a,ar
!!$adiff = abs(alpha-aref)
!!$if(adiff.lt.180.0)then
!!$ xn = IOView*(alpha-aref)
!!$else
!!$ if(alpha.lt.180.0)then
!!$ a = alpha+180.0
!!$ ar= aref
!!$ else
!!$ a = alpha
!!$ ar = aref+180.0
!!$ endif
!!$xn = IOView*(a-ar)
!!$endif
xn = xn/pixel_ang
yn =( delta-dref)/(pixel_ang)
!........................
END SUBROUTINE S_CAR_ADYZ
!........................
!| D. MORE GENERAL SUBROUTINES FOR PROJECTION/BACK PROJECTION
!| D_CONVN_YZYZ - TAN backprojection and projection
!| PROJECTION TAN(CAR) - TAN/CAR backprojection and projection
!|
!...................................................................
SUBROUTINE D_CONVN_YZYZ(y1,z1,y2,z2,rot_matrix,pixel1,pixel2,status)
!..................................................................
Use ATTI_DEFS
Implicit None
! INPUT VARIABLES
Real(kind=8) :: y1,z1 ! COORD.( IN THE IMAGE) TANGENT PLANE
Real(kind=8),Dimension(3,3)::rot_matrix ! ROTATION MATRIX
REAL(kind=8),Intent(in)::pixel1,pixel2 !pixel sizes
!OUTPUT VARIABLES
Real(kind=8),Intent(out) :: y2,z2 ! COORD.( IN THE CARTE) TANGENT PLANE
Integer ,Intent(out) :: status
! status = 1 when x< 0
! The arrival direction is below the detector plane.
! In this case the direction cosines are conserved but
! the resulting point (y,z) is placed outside the radius
! yz_radius.To recover the original position do
! n= dsqrt(y**2+z**2)
! y = y*yz_radius/n
! z = z*yz_radius/n
! status = 2 when x near 0
! This means a very great direction angle with respect to
! the line-of-sight-axis X
! status = 0 otherwise
! AUXILIARY VARIABLES
Real(kind=8)::n1
vector(1) = 1.0d0
vector(2) = IOView*(y1*pixel1)
vector(3) = (z1*pixel1)
Call sla_dmxv(rot_matrix,vector,vector1)
! NORMALISATION FACTOR
! transformation to pixel units
n1 = vector1(1)
If(n1.Le.0.d0)Then
! ARRIVAL DIRECTION BELOW THE DETECTOR PLANE
STATUS = 1
n1 = (1.d0+10.0d-10 -n1**2) / yz_radius
Else
If(vector1(1).Le.x_tol) Then
! TOO BIG ARRIVAL ANGLE
STATUS = 2
Endif
Endif
n1=n1*pixel2
vector1 = vector1/n1
! reflection of Y axis
! RETOUR TO THE SINGLE PRECISION
y2 = IOView*vector1(2)
z2 = vector1(3)
!..............................
END SUBROUTINE D_CONVN_YZYZ
!..............................
!.......................................................
SUBROUTINE IMAGE_TO_SKY_PROJECTION(InprojType,OutProjType,pixel1,pixel2,&
pixel_ang1,pixel_ang2,&
arefimage,drefimage,lrefimage,brefimage,&
aref,dref,lref,bref,&
rot_mat1,rot_mat2,rot_mat3,rot_mat4,&
ri,rj,xn,yn,status)
!.......................................................
Use ATTI_DEFS
! USE MIMOSA_GLOBVAR_MODULE
USE MIMOSA_CONTROL_MODULE
Implicit None
!INPUT VARIABLES
INTEGER::InprojType,OutProjType
REAL(kind=8)::pixel1,pixel2,pixel_ang1,&
pixel_ang2,aref,dref,lref,bref
REAL(kind=8)::arefimage,drefimage,lrefimage,brefimage
Real(kind=8),Dimension(3,3)::rot_mat1,rot_mat2,rot_mat3,rot_mat4
REAL(kind=8)::ri,rj
!OUTPUT VARIABLES
REAL(kind=8)::xn,yn
INTEGER::status
!AUXILIARY VARIABLES
REAL(kind=8)::ALPHA,DELTA,l,b
status = 0
!OutProjType - final map projection type
! 0 - cartesian
! 1 - Tangential
! EquaGal - final map proj coordinate system : only for OutProjType=1
! 1 - GAL
! 0 - RA/DEC
!InProjType - input map projection type
! 0 - GAL--CAR
! 1 - RA--CAR
! 2 - RA--TAN
!.................................
!Image - to sky projection
!..................................
!............................
select case (OutProjType)
!............................
!................................
case(1)!
! output projection TANGENTIAL
!..-->TAN
!...............................
select case (InProjType)
case(0)
!GAL--CAR --> TAN
call D_CAR_YZAD(ri,rj,l,b,lrefimage,brefimage,pixel_ang1)
call D_CONV_LB_AD(l,b,alpha,delta)
Call D_CONVN_ADYZ(alpha,delta,xn,yn,&
rot_mat2,pixel2,status)
case(1)
!RA--CAR --> TAN
call D_CAR_YZAD(ri,rj,alpha,delta,arefimage,drefimage,pixel_ang1)
Call D_CONVN_ADYZ(alpha,delta,xn,yn,&
rot_mat2,pixel2,status)
case(2)
!TAN --> TAN
Call D_CONVN_YZYZ(ri,rj,xn,yn,rot_mat3,&
pixel1,pixel2,status)
end select !InProjType
!........................................
case(0)!
! output projection CARTESIAN -->CAR
!........................................
select case (InProjType)
case(0)
!GAL--CAR --> CAR
call D_CAR_YZAD(ri,rj,l,b,lrefimage,brefimage,pixel_ang1)
IF(EquaGal==0)then
!GAL--CAR --> RA-CAR
call D_CONV_LB_AD(l,b,alpha,delta)
Call D_CAR_ADYZ(alpha,delta,xn,yn,aref,dref,pixel_ang2)
else
!GAL--CAR --> GAL-CAR
Call D_CAR_ADYZ(l,b,xn,yn,lref,bref,pixel_ang2)
endif
case(1)
!RA--CAR --> CAR
call D_CAR_YZAD(ri,rj,alpha,delta,arefimage,drefimage,pixel_ang1)
IF(EquaGal==0)then
!RA--CAR -->RA-- CAR
Call D_CAR_ADYZ(alpha,delta,xn,yn,aref,dref,pixel_ang2)
else
!RA--CAR -->GAL-- CAR
call D_CONV_AD_LB(alpha,delta,l,b)
Call D_CAR_ADYZ(l,b,xn,yn,lref,bref,pixel_ang2)
endif
case(2)
!TAN --> CAR
Call D_CONVN_YZAD(ri,rj,alpha,delta,rot_mat1,pixel1)
IF(EquaGal==0)then
!TAN -->RA-- CAR
Call D_CAR_ADYZ(alpha,delta,xn,yn,aref,dref,pixel_ang2)
else
!TAN -->GAL-- CAR
call D_CONV_AD_LB(alpha,delta,l,b)
Call D_CAR_ADYZ(l,b,xn,yn,lref,bref,pixel_ang2)
endif
end select !InProjType
end select !OutProjtype
!aproj = alpha
!dproj = delta
!lproj = l
!bproj = b
!..........................
END SUBROUTINE IMAGE_TO_SKY_PROJECTION
!..........................
!.......................................................
SUBROUTINE SKY_TO_IMAGE_PROJECTION(InprojType,OutProjType,pixel1,pixel2,&
pixel_ang1,pixel_ang2,&
arefimage,drefimage,lrefimage,brefimage,&
aref,dref,lref,bref,&
rot_mat1,rot_mat2,rot_mat3,rot_mat4,&
ri,rj,xn,yn,status)
!.......................................................
Use ATTI_DEFS
USE MIMOSA_GLOBVAR_MODULE
USE MIMOSA_CONTROL_MODULE
Implicit None
!INPUT VARIABLES
INTEGER ::InprojType,OutProjType
REAL(kind=8) ::pixel1,pixel2,pixel_ang1,&
pixel_ang2,aref,dref,lref,bref
REAL(kind=8)::arefimage,drefimage,lrefimage,brefimage
Real(kind=8),Dimension(3,3)::rot_mat1,rot_mat2,rot_mat3,rot_mat4
REAL(kind=8) ::ri,rj
!OUTPUT VARIABLES
REAL(kind=8)::xn,yn
INTEGER::status
!AUXILIARY VARIABLES
REAL(kind=8)::ALPHA,DELTA,l,b
status = 0
!OutProjType - final map projection type
! 0 - cartesian
! 1 - Tangential
! EquaGal - final map proj coordinate system : only for OutProjType=1
! 1 - GAL
! 0 - RA/DEC
!InProjType - input map projection type
! 0 - GAL--CAR
! 1 - RA--CAR
! 2 - RA--TAN
!.................................
!SKY to image projection
!..................................
!............................
select case (OutProjType)
!............................
!................................
case(1)!
! output projection TANGENTIAL
!..-->TAN
!...............................
select case (InProjType)
case(0)
!GAL--CAR <-- TAN
Call D_CONVN_YZAD(ri,rj,alpha,delta,rot_mat2,pixel2)
call D_CONV_AD_LB(alpha,delta,l,b)
Call D_CAR_ADYZ(l,b,xn,yn,lrefimage,brefimage,pixel_ang1)
case(1)
!RA--CAR <-- TAN
Call D_CONVN_YZAD(ri,rj,alpha,delta,rot_mat2,pixel2)
Call D_CAR_ADYZ(alpha,delta,xn,yn,arefimage,drefimage,pixel_ang1)
case(2)
!TAN <-- TAN
Call D_CONVN_YZYZ(ri,rj,xn,yn,rot_mat4,&
pixel2,pixel1,status)
end select !InProjType
!........................................
case(0)!
! output projection CARTESIAN -->CAR
!........................................
select case (InProjType)
case(0)
!GAL--CAR <-- CAR
IF(EquaGal==0)then
!GAL--CAR <-- RA-CAR
Call D_CAR_YZAD(ri,rj,alpha,delta,aref,dref,pixel_ang2)
call D_CONV_AD_LB(alpha,delta,l,b)
Call D_CAR_ADYZ(l,b,xn,yn,lrefimage,brefimage,pixel_ang1)
else
!GAL--CAR <-- GAL-CAR
Call D_CAR_YZAD(ri,rj,l,b,lref,bref,pixel_ang2)
Call D_CAR_ADYZ(l,b,xn,yn,lrefimage,brefimage,pixel_ang1)
endif
case(1)
!RA--CAR <-- CAR
IF(EquaGal==0)then
!RA--CAR <-- RA-- CAR
Call D_CAR_YZAD(ri,rj,alpha,delta,aref,dref,pixel_ang2)
Call D_CAR_ADYZ(alpha,delta,xn,yn,arefimage,drefimage,pixel_ang1)
else
!RA--CAR <--GAL-- CAR
Call D_CAR_YZAD(ri,rj,l,b,lref,bref,pixel_ang2)
call D_CONV_LB_AD(l,b,alpha,delta)
Call D_CAR_ADYZ(alpha,delta,xn,yn,arefimage,drefimage,pixel_ang1)
endif
case(2)
!TAN <-- CAR
IF(EquaGal==0)then
!TAN <--RA-- CAR
Call D_CAR_YZAD(ri,rj,alpha,delta,aref,dref,pixel_ang2)
Call D_CONVN_ADYZ(alpha,delta,xn,yn,&
rot_mat1,pixel1,status)
else
!TAN <--GAL-- CAR
Call D_CAR_YZAD(ri,rj,l,b,lref,bref,pixel_ang2)
call D_CONV_LB_AD(l,b,alpha,delta)
Call D_CONVN_ADYZ(alpha,delta,xn,yn,&
rot_mat1,pixel1,status)
endif
end select !InProjType
end select !OutProjtype
aproj = alpha
dproj=delta
lproj=l
bproj = b
!..........................
END SUBROUTINE SKY_TO_IMAGE_PROJECTION
!..........................
!......................................
SUBROUTINE add_val0(is,im,i,j,in,jn,time,image,ScwExposition,imagevar,&
carte,cartevar,exposure)
!......................................
Implicit None
!INPUT VARIABLES
INTEGER,Intent(in)::is,im,i,j,in,jn
REAL(kind=4) :: time
REAL(kind=4),dimension(:,:),pointer::image,ScwExposition