sudo apt-get install lib32z1
分类: 学习
[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);
perl求汉字字符串长度
perl在进行汉字操作之前要先转码,不然无法正确操作。
use Encode;
$s=’汉字’;
$str=decode ‘utf8’,$s; #######或者gb2312之类的
$len=length($str); ######这样就可以正确得到汉字字符串的长度了
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);
}
C调用fortran
1. fortran中的函数名全部用小写,记得带下划线,如func_
2. 参数必须是地址
3. 编译时加上-lgfortran
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
用python中的time模块求epoch时间
import time
a='1987-06-05 12:31:28'
tm=time.strptime(a,'%Y-%m-%d %H:%M:%S')
epo_time=time.mktime(tm)