人生的意义就是思考其意义分享 http://blog.sciencenet.cn/u/qianlivan 天体物理工作者,家乡云南昆明。

博文

地理坐标转网格定位码python脚本

已有 2153 次阅读 2021-7-29 21:48 |个人分类:知识|系统分类:科研笔记

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])







https://wap.sciencenet.cn/blog-117333-1297563.html

上一篇:arXiv周记202107_3(20210719-20210723)
下一篇:arXiv周记202107_4(20210726-20210730)
收藏 IP: 124.17.44.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-11-9 07:17

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部