##// END OF EJS Templates
bfield2 supports general path to call bfmodel
rflores -
r1573:4add2f3d5a7c
parent child
Show More
@@ -1,668 +1,676
1 1 subroutine geobfield(tm,r,theta,phi,br,bt,bp,b)
2 2 c*****evaluate bfield at geocentric coords r,theta,phi
3 3 c and return components of field in r,theta and phi directions
4 4 c and magnitude
5 5 c*****theta and phi are in radians, r is in km, b is in gauss
6 6 c ===============================================================
7 7 c
8 8 c essentially, this is an adaptation of igrfdemo. it interpolates
9 9 c smoothly between the coefficients from 1945 to 1985.
10 10 c
11 11 c subroutines:
12 12 c getshc, interpshc, extrapshc, shval3
13 13 c
14 14 c igrfdemo is due to:
15 15 c a. zunde
16 16 c usgs, ms 964, box 25046 federal center, denver, co 80225
17 17 c
18 18 c ===============================================================
19 19 character*8 filmod(17)
20 character*9 fqual
20 c character*31 fqual
21 21 dimension gh1(220), gh2(220), gha(224), ext(3), dtemod(17)
22 22 data ext /3*0./
23 23 data filmod / 'dgrf45', 'dgrf50',
24 24 1 'dgrf55', 'dgrf60', 'dgrf65',
25 25 2 'dgrf70', 'dgrf75', 'dgrf80',
26 26 3 'dgrf85', 'dgrf90', 'dgrf95',
27 27 4 'dgrf00', 'dgrf05', 'dgrf10',
28 28 5 'dgrf15', 'igrf20', 'igrf20s'/
29 data fqual/"/bfmodel/"/
29 c data fqual/"/usr/local/lib/faraday/bfmodel/"/
30 30 data dtemod / 1945., 1950., 1955., 1960.,
31 31 1 1965., 1970., 1975., 1980., 1985., 1990., 1995., 2000.,
32 32 2 2005.,2010.,2015.,2020.,2025./
33 33 data iu/98/,ndt/17/
34 34 c data a2/40680925./, b2/40408588./
35 35 data a2/40680631.6/, b2/40408296.0/ ! updated 2010
36 36 c
37 37 data rtd/57.29577951/
38 38 data tmp/0./,lp/0/
39 character(1024) :: fqual_temp
40 character(:), allocatable :: fqual
41 call get_path(fqual_temp)
42 c write(*,*) "L_BEF: ", fqual_temp, "L_BEF_end"
43 fqual = TRIM(fqual_temp)
44 c write(*,*) "L: ", fqual, "L_end"
45
39 46 flat=90. - theta*rtd
40 47 flon=rtd*phi
41 48 c*****if previous time is not equal to current time
42 49 if(tm .ne. tmp)then
43 50 l=0
44 51 C for i=1,ndt
45 52 DO 1010 i=1,ndt
46 53 C exit for if(tm .lt. dtemod(i))
47 54 if(tm .lt. dtemod(i)) GO TO 1011
48 55 l=i
49 56 C end for
50 57 1010 CONTINUE
51 58 1011 CONTINUE
52 59 c write(*,-)tm,l
53 60 if(l .eq. 0)then
54 61 write(*,fmt='(" geobfield: time is before earliest model.")')
55 62 stop
56 63 end if
57 64 if(l .eq. ndt)then
58 65 l=l-1
59 66 write(*,fmt='(" geobfield: warning - extrapolating beyond ",
60 67 1 "last set of coefficients.")')
61 68 end if
62 69 if(l .ne. lp)then
63 70 c*********if previous epoch not the same, read in new coefs
64 71 c write(*,fmt='(" read coefs"))')
65 c write(*,*) fqual//filmod(l)
72 c write(*,*) "filmod", fqual//filmod(l)
66 73 call getshc2 (iu, fqual//filmod(l), nmax1, erad, gh1, ier)
74 c write(*,*) "AA: ", ier, filmod(l)
67 75 if(ier .ne. 0)then
68 76 write(*,fmt='(" geobfield: read error=",i2," on ",a)')
69 77 1 ier,filmod(l)
70 78 stop
71 79 end if
72 80
73 81 call getshc2 (iu, fqual//filmod(l+1), nmax2, erad, gh2, ier)
74 82 if(ier .ne. 0)then
75 83 write(*,fmt='(" geobfield: read error=",i2," on ",a)')
76 84 1 ier,filmod(l+1)
77 85 stop
78 86 end if
79 87 end if
80 88 if (l .lt. ndt-1) then
81 89 call interpshc (tm, dtemod(l), nmax1, gh1, dtemod(l+1),
82 90 1 nmax2, gh2, nmax, gha)
83 91 c write(*,fmt='(" interpolate"))')
84 92 else
85 93 call extrapshc (tm, dtemod(l), nmax1, gh1, nmax2,
86 94 1 gh2, nmax, gha)
87 95 c write(*,fmt='(" extrapolate"))')
88 96 end if
89 97 end if
90 98 c tmp=tm
91 99 c lp=l
92 100 call shval3(2,flat,flon,r,erad,a2,b2,nmax,gha,0,ext,x,y,z)
93 101 br=-z/100000.
94 102 bp=y/100000.
95 103 bt=-x/100000.
96 104 b=sqrt(br**2 + bp**2 + bt**2)
97 105
98 106 C write(*,*)flat,flon,r,erad,a2,b2,nmax,gha,ext
99 107 C write(*,*)tm,r,theta,phi,br,bt,bp,b
100 108 return
101 109 end
102 110 c
103 111 subroutine convrt(i, gdlat, gdalt, gclat, rkm)
104 112
105 113 c convrt converts between geodetic and geocentric coordinates. the
106 114 c reference geoid is that adopted by the iau in 1964. a=6378.16,
107 115 c b=6356.7746, f=1/298.25. the equations for conversion from
108 116 c geocentric to geodetic are from astron. j., vol 66, 1961, p. 15.
109 117
110 118 c i=1 geodetic to geocentric
111 119 c i=2 geocentric to geodetic
112 120 c gdlat geodetic latitude (degrees)
113 121 c gdalt altitude above geoid (km)
114 122 c gclat geocentric latitude (degrees)
115 123 c rkm geocentric radial distance (km)
116 124 c
117 125 c data a/6378.16/, ab2/1.0067397/, ep2/.0067397/
118 126 c update 2010
119 127 data a/6378.137/, ab2/1.0067396/, ep2/.0067396/
120 128 data dtr/.0174532925199/
121 129
122 130 if (i .eq. 1) then
123 131
124 132 c .....geodetic to geocentric.....
125 133
126 134 gdl = dtr*gdlat
127 135 sinlat = sin(gdl)
128 136 coslat = cos(gdl)
129 137 sl2 = sinlat*sinlat
130 138 cl2 = ab2*coslat
131 139 cl2 = cl2*cl2
132 140 sinbet = sinlat/sqrt(sl2+cl2)
133 141 sb2 = amin1(sinbet*sinbet, 1.)
134 142 cosbet = sqrt(1. - sb2)
135 143 rgeoid = a/sqrt(1. + ep2*sb2)
136 144 x = rgeoid*cosbet + gdalt*coslat
137 145 y = rgeoid*sinbet + gdalt*sinlat
138 146 rkm = sqrt(x*x + y*y)
139 147 gclat = atan2(y,x)/dtr
140 148 return
141 149
142 150 else if (i .eq. 2) then
143 151
144 152 c .....geocentric to geodetic.....
145 153
146 154 rer = rkm/a
147 155 a2 = ((-1.4127348e-8/rer + .94339131e-8)/rer +
148 156 1 .33523288e-2)/rer
149 157 a4 = (((-1.2545063e-10/rer + .11760996e-9)/rer +
150 158 1 .11238084e-4)/rer - .2814244e-5)/rer
151 159 a6 = ((54.939685e-9/rer - 28.301730e-9)/rer +
152 160 1 3.5435979e-9)/rer
153 161 a8 = (((320./rer - 252.)/rer + 64.)/rer - 5.)
154 162 1 /rer*0.98008304e-12
155 163 gcl = dtr*gclat
156 164 ccl = cos(gcl)
157 165 scl = sin(gcl)
158 166 s2cl = 2.*scl*ccl
159 167 c2cl = 2.*ccl*ccl - 1.
160 168 s4cl = 2.*s2cl*c2cl
161 169 c4cl = 2.*c2cl*c2cl - 1.
162 170 s8cl = 2.*s4cl*c4cl
163 171 s6cl = s2cl*c4cl + c2cl*s4cl
164 172 dltcl = s2cl*a2 + s4cl*a4 + s6cl*a6 + s8cl*a8
165 173 gdlat = gclat + dltcl/dtr
166 174 gdalt = rkm - a/sqrt(1.+ep2*scl*scl)
167 175 return
168 176
169 177 end if
170 178 end
171 179 c
172 180 subroutine getshc2 (iu, fspec, nmax, erad, gh, ier)
173 181
174 182 c ===============================================================
175 183 c
176 184 c version 1.01
177 185 c
178 186 c reads spherical harmonic coefficients from the specified
179 187 c file into an array.
180 188 c
181 189 c input:
182 190 c iu - logical unit number
183 191 c fspec - file specification
184 192 c
185 193 c output:
186 194 c nmax - maximum degree and order of model
187 195 c erad - earth's radius associated with the spherical
188 196 c harmonic coefficients, in the same units as
189 197 c elevation
190 198 c gh - schmidt quasi-normal internal spherical
191 199 c harmonic coefficients
192 200 c ier - error number: = 0, no error
193 201 c = -2, records out of order
194 202 c = fortran run-time error number
195 203 c
196 204 c a. zunde
197 205 c usgs, ms 964, box 25046 federal center, denver, co 80225
198 206 c
199 207 c ===============================================================
200 208
201 209 character fspec*(*)
202 210 dimension gh(*)
203 211
204 212 c ---------------------------------------------------------------
205 213 c open coefficient file. read past first header record.
206 214 c read degree and order of model and earth's radius.
207 215 c ---------------------------------------------------------------
208 216
209 217
210 218 open (iu, file=fspec, status='old', iostat=ier, err=999 )
211 219
212 220
213 221 read (iu, *, iostat=ier, err=999)
214 222 read (iu, *, iostat=ier, err=999) nmax, erad
215 223
216 224
217 225 c ---------------------------------------------------------------
218 226 c read the coefficient file, arranged as follows:
219 227 c
220 228 c n m g h
221 229 c ----------------------
222 230 c / 1 0 gh(1) -
223 231 c / 1 1 gh(2) gh(3)
224 232 c / 2 0 gh(4) -
225 233 c / 2 1 gh(5) gh(6)
226 234 c nmax*(nmax+3)/2 / 2 2 gh(7) gh(8)
227 235 c records \ 3 0 gh(9) -
228 236 c \ . . . .
229 237 c \ . . . .
230 238 c nmax*(nmax+2) \ . . . .
231 239 c elements in gh \ nmax nmax . .
232 240 c
233 241 c n and m are, respectively, the degree and order of the
234 242 c coefficient.
235 243 c ---------------------------------------------------------------
236 244
237 245 i = 0
238 246 C for nn = 1, nmax
239 247 DO 1010 nn = 1, nmax
240 248 C for mm = 0, nn
241 249 DO 1020 mm = 0, nn
242 250 read (iu, *, iostat=ier, err=999) n, m, g, h
243 251 c write(*,*) n,m,g,h,nn,nmax,mm,ier
244 252 if (nn .ne. n .or. mm .ne. m) then
245 253 ier = -2
246 254 goto 999
247 255 endif
248 256 i = i + 1
249 257 gh(i) = g
250 258 if (m .ne. 0) then
251 259 i = i + 1
252 260 gh(i) = h
253 261 endif
254 262 C end for
255 263 1020 CONTINUE
256 264 1021 CONTINUE
257 265 C end for
258 266 1010 CONTINUE
259 267 1011 CONTINUE
260 268
261 269 999 close (iu)
262 270
263 271 return
264 272 end
265 273 c
266 274 c ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bfieldsr ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
267 275 c
268 276 subroutine interpshc (date, dte1, nmax1, gh1, dte2,
269 277 1 nmax2, gh2, nmax, gh)
270 278
271 279 c ===============================================================
272 280 c
273 281 c version 1.01
274 282 c
275 283 c interpolates linearly, in time, between two spherical
276 284 c harmonic models.
277 285 c
278 286 c input:
279 287 c date - date of resulting model (in decimal year)
280 288 c dte1 - date of earlier model
281 289 c nmax1 - maximum degree and order of earlier model
282 290 c gh1 - schmidt quasi-normal internal spherical
283 291 c harmonic coefficients of earlier model
284 292 c dte2 - date of later model
285 293 c nmax2 - maximum degree and order of later model
286 294 c gh2 - schmidt quasi-normal internal spherical
287 295 c harmonic coefficients of later model
288 296 c
289 297 c output:
290 298 c gh - coefficients of resulting model
291 299 c nmax - maximum degree and order of resulting model
292 300 c
293 301 c a. zunde
294 302 c usgs, ms 964, box 25046 federal center, denver, co 80225
295 303 c
296 304 c ===============================================================
297 305
298 306 dimension gh1(*), gh2(*), gh(*)
299 307
300 308 c ---------------------------------------------------------------
301 309 c the coefficients (gh) of the resulting model, at date
302 310 c date, are computed by linearly interpolating between the
303 311 c coefficients of the earlier model (gh1), at date dte1,
304 312 c and those of the later model (gh2), at date dte2. if one
305 313 c model is smaller than the other, the interpolation is
306 314 c performed with the missing coefficients assumed to be 0.
307 315 c ---------------------------------------------------------------
308 316
309 317 factor = (date - dte1) / (dte2 - dte1)
310 318
311 319 if (nmax1 .eq. nmax2) then
312 320 k = nmax1 * (nmax1 + 2)
313 321 nmax = nmax1
314 322 else if (nmax1 .gt. nmax2) then
315 323 k = nmax2 * (nmax2 + 2)
316 324 l = nmax1 * (nmax1 + 2)
317 325 C for i = k + 1, l
318 326 DO 1010 i = k + 1, l
319 327 gh(i) = gh1(i) + factor * (-gh1(i))
320 328 C end for
321 329 1010 CONTINUE
322 330 1011 CONTINUE
323 331 nmax = nmax1
324 332 else
325 333 k = nmax1 * (nmax1 + 2)
326 334 l = nmax2 * (nmax2 + 2)
327 335 C for i = k + 1, l
328 336 DO 1020 i = k + 1, l
329 337 gh(i) = factor * gh2(i)
330 338 C end for
331 339 1020 CONTINUE
332 340 1021 CONTINUE
333 341 nmax = nmax2
334 342 endif
335 343
336 344 C for i = 1, k
337 345 DO 1030 i = 1, k
338 346 gh(i) = gh1(i) + factor * (gh2(i) - gh1(i))
339 347 C end for
340 348 1030 CONTINUE
341 349 1031 CONTINUE
342 350
343 351 return
344 352 end
345 353 c
346 354 c ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bfieldsr ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
347 355 c
348 356 subroutine extrapshc (date, dte1, nmax1, gh1, nmax2,
349 357 1 gh2, nmax, gh)
350 358
351 359 c ===============================================================
352 360 c
353 361 c version 1.01
354 362 c
355 363 c extrapolates linearly a spherical harmonic model with a
356 364 c rate-of-change model.
357 365 c
358 366 c input:
359 367 c date - date of resulting model (in decimal year)
360 368 c dte1 - date of base model
361 369 c nmax1 - maximum degree and order of base model
362 370 c gh1 - schmidt quasi-normal internal spherical
363 371 c harmonic coefficients of base model
364 372 c nmax2 - maximum degree and order of rate-of-change
365 373 c model
366 374 c gh2 - schmidt quasi-normal internal spherical
367 375 c harmonic coefficients of rate-of-change model
368 376 c
369 377 c output:
370 378 c gh - coefficients of resulting model
371 379 c nmax - maximum degree and order of resulting model
372 380 c
373 381 c a. zunde
374 382 c usgs, ms 964, box 25046 federal center, denver, co 80225
375 383 c
376 384 c ===============================================================
377 385
378 386 dimension gh1(*), gh2(*), gh(*)
379 387
380 388 c ---------------------------------------------------------------
381 389 c the coefficients (gh) of the resulting model, at date
382 390 c date, are computed by linearly extrapolating the coef-
383 391 c ficients of the base model (gh1), at date dte1, using
384 392 c those of the rate-of-change model (gh2), at date dte2. if
385 393 c one model is smaller than the other, the extrapolation is
386 394 c performed with the missing coefficients assumed to be 0.
387 395 c ---------------------------------------------------------------
388 396
389 397 factor = (date - dte1)
390 398
391 399 if (nmax1 .eq. nmax2) then
392 400 k = nmax1 * (nmax1 + 2)
393 401 nmax = nmax1
394 402 else if (nmax1 .gt. nmax2) then
395 403 k = nmax2 * (nmax2 + 2)
396 404 l = nmax1 * (nmax1 + 2)
397 405 C for i = k + 1, l
398 406 DO 1010 i = k + 1, l
399 407 gh(i) = gh1(i)
400 408 C end for
401 409 1010 CONTINUE
402 410 1011 CONTINUE
403 411 nmax = nmax1
404 412 else
405 413 k = nmax1 * (nmax1 + 2)
406 414 l = nmax2 * (nmax2 + 2)
407 415 C for i = k + 1, l
408 416 DO 1020 i = k + 1, l
409 417 gh(i) = factor * gh2(i)
410 418 C end for
411 419 1020 CONTINUE
412 420 1021 CONTINUE
413 421 nmax = nmax2
414 422 endif
415 423
416 424 C for i = 1, k
417 425 DO 1030 i = 1, k
418 426 gh(i) = gh1(i) + factor * gh2(i)
419 427 C end for
420 428 1030 CONTINUE
421 429 1031 CONTINUE
422 430
423 431 return
424 432 end
425 433 c
426 434 c ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bfieldsr ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
427 435 c
428 436 subroutine shval3 (igdgc, flat, flon, elev, erad, a2, b2,
429 437 1 nmax, gh, iext, ext, x, y, z)
430 438
431 439 c ================================================================
432 440 c
433 441 c version 1.01
434 442 c
435 443 c calculates field components from spherical harmonic (sh)
436 444 c models.
437 445 c
438 446 c input:
439 447 c igdgc - indicates coordinate system used; set equal to
440 448 c 1 if geodetic, 2 if geocentric
441 449 c flat - north latitude, in degrees
442 450 c flon - east longitude, in degrees
443 451 c elev - elevation above mean sea level (igdgc=1), or
444 452 c radial distance from earth's center (igdgc=2)
445 453 c erad - value of earth's radius associated with the sh
446 454 c coefficients, in same units as elev
447 455 c a2,b2 - squares of semi-major and semi-minor axes of
448 456 c the reference spheroid used for transforming
449 457 c between geodetic and geocentric coordinates or
450 458 c components
451 459 c nmax - maximum degree and order of coefficients
452 460 c gh - schmidt quasi-normal internal spherical
453 461 c harmonic coefficients
454 462 c iext - external coefficients flag (= 0 if none)
455 463 c ext - the three 1st-degree external coefficients
456 464 c (not used if iext = 0)
457 465 c
458 466 c output:
459 467 c x - northward component
460 468 c y - eastward component
461 469 c z - vertically-downward component
462 470 c
463 471 c based on subroutine "igrf" by d. r. barraclough and
464 472 c s. r. c. malin, report no. 71/1, institute of geological
465 473 c sciences, u.k.
466 474 c
467 475 c norman w. peddie, u.s. geological survey, mail stop 964,
468 476 c federal center, box 25046, denver, colorado 80225
469 477 c
470 478 c ================================================================
471 479
472 480 c the required sizes of the arrays used in this subroutine
473 481 c depend on the value of nmax. the minimum dimensions
474 482 c needed are indicated in the table below. (note that this
475 483 c version is dimensioned for nmax of 14 or less).
476 484 c
477 485 c minimum dimension
478 486 c --------------------------
479 487 c nmax
480 488 dimension sl(14), cl(14)
481 489 c (nmax * (nmax + 3)) / 2
482 490 dimension p(119), q(119)
483 491 c nmax * (nmax + 2)
484 492 dimension gh(224)
485 493 c 3
486 494 dimension ext(3)
487 495
488 496 c ================================================================
489 497
490 498 parameter (dtr = .01745329)
491 499
492 500 r = elev
493 501 slat = sin (flat * dtr)
494 502 if (90. - flat .lt. .001) then
495 503 c 300 ft from n. pole
496 504 aa = 89.999
497 505 else if (90. + flat .lt. .001) then
498 506 c 300 ft from s. pole
499 507 aa = -89.999
500 508 else
501 509 aa = flat
502 510 endif
503 511 clat = cos (aa * dtr)
504 512 sl(1) = sin (flon * dtr)
505 513 cl(1) = cos (flon * dtr)
506 514 x = 0.
507 515 y = 0.
508 516 z = 0.
509 517 sd = 0.
510 518 cd = 1.
511 519 n = 0
512 520 l = 1
513 521 m = 1
514 522 npq = (nmax * (nmax + 3)) / 2
515 523
516 524 if (igdgc .eq. 1) then
517 525 aa = a2 * clat * clat
518 526 bb = b2 * slat * slat
519 527 cc = aa + bb
520 528 dd = sqrt (cc)
521 529 r = sqrt (elev * (elev + 2. * dd)
522 530 1 + (a2 * aa + b2 * bb) / cc)
523 531 cd = (elev + dd) / r
524 532 sd = (a2 - b2) / dd * slat * clat / r
525 533
526 534 aa = slat
527 535 slat = slat * cd - clat * sd
528 536 clat = clat * cd + aa * sd
529 537 endif
530 538
531 539 ratio = erad / r
532 540
533 541 aa = sqrt (3.)
534 542 p(1) = 2. * slat
535 543 p(2) = 2. * clat
536 544 p(3) = 4.5 * slat * slat - 1.5
537 545 p(4) = 3. * aa * clat * slat
538 546 q(1) = -clat
539 547 q(2) = slat
540 548 q(3) = -3. * clat * slat
541 549 q(4) = aa * (slat * slat - clat * clat)
542 550
543 551 C for k = 1, npq
544 552 DO 1010 k = 1, npq
545 553 if (n .lt. m) then
546 554 m = 0
547 555 n = n + 1
548 556 rr = ratio**(n + 2)
549 557 fn = n
550 558 endif
551 559 fm = m
552 560 if (k .ge. 5) then
553 561 if (m .eq. n) then
554 562 aa = sqrt (1. - .5 / fm)
555 563 j = k - n - 1
556 564 p(k) = (1. + 1. / fm) * aa * clat * p(j)
557 565 q(k) = aa * (clat * q(j) + slat / fm * p(j))
558 566 sl(m) = sl(m-1) * cl(1) + cl(m-1) * sl(1)
559 567 cl(m) = cl(m-1) * cl(1) - sl(m-1) * sl(1)
560 568 else
561 569 aa = sqrt (fn * fn - fm * fm)
562 570 bb = sqrt ((fn - 1.)**2 - fm * fm) / aa
563 571 cc = (2. * fn - 1.) / aa
564 572 i = k - n
565 573 j = k - 2 * n + 1
566 574 p(k) = (fn + 1.) * (cc * slat / fn * p(i) - bb
567 575 1 / (fn - 1.) * p(j))
568 576 q(k) = cc * (slat * q(i) - clat / fn * p(i))
569 577 1 - bb * q(j)
570 578 endif
571 579 endif
572 580
573 581 aa = rr * gh(l)
574 582
575 583 if (m .eq. 0) then
576 584 x = x + aa * q(k)
577 585 z = z - aa * p(k)
578 586 l = l + 1
579 587 else
580 588 bb = rr * gh(l+1)
581 589 cc = aa * cl(m) + bb * sl(m)
582 590 x = x + cc * q(k)
583 591 z = z - cc * p(k)
584 592 if (clat .gt. 0.) then
585 593 y = y + (aa * sl(m) - bb * cl(m)) * fm * p(k)
586 594 1 / ((fn + 1.) * clat)
587 595 else
588 596 y = y + (aa * sl(m) - bb * cl(m)) * q(k)
589 597 1 * slat
590 598 endif
591 599 l = l + 2
592 600 endif
593 601 m = m + 1
594 602 C end for
595 603 1010 CONTINUE
596 604 1011 CONTINUE
597 605
598 606 if (iext .ne. 0) then
599 607 aa = ext(2) * cl(1) + ext(3) * sl(1)
600 608 x = x - ext(1) * clat + aa * slat
601 609 y = y + ext(2) * sl(1) - ext(3) * cl(1)
602 610 z = z + ext(1) * slat + aa * clat
603 611 endif
604 612
605 613 aa = x
606 614 x = x * cd + z * sd
607 615 z = z * cd - aa * sd
608 616
609 617
610 618 return
611 619 end
612 620 c
613 621 c ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bfieldsr ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
614 622 c
615 623 subroutine dihf (x, y, z, d, i, h, f)
616 624
617 625 c ===============================================================
618 626 c
619 627 c version 1.01
620 628 c
621 629 c computes the geomagnetic elements d, i, h, and f from
622 630 c x, y, and z.
623 631 c
624 632 c input:
625 633 c x - northward component
626 634 c y - eastward component
627 635 c z - vertically-downward component
628 636 c
629 637 c output:
630 638 c d - declination
631 639 c i - inclination
632 640 c h - horizontal intensity
633 641 c f - total intensity
634 642 c
635 643 c a. zunde
636 644 c usgs, ms 964, box 25046 federal center, denver, co 80225
637 645 c
638 646 c ===============================================================
639 647
640 648 real i
641 649 parameter ( sn = 0.0001 )
642 650
643 651 c ---------------------------------------------------------------
644 652 c if d and i cannot be determined, set equal to 999.0.
645 653 c ---------------------------------------------------------------
646 654
647 655 h2 = x*x + y*y
648 656 h = sqrt (h2)
649 657 f = sqrt (h2 + z*z)
650 658 if (f .lt. sn) then
651 659 d = 999.
652 660 i = 999.
653 661 else
654 662 i = atan2 (z, h)
655 663 if (h .lt. sn) then
656 664 d = 999.
657 665 else
658 666 hpx = h + x
659 667 if (hpx .lt. sn) then
660 668 d = 180.
661 669 else
662 670 d = 2. * atan2 (y, hpx)
663 671 endif
664 672 endif
665 673 endif
666 674
667 675 return
668 676 end
@@ -1,222 +1,235
1 1 # Copyright (c) 2012-2020 Jicamarca Radio Observatory
2 2 # All rights reserved.
3 3 #
4 4 # Distributed under the terms of the BSD 3-clause license.
5 5 """schainpy is an open source library to read, write and process radar data
6 6
7 7 Signal Chain is a radar data processing library wich includes modules to read,
8 8 and write different files formats, besides modules to process and visualize the
9 9 data.
10 10 """
11 11
12 12 import os
13 13 from setuptools import setup, Extension
14 14 from setuptools.command.build_ext import build_ext as _build_ext
15 15 from schainpy import __version__
16 16
17 17 DOCLINES = __doc__.split("\n")
18 18
19 19 class build_ext(_build_ext):
20 20 def finalize_options(self):
21 21 _build_ext.finalize_options(self)
22 22 # Prevent numpy from thinking it is still in its setup process:
23 23 __builtins__.__NUMPY_SETUP__ = False
24 24 import numpy
25 25 self.include_dirs.append(numpy.get_include())
26 26
27 27 setup(
28 28 name = "schainpy",
29 29 version = __version__,
30 30 description = DOCLINES[0],
31 31 long_description = "\n".join(DOCLINES[2:]),
32 32 url = "https://github.com/JRO-Peru/schainpy",
33 33 author = "Jicamarca Radio Observatory",
34 34 author_email = "jro-developers@jro.igp.gob.pe",
35 35 license="BSD-3-Clause",
36 36 classifiers=[
37 37 "Development Status :: 4 - Beta",
38 38 "Environment :: Console",
39 39 "Intended Audience :: Science/Research",
40 40 "License :: OSI Approved :: BSD License",
41 41 "Operating System :: MacOS :: MacOS X",
42 42 "Operating System :: POSIX :: Linux",
43 43 "Programming Language :: Python :: 2",
44 44 "Programming Language :: Python :: 2.7",
45 45 "Programming Language :: Python :: 3",
46 46 "Programming Language :: Python :: 3.5",
47 47 "Programming Language :: Python :: 3.6",
48 48 "Programming Language :: Python :: 3.7",
49 49 "Programming Language :: Python :: 3.8",
50 50 "Topic :: Scientific/Engineering",
51 51 ],
52 52 packages = {
53 53 'schainpy',
54 54 'schainpy.model',
55 55 'schainpy.model.data',
56 56 'schainpy.model.graphics',
57 57 'schainpy.model.io',
58 58 'schainpy.model.proc',
59 59 'schainpy.model.utils',
60 60 'schainpy.utils',
61 61 'schainpy.gui',
62 62 'schainpy.cli',
63 63 },
64 64 package_data = {'': ['schain.conf.template'],
65 65 'schainpy.files': ['*.oga']
66 66 },
67 67 include_package_data = False,
68 68 scripts = ['schainpy/gui/schainGUI'],
69 69 entry_points = {
70 70 'console_scripts': [
71 71 'schain = schainpy.cli.cli:main',
72 72 ],
73 73 },
74 74 cmdclass = {'build_ext': build_ext},
75 75 ext_modules=[
76 76 Extension("schainpy.model.data._noise", ["schainc/_noise.c"]),
77 77 Extension("schainpy.model.data._HS_algorithm", ["schainc/_HS_algorithm.c"]),
78 78 ],
79 79 setup_requires = ["numpy"],
80 80 install_requires = [
81 81 "scipy",
82 82 "h5py",
83 83 "matplotlib",
84 84 "pyzmq",
85 85 "fuzzywuzzy",
86 86 "click",
87 87 ],
88 88 )
89 89
90 main_path = os.getcwd()
91 child_path = '/schainf/mkfact/bfmodel/'
92 #print("main_path: ", main_path)
93 my_str = ' '+"ppath = "+"\""+main_path+"\"\n"
94 my_str_2 = ' '+"cpath = "+"\""+child_path+"\""
95
96 #'''
97 with open('./schainf/mkfact/get_path_1.f', 'r') as path1: data1 = path1.read()
98 with open('./schainf/mkfact/get_path_2.f', 'r') as path2: data2 = path2.read()
99 with open('./schainf/mkfact/get_path.f', 'w') as final: final.write(data1+my_str+my_str_2+data2)
100 #'''
101
90 102 from numpy.distutils.core import Extension, setup
91 103
92 104 setup(name='schainpy',
93 105 ext_modules = [
94 106 Extension("schainpy.model.proc.mkfact_short_2020_2",
95 107 sources=[
96 108 "schainf/mkfact/mkfact_short_2020_2.pyf",
97 109 "schainf/mkfact/lmdif1.f",
98 110 "schainf/mkfact/mkfact.f",
99 111 "schainf/mkfact/r1mach.f",
100 "schainf/mkfact/bfield2.f"])
112 "schainf/mkfact/bfield2.f",
113 "schainf/mkfact/get_path.f"])
101 114 ]
102 115 )
103 116
104 117 '''
105 118 setup(name='schainpy',
106 119 ext_modules = [
107 120 Extension("schainpy.model.proc.mkfact_short_2020_2",
108 121 sources=[
109 122 "schainf/mkfact/mkfact_short_2020_2.pyf",
110 123 "schainf/mkfact/lmdif1.f",
111 124 "schainf/mkfact/mkfact.f",
112 125 "schainf/mkfact/r1mach.f",
113 126 "schainf/mkfact/bfield2.f"]),
114 127 Extension("schainpy.model.proc.full_profile_profile",
115 128 sources=[
116 129 "schainf/full_profile/full_profile_profile.pyf",
117 130 "schainf/full_profile/full_profile_profile.f",
118 131 "schainf/full_profile/fitacf.f",
119 132 "schainf/full_profile/r1mach.f",
120 133 "schainf/full_profile/lmdif1.f",
121 134 "schainf/full_profile/lagp.f",
122 135 "schainf/full_profile/reader.c",
123 136 "schainf/full_profile/cbesi.f",
124 137 "schainf/full_profile/i1mach.f",
125 138 "schainf/full_profile/zeta.f",
126 139 "schainf/full_profile/qc25f.f",
127 140 "schainf/full_profile/qwgtf.f",
128 141 "schainf/full_profile/qcheb.f",
129 142 "schainf/full_profile/sgtsl.f",
130 143 "schainf/full_profile/qk15w.f",
131 144 "schainf/full_profile/complex.c",
132 145 "schainf/full_profile/cbinu.f",
133 146 "schainf/full_profile/cseri.f",
134 147 "schainf/full_profile/cwrsk.f",
135 148 "schainf/full_profile/crati.f",
136 149 "schainf/full_profile/casyi.f",
137 150 "schainf/full_profile/cbuni.f",
138 151 "schainf/full_profile/cuni2.f",
139 152 "schainf/full_profile/gamln.f",
140 153 "schainf/full_profile/cuchk.f",
141 154 "schainf/full_profile/cbknu.f",
142 155 "schainf/full_profile/cshch.f",
143 156 "schainf/full_profile/ckscl.f",
144 157 "schainf/full_profile/cuoik.f",
145 158 "schainf/full_profile/cunik.f",
146 159 "schainf/full_profile/cuni1.f",
147 160 "schainf/full_profile/cairy.f",
148 161 "schainf/full_profile/cmlri.f",
149 162 "schainf/full_profile/cunhj.f",
150 163 "schainf/full_profile/cacai.f",
151 164 "schainf/full_profile/csisl.f",
152 165 "schainf/full_profile/caxpy.f",
153 166 "schainf/full_profile/cs1s2.f",
154 167 "schainf/full_profile/scabs1.f",
155 168 "schainf/full_profile/cdotu.f",
156 169 "schainf/full_profile/rs.f",
157 170 "schainf/full_profile/sppfa.f",
158 171 "schainf/full_profile/sdot.f",
159 172 "schainf/full_profile/tred2.f",
160 173 "schainf/full_profile/tql2.f",
161 174 "schainf/full_profile/sppdi.f",
162 175 "schainf/full_profile/saxpy.f",
163 176 "schainf/full_profile/sscal.f",
164 177 "schainf/full_profile/pythag.f",
165 178 "schainf/full_profile/tql1.f",
166 179 "schainf/full_profile/tred1.f"]),
167 180 Extension("schainpy.model.proc.fitacf_acf2",
168 181 sources = [
169 182 "schainf/acf2/fitacf_acf2.pyf",
170 183 "schainf/acf2/full_profile_profile.f",
171 184 "schainf/acf2/fitacf.f",
172 185 "schainf/acf2/r1mach.f",
173 186 "schainf/acf2/lmdif1.f",
174 187 "schainf/acf2/lagp.f",
175 188 "schainf/acf2/reader.c",
176 189 "schainf/acf2/cbesi.f",
177 190 "schainf/acf2/i1mach.f",
178 191 "schainf/acf2/zeta.f",
179 192 "schainf/acf2/qc25f.f",
180 193 "schainf/acf2/qwgtf.f",
181 194 "schainf/acf2/qcheb.f",
182 195 "schainf/acf2/sgtsl.f",
183 196 "schainf/acf2/qk15w.f",
184 197 "schainf/acf2/complex.c",
185 198 "schainf/acf2/cbinu.f",
186 199 "schainf/acf2/cseri.f",
187 200 "schainf/acf2/cwrsk.f",
188 201 "schainf/acf2/crati.f",
189 202 "schainf/acf2/casyi.f",
190 203 "schainf/acf2/cbuni.f",
191 204 "schainf/acf2/cuni2.f",
192 205 "schainf/acf2/gamln.f",
193 206 "schainf/acf2/cuchk.f",
194 207 "schainf/acf2/cbknu.f",
195 208 "schainf/acf2/cshch.f",
196 209 "schainf/acf2/ckscl.f",
197 210 "schainf/acf2/cuoik.f",
198 211 "schainf/acf2/cunik.f",
199 212 "schainf/acf2/cuni1.f",
200 213 "schainf/acf2/cairy.f",
201 214 "schainf/acf2/cmlri.f",
202 215 "schainf/acf2/cunhj.f",
203 216 "schainf/acf2/cacai.f",
204 217 "schainf/acf2/csisl.f",
205 218 "schainf/acf2/caxpy.f",
206 219 "schainf/acf2/cs1s2.f",
207 220 "schainf/acf2/scabs1.f",
208 221 "schainf/acf2/cdotu.f",
209 222 "schainf/acf2/rs.f",
210 223 "schainf/acf2/sppfa.f",
211 224 "schainf/acf2/sdot.f",
212 225 "schainf/acf2/tred2.f",
213 226 "schainf/acf2/tql2.f",
214 227 "schainf/acf2/sppdi.f",
215 228 "schainf/acf2/saxpy.f",
216 229 "schainf/acf2/sscal.f",
217 230 "schainf/acf2/pythag.f",
218 231 "schainf/acf2/tql1.f",
219 232 "schainf/acf2/tred1.f"])
220 233 ]
221 234 )
222 235 '''
General Comments 0
You need to be logged in to leave comments. Login now