[GMT]已知相对于某固定点的方位角和距离,求该点位置

如题,已知某固定点A的经纬度lo1,la1,另已知某一点B相对于A的方位角az和距离dist,求B点的经纬度。用GMT的project命令。

project -Q -G10 -Clo1/la1 -Aaz -Ldist/​10000

-Q指定结果按度输出

-G指定在该方向上的采样步长

-C指定中心点或起始点

-A方位角

-L起止长度

输出的第一行前两列即是所需结果

fortran tips

1.  先定义类型,再定义存储大小

character a

dimension a(10)​

2.  获取当前时间​

第一种方法

program when 

 integer*4 today(3), now(3) 

 call idate(today) ! today(1)=day, (2)=month, (3)=year 

 call itime(now) ! now(1)=hour, (2)=minute, (3)=second 

 write ( *, 1000 ) today(2), today(1), today(3), now 

 1000 format ( 'Date ', i2.2, '/', i2.2, '/', i4.4, '; time ', & i2.2, ':', i2.2, ':', i2.2 )

 stop 

 end​

第二种方法

program now_time

integer date_time(8)       

character*10 b(3)       

call date_and_time(b(1), b(2), b(3), date_time)       

print *,’date_time    array values:’       

print *,’year=’,date_time(1)       

print *,’month_of_year=’,date_time(2)      

 print *,’day_of_month=’,date_time(3)       

print *,’time difference in minutes=’,date_time(4)       

print *,’hour of day=’,date_time(5)       

print *,’minutes of hour=’,date_time(6)       

print *,’seconds of minute=’,date_time(7)      

 print *,’milliseconds of second=’,date_time(8)      

 print *, ’DATE=’,b(1)      

 print *, ’TIME=’,b(2)       

print *, ’ZONE=’,b(3)

end

3.   数字转字符

      program tran

      integer i

      character*3 a

      i=500

      write(a,'(i3)') i

      print *, a // ' this is a test'

      end

余纬度colatitude

https://en.wikipedia.org/wiki/Colatitude

In spherical coordinates, colatitude is the complementary angle of the latitude, i.e. the difference between 90° and the latitude,[1] where southern latitudes are denoted with a minus sign.

Examples

Latitude and colatitude sum up to 90°.

place                latitude               colatitude

north pole​        90°                           0°

equator              ​0°                           90° 

south pole        -90°                       180°

C语言结构体拷贝

定义了一个结构体数组,每个成员都想从另一个相同的结构体中拷贝过来,遂用了memcpy,比如

typedef struct cata *CATA, single_cata;

int size=​sizeof(single_cata);

memcpy(CATA+i*size,&single_cata,size);​

运行时发现除了结构体数组CATA的第一个值是正确的,后面的全错了,后来搜了一下,发现要如是改:

​memcpy((char*)CATA+i*size,&single_cata,size);​

c语言产生随机的高斯分布

参考http://www.cnblogs.com/tsingke/p/6194737.html

采用box-muller方法:

​

#include

#include ​

double gaussrand2(double mu,double sigma){​

  static double u,v;

  static int phase=0;

  double z;

  if(phase==0){

    u=rand()/(RAND_MAX+1.0);

    v=rand()/(RAND_MAX+1.0);

    z=sqrt(-2.0*log(u))*sin(2.0*pi*v);

  }

  else{

    z=sqrt(-2.0*log(u))*cos(2.0*pi*v);

  }

  phase=1-phase;

  return(mu+z*sigma);

}

obspy绘制beach ball

import numpy as np

​import matplotlib.pyplot as plt 

 from mpl_toolkits.basemap import Basemap 

 from obspy import read_events 

from obspy.imaging.beachball import beach 

 event = read_events( 'https://earthquake.usgs.gov/archive/product/moment-tensor/' 'us_20005ysu_mww/us/1470868224040/quakeml.xml', format='QUAKEML')[0] 

origin = event.preferred_origin() or event.origins[0] 

ocmec = event.preferred_focal_mechanism() or event.focal_mechanisms[0] 

tensor = focmec.moment_tensor.tensor