-
Notifications
You must be signed in to change notification settings - Fork 3
/
find_COPdem_fn.py
executable file
·43 lines (35 loc) · 1.39 KB
/
find_COPdem_fn.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import numpy as np
import sys
import os
import inspect
sys.path.append('/mnt/data01/Code/')
def find_COPdem_fn(lat,lon):
"""
% (C) Nick Holschuh - Amherst College -- 2022 (Nick.Holschuh@gmail.com)
%
% This is a function that outputs the filename associated wtih the
% desired latitude & longitude of the COPdem
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The inputs are:
%
% lat -- individual latitude value to use for search
% lon -- individual longitude value to use for search
%
%%%%%%%%%%%%%%%
% The outputs are:
%
% file_info -- the filename for the COPDem tile that you want
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"""
from NDH_Tools import find_nearest_xy
from NDH_Tools import loadmat
curpath = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
mf_name = curpath+'/COPdem_filelist.mat'
file_info = loadmat(mf_name)
target = np.array([[float(lat)], [float(lon)]])
result = find_nearest_xy(file_info['latlon'],target)
if result['distance'] > 1:
print('This DEM likely doesn\'t contain your point of interest.')
print('The DEM center is %0.2f degrees away from the target point.' % result['distance'])
return file_info['fn'][result['index'][0]]