text: ##########################################################################
  # Name: plotCycloneloc.py
  #
  # Plot cyclone center location data made by cal_cycloneDeepenigRate.py
  #
  # Usage: python3 plotcyclone_dir.py [-d|--dir] <directory>
  #
  # Author:
  # Date: 2021/08/18
  ##########################################################################
  import os
  from os.path import*
  import pandas as pd
  import numpy as np
  import matplotlib.pyplot as plt
  import matplotlib.ticker as mticker
  import cartopy.crs as ccrs
  import cartopy.feature as cfea
  from cartopy.mpl.ticker import LatitudeFormatter,LongitudeFormatter
  import argparse
  import re
  
  
  def parse_args():
      parser = argparse.ArgumentParser()
      parser.add_argument("-d","--dir",help="set directory which contained csv files.",type=str)
      p = parser.parse_args()
      args = {"dir":p.dir}
      return args
  
  
  def mkfile_list(DIRPATH):
      def cat_path(dir_path,files):
          abspath = join(dir_path,files)
          return abspath
      csv_list = sorted([cat_path(DIRPATH,i) for i in os.listdir(DIRPATH)])
      return csv_list
  
  
  def read_csv(csvfile):
      df = pd.read_csv(csvfile,header=0)
      lat = df["latitude"]
      lon = df["longitude"]
      prmsl = df["prmsl center (hPa)"]
      return lat,lon,prmsl
  
  class PlotCycloneMap:
  
      def make_map(self):
          self.fig = plt.figure(figsize=(36,24),facecolor='w')
          self.ax = self.fig.add_subplot(1,1,1,
              projection=ccrs.PlateCarree(central_longitude=0.0))
          self.ax.set_global()
          self.ax.coastlines()
          dlon,dlat = 10,10 #grid line interval
          xticks = np.arange(-180,180.1,dlon)
          yticks = np.arange(-90,90.1,dlat)
          self.ax.set_xticks(xticks,crs=ccrs.PlateCarree())
          self.ax.set_yticks(yticks,crs=ccrs.PlateCarree())
          latfmt = LatitudeFormatter() #axis = degree
          lonfmt = LongitudeFormatter(zero_direction_label=True) # No NS mark 0 degree
          self.ax.xaxis.set_major_formatter(lonfmt)
          self.ax.yaxis.set_major_formatter(latfmt)
          self.ax.axes.tick_params(labelsize=12)
          self.ax.add_feature(cfea.LAND,color='#98fb98')
          self.ax.add_feature(cfea.OCEAN,color='#87cefa')
  
          grid = self.ax.gridlines(crs         = ccrs.PlateCarree(),
                              draw_labels = False,
                              linewidth   = 1,
                              alpha       = 0.8,
                              color       = 'k')
          self.ax.set_xlim(110,180)
          self.ax.set_ylim(20,60)
          grid.xlocator = mticker.FixedLocator(xticks)
          grid.ylocator = mticker.FixedLocator(yticks)
  
          return None
  
  
      def plot_data(self,lat,lon,prmsl,label,i):
          color_list = ['#b22222','#ffa500','#ffd700','#006400','#3cb371','#00bfff','#0000ff','#9932cc','#c71585']
          self.ax.plot(lon,lat,'bo',
                       label = label,
                       markersize      = 15,
                       markeredgewidth = 1.6,
                       color           = color_list[i],
                       markeredgecolor = '#000000',
                       linestyle       = "solid")
          self.ax.set_xlabel("lat",)
          self.ax.set_ylabel("lon",)
          #[self.ax.plot(lon[i],lat[i],marker=str(f'${prmsl[i]:.2f}$'),markersize=90,color='k',) for i in range(len(lat))]
          return None
  
      def save_fig(self):
          bar,label = self.ax.get_legend_handles_labels()
          self.ax.legend(bar,label,loc='upper left', borderaxespad=0, bbox_to_anchor=(1.05,1))
          self.fig.savefig("test",bbox_inches="tight",pad_inches=0.5)
  
  
  def main():
      args = parse_args()
  
      DIRPATH = abspath(join(dirname(__file__),args["dir"]))
      mkfile_list(DIRPATH)
      csv_list = mkfile_list(DIRPATH)
  
      PltMap = PlotCycloneMap()
      PltMap.make_map()
  
      for i,data in enumerate(csv_list):
          label = re.search("[0-9]{10}",data).group()
          lat,lon,prmsl = read_csv(data)
          PltMap.plot_data(lat,lon,prmsl,str(label),i)
  
      PltMap.save_fig()
  
      return None
  
  
  if __name__ == "__main__":
      main()
  