2017年9月15日金曜日

python module which generates the list of points, which are on an ellipse on the Earth.

Because, interestingly, there is no command which draws ellipse/circle in KML


import geopy
import geopy.point as point
import geopy.distance as distance
import math

#clat, clon: epicenter
#smajax, sminax: major/minor axis length in km
#strike; direction of the major axis from north
#numVer: number of points of ellipse.
def calcEllipse(clat,clon,smajax,sminax,strike,numVer):

   dDeg = 0.1
   rot = -strike * math.pi/180.0
   points = []

# Calc the length per deg around the center [km] / [deg]
   dlat = distance.distance((clat,clon),(clat+dDeg,clon     )).km;
   dlng = distance.distance((clat,clon),(clat     ,clon+dDeg)).km;
   dTheta = (360.0/numVer);

   i = 0.0
   while i <= 360.001:
      y = smajax * math.cos(i * math.pi/180);
      x = sminax * math.sin(i * math.pi/180);
      lng = (x*math.cos(rot)-y*math.sin(rot))/dlat*dDeg; #Recover in deg
      lat = (y*math.cos(rot)+x*math.sin(rot))/dlon*dDeg;
      points.append((clat+lat,clon+lng))
      i = i+dTheta;

   return points

2017年9月14日木曜日

matplotlibで自分用のTTFを追加 (times)

fpath = os.path.join("/path/to/times.ttf')
import matplotlib.font_manager as fm
from matplotlib import ft2font
from matplotlib.font_manager import ttfFontProperty


font = ft2font.FT2Font(fpath)
fprop = fm.FontProperties(fname=fpath)

ttfFontProp = ttfFontProperty(font)
fontsize=15
fontprop = fm.FontProperties(family='serif',
                            #name=ap.fontprop.name,
                            fname=ttfFontProp.fname,
                            size=fontsize,
                            stretch=ttfFontProp.stretch,
                            style=ttfFontProp.style,
                            variant=ttfFontProp.variant,
                            weight=ttfFontProp.weight)

matplotlib.rcParams.update({'font.size': fontsize,
                        'font.family': 'serif'})

2017年9月12日火曜日

Oracleで他のデータベースから自分のローカルにデータをコピーする

$ sqlplus ID/PW@DB

ID@DB > copy from ID_from/PW_from@DB_from to ID_dst/PW_dst/@DB_dst {insert/create} TABLE_NAME using select * from TABLE_from;

自分用メモ

2017年6月18日日曜日

llvm-flang compilation

I have just completed the build of llvm-flang.
The procedure was almost the same as the official;
https://github.com/flang-compiler/flang

However, my environment is RH6.4, somehow out-dated, and needs a little effort.
(1) Need to install a newer GCC, probably, 4.7 or newer (libstdc++4.7 is required).
    My case, I used 7.1
(2) at the cmake phase "-DGCC_INSTALL_PREFIX=/opt/GCC/7.1.0" is needed.
   Otherwise, clang/clang++ complains there is no proper libstdc++.

2017年5月22日月曜日

pythonでprogress bar with multiprocessing

multiprocessingしてるということは時間かかるってことなので進行状況がしりたい。いい記事をみつけたのでメモ

from multiprocessing import Pool
import tqdm

pool = Pool(processes=8)
for _ in tqdm.tqdm(pool.imap_unordered(do_work, tasks), total=len(tasks)):
    pass
http://stackoverflow.com/questions/5666576/show-the-progress-of-a-python-multiprocessing-pool-map-call

2017年5月12日金曜日

Cartopy with Conda

Cartopyというのを使ってみたいのだけど、私の環境ではなかなか面倒。
Condaというのを使うとpythonからcartopyまで楽に入れてくれそうなので使ってみる。

https://conda.io/miniconda.html

2017年5月5日金曜日

Gentoo prefix

会社のLinux(Redhat 6.4)は勝手にパッケージをインストール出来ないので、下記を試す。
ebuild.sh のbash のバージョンチェックだけ4.1に無理やり修正した以外は、ほぼこのまま。

https://wiki.gentoo.org/wiki/Project:Prefix/Manual_Bootstrap

2017年2月17日金曜日

mapproxy 1.9.1 + pillow 3.4.2

mapproxy 1.9.1 + pillow 3.4.2, this combination causes a little error in the images.
pillow 3.3.1 does not.
just a memo