forked from lucasjord/spirals
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfit_geoblocks_tropos.f
3602 lines (2897 loc) · 108 KB
/
fit_geoblocks_tropos.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
program fit_geoblocks_tropos
c v4: skipped
c v5: free format reading of delay-rate file, hopefully to
c be more immune to print format changes in AIPS versions
c v5a: added LMT coordinates (very approximate; get better ones later)
c v5b: added AuScope antennas
c v5c: upped dimension to allow for more than 100 sources in SU table
c v6: Added the effects of clock accelerations to ATMOS.FITS file
c This will replace the normal ATMOS.FITS file with one that
c has entries more often so as to track clock acceleration.
c v6a: Found a test for 100 sources in read_geodetic_file;
c changed to 300
c v6b: Increased from 1000 to 3000 station-oriented data points
c v7: Expanded to allow up to 10 geoblocks
c v7a: Found a test for 500 sources in read_geodetic_file;
c changed to 1000
c This version is for tropospheric data only (eg, dispersive
c delay corrected X-band or high (>20 GHz) frequency data).
c Uses Niell (1999) mapping wet function instead of approximation
c in TMS used in fit_geoblocks_v2c.f
C Input files:
C 1) "control_file.inp" provides parameter controls,
C date & freq
C 2) "station_file.inp" provides station names/numbers
C 3) "calibrator_file.inp provides 2 file names:
c delay/rate data
c su_table positions
implicit real*8 ( a-h, o-z )
real*8 new_params(156),param_sigmas(156),
+ params(156), param_incr(156), param_limits(156)
character*8 parnames(156)
integer paramids(156)
real*8 data(200000), model(200000), resids(200000),
+ res_err(200000), wtres(200000), gst(200000)
real*8 partls(200000,156)
real*8 ut_min(10), ut_max(10), ut_blk(10)
integer n_stat_a(200000), n_stat_b(200000),
+ n_source(200000), n_block(200000)
integer num_per_stat_geo(12), num_per_stat_blk(12,10),
+ list_stations(12)
character*32 infile, outfile, geodetic_data_file
logical print_cor, print_solution, used_clock_accel
common /constants/ c,pi,twopi,secday,sidereal_rate,
+ deg_rad,asec_rad,frequency,wavelength
real*8 x(12), y(12), z(12), cal_ra(1000), cal_dec(1000)
common/geometry/ x,y,z,gast0,cal_ra,cal_dec,num_stations
luprint = 6
write (luprint,1100)
1100 format (/30x,'Program fit_geoblocks_tropos_v7: 2017 Apr 10')
c Dimension Limits:
max_num_data =200000 ! max number data equations
num_params = 156 ! max number of parameters
num_stations = 12 ! max number of antennas
max_blocks = 10 ! max number of blocks
c ------------------------------------------------------------
c Constants, Array Geometry, and Control Parameters
call set_constants
c Read "stations_file.inp"...
call input_stations ( list_stations, n_stats_used )
c Read "calibrator_file.inp"...
call input_calibrators ( geodetic_data_file )
c Read "control_file.inp" (to get control parameters)...
call input_controls ( max_blocks,
+ num_sources,itermax,gain,debug,
+ data_format, nth_print,
+ iyr, mon, iday,
+ num_blocks, ut_min, ut_max, stm_mid,
+ delay_err, rate_err, geo_reweight,
+ num_params, params, paramids, parnames,
+ param_incr, param_limits)
C --------------------------------------------------------------------
C Geodetic-like data input
infile = geodetic_data_file ! rates/delays for many calibrators
c Read in rate-delay data pairs for many calibrators,
c and add to end of "data" array
call read_geodetic_file ( debug, infile,
+ max_num_data, num_data,
+ max_blocks, num_blocks,
+ ut_min, ut_max, ut_blk,
+ gst, gst_mid,
+ n_stat_a, n_stat_b, n_source, n_block,
+ num_per_stat_geo, num_per_stat_blk,
+ num_geo_pts, num_geos,
+ data )
if ( stm_mid .eq. 0.d0 ) stm_mid = gst_mid
C -------------------------------------------------------------
C Don't solve for parms if too little data
i_0 = 0 ! start of clock offsets
i_1 = 1 * num_stations ! start of clock rates
i_2 = 2 * num_stations ! start of clock accelerations
do i_ns = 1, num_stations
if ( num_per_stat_geo(i_ns) .lt. 4 ) then
paramids(i_0 + i_ns) = 0 ! clock offsets
paramids(i_1 + i_ns) = 0 ! clock rates
paramids(i_2 + i_ns) = 0 ! clock accelerations
endif
enddo
c Check each station/block for too little data...
do i_ns = 1, num_stations
do i_b = 1, num_blocks
if ( num_per_stat_blk(i_ns,i_b) .lt. 4 ) then
i_0 = (2 + i_b) * num_stations
paramids(i_0 + i_ns) = 0 ! zenith delay for station/block
endif
enddo
enddo
C -------------------------------------------------------------
C Count up number of solved-for parameters
num_params_solved_for = 0
do i_p = 1, num_params
if ( paramids(i_p) .gt. 0 ) then
num_params_solved_for = num_params_solved_for + 1
endif
enddo
write (6,1200) num_params_solved_for
1200 format(/' Solving for',i3,' parameters',/1x)
C ------------------------------------------------------------
C Print out reference time being used...
ut_mid_rads = (stm_mid - gast0)/sidereal_rate ! UT (radians)
call radians_to_hhmmss (ut_mid_rads, ut_mid_hhmmss)
write (6,1226) ut_mid_hhmmss
1226 format(/' Reference UT time for fits (hhmmss.s):',f12.1)
C ------------------------------------------------------------
C Iterate Least-Squares Fitting
idebug = debug + 0.5
print_cor = .false.
iterpass = 0
sigsq = 9999.d0
do while ( iterpass.le.itermax )
if ( iterpass .ge. 1 ) then
call calc_partials ( debug,
+ num_data,
+ gst, stm_mid,
+ n_stat_a, n_stat_b, n_source, n_block,
+ num_params, params, paramids,
+ partls )
c Before calling l-s-fit, decide what it will print out...
if ( iterpass.eq.itermax ) then
c Always print out last solution and correlations
print_cor = .true.
print_solution = .true.
else
if ( mod(iterpass-1,nth_print).eq.0 .and.
+ iterpass .ne. 1 ) then
print_solution = .true.
else
print_solution = .false.
endif
endif
c Pass error correction factor to L-S routine
err_factor = sqrt( float(num_geos)/float(num_geo_pts) )
call least_squares_fit( idebug,print_solution,
+ print_cor,max_num_data,
+ num_params,num_data, err_factor,
+ parnames,params,paramids,resids,
+ partls,res_err,new_params,param_sigmas )
call update_params ( debug, num_params, param_incr,
+ param_limits, gain, params, new_params )
endif
call calc_residuals ( debug, params,
+ num_data,
+ gst, stm_mid, n_source,
+ n_stat_a, n_stat_b, n_block,
+ data, model, resids )
call weight_data (num_data,
+ delay_err, rate_err, geo_reweight,
+ resids, res_err)
call calc_sigsq (num_data, num_params_solved_for,
+ geo_reweight,
+ resids, res_err,
+ sigsq_old, sigsq, sigma_pdf)
if ( iterpass .ge. 1 ) then
write (luprint,2500) iterpass
2500 format (' End iteration #',i2,/)
endif
iterpass = iterpass + 1
enddo
c ==============================================================
c OUTPUTS
c --------------------------------------------------------------
c Make a copy of the "control_file.inp" with all the new
c parameter values...call it "control_file.out"
call new_control_file (parnames,params,paramids,
+ num_params, num_sources,
+ data_format, itermax, gain, debug,
+ iyr,mon,iday,
+ max_blocks, ut_min, ut_max, stm_mid,
+ delay_err, rate_err, geo_reweight )
c --------------------------------------------------------------
c Print data/model/residuals...
if ( debug .ge. 1.d0 ) then
call print_all_resids ( data, model, resids,
+ res_err, wtres, num_data, lu_print )
endif
c --------------------------------------------------------------
c Make ascii files for plotting...
call geo_plot_files ( num_data,
+ list_stations, n_stats_used,
+ n_stat_a, n_stat_b, gst,
+ data, model, resids, res_err )
c --------------------------------------------------------------
c Make file of atmospheric corrections in CLCOR/ATMO format
ut_mid_data_rads = (gst_mid - gast0)/sidereal_rate ! UT (radians)
call make_delzn_2c( params, param_sigmas, delay_err,
+ ut_mid_rads, ut_blk,
+ num_sources, num_blocks,
+ list_stations, n_stats_used )
c Check if a clock acceleration was used...if so need frequent
c entries in ATMOS.FITS to track the changes.
used_clock_accel = .false.
do i_s = 1, n_stats_used
n_s = 2*num_stations + i_s
if ( params(n_s) .ne. 0.d0 ) used_clock_accel = .true.
enddo
if ( used_clock_accel ) then
c Will read back the ATMOS.FILE, and make more frequent entries
call make_atmos_fits_w_accel( params, ut_mid_rads,
+ list_stations )
endif
stop
end
c
subroutine set_constants
implicit real*8 (a-h,o-z)
common /constants/ c,pi,twopi,secday,sidereal_rate,
+ deg_rad,asec_rad,frequency,wavelength
c = 2.9979248d10 ! speed light (cm/sec)
pi = 4.d0*atan(1.d0)
twopi = 2.d0*pi
secday = 86400.d0 ! seconds per solar day
sidereal_rate = 1.002737923d0 ! solar to sidereal conv
deg_rad = pi/180.d0 ! convert deg's to rad's
asec_rad = deg_rad/3600.d0 ! arcsec to radians
return
end
c
subroutine input_stations ( list_stations, n_stats_used )
C Reads "station_file.inp" for station codes; the puts station coords
C in common/geometry/
implicit real*8 (a-h,o-z)
character*32 station_file
character*2 stat2
logical used
integer list_stations(12)
real*8 x(12), y(12), z(12), cal_ra(1000), cal_dec(1000)
common/geometry/ x,y,z,gast0,cal_ra,cal_dec,num_stations
c --------------------------------------------------------------------------
c Get station location info organized
lu_stat = 9
station_file = 'station_file.inp' ! Hardwired station input file
open (lu_stat, file=station_file, status='old')
write (6, 3999) station_file
3999 format(/' "',a15,'" info...')
c Initialize station coordinates to zero so that we can test when station not used
do i_st = 1, num_stations
x(i_st) = 0.d0
y(i_st) = 0.d0
z(i_st) = 0.d0
list_stations(i_st) = -1
enddo
ieof = 0
n_stats = 0
do while ( ieof .ge. 0 )
read (lu_stat, 1000, iostat=ieof) stat2, i_stat_num
1000 format(a2,1x,i2)
if ( ieof .ge. 0 ) then
used = .false.
c Check if station number is between 1 and num_stations...
if ( i_stat_num .lt. 1 .or.
+ i_stat_num .gt. num_stations ) then
write (6,2000) stat2, i_stat_num
2000 format(/' Sub input_stations: Bad stat #: ',a2,i3)
stop
endif
C Set station coordinates in standard *left-handed* geodetic coordinate system:
C X toward Greenwich longitude; Y toward 90 West longitude; Z toward N pole
if ( stat2 .eq. 'FD' ) then
x(i_stat_num) = -1324009.0026d0 ! FD
y(i_stat_num) = 5332182.0834d0 ! (meters)
z(i_stat_num) = 3231962.4355d0
used = .true.
endif
if ( stat2 .eq. 'KP' ) then
x(i_stat_num) = -1995678.4969d0 ! KP
y(i_stat_num) = 5037317.8209d0
z(i_stat_num) = 3357328.0825d0
used = .true.
endif
if ( stat2 .eq. 'LA' ) then
x(i_stat_num) = -1449752.2303d0 ! LA
y(i_stat_num) = 4975298.7034d0
z(i_stat_num) = 3709123.8860d0
used = .true.
endif
if ( stat2 .eq. 'OV' ) then
x(i_stat_num) = -2409149.9782d0 ! OV
y(i_stat_num) = 4478573.3221d0
z(i_stat_num) = 3838617.3390d0
used = .true.
endif
if ( stat2 .eq. 'PT' ) then
x(i_stat_num) = -1640953.5776d0 ! PT
y(i_stat_num) = 5014816.1165d0
z(i_stat_num) = 3575411.8292d0
used = .true.
endif
if ( stat2 .eq. 'BR' ) then
x(i_stat_num) = -2112064.8515d0 ! BR
y(i_stat_num) = 3705356.6129d0
z(i_stat_num) = 4726813.7587d0
used = .true.
endif
if ( stat2 .eq. 'NL' ) then
x(i_stat_num) = -130872.1216d0 ! NL
y(i_stat_num) = 4762317.2264d0
z(i_stat_num) = 4226850.9983d0
used = .true.
endif
if ( stat2 .eq. 'HN' ) then
x(i_stat_num) = +1446375.2506d0 ! HN
y(i_stat_num) = 4447939.7520d0
z(i_stat_num) = 4322306.0648d0
used = .true.
endif
if ( stat2 .eq. 'SC' ) then
x(i_stat_num) = +2607848.6047d0 ! SC
y(i_stat_num) = 5488069.8283d0
z(i_stat_num) = 1932739.4616d0
used = .true.
endif
if ( stat2 .eq. 'MK' ) then
x(i_stat_num) = -5464074.8410d0 ! MK
y(i_stat_num) = 2495249.3104d0
z(i_stat_num) = 2148296.7183d0
used = .true.
endif
if ( stat2.eq.'VL' .or. stat2.eq.'Y ' ) then
x(i_stat_num) = -1601185.3039d0 ! VLA
y(i_stat_num) = 5041977.1810d0
z(i_stat_num) = 3554875.6407d0
used = .true.
endif
if ( stat2.eq.'EB' .or. stat2.eq.'EF' ) then
x(i_stat_num) = 4033947.46164d0 ! Effelsberg
y(i_stat_num) = -486990.51504d0
z(i_stat_num) = 4900430.80011d0
used = .true.
endif
if ( stat2 .eq. 'GB' ) then
x(i_stat_num) = 882589.64360d0 ! Green Bank
y(i_stat_num) = 4924872.32087d0
z(i_stat_num) = 3943729.36253d0
used = .true.
endif
if ( stat2.eq.'JV' .or. stat2.eq.'JB' ) then
x(i_stat_num) = 3822626.4970d0 ! Jodrell Bank
y(i_stat_num) = 154105.5889d0
z(i_stat_num) = 5086486.2618d0
used = .true.
endif
if ( stat2 .eq. 'MC' ) then
x(i_stat_num) = 4461369.9883d0 ! Medicina
y(i_stat_num) = -919596.8324d0
z(i_stat_num) = 4449559.1894d0
used = .true.
endif
if ( stat2 .eq. 'NT' ) then
x(i_stat_num) = 4934563.1230d0 ! Noto
y(i_stat_num) = -1321201.2698d0
z(i_stat_num) = 3806484.4778d0
used = .true.
endif
if ( stat2 .eq. 'ON' ) then
x(i_stat_num) = 3370968.1810d0 ! Onsala 85
y(i_stat_num) = -711464.9170d0
z(i_stat_num) = 5349664.1130d0
used = .true.
endif
if ( stat2 .eq. 'TR' ) then
x(i_stat_num) = 3638558.0000d0 ! Torun
y(i_stat_num) = -1221967.0000d0
z(i_stat_num) = 5077041.0000d0
used = .true.
endif
if ( stat2 .eq. 'WB' ) then
x(i_stat_num) = 3828440.6400d0 ! Westerbork
y(i_stat_num) = -445226.0300d0
z(i_stat_num) = 5064923.0800d0
used = .true.
endif
if ( stat2 .eq. 'HH' ) then
x(i_stat_num) = 5085442.7805d0 ! Hartebeestok
y(i_stat_num) = -2668263.4908d0
z(i_stat_num) = -2768697.0345d0
used = .true.
endif
if ( stat2 .eq. 'UR' ) then
x(i_stat_num) = 228310.726d0 ! Urumuqui
y(i_stat_num) = -4631922.805d0
z(i_stat_num) = 4367063.964d0
used = .true.
endif
if ( stat2 .eq. 'CM' ) then
x(i_stat_num) = 3920354.8000d0 ! Cambridge 32m
y(i_stat_num) = -2545.7000d0
z(i_stat_num) = 5014285.0000d0
used = .true.
endif
if ( stat2 .eq. 'MH' ) then
x(i_stat_num) = 2892579.9681d0 ! Metsahovi
y(i_stat_num) = -1311719.0699d0
z(i_stat_num) = 5512640.6897d0
used = .true.
endif
c Very approximate values for VERA stations...
if ( stat2 .eq. 'VM' ) then
x(i_stat_num) = -3852030.d0 ! Mizusawa
y(i_stat_num) = -3119313.d0
z(i_stat_num) = 4013805.d0
used = .true.
endif
if ( stat2 .eq. 'VR' ) then
x(i_stat_num) = -3512768.d0 ! Iriki (Kagoshima)
y(i_stat_num) = -4112922.d0
z(i_stat_num) = 3379825.d0
used = .true.
endif
if ( stat2 .eq. 'VO' ) then
x(i_stat_num) = -4508500.d0 ! Ogasawara (Chichijima)
y(i_stat_num) = -3459494.d0
z(i_stat_num) = 2895551.d0
used = .true.
endif
if ( stat2 .eq. 'VS' ) then
x(i_stat_num) = -3215912.d0 ! Ishigaki
y(i_stat_num) = -4858713.d0
z(i_stat_num) = 2594166.d0
used = .true.
endif
if ( stat2 .eq. 'HH' ) then
x(i_stat_num) = 5085442.7845d0 ! Hart
y(i_stat_num) = -2668263.4862d0
z(i_stat_num) = -2768697.0160d0
used = .true.
endif
if ( stat2 .eq. 'AT' ) then
x(i_stat_num) = -4752447.5000d0 ! ATCA
y(i_stat_num) = -2790326.6000d0
z(i_stat_num) = -3200491.2900d0
used = .true.
endif
if ( stat2 .eq. 'CD' ) then
x(i_stat_num) = -3753440.7000d0 ! Ceduna
y(i_stat_num) = -3912708.3000d0
z(i_stat_num) = -3348066.9000d0
used = .true.
endif
if ( stat2 .eq. 'WA' ) then
x(i_stat_num) = -5115425.6350d0 ! Warkworth
y(i_stat_num) = 477880.3040d0
z(i_stat_num) = -3767042.8370d0
used = .true.
endif
if ( stat2 .eq. 'HO' ) then
x(i_stat_num) = -3950236.7341d0 ! Hobart
y(i_stat_num) = -2522347.5530d0
z(i_stat_num) = -4311562.5434d0
used = .true.
endif
if ( stat2 .eq. 'MP' ) then
x(i_stat_num) = -4682768.6300d0 ! Mopra
y(i_stat_num) = -2802619.0600d0
z(i_stat_num) = -3291759.9000d0
used = .true.
endif
if ( stat2 .eq. 'PA' ) then
x(i_stat_num) = -4554232.0016d0 ! Parkes
y(i_stat_num) = -2816758.9592d0
z(i_stat_num) = -3454035.8457d0
used = .true.
endif
if ( stat2 .eq. 'HB' ) then
x(i_stat_num) = -3949990.687d0 ! Hobart-12m
y(i_stat_num) = -2522421.191d0
z(i_stat_num) = -4311708.164d0
used = .true.
endif
if ( stat2 .eq. 'KE' ) then
x(i_stat_num) = -4147354.453d0 ! Katherine-12m
y(i_stat_num) = -4581542.384d0
z(i_stat_num) = -1573303.310d0
used = .true.
endif
if ( stat2 .eq. 'YG' ) then
x(i_stat_num) = -2388896.040d0 ! Yarragedee-12m
y(i_stat_num) = -5043349.973d0
z(i_stat_num) = -3078590.989d0
used = .true.
endif
if ( stat2 .eq. 'YS' ) then ! Yebes
x(i_stat_num) = 4848761.964d0
y(i_stat_num) = -261484.496d0
z(i_stat_num) = 4123084.827d0
used = .true.
endif
if ( stat2 .eq. 'YM' ) then
x(i_stat_num) = -3502544.259d0 ! Yamaguchi 32
y(i_stat_num) = -3950966.397d0
z(i_stat_num) = 3566381.165d0
used = .true.
endif
if ( stat2 .eq. 'SH' ) then
x(i_stat_num) = -2831686.912d0 ! Shanghai
y(i_stat_num) = 4675733.665d0
z(i_stat_num) = 3275327.685d0
used = .true.
endif
if ( stat2 .eq. 'DA' ) then
x(i_stat_num) = 3829087.7497d0 ! DArnhall
y(i_stat_num) = 169568.7360d0
z(i_stat_num) = 5081082.4658d0
used = .true.
endif
if ( stat2 .eq. 'LM' ) then
c FOLLOWING ARE VERY APPROXIMATE (eg, +/-10,000 m)
x(i_stat_num) = -767029.d0 ! LMT Mexico
y(i_stat_num) = 5975413.d0
z(i_stat_num) = 2072618.d0
used = .true.
endif
c Check if the station code matched one of the known station names...
if ( used ) then
n_stats = n_stats + 1
list_stations(n_stats) = i_stat_num
write (6,2008) stat2, i_stat_num,
+ x(i_stat_num), y(i_stat_num), z(i_stat_num)
2008 format(1x,a2,i5,3f15.4)
else
write (6,2010) stat2, i_stat_num
2010 format(/' Sub input_stations: Station not a',
+ ' recognized 2-char code: ',a2,i3)
endif
endif
enddo
n_stats_used = n_stats
close (unit=lu_stat)
return
end
c
subroutine input_calibrators ( geodetic_data_file )
c Reads "calibrator_file.inp" for calibrator positions.
c File is in correlator job (job____.fx) format
c Info is put in common/geometry/
implicit real*8 (a-h,o-z)
character*32 calibrator_file, geodetic_data_file, su_file
common /constants/ c,pi,twopi,secday,sidereal_rate,
+ deg_rad,asec_rad,frequency,wavelength
real*8 x(12), y(12), z(12), cal_ra(1000), cal_dec(1000)
common/geometry/ x,y,z,gast0,cal_ra,cal_dec,num_stations
character*8 cal_name
character*8 epoch
max_num_sources = 1000 ! dimension limit for cal_ra, cal_dec arrays
c -----------------------------------------------------------------------
c Input calibrator data file name and "SU" positions for geodetic like data
lu_cal = 9
calibrator_file = 'calibrator_file.inp' ! Hardwired source input file
open (lu_cal, file=calibrator_file, status='old')
write (6, 3999) calibrator_file
3999 format(/' "',a15,'" info...')
c First, read in file name for geodetic-like (rates, multi-band delays) data
read (lu_cal, 4020) geodetic_data_file
4020 format(a32)
write (6,4020 ) geodetic_data_file
c Next, read in file name for source table
read (lu_cal, 4020) su_file
write (6,4020 ) su_file
close (unit=lu_cal)
c ------------------------------------------------------------------
c Next read source coordinates from su-file
open (lu_cal, file=su_file, status='old')
n_found = 0
n_cal = 0
ieof = 0
do while ( ieof .ge. 0 )
c Required format for SU_file: in PRTAN use the following
c inext 'su'
c box 1 2 11 12 13 14 15
c Will use free-format reads to avoid changes in AIPS PRTAN formatting
read (lu_cal,*,iostat=ieof) irow,n_cal,cal_name,
+ ra_deg,dec_deg,xepoch
if ( ieof .ge. 0 ) then
c Select only lines with source coordinates (selected by xepoch=2000)
if ( abs(xepoch-2000.d0) .lt. 0.1d0 ) then
c This line contains source coordinates...
backspace (unit=lu_cal) ! and re-read line
read (lu_cal,*,iostat=ieof) irow,n_cal,cal_name,
+ ra_deg,dec_deg,xepoch
if ( n_cal.ge.1 .and. n_cal.le.max_num_sources ) then
cal_ra (n_cal) = ra_deg * deg_rad ! radians
cal_dec(n_cal) = dec_deg * deg_rad ! radians
else
print *,'INVALID SU-TABLE SOURCE NUMBER (1-1000 allowed):', n_cal
stop
endif
c Convert format to print out...
call radians_to_hhmmss (cal_ra(n_cal), ra_hhmmss )
call radians_to_ddmmss (cal_dec(n_cal), dec_ddmmss)
write (6,3720) n_cal, cal_name, ra_hhmmss, dec_ddmmss
3720 format(' Geodetic Calibrator:',i3,1x,a8,f17.5,f16.4)
n_found = n_found + 1
endif
endif
enddo
print *,'Done reading calibrator (SU) file'
close (unit=lu_cal)
if ( n_found .lt. 1 ) then
print *,' Found no calibrators: check SU-PRTAB format'
STOP
endif
return
end
c
subroutine input_controls( max_blocks,
+ num_sources,num_iter,gain,debug,
+ data_format, nth_print,
+ iyr, mon, iday,
+ num_blocks, ut_min, ut_max, stm_mid,
+ delay_err, rate_err, geo_reweight,
+ num_params, params, paramids, parnames,
+ param_incr, param_limits )
implicit real*8 (a-h,o-z)
real*8 params(156), param_limits(156), param_incr(156)
character*8 parnames(156)
integer paramids(156)
real*8 ut_min(10), ut_max(10)
real*8 del_tau_b1(12), tau_id_b1(12),
+ del_tau_b2(12), tau_id_b2(12),
+ del_tau_b3(12), tau_id_b3(12),
+ del_tau_b4(12), tau_id_b4(12),
+ del_tau_b5(12), tau_id_b5(12),
+ del_tau_b6(12), tau_id_b6(12),
+ del_tau_b7(12), tau_id_b7(12),
+ del_tau_b8(12), tau_id_b8(12),
+ del_tau_b9(12), tau_id_b9(12),
+ del_tau_b10(12),tau_id_b10(12),
+ delay_offset(12), delay_id(12),
+ delay_rate(12), delay_rate_id(12),
+ delay_accel(12), delay_accel_id(12)
character*32 control_file
common /constants/ c,pi,twopi,secday,sidereal_rate,
+ deg_rad,asec_rad,frequency,wavelength
real*8 x(12), y(12), z(12), cal_ra(1000), cal_dec(1000)
common/geometry/ x,y,z,gast0,cal_ra,cal_dec,num_stations
write (6,5010)
5010 format(//'"control_file" info...')
control_file = 'control_file.inp'
open (unit=8, file=control_file, status='old')
read (8,*) data_format
read (8,*) xnum_iter
num_iter = xnum_iter + 0.5
read (8,*) gain
read (8,*) debug
C Date and time info...
read (8,*) iyr, mon, iday
c Check for reasonable values...
if ( iyr.lt.2000 .or. iyr.gt.2050 ) then
print *,' Unreasonable year: ',iyr
stop
endif
if ( mon.lt.1 .or. mon.gt.12 ) then
print *,' Unreasonable month: ',mon
stop
endif
if ( iday.lt.1 .or. iday.gt.31 ) then
print *,' Unreasonable day: ',iday
stop
endif
call JULDA (iyr, mon, iday,
+ date, gmst_hr )
c Ignore ~1 sec differences between GAST and GMST
gast0 = gmst_hr * pi / 12.d0 ! [rad] to put in commons
call radians_to_hhmmss ( gast0, gast0_hhmmss )
write (6,5000) iyr, mon, iday, gast0_hhmmss
5000 format(' Date & GAST0:',i5,2i3,5x,f13.4)
read (8, *) frequency ! Hz
if ( frequency .lt. 1.d9 .or.
+ frequency .gt. 1.d12 ) then
write (6,5001) frequency
5001 format(/' Invalid frequency: ',1pd12.3,' Hz')
stop
endif
wavelength = c/frequency ! cm
freq_GHz = frequency * 1.d-09
write (6,5002) freq_GHz, wavelength
5002 format(/' Observing frequency =',f7.3,' GHz;',
+ ' wavelength =',f7.3,' cm')
c Data uncertainties and re-weighting flag
read (8,*) delay_err, rate_err, geo_reweight
write (6,5003) delay_err, rate_err, geo_reweight
5003 format(/' Delay unc =',f5.1,' cm; Rate unc =',f6.3,' Hz;',
+ ' Automatic re-weighting flag =',f3.0)
c read (8,8010) xnth_print
c if ( xnth_print.gt.0.99 ) then
c nth_print = xnth_print + 0.5
c else
c nth_print = 1
c endif
nth_print = num_iter ! hardwire to number of iterations
c Enter referenced time for clocks
read (8,8010) ut_hhmmss
c Calculate middle GST (if entered mid UT time .ne. 0.0)
stm_mid = 0.d0
if ( ut_hhmmss .ne. 0.d0 ) then
call hmsrad( ut_hhmmss, ut_mid_rad)
stm_mid = gast0 + ut_mid_rad*sidereal_rate ! radians
endif
write (6,5004) ut_hhmmss
5004 format(/' Input UT center time (hhmmss):',f10.1,/1x)
c Enter UT time ranges for up to "max_blocks"...
num_blocks = 0
do i_b = 1, max_blocks
read (8,8010) ut_min(i_b), ut_max(i_b)
write (6,5005)i_b, ut_min(i_b), ut_max(i_b)
5005 format(' Block ',i2,': ut_min and max (days):',2f7.3)
if ( ut_min(i_b) .gt. ut_max(i_b) ) then
print *,' *** Invalid UT time range for block!'
stop
endif
if ( ut_max(i_b) .gt. 0.d0 ) num_blocks = num_blocks + 1
enddo
write (6,5006) num_blocks
5006 format(/' Number of time-blocks requested =',i3)
c FOR VLBA data, SNR not currently passed to input files.
c ignore this parameter...
c read (8,8010) snr_limit
c print *, 'SNR lower limit: ', snr_limit
c snr_limit = 0.d0
c Station clocks...
do i=1, num_stations ! Station m-b delay offsets
read (8,8010) delay_offset(i), delay_id(i)
enddo
do i=1, num_stations ! Station m-b delay rates
read (8,8010) delay_rate(i), delay_rate_id(i)
enddo
do i=1, num_stations ! Station m-b delay accels
read (8,8010) delay_accel(i), delay_accel_id(i)
enddo
c Station zenith delays...
c Time block 1
do i=1, num_stations ! Station zenith delay offsets
read (8,8010) del_tau_b1(i), tau_id_b1(i)
enddo
c Time block 2
do i=1, num_stations ! Station zenith delay offsets
read (8,8010) del_tau_b2(i), tau_id_b2(i)
enddo
c Time block 3
do i=1, num_stations ! Station zenith delay offsets
read (8,8010) del_tau_b3(i), tau_id_b3(i)
enddo
c Time block 4
do i=1, num_stations ! Station zenith delay offsets
read (8,8010) del_tau_b4(i), tau_id_b4(i)
enddo
c Time block 5
do i=1, num_stations ! Station zenith delay offsets
read (8,8010) del_tau_b5(i), tau_id_b5(i)
enddo
c Time block 6
do i=1, num_stations ! Station zenith delay offsets
read (8,8010) del_tau_b6(i), tau_id_b6(i)
enddo
c Time block 7
do i=1, num_stations ! Station zenith delay offsets
read (8,8010) del_tau_b7(i), tau_id_b7(i)
enddo
c Time block 8
do i=1, num_stations ! Station zenith delay offsets
read (8,8010) del_tau_b8(i), tau_id_b8(i)
enddo
c Time block 9
do i=1, num_stations ! Station zenith delay offsets
read (8,8010) del_tau_b9(i), tau_id_b9(i)
enddo
c Time block 10
do i=1, num_stations ! Station zenith delay offsets
read (8,8010) del_tau_b10(i), tau_id_b10(i)
enddo
8010 format(8f10.3)
c Done reading...
close (unit=8)
c ====================================================================
c Transfer values to params array...
c ----------------
c Clock parameters...
i_0 = 0
c Set parameters 1 through 12 from clock errors for 12 stations
do i = 1, num_stations
params(i_0 + i) = delay_offset(i) ! cm
param_limits(i_0 + i) = 9.9d9 ! cm
param_incr(i_0 + i) = 9.9d9 ! cm
enddo
i_0 = i_0 + num_stations
c Set parameters 13 through 24 from clock rates for 12 stations
do i = 1, num_stations
params(i_0 + i) = delay_rate(i) ! cm/hr
param_limits(i_0 + i) = 9.9d9 ! cm/hr
param_incr(i_0 + i) = 9.9d9 ! cm/hr
enddo
i_0 = i_0 + num_stations