Apply current workspace changes
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import numpy as np
|
||||
import os
|
||||
import sys
|
||||
import argparse
|
||||
import subprocess
|
||||
from pyint import _utils as ut
|
||||
|
||||
def cmdLineParse():
|
||||
parser = argparse.ArgumentParser(description='convert psokinv quadtree result to SDM.',\
|
||||
formatter_class=argparse.RawTextHelpFormatter,\
|
||||
epilog=INTRODUCTION+'\n'+EXAMPLE)
|
||||
|
||||
parser.add_argument('inputfile', help='psokinv quadtree file name ')
|
||||
parser.add_argument('outfile', help=' file name for SDM ')
|
||||
inps = parser.parse_args()
|
||||
return inps
|
||||
INTRODUCTION = '''
|
||||
-------------------------------------------------------------------
|
||||
create_files for SDM software running file by generated by psokinv
|
||||
'''
|
||||
|
||||
EXAMPLE = """Usage:
|
||||
|
||||
PSOKINV2SDM.py inputfile outfile
|
||||
|
||||
create_psokinv.py 20241015_20250107.inp 20241015_20250107_los_for_sdm
|
||||
-------------------------------------------------------------------
|
||||
"""
|
||||
|
||||
def phitheta2neu(phi,theta):
|
||||
#
|
||||
import numpy as np
|
||||
#
|
||||
deg2rad=np.pi/180.
|
||||
#
|
||||
theta=theta*deg2rad; phi=phi*deg2rad;
|
||||
#
|
||||
vn= np.sin(theta)*np.sin(phi)
|
||||
ve=-np.sin(theta)*np.cos(phi)
|
||||
vu= np.cos(theta)
|
||||
#
|
||||
return vn,ve,vu
|
||||
#
|
||||
def neu2phitheta(vn,ve,vu):
|
||||
#
|
||||
import numpy as np
|
||||
#
|
||||
rad2deg=180./np.pi;
|
||||
#
|
||||
theta=np.arccos(vu)*rad2deg; phi=np.arctan2(vn,-ve)*rad2deg;
|
||||
#
|
||||
return theta,phi
|
||||
#
|
||||
def psokinv2sdm(file,file_out):
|
||||
#
|
||||
import numpy as np
|
||||
#
|
||||
data=np.genfromtxt(file);
|
||||
length=len(data)
|
||||
inc=[]
|
||||
azi=[]
|
||||
out_data={}
|
||||
for i in range(length):
|
||||
(inc,azi)=neu2phitheta(data[i,4],data[i,3],data[i,5]);
|
||||
out_data[i]=(data[i,0],data[i,1],data[i,2],inc,azi);
|
||||
data1=np.array(list(out_data.values()))
|
||||
txt_data = np.savetxt(file_out,data1,fmt='%.8f')
|
||||
|
||||
|
||||
def main(argv):
|
||||
inps = cmdLineParse()
|
||||
input_file = inps.inputfile
|
||||
out_file = inps.outfile
|
||||
psokinv2sdm(input_file, out_file)
|
||||
print("convert psokinv products to sdm is done!")
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(sys.argv[:])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user