||
import ephem
import numpy as np
import sys
convert_radian2degree=180.0/np.pi
if (len(sys.argv)<3):
print 'too few input parameters, format:'
print 'python terr_radec2grid_location.py terr_ra terra_dec'
print ' (degree) (degrees)'
sys.exit()
else:
rad=sys.argv[1]
decd=sys.argv[2]
rad0=float(ephem.degrees(rad))*convert_radian2degree
decd0=float(ephem.degrees(decd))*convert_radian2degree
if(rad0<-180 or rad0>180 or decd0<-90 or decd0>90):
print('Wrong longitude or latitude!')
sys.exit()
rd = int(abs(rad0))
rm = int((abs(rad0)-rd)*60)
rs = (abs(rad0)-rd-rm/60.0)*3600
dd = int(abs(decd0))
dm = int((abs(decd0)-dd)*60)
ds = (abs(decd0)-dd-dm/60.0)*3600
indexf1=int(rad0+180)/20
indexf2=int(decd0+90)/10
indexs1=int(rad0-(indexf1*20-180))
indexs2=int(decd0-(indexf2*10-90))
indexss1=int((rad0-int(rad0))*60/5)
indexss2=int((decd0-int(decd0))*60/2.5)
string1='ABCDEFGHIJKLMNOPQR'
string2='ABCDEFGHIJKLMNOPQRSTUVWX'
print('The grid location ('+rad+','+decd+') is:')
print(string1[indexf1]+string1[indexf2]+str(indexs1)+str(indexs2)+string2[indexss1]+string2[indexss2])
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-11-9 07:17
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社