余纬度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