nastasin/swephetest

Swiss Ephemeris swisseph 命令的包装器 - swetest。可用于获取指定位置和时间的行星位置。

dev-master 2022-02-17 08:06 UTC

This package is auto-updated.

Last update: 2024-09-24 13:36:11 UTC


README

此包是围绕瑞士天文历测试命令的简单包装,以默认的 '-sid1' 选项获取行星位置,以应用黄道(Lahiri Ayanamsha)计算。

您可以在瑞士天文历测试页面上找到更多关于选项的文档。

此存储库包含以下天文历文件,时间跨度为公元1800年至2399年:

  • sepl_18.se1 = 行星文件
  • semo_18.se1 = 月球文件
  • seas_18.se1 = 主要小行星文件
  • swetest = 可执行文件

要求

此包已在基于 Linux(Ubuntu)和 PHP 7.4-fpm 以及 PHP 8.0-fpm 的构建上进行测试。额外的包已包含在 composer 文件中。

特性

  • 内置步进和步长选项,可以在一次执行中获取一段时间内的行星位置。
  • 接受带有 UTC 的 Carbon 对象,在结果输出中
  • 默认计算太阳和月球位置。
  • 接受十进制度数纬度和经度进行地理定位。
  • 海拔高度
  • 输出映射数据的Laravel 集合

用法和代码示例

使用 composer require nastasin/swephetest 安装

use Carbon\Carbon;
use Nastasin\SwissEpheWrapper\SwissEpheWrapper;

//Sun and Moon longitude positions by default
$options = [
    SwissEpheWrapper::OPT_DATETIME => Carbon::now()->setTimezone('UTC'), //UTC required
    SwissEpheWrapper::OPT_LNG => 24.105078, //coordinates for city (Riga/Europe in example)
    SwissEpheWrapper::OPT_LAT => 56.946285
];

$planetary = new SwissEpheWrapper($options);

$planetary->get()

输出

Illuminate\Support\Collection {#7 ▼
#items: array:1 [▼
    0 => Illuminate\Support\Collection {#5 ▼
      #items: array:3 [▼
        0 => array:2 [▼
          0 => 303.868487 //Sun longitude at present day
          1 => 1.0092834 //Sun speed longitude decimal (degrees/day)
        ]
        1 => array:2 [▼
          0 => 124.2552189 //Moon longitude at present day
          1 => 12.7868005 //Moon speed longitude decimal (degrees/day)
        ]
        2 => Carbon\Carbon @1645033465 { ▼
          ...
          date: 2022-02-16 17:44:25.800801 UTC (+00:00) //Carbon::now(at a moment of example)
        }
      ]
    }
]
}

带有解释的选项。从 2022 年 3 月 1 日 12:00 UTC 开始,连续两天的月球经度

use Carbon\Carbon;
use Nastasin\SwissEpheWrapper\SwissEpheWrapper;

$time = Carbon::parse('1-03-2022 12:00:00')->setTimezone('UTC');

$options = [
    SwissEpheWrapper::OPT_DATETIME => $time,
    SwissEpheWrapper::OPT_LNG => 24.105078, //for Riga/Europe
    SwissEpheWrapper::OPT_LAT => 56.946285,
    SwissEpheWrapper::OPT_GEOPOS    => 'geopos',
    SwissEpheWrapper::OPT_PARAMS    => 'l', //get only longitude (long. and long speed by default)
    SwissEpheWrapper::OPT_PLIST     => SwissEpheWrapper::MOON, //only Moon
    SwissEpheWrapper::OPT_STEP      => 2, //two consecutive days
    SwissEpheWrapper::OPT_STEPSIZE  => 1,
    SwissEpheWrapper::OPT_ELEVATION => 20 //20m above sea level
];


$planetary = new SwissEpheWrapper($options);

$planetary->get();

输出

^ Illuminate\Support\Collection {#8 ▼
  #items: array:2 [▼
    0 => Illuminate\Support\Collection {#7 ▼
      #items: array:2 [▼
        0 => array:1 [▼
          0 => 300.5799517
        ]
        1 => Carbon\Carbon @1646136000 {#15 ▼
          ...
          date: 2022-03-01 12:00:00.0 UTC (+00:00)
        }
      ]
    }
    1 => Illuminate\Support\Collection {#5 ▼
      #items: array:2 [▼
        0 => array:1 [▼
          0 => 314.7017604
        ]
        1 => Carbon\Carbon @1646222400 {#16 ▼
          ...
          date: 2022-03-02 12:00:00.0 UTC (+00:00)
        }
      ]
    }
  ]
}