text: # -*- coding: utf-8 -*-
  # -----------------------------------------------------------------------------
  # Copyright © Climate Data Preprocessing Tool Project Contributors
  # https://github.com/cgq-qgc/climate-data-preprocessing-tool
  #
  # This file is part of Climate Data Preprocessing Tool.
  # Licensed under the terms of the GNU General Public License.
  # -----------------------------------------------------------------------------
  
  
  # ---- Standard lirary imports
  import csv
  import os
  import os.path as osp
  from shutil import rmtree
  
  
  # ---- Third party imports
  import numpy as np
  import xlsxwriter
  import xlwt
  
  
  def calc_dist_from_coord(lat1, lon1, lat2, lon2):
      """
      Compute the  horizontal distance in km between a location given in
      decimal degrees and a set of locations also given in decimal degrees.
      """
      lat1, lon1 = np.radians(lat1), np.radians(lon1)
      lat2, lon2 = np.radians(lat2), np.radians(lon2)
  
      r = 6373  # r is the Earth radius in km
  
      dlon = lon2 - lon1
      dlat = lat2 - lat1
      a = np.sin(dlat/2)**2 + np.cos(lat1)*np.cos(lat2)*np.sin(dlon/2)**2
      c = 2 * np.arctan2(np.sqrt(a), np.sqrt(1-a))
  
      return r * c
  