import numpy as np
import pandas as pd
import matplotlib as mpl
import os
import math
import glob
import datetime
from matplotlib import pyplot as plt
path=r'E:\Check_met_fnl.xlsx'
df=pd.read_excel(path,sheet_name='Mea',index_col=0,header=0,parse_dates=True)
Lat_fnl=-np.arange(-90,91,1) ### 1°
Lon_fnl=np.arange(0,360,1) ### 1°
Len=len(df)
result=np.zeros((181,360))
result_loc=np.zeros((Len,2))
for i in np.arange(Len):
lat=df['LAT_merge'][i]
lon=df['LON_merge'][i]
templat=(lat-Lat_fnl)*(lat-Lat_fnl)
templon=(lon-Lon_fnl)*(lon-Lon_fnl)
for j in np.arange(181):
for k in np.arange(360):
result[j,k]=np.sqrt(templat[j]+templon[k])
temp=np.where(result==np.min(result))
print(temp[0])
print(temp[1])
result_loc[i,0]=Lat_fnl[temp[0][0]] ## Possible to find 2 groups results.
result_loc[i,1]=Lon_fnl[temp[1][0]]
网友评论