rnanba / galaxyannotator Goto Github PK
View Code? Open in Web Editor NEWGenerate annotations for distant galaxies from image and astrometry.net's 'wcs.fits'.
Generate annotations for distant galaxies from image and astrometry.net's 'wcs.fits'.
leda-get-votable.py でSQLクエリのWHEREにしている赤経赤緯の範囲指定の計算で、写野に極が含まれる場合を考慮していない。
leda-get-votable.py では単純に四隅の座標の赤経・赤緯の min, max を取っているが、それだと写野に極がある場合は極付近等に範囲に入らない部分が出てくる。本来は赤経の範囲は 0h 〜 24h (全周)、赤緯の範囲は写野に北極がある場合は四隅の赤緯の最小値 〜 90度、写野に南極がある場合は -90度 〜 四隅の赤緯の最大値、になるはず。
M31付近を中望遠で撮った写真の wcs.fits を leda-get-votable.py に渡して銀河のデータを取得すると、M31 のデータが入っていなかった。
矩形の頂点の座標が、以下の時、
top-left: 1.6886829535187702, 30.367468713549176
bottom-right: 23.956642040157973, 39.29991228113341
bottom-left: 0.8618865859973092, 24.05345124489381
top-right: 0.8848739783242575, 47.058537285933326
HyperLeda に問い合わせるSQLクエリの WHERE が以下のようになっていた。
al2000<23.956642040157973 and al2000>0.8618865859973092 and de2000<47.058537285933326 and de2000>24.05345124489381 and objtype='G'
WHERE の赤経の範囲指定は、以下のようになるべき(最小値は bottom-right の赤経から 24h 引いた値)。
al2000<1.6886829535187702 and al2000>-0.04335795984202662
v0.9.1 で galaxies.json で特定の銀河のスタイルでマーカーに指定した label-position が、後続の他の銀河のマーカーの名前のラベルの表示に影響を与える。
galaxies.json
{
"galaxies": [
{
"name": "NGC4826",
"al2000": 12.9454673,
"de2000": 21.6821044,
"pa": 114.0,
"logd25": 2.022,
"logr25": 0.295,
"descs": [
"1440万光年"
],
"style": {
"marker": {
"label-position": "top-left"
}
}
},
{
"name": "PGC 1651721",
"al2000": 12.9409511,
"de2000": 21.5214739,
"pa": 36.24,
"logd25": 0.549,
"logr25": 0.14,
"descs": [
"10億4200万光年"
],
"style": {
"name": {
"fill": "red"
}
}
}
]
}
リポジトリのサンプル sample-style.json
, test-data/test-wcs.fits
, test-data/test-in.jpg
を使用して、以下を実行する。
./galaxy-annotator.py galaxies.json sample-style.json test-data/test-wcs.fits test-data/test-in.jpg out.svg
NGC4826 のラベルは左上に表示され、PGC 1651721 のラベルは名前が赤くなる以外は style.json に従い右上に表示される。
PGC 1651721 のラベルの名前だけ左上に表示されてしまう。正確には右上用のラベルの基準位置にラベルの右端が揃えられてしまう(本来はラベルの左端を揃える)。
leda-votable-to-galaxy.py の距離表示で、100万光年の桁以下を一律四捨五入しているので100万光年未満の銀河の距離が正しく表示されず「0.000 Gly」あるいは -j
オプション使用時は「光年」になってしまう。
100万光年未満の銀河としては大マゼラン雲(PGC17223)があるが、視線速度から距離を計算すると1400万光年になるため実際にはこの不具合は発現しない。
leda-get-votable.py で取得したM83周辺のデータから17等以下の銀河を抽出するため -m 17 オプションを指定したところ以下のようにエラーが発生しました。
$ ./leda-votable-to-galaxy.py -m 17 -d -j work/M83-20210315-stretch-2-16bit-starless-wavelet+star-votable.xml > work/M83-20210315-stretch-2-16bit-starless-wavelet+star-galaxies.json
Traceback (most recent call last):
File "./leda-votable-to-galaxy.py", line 42, in
if float(it) > options.max_mag:
TypeError: float() argument must be a string or a number, not 'NoneType'
入力した votable: M83-20210315-stretch-2-16bit-starless-wavelet+star-votable.xml.txt
style.json では色や線の設定項目が SVG のスタイルシートのサブセットになっているが、任意のスタイルプロパティを指定できるようにして欲しい。文字の透明度等を設定したい。
マーカーのサイズは style.json
の size
プロパティで銀河のサイズに対する倍率の形で指定するが、小さな銀河に合わせて大きめの size を指定すると(1.5など)、主題の大きな銀河のマーカーが大きくなりすぎてしまい、画面からはみ出てしまうことがある。マーカーが大きすぎるとラベルの位置も銀河から離れすぎてわかりづらくなる。
wcs.fitsを得た元画像によって、votable.xmlを得る時に
WARNING: FITSFixedWarning: The WCS transformation has more axes (2) than the image it is associated with (0) [astropy.wcs.wcs]
と警告が出て、 leda-votable-to-galaxy.pyの実行時にエラーがでて上手くいかないことがありました、
Windows の Anaconda 環境は PowerShell 上で動くため、リダイレクトで出力したファイルの文字コードがUTF-16になってしまう。leda-get-votable.py の出力はXMLなのでUTF-16で問題ないが、leda-votable-to-galaxy.py の出力はJSONなのでUTF-8にしないと galaxy-annotator.py がJSONの読み込みでエラーになる。
v0.9.1 で以下のような galaxies.json を指定すると NameError: name 's_label_position' is not defined. Did you mean: 'def_label_position'?
が発生してエラーで終了する。
galaxies.json:
{
"galaxies": [
{
"name": "NGC4826",
"al2000": 12.9454673,
"de2000": 21.6821044,
"pa": 114.0,
"logd25": 2.022,
"logr25": 0.295,
"descs": [
"1440万光年"
],
"style": {
"name": {
"fill": "red"
}
}
}
]
}
エラー:
Traceback (most recent call last):
File "/archive/rna/tmp/GalaxyAnnotator/./galaxy-annotator.py", line 269, in <module>
if not('text-anchor' in s['name']) and s_label_position:
^^^^^^^^^^^^^^^^
NameError: name 's_label_position' is not defined. Did you mean: 'def_label_position'?
galaxies.json:
{
"galaxies": [
{
"name": "NGC4826",
"al2000": 12.9454673,
"de2000": 21.6821044,
"pa": 114.0,
"logd25": 2.022,
"logr25": 0.295,
"descs": [
"1440万光年"
],
"style": {
"desc": [
{
"fill": "red"
}
]
}
}
]
}
エラー:
Traceback (most recent call last):
File "/archive/rna/tmp/GalaxyAnnotator/./galaxy-annotator.py", line 275, in <module>
if not('text-anchor' in desc) and s_label_position:
^^^^^^^^^^^^^^^^
NameError: name 's_label_position' is not defined. Did you mean: 'def_label_position'?
style.json による一括指定とは別に銀河毎に個別のスタイル指定ができるようにして欲しい。画像の端で切れているラベルの位置調整や、ラベル同士で衝突して読めないラベルの位置やサイズの調整を SVG エディタを使わずにできてほしい。
SVGエディタでの調整は style.json を調整してSVGを再作成するとやり直しになってしまうので galaxies.json 等で記述できるのが望ましい。
各スクリプトに渡す引数を一括して管理できるプロジェクトファイルを用意し、それだけ指定したら自動的に足りないファイルをスクリプトで生成するスクリプトが欲しい。画像や中間ファイルの管理が煩雑で面倒。
日本語Windowsで galaxy-annotator.py にサンプルの json ファイルを指定して実行すると以下のエラーが発生する。
Traceback (most recent call last):
File ".\galaxy-annotator.py", line 20, in <module>
galaxies = json.load(f)
File "C:\Users\nanba\anaconda3\lib\json\__init__.py", line 293, in load
return loads(fp.read(),
UnicodeDecodeError: 'cp932' codec can't decode byte 0x84 in position 212: illegal multibyte sequence
元の写真がJPEGの場合、最終的なPNG/JPEG画像に元の写真のExifを引き継ぐ方法はないか。#10 でPNG/JPEG生成まで自動化するなら引き継げるようにして欲しい。
leda-votable-to-galaxy.py の -d オプションで、1億光年以下の近距離の銀河の距離表示の精度が悪いので、HyperLeda に mod0 がある銀河なら mod0 から計算できる光度距離を表示したほうがよいのではないか。mod0 は赤方偏移と独立に測定された距離を元にしているので精度がよいはず。
Anaconda3-2023.07-2 をインストールした環境で leda-votable-to-galaxy.py
が「ValueError: Use of bounds
is incompatible with 'method=Brent'.」で異常終了する。
Traceback (most recent call last):
File "/home/rna/Projects/GalaxyAnnotator/leda-votable-to-galaxy.py", line 100, in <module>
z = z_at_value(cosmo.luminosity_distance, ld)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/rna/anaconda3_2023/lib/python3.11/site-packages/astropy/cosmology/funcs.py", line 358, in z_at_value
zs[...] = _z_at_scalar_value(func, fv * unit, zmin=zmn, zmax=zmx,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/rna/anaconda3_2023/lib/python3.11/site-packages/astropy/cosmology/funcs.py", line 79, in _z_at_scalar_value
res = minimize_scalar(f, method=method, bounds=(zmin, zmax),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/rna/anaconda3_2023/lib/python3.11/site-packages/scipy/optimize/_minimize.py", line 887, in minimize_scalar
raise ValueError(message)
ValueError: Use of `bounds` is incompatible with 'method=Brent'.
アノテーションの天体名と説明文の表示位置を変更できるようにして欲しい。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.