コマンドラインから日の出やその他の天文データ

コマンドラインから日の出やその他の天文データ

特定の日付と場所の日の出と日没の時間と月と惑星のデータを表示するための簡単なオープンソースのコマンドラインプログラムはありますか?

Debian パッケージデータベースを閲覧し、Google で検索しても関連項目が見つかりません。これは私を驚かせます。天文学のオタクとUnixオタクの数を考えると、私は事実上の標準sunrise(1)(またはおそらくsunrise(6))を期待したでしょう。

私は、空地図(celestia、kstars、starplot、stellarium)、地球地図(sunclock、xplanet)、カレンダー/議題(emacs、Remember)、時計(glunarclock、wmsun)など、偶然に計算を実行するより複雑なプログラムに興味があります。ありません。 ) ) 、朝夕年鑑(xtide)。たぶんあるかもしれませんaa天文年鑑)、しかし、この経度と緯度で、この日に太陽が何時に浮かぶかを尋ねる簡単な方法はありません。

私が逃したものは何ですか?

答え1

試してみましたsunwaitか?

Sunwaitは、日の出と日没だけでなく、民間、海上、天文学の夕暮れを計算するために使用される小さなCプログラムです。 [..]

このアイテムは利用可能ですGitHubから次のように複製できます。

$ git clone https://github.com/risacher/sunwait
Cloning into 'sunwait'...
remote: Enumerating objects: 107, done.
remote: Counting objects: 100% (62/62), done.
remote: Compressing objects: 100% (26/26), done.
remote: Total 107 (delta 45), reused 37 (delta 36), pack-reused 45
Receiving objects: 100% (107/107), 121.93 KiB | 2.65 MiB/s, done.
Resolving deltas: 100% (55/55), done.
$ cd sunwait/

修理後ブラケットの問題、プログラムを作成することができます

$ make
gcc -c -Wall  sunwait.cpp -o sunwait.o
gcc -c -Wall  sunriset.cpp -o sunriset.o
sunriset.cpp: In function ‘void sun_RA_dec(double, double*, double*, double*)’:
sunriset.cpp:151:18: warning: variable ‘zs’ set but not used [-Wunused-but-set-variable]
  151 |   double xs, ys, zs;
      |                  ^~
gcc -c -Wall  print.cpp -o print.o
gcc sunwait.o sunriset.o print.o -o sunwait -lm -lstdc++
$ ./sunwait help
Calculate sunrise and sunset times for the current or targetted day.
The times can be adjusted either for twilight or fixed durations.

The program can either: wait for sunrise or sunset   (function: wait),
  or return the time (GMT or local) the event occurs (function: list),
  or report the day length and twilight timings      (function: report),
  or simply report if it is DAY or NIGHT             (function: poll).

You should specify the latitude and longitude of your target location.


Usage: sunwait [major options] [minor options] [twilight type] [rise|set] [offset] [latitude] [longitude]

Major options, either:
    poll          Returns immediately indicating DAY or NIGHT. See 'program exit codes'. Default.
    wait          Sleep until specified event occurs. Else exit immediate.
    list [X]      Report twilight times for next 'X' days (inclusive). Default: 1.
    report        Generate a report about the days sunrise and sunset timings.

Minor options, any of:
    [no]debug     Print extra info and returns in one minute. Default: nodebug.
    [no]version   Print the version number. Default: noversion.
    [no]help      Print this help. Default: nohelp.
    [no]gmt       Print times in GMT or local-time.  Default: nogmt.

Twilight types, either:
    daylight      Top of sun just below the horizon. Default.
    civil         Civil Twilight.         -6 degrees below horizon.
    nautical      Nautical twilight.     -12 degrees below horizon.
    astronomical  Astronomical twilight. -18 degrees below horizon.
    angle [X.XX]  User-specified twilight-angle (degrees). Default: 0.

Sunrise/sunset. Only useful with major-options: 'wait' and 'list'. Any of: (default: both)
    rise          Wait for the sun to rise past specified twilight & offset.
    set           Wait for the sun to  set past specified twilight & offset.

Offset:
    offset [MM|HH:MM] Time interval (+ve towards noon) to adjust twilight calculation.

Target date. Only useful with major-options: 'report' or 'list'. Default: today
    d [DD]        Set the target Day-of-Month to calculate for. 1 to 31.
    m [MM]        Set the target Month to calculate for. 1 to 12.
    y [YYYY]      Set the target Year to calculate for. 2000 to 2099.

latitude/longitude coordinates: floating-point degrees, with [NESW] appended. Default: Bingham, England.

Exit (return) codes:
    0           OK: exit from 'wait' or 'list' only.
    1           Error.
    2           Exit from 'poll': it is DAY or twilight.
    3           Exit from 'poll': it is NIGHT (after twilight).

Example 1: sunwait wait rise offset -1:15:10 51.477932N 0.000000E
Wait until 1 hour 15 minutes 10 secs before the sun rises in Greenwich, London.

Example 2: sunwait list 7 civil 55.752163N 37.617524E
List civil sunrise and sunset times for today and next 6 days. Moscow.

Example 3: sunwait poll exit angle 10 54.897786N -1.517536E
Indicate by program exit-code if is Day or Night using a custom twilight angle of 10 degrees above horizon. Washington, UK.

Example 4: sunwait list 7 gmt sunrise angle 3
List next 7 days sunrise times, custom +3 degree twilight angle, default location.
Uses GMT; as any change in daylight saving over the specified period is not considered.

Note that program uses C library functions to determine time and localtime.
Error for timings are estimated at: +/- 4 minutes.

グローバルにインストールするには、次のように入力します。

$ sudo install -vpm 755 sunwait /usr/local/bin/
'sunwait' -> '/usr/local/bin/sunwait'

答え2

私は最終的にPerlを使うようになりましたDateTime::Event::Sunriseこれは、Cプログラムをコンパイルするよりも、CPANからモジュールを配布する方が簡単だからです。

使用例:

use DateTime;
use DateTime::Astro::Sunrise;
$latitude = "+48.857"; $longitude = "+2.351"; 
$sr = DateTime::Astro::Sunrise->new($longitude, $latitude, 0, 3);
$date = DateTime->now; $date->set_time_zone("local");
($rise, $set) = $sr->sunrise($date);
$rise->set_time_zone("local"); $set->set_time_zone("local");
print $rise, " to ", $set, "\n";

私のsunriseスクリプト

答え3

私のように怠惰な人のための非常に単純なプログラムがあります。日付、さまざまなディストリビューションで利用可能(apt-get install hdateDebian/Ubuntu/...):

hdate -s -l N50 -L E14 -z2

出力:

Wednesday, 26 June 2019, 23 Sivan 5779
sunrise: 04:55
sunset: 21:17

オプション:

  • -s sunset sunrise
  • -l-L:プラハの高度と緯度(50°05′N 14°25′E)
  • -z zone:SELC=+2

すべて終わった。 :-)

答え4

確認してみてくださいLinuxホームオートメーション Linuxホームオートメーションウェブサイトで「sunrise」ページを検索してください。 cにはいくつかのコマンドラインプログラムがあります。 1985年のスタイルはとてもミニマリストでした。その時代の多くの関連プログラムのソースコードがありますが、オンラインでは見つかりません。

アップデート:sdateを含む他のアイテムのソースが見つかりました。イベントレコーダーページ。ページで「rise_set」を検索してください。

2017-12-23 アップデート:Linuxホームオートメーションプロジェクトは移動されましたが、日の出、日没などのコマンドラインプログラムは引き続き使用できるようです。ここそしてここ。元のページリンクに線を引いたが、参照用にアーカイブして新しいページへのリンクを追加しました。

関連情報