Public API reference

简体中文 · Documentation

These APIs are rendered from their defining modules. Public summaries and contracts are bilingual; both language views use the same definitions. See birth inputs, requested configuration, charts, aspects and chart results for executed examples. The knowledge guide covers chart-independent queries.

Calculation boundaries: initialization and I/O, constructor checks, and house-system failures.

Birth records and resolution

Original birth records and explicit modern time resolution.

原始出生记录与显式的现代时刻解析。

exception astrology.birth.MissingBirthDataError

Required birth information is absent. 缺少必需的出生资料。

exception astrology.birth.AmbiguousBirthTimeError

A repeated wall time needs an explicit fold. 重复的本地钟点需要显式选择 fold。

exception astrology.birth.NonexistentBirthTimeError

The wall time falls in a clock-change gap. 本地钟点落在时钟调整的空缺中。

exception astrology.birth.HistoricalTimeError

The instant needs the future historical-time contract. 该时刻需要未来的历史时间合同。

class astrology.birth.TimePrecision(*values)

Stated clock precision, without inventing uncertainty bounds.

记录所声明的钟点精度,不推定不确定区间。

HOUR = 'hour'
MINUTE = 'minute'
SECOND = 'second'
MICROSECOND = 'microsecond'
class astrology.birth.Location(latitude, longitude)

Finite degrees: latitude [-90, 90], longitude [-180, 180], north/east positive.

有限角度:纬度 [-90, 90]、经度 [-180, 180],北纬和东经为正。

Parameters:
latitude: float
longitude: float
class astrology.birth.IanaTimezone(key)

An ASCII key with nonempty slash-separated letter/digit/_+- segments.

Require a plain string and valid shape at construction; check exact case and existence against the packaged keys only during explicit resolution.

ASCII 标识,各非空段仅含字母、数字或 _+-,以斜线分隔。构造时要求普通字符串及有效形状; 仅在显式解析时按包内标识检查大小写和是否存在。

Parameters:

key (str)

key: str
class astrology.birth.FixedOffset(offset)

An explicit UTC offset strictly between -24 and +24 hours, without a database.

显式 UTC 偏移量,严格介于 -24 和 +24 小时之间,不使用时区数据库。

Parameters:

offset (timedelta)

offset: timedelta
class astrology.birth.BirthRecord(birth_date, birth_time=None, timezone=None, location=None, precision=None, source=<factory>, calendar='gregorian')

A proleptic Gregorian record, retaining missing fields and copied source metadata.

The clock must be naive with fold=0. Fields smaller than the stated precision must be zero; precision=None means unstated, not an assumed accuracy. Historical date labels remain storable without Julian-calendar conversion. Source keys and values must be plain strings, not mutable subclasses.

公历(proleptic Gregorian)记录,保留缺失字段并复制来源元数据。钟点须无时区且 fold=0;比所声明精度更小的 钟点字段须为零,precision=None 表示未声明,不代表推定精度。历史日期标签仍可保存, 但不转换儒略历。 来源键值须为普通字符串,不接纳可变子类。

Parameters:
birth_date: date
birth_time: time | None
timezone: IanaTimezone | FixedOffset | None
location: Location | None
precision: TimePrecision | None
source: Mapping[str, str]
calendar: Literal['gregorian']
class astrology.birth.ResolvedBirth(record, utc, utc_offset, timezone_key, fold, tzdata_version, iana_version)

A preserved record and separate UTC, offset, choice, and data provenance.

UTC requires tzinfo=datetime.UTC and fold=0, at or after 1972-01-01T00:00:00Z. IANA results carry both data versions; fixed offsets carry neither. Construction checks shape and preservation of the recorded clock as UTC plus offset, without loading timezone data to authenticate supplied offsets, folds or versions. resolve_birth_time validates the actual candidate and reads its data versions.

保留原始记录,另存 UTC、偏移、消歧选择和数据来源。UTC 须使用 tzinfo=datetime.UTC、fold=0, 且不早于 1972-01-01T00:00:00Z。IANA 结果记录两种数据版本,固定偏移不记录版本。 构造时检查形状,并确认 UTC 加偏移仍为原始钟点,不加载时区数据核实所提供偏移、fold 或版本; resolve_birth_time 负责校验实际候选并读取数据版本。

Parameters:
record: BirthRecord
utc: datetime
utc_offset: timedelta
timezone_key: str | None
fold: Literal[0, 1] | None
tzdata_version: str | None
iana_version: str | None
property timezone_source: Literal['fixed_offset', 'tzdata']

Identify the resolution data source. 标识时刻解析的数据来源。

property timezone_identity: str

Return the IANA key or explicit UTC-offset name. 返回 IANA 标识或显式 UTC 偏移名称。

astrology.birth.resolve_birth_time(record, *, fold=None)

Resolve a known clock/timezone without requiring a location or changing the record.

IANA folds require 0 (earlier) or 1 (later); gaps and irrelevant choices fail. Read pinned tzdata only here. UTC before 1972 or outside datetime’s range fails. Unknown keys/malformed timezone data raise ValueError. Missing packages, invalid version metadata and remaining resource I/O failures are environment errors.

解析已知钟点和时区,不要求地点,也不改变记录。IANA 重叠时刻须选 0(较早)或 1(较晚); 空缺时刻和无关选择均报错。仅在此处读取钉版 tzdata;早于 1972 或超出 datetime 范围的 UTC 报错。 未知标识或格式错误的时区数据抛出 ValueError;包缺失、版本元数据无效及其余资源 I/O 故障仍属环境错误。

Parameters:
Return type:

ResolvedBirth

astrology.birth.prepare_natal_input(record, *, fold=None)

Require known clock, timezone and location, then resolve; this does not calculate a chart.

要求已知钟点、时区和地点后解析;此函数不计算命盘。

Parameters:
Return type:

ResolvedBirth

Requested configuration

Object identities live in astrology.objects; existing imports of Body, LunarNode and NodeDefinition from astrology.config remain aliases to the same enum classes. Axis is also available from astrology.

Object identities and the families admitted by their consumers.

对象身份及各使用方接纳的对象类别。

class astrology.objects.Body(*values)

Physical celestial bodies, distinct from mathematical nodes. 物理天体,与数学交点区分。

SUN = 'sun'
MOON = 'moon'
MERCURY = 'mercury'
VENUS = 'venus'
MARS = 'mars'
JUPITER = 'jupiter'
SATURN = 'saturn'
URANUS = 'uranus'
NEPTUNE = 'neptune'
PLUTO = 'pluto'
class astrology.objects.NodeDefinition(*values)

Named lunar-node definitions, not accuracy settings. 具名月交点定义,不是精度档位。

MEAN = 'mean'
MEEUS_FIVE_TERM_TRUE = 'meeus_five_term_true'
class astrology.objects.LunarNode(*values)

Mathematical nodes whose identity includes their definition and direction.

数学月交点,其标识同时包含定义与升降方向。

MEAN_ASCENDING = 'mean_ascending_node'
MEAN_DESCENDING = 'mean_descending_node'
MEEUS_FIVE_TERM_TRUE_ASCENDING = 'meeus_five_term_true_ascending_node'
MEEUS_FIVE_TERM_TRUE_DESCENDING = 'meeus_five_term_true_descending_node'
property definition: NodeDefinition

Return the identity’s named definition. 返回该标识对应的具名定义。

class astrology.objects.Axis(*values)

Stored chart axes, distinct from bodies, nodes and house cusps.

Chart composition appends selected axes after bodies/nodes, in ASC/MC/DSC/IC iteration order.

命盘保存的四轴身份,与天体、交点及宫头区分。 命盘组合按枚举迭代顺序,在天体和交点之后追加所选四轴:上升、中天、下降、天底。

ASCENDANT = 'ascendant'
MIDHEAVEN = 'midheaven'
DESCENDANT = 'descendant'
IMUM_COELI = 'imum_coeli'
astrology.objects.AstronomicalObject: TypeAlias = astrology.objects.Body | astrology.objects.LunarNode

Native-output identities, also used by placements and statistics. 天文输出、落点及统计所用的身份。

astrology.objects.ChartObject: TypeAlias = astrology.objects.Body | astrology.objects.LunarNode | astrology.objects.Axis

Identities for aspects and house overlays, including selected axes. 相位及双盘落宫所用的身份,含所选四轴。

Immutable requested chart choices.

不可变的排盘请求配置。

class astrology.config.HouseSystem(*values)

The requested house system: Whole Sign, Equal or Placidus.

请求的宫制:Whole Sign、Equal 或 Placidus。

WHOLE_SIGN = 'whole_sign'
EQUAL = 'equal'
PLACIDUS = 'placidus'
class astrology.config.MajorAspect(*values)

The five supported aspects; astrology.aspects defines their angles and evaluation.

支持的五种相位;角度定义和判断函数在 astrology.aspects 里。

CONJUNCTION = 'conjunction'
SEXTILE = 'sextile'
SQUARE = 'square'
TRINE = 'trine'
OPPOSITION = 'opposition'
class astrology.config.OrbCombination(*values)

Combine two objects’ orbs into one limit, without prescribing a tradition’s rule.

Each object has an orb for the aspect (its own override or the rule’s orb). A pair is within the limit when its deviation from the exact angle satisfies the rule: either object’s orb contains it (the larger orb), both objects’ orbs contain it (the smaller orb), or the mean of the two orbs contains it. A limit is inclusive.

将两个对象的容许度合成一个上限,不指定哪个规则属于哪个传统。每个对象使用单独设置的容许度, 未单独设置时使用相位规则的容许度。三种合成方式分别取较大值、较小值或平均值; 偏差的绝对值不超过该上限就算符合规则,等于上限也算。

EITHER_WITHIN_OWN_ORB = 'either_within_own_orb'
BOTH_WITHIN_OWN_ORB = 'both_within_own_orb'
MEAN_OF_ORBS = 'mean_of_orbs'
class astrology.config.ObjectOrb(identity, orb_degrees)

One object’s own orb for one aspect rule, in degrees; finite and nonnegative.

为某个对象在一条相位规则中单独设置的容许度,单位为度,必须有限且非负。

Parameters:
identity: Body | LunarNode | Axis
orb_degrees: float
class astrology.config.AspectRule(aspect, orb_degrees, object_orbs=())

An explicit caller-supplied orb for one aspect, with optional per-object orbs.

orb_degrees is finite, nonnegative and in degrees; it applies to every object without an entry in object_orbs. The entries are copied into a tuple and name each object once. There is no default orb, and this type does not evaluate.

由调用方给出一种相位的容许度,也可以为对象单独设置。orb_degrees 必须有限、非负, 单位为度。未在 object_orbs 中单独设置的对象使用这个值。条目复制为元组, 每个对象只能出现一次。没有默认容许度;这个类型只保存规则,不计算相位。

Parameters:
aspect: MajorAspect
orb_degrees: float
object_orbs: Sequence[ObjectOrb]
class astrology.config.ChartConfig(house_system, objects, aspects, zodiac='tropical', center='geocentric', aspect_objects=None, orb_combination=None)

Requested choices only, preserving order in isolated immutable tuples.

Select a house system, nonempty unique objects, and explicit unique aspect rules. An empty aspect sequence is allowed. Aspects are judged among aspect_objects, which selects requested bodies/nodes and may explicitly add stored axes. Omitted, it means all requested bodies/nodes and no axes. Axes are not native outputs. orb_combination is required exactly when some rule has per-object orbs, and a per-object orb may name only a participating object. Only tropical/geocentric is admitted. The caller must supply the house system and every orb.

只保存排盘请求。对象和相位规则按原顺序复制为不可变元组,不受调用方后续修改列表的影响。 必须指定宫制和至少一个对象,对象不能重复;相位规则也不能重复,但可以为空。 aspect_objects 从请求的天体或交点中选择参与者,也可显式加入已存四轴;省略时所有请求的 天体或交点都参与,不加入四轴。四轴不是天文输出对象。 只要有规则为对象单独设置容许度,就必须给出 orb_combination,否则不能给。 单独设置容许度的对象必须参与相位。仅支持热带黄道和地心;调用方必须指定宫制及每条容许度。

Parameters:
house_system: HouseSystem
objects: Sequence[Body | LunarNode]
aspects: Sequence[AspectRule]
zodiac: Literal['tropical']
center: Literal['geocentric']
aspect_objects: Sequence[Body | LunarNode | Axis] | None
orb_combination: OrbCombination | None
aspect_participants()

Return requested bodies/nodes in order, then selected axes in ASC/MC/DSC/IC order.

No rules means no participants. 没有规则时返回空元组;天体和交点按请求顺序排列, 所选四轴按上升、中天、下降、天底顺序追加。

Return type:

tuple[Body | LunarNode | Axis, …]

Natal and moment chart composition

Immutable natal and moment results and modern tropical chart composition.

不可变本命盘与时刻盘结果,以及现代热带命盘的组合。

exception astrology.chart.ChartDomainError(message, *, house_system, operation=None, recorded=None, upstream_message=None)

The chart request was rejected or its calculation failed.

house_system identifies the requested geometry. Pre-call rejections leave upstream_message as None; upstream failures retain the exception text, even if empty. operation and recorded retain diagnostics supplied by the upstream exception; both are None for a domain rejection reported as ValueError.

命盘请求被拒绝,或计算失败。house_system 标明请求的宫制。调用前的拒绝将 upstream_message 留为 None;上游失败保留异常文本,即使文本为空。operation 与 recorded 保留上游异常提供的诊断;以 ValueError 报告的域拒绝将这两个字段留为 None。

Parameters:
Return type:

None

class astrology.chart.ChartTimes(jd_ut1, jde_tt)

UT1-based Julian Day and TT-based Julian Ephemeris Day of the calculated instant.

所算时刻的 UT1 儒略日与 TT 儒略历书日。

Parameters:
jd_ut1: float
jde_tt: float
class astrology.chart.EclipticPosition(identity, longitude_deg, latitude_deg, distance_au, longitude_rate_deg_per_tt_day)

Apparent geocentric state on the true ecliptic and equinox of date.

Distances are AU and absent (None) for lunar nodes, whose latitude is zero by definition. The longitude rate is degrees per TT day; negative means decreasing at that instant. Positions do not depend on the birth location.

以该时刻的真黄道和真春分点为基准的地心视位置与速率。距离以 AU 计;月交点按定义没有 距离(为 None),黄纬为零。黄经速率以每 TT 日的度数计,负值表示此刻黄经在减小。 位置与出生地点无关。

Parameters:
identity: Body | LunarNode
longitude_deg: float
latitude_deg: float
distance_au: float | None
longitude_rate_deg_per_tt_day: float
class astrology.chart.ChartHouses(system, ascendant_deg, midheaven_deg, descendant_deg, imum_coeli_deg, cusps_deg)

Four axes and twelve cyclically ordered cusps, all in [0, 360) degrees.

The cusps are copied into a tuple, so a list given by the caller is not aliased.

四轴与十二个宫头,宫头按循环顺序排列,度数都在 [0, 360) 内。宫头会复制成元组, 不会引用调用方传入的列表。

Parameters:
system: HouseSystem
ascendant_deg: float
midheaven_deg: float
descendant_deg: float
imum_coeli_deg: float
cusps_deg: tuple[float, ...]
class astrology.chart.Placement(identity, sign, sign_degree_deg, house)

Derived sign and house membership of one chart object; unrounded degrees retained.

单个盘上对象推出的星座和落宫;度数保留未舍入的值。

Parameters:
identity: Body | LunarNode
sign: Sign
sign_degree_deg: float
house: int
class astrology.chart.EffectiveConfiguration(house_system, delta_t_model, evaluation, aspect_objects, orb_combination)

The resolved choices actually used in the calculation.

delta_t_model is the upstream ΔT model member value the adapter fixed for this calculation, not a caller request. evaluation names the joint evaluation that produced the positions: selecting a subset of the requested objects filters that output and does not narrow the evaluated domain. aspect_objects holds the objects aspects were judged among, in the order of the requested bodies/nodes, then selected axes in ASC/MC/DSC/IC order. It is empty when no aspect rules were requested. orb_combination repeats the requested rule, or None when no rule has per-object orbs.

计算实际采用的已确定选择。delta_t_model 是适配层为 这次计算固定下来的上游 ΔT 模型取值,不是调用方的请求;evaluation 说明位置来自哪种 联合求值:只选一部分对象时,只是筛选输出,不缩小求值域。aspect_objects 是判断相位时 所用的对象,天体和交点按请求顺序排列,所选四轴按上升、中天、下降、天底顺序追加; 没有请求相位规则时为空。orb_combination 保存请求中的 合成规则;没有规则带按对象的容许度时为 None。

Parameters:
house_system: HouseSystem
delta_t_model: str
evaluation: Literal['fixed_fourteen_object_joint_snapshot']
aspect_objects: tuple[Body | LunarNode | Axis, ...]
orb_combination: OrbCombination | None
class astrology.chart.ChartProvenance(celestial_version, position_frame, ut1_derivation, astrology_version)

Package versions and coordinate conventions retained with the result.

随结果一起保存的包版本和坐标约定。

Parameters:
  • celestial_version (str)

  • position_frame (Literal['apparent_geocentric_true_ecliptic_of_date'])

  • ut1_derivation (Literal['delta_t_model_from_civil_utc'])

  • astrology_version (str)

celestial_version: str
position_frame: Literal['apparent_geocentric_true_ecliptic_of_date']
ut1_derivation: Literal['delta_t_model_from_civil_utc']
astrology_version: str
class astrology.chart.NatalChart(resolved, requested, effective, provenance, times, positions, houses, placements, aspects)

A complete immutable natal result; objects follow the requested order.

Aspects are those requested in requested.aspects, among the objects named in effective.aspect_objects, in the order documented by find_aspects. The positions, placements and aspects are copied into tuples, so lists given by the caller are not aliased.

Construction checks field types, ranges and pure derived-value consistency. Equality includes the resolved input; hashing excludes it because its source mapping is unhashable.

完整且不可变的本命盘结果;对象按请求的顺序排列。按 requested.aspects 中的规则, 在 effective.aspect_objects 所列对象之间计算相位,结果顺序见 find_aspects。 位置、落宫和相位会复制成元组,不会引用调用方传入的列表。 构造时检查字段类型、范围及纯规则推导结果的一致性。 相等判断包括已解析输入;哈希不包括它,因为其中的来源映射不可哈希。

Parameters:
resolved: ResolvedBirth
requested: ChartConfig
effective: EffectiveConfiguration
provenance: ChartProvenance
times: ChartTimes
positions: tuple[EclipticPosition, ...]
houses: ChartHouses
placements: tuple[Placement, ...]
aspects: tuple[AspectHit, ...]
class astrology.chart.MomentInput(utc, location, source_jde_tt=None)

A modern UTC instant and explicit location, optionally retaining a source event’s TT.

The aware built-in datetime is normalized to UTC and isolated from caller-owned tzinfo. source_jde_tt is the original event time, not a replacement for the calculation times. Construction validates supplied values without astronomy I/O.

现代 UTC 时刻及显式地点,可另存来源事件的 TT。有时区的内建 datetime 会归一为 UTC, 不引用调用方的 tzinfo。source_jde_tt 是原始事件时刻,不替代计算时标。 构造时只校验给定值,不调用天文计算。

Parameters:
utc: datetime
location: Location
source_jde_tt: float | None
class astrology.chart.MomentChart(moment, requested, effective, provenance, times, positions, houses, placements, aspects)

An immutable chart at a supplied instant and location, without birth metadata.

Common result checks and intra-chart aspects follow NatalChart. Sequences are copied into tuples. The moment input participates in equality and hashing; constructors check pure consistency without recalculating astronomical values.

给定时刻与地点的不可变命盘,不含出生资料。共用结果校验及盘内相位规则与 NatalChart 相同,序列会复制为元组。时刻输入参与相等与哈希判断;构造器检查纯规则一致性, 不重新计算天文值。

Parameters:
moment: MomentInput
requested: ChartConfig
effective: EffectiveConfiguration
provenance: ChartProvenance
times: ChartTimes
positions: tuple[EclipticPosition, ...]
houses: ChartHouses
placements: tuple[Placement, ...]
aspects: tuple[AspectHit, ...]
astrology.chart.Chart: TypeAlias = astrology.chart.NatalChart | astrology.chart.MomentChart

A natal or supplied-instant chart. 本命盘或给定时刻的命盘。

astrology.chart.natal_chart(resolved, config)

Calculate a tropical, geocentric natal chart for a resolved birth instant.

The record must carry a location; unknown time was already rejected by preparation. The astronomy adapter is imported here, not at package import, so importing astrology or querying knowledge never initializes native astronomy. A requested geometry outside the joint upstream domain raises ChartDomainError. Requested aspect rules are judged among the objects of config.aspect_objects, or among all requested bodies/nodes when it is unset. Explicitly selected axes use the stored axis fields, not cusps, and have no supplied rate. Their non-exact hits are INDETERMINATE; zero deviation still gives EXACT. No axis is added to raw positions or placements. The distribution must be installed: missing package metadata raises importlib.metadata.PackageNotFoundError rather than inventing a version.

为已解析的出生时刻计算热带地心本命盘。出生记录必须带地点;时间未知的记录在准备阶段 就已被拒绝。天文适配层在这个函数里才导入,不在导入包时导入,所以导入 astrology 或查询 知识都不会初始化原生天文库。请求的几何超出上游的联合求值域时,抛出 ChartDomainError。根据这次计算的位置和黄经速率, 在 config.aspect_objects 指定的对象之间计算相位;未设置时,所有请求的天体和交点都参与。 显式所选四轴直接使用已存轴字段,不使用宫头,也不提供速率;其非精确命中为 INDETERMINATE, 偏差恰为零时仍为 EXACT。不把四轴加入原始位置或落点。 分发包必须已安装;元数据缺失时抛出 importlib.metadata.PackageNotFoundError,不编造版本号。

Parameters:
Return type:

NatalChart

astrology.chart.moment_chart(instant, location, config)

Calculate a moment chart from an aware instant or a retained TransitHit.

Location and configuration are explicit. A datetime is normalized to modern UTC; a hit’s JDE(TT) is converted upstream at this calculation boundary. Its original time is retained in moment.source_jde_tt, separately from the normalized UTC and derived ChartTimes. Conversion follows the upstream fixed leap table and Python’s microsecond datetime representation; it need not round-trip exactly at leap steps or the 1972 boundary. The converted UTC must itself be at or after 1972-01-01. House geometry and the joint snapshot domain follow natal_chart. Conversion/domain failures raise ChartDomainError; pre-1972 UTC raises HistoricalTimeError. See entry.moment_charts and entry.transit_aspects for the project conventions.

从有时区的时刻或保留的 TransitHit 计算时刻盘。地点与配置须显式给出。datetime 归一为 现代 UTC;命中的 JDE(TT) 在此计算入口由上游转换。原事件时刻保存在 moment.source_jde_tt, 与归一后的 UTC 及导出的 ChartTimes 分开。转换使用上游固定闰秒表和 Python 微秒级 datetime, 在闰秒阶跃或 1972 边界不保证精确往返;转换后的 UTC 本身也须不早于 1972-01-01。 宫几何与联合快照有效域沿用 natal_chart。转换或求值域失败抛出 ChartDomainError, 早于 1972 的 UTC 抛出 HistoricalTimeError。项目约定见 entry.moment_charts 和 entry.transit_aspects。

Parameters:
Return type:

MomentChart

Chart text

See the complete natal result and text example for natal output, or render comparison text for cross-chart aspects and house overlays.

Render chart results using caller-supplied bilingual vocabulary.

用调用方提供的双语词汇显示命盘结果。

astrology.text.format_chart(chart, catalog, *, language='en')

Return a text table of chart positions, houses, aspects, configuration and provenance.

The caller supplies the loaded Catalog. Names must exist with current translations for en or zh-CN, otherwise raise ValueError (KeyError for a missing sign ID). Angles use truncate_display’s whole-arcsecond rule, without changing classifications, house or motion. Even a deviation displayed as zero retains its original motion label. Invalid chart/catalog types raise TypeError. Nonprinting characters, backslashes and table delimiters in supplied names and provenance are escaped for display; the chart values are unchanged.

Natal output retains recorded birth/timezone provenance. A moment chart shows supplied UTC/location and optional source-event TT without birth/timezone metadata.

返回命盘位置、宫位、相位、配置及来源的文本表格。调用方须提供已加载的 Catalog; en 或 zh-CN 的名称及译文必须齐备且为当前版本, 否则抛出 ValueError(缺少星座标识时为 KeyError)。角度沿用 truncate_display 的整角秒截断规则, 不改分类、宫位或运动状态;偏差显示为零时也保留原运动标签。 chart/catalog 类型错误时抛出 TypeError。 传入名称及来源中的非打印字符、反斜线和表格分隔符会转义显示,不改命盘中的值。 本命盘保留出生钟点及时区来源;时刻盘显示给定 UTC、地点及可选的来源事件 TT, 不显示出生或时区资料。

Parameters:
Return type:

str

astrology.text.format_cross_aspects(result, catalog, *, language='en')

Format all static cross-chart aspect hits and their rules as a table.

The table includes chart provenance and selected objects, without motion labels. Branches, deviations and effective orb limits are angles in degrees, displayed with the whole-arcsecond truncation rule. A deviation whose absolute value equals the orb limit counts as a hit. Truncation changes only the display, never which records appear. Rules show base orbs, object overrides and the chosen combination.

Names come from the supplied Catalog; text is escaped as in format_house_overlays. Invalid result or catalog types raise TypeError. Invalid language, or missing or stale displayed names, raises ValueError.

将全部静态双盘相位及其规则排成表格。表中包含命盘来源信息和所选对象,不添加运动标签。 分支、偏差和实际容许度上限以度计,按整角秒截断显示;偏差的绝对值等于上限时也算命中。 截断只影响显示,不改变输出哪些记录。规则列出基础容许度、对象单独设置及所选合成方式。

名称取自传入的 Catalog,文字按 format_house_overlays 的规则转义。 结果或目录类型错误时抛出 TypeError;语言非法,或所需名称缺失、过期时,抛出 ValueError。

Parameters:
Return type:

str

astrology.text.format_house_overlays(result, catalog, *, language='en')

Format house overlays as a table that identifies both charts for each placement.

The table includes both charts’ provenance, selected objects and every placement, distinguishing the chart the object comes from and the chart whose houses are used. Names come from the supplied Catalog. Invalid result or catalog types raise TypeError. Invalid language, or missing or stale displayed names, raises ValueError. Text is escaped as in format_chart.

将落宫结果排成表格,每条记录都标明对象来自哪张盘、使用哪张盘的宫位。 表中包含两张盘的来源信息、所选对象和全部落宫,名称取自传入的 Catalog。 结果或目录类型错误时抛出 TypeError; 语言非法,或所需名称缺失、过期时,抛出 ValueError。文字按 format_chart 的规则转义。

Parameters:
Return type:

str

astrology.text.format_house_rulers(result, catalog, *, language='en')

Show all twelve rulers, available placements and every assessed status.

Distinguish uncalculated placements from no match among the four statuses. Type, language and name errors follow format_sign_distribution.

显示十二宫主星、可用落点及全部命中状态,区分落点未计算与四项均未命中。 类型、语言及名称错误沿用 format_sign_distribution。

Parameters:
Return type:

str

astrology.text.format_lunar_phase(result, catalog, *, language='en')

Render the type and untruncated numerical angle using the supplied bilingual catalog.

repr-style degree output preserves the stored float; direction and type never come from display rounding. Type, language and name errors follow format_sign_distribution; supplied names are escaped as in format_chart.

用给定双语目录显示类型及未经截断的数值角度。度数按 repr 形式保留存储的浮点值;方向和类型 不由显示舍入决定。类型、语言和名称错误沿用 format_sign_distribution, 名称按 format_chart 的规则转义。

Parameters:
Return type:

str

astrology.text.format_sign_distribution(result, catalog, *, language='en')

Render counted identities, denominator and all category counts using the supplied catalog.

Proportions display as percentages with two decimal places; exact count/total remains visible. Invalid result/catalog types raise TypeError, invalid language or missing/stale names ValueError (missing IDs raise KeyError). Supplied names are escaped as in format_chart.

用给定目录显示计数对象、分母和各类计数。比例显示为两位小数的百分比,同时保留精确的 计数 / 总数。结果或目录类型错误抛出 TypeError,语言非法或 名称缺失或过期抛出 ValueError(标识缺失抛出 KeyError)。名称按 format_chart 的规则转义。

Parameters:
Return type:

str

astrology.text.format_transit_aspects(result, catalog, *, language='en')

Format fixed-instant aspects with moving/natal roles, rules and local motion.

Both source charts and selections are identified. Branch, deviation and orb limit use the same whole-arcsecond truncation as format_chart; even displayed-zero deviations retain their original motion. Names/escaping and type/language errors follow format_cross_aspects. No chart calculation or catalog loading is performed.

显示固定时刻相位,区分移动与本命角色,并列出规则及局部运动。表明双侧源盘及选择; 分支、偏差和容许度上限按 format_chart 的整角秒规则截断,即使偏差显示为零,仍保留 原运动标签。名称、转义及类型和语言错误沿用 format_cross_aspects。 不进行排盘或目录加载。

Parameters:
Return type:

str

Zodiac classification

Modality.FIXED and AshmandSignGroup.FIXED both have the string value "fixed" and compare and hash equal as StrEnum members. To keep both in one Python mapping, use (type(member), member.value) keys or their distinct qualified catalog IDs. The classifications and their historical meanings remain distinct.

Tropical signs, elements, modalities and Ashmand’s groups.

热带黄道星座、元素、模式与 Ashmand 分组。

class astrology.zodiac.Sign(*values)

One of the twelve tropical signs, identified by its 30-degree longitude sector.

热带黄道十二星座之一,由各自 30° 的黄经区间界定。

ARIES = 'aries'
TAURUS = 'taurus'
GEMINI = 'gemini'
CANCER = 'cancer'
LEO = 'leo'
VIRGO = 'virgo'
LIBRA = 'libra'
SCORPIO = 'scorpio'
SAGITTARIUS = 'sagittarius'
CAPRICORN = 'capricorn'
AQUARIUS = 'aquarius'
PISCES = 'pisces'
class astrology.zodiac.AshmandSignGroup(*values)

One of four sign groups in Ashmand’s 1822 edition, Book I, chapter XIV.

TROPICAL means the two solstitial signs, not the whole tropical zodiac.

Ashmand 1822 年版第一卷第 XIV 章的四种星座分组之一。TROPICAL 指两个至点星座, 不是整个热带黄道。

TROPICAL = 'tropical'
EQUINOCTIAL = 'equinoctial'
FIXED = 'fixed'
BICORPOREAL = 'bicorporeal'
class astrology.zodiac.Element(*values)

The four elements used to classify signs. 用于星座分类的四元素。

FIRE = 'fire'
EARTH = 'earth'
AIR = 'air'
WATER = 'water'
class astrology.zodiac.Modality(*values)

Modern three-way sign classification, distinct from Ashmand’s four groups.

现代星座三模式分类,与 Ashmand 的四分组身份不同。

CARDINAL = 'cardinal'
FIXED = 'fixed'
MUTABLE = 'mutable'
astrology.zodiac.element_of(sign)

Return the sign’s element under rule.zodiac.elements; accept only Sign members.

Source: Astrodienst, The four Elements and the Signs (see the catalog). Strings and other enums raise TypeError.

按 rule.zodiac.elements 返回星座元素,只接受 Sign 成员。来源为 Astrodienst 的 The four Elements and the Signs,书目见目录。字符串和其他枚举抛出 TypeError。

Parameters:

sign (Sign)

Return type:

Element

astrology.zodiac.modality_of(sign)

Return the sign’s modality under rule.zodiac.modalities; accept only Sign members.

Source: Astrodienst, The four Elements and the Signs (see the catalog). Strings and other enums raise TypeError. This does not return an Ashmand group.

按 rule.zodiac.modalities 返回星座模式,只接受 Sign 成员。来源为 Astrodienst 的 The four Elements and the Signs,书目见目录。字符串和其他枚举抛出 TypeError;结果不是 Ashmand 分组。

Parameters:

sign (Sign)

Return type:

Modality

astrology.zodiac.ashmand_sign_group(sign)

Return a sign’s group under rule.ptolemy_ashmand.sign_groups.

Accept a Sign member; raw strings and unrelated enums raise TypeError. Source: Ashmand 1822, Book I, chapter XIV, printed pp. 34-35.

按 rule.ptolemy_ashmand.sign_groups 返回星座分组。只接受 Sign 成员; 字符串或其他枚举抛出 TypeError。来源为 Ashmand 1822 年版第一卷第 XIV 章、印刷页 34-35。

Parameters:

sign (Sign)

Return type:

AshmandSignGroup

astrology.zodiac.sign_of(longitude_deg)

Classify a tropical longitude by half-open [0, 30) degree sectors.

Boundaries belong to the higher sign: exactly 30° is Taurus, exactly 0° is Aries.

按半开的 [0, 30) 度区间给热带黄经分星座。区间边界归后一个星座:恰好 30° 是金牛,恰好 0° 是白羊。

Parameters:

longitude_deg (float)

Return type:

Sign

astrology.zodiac.sign_degree(longitude_deg)

Return the unrounded degree within its sign, in [0, 30).

返回黄经在所属星座内的未舍入度数,范围 [0, 30)。

Parameters:

longitude_deg (float)

Return type:

float

astrology.zodiac.truncate_display(longitude_deg)

Truncate toward zero at arcsecond resolution; display never crosses a boundary.

Display rounding must not change a classification. Truncation is the named rule: 29.9999999° displays as 29°59’59”, never as 30°00’00” of the next sign.

The arcsecond count is floored in exact integer arithmetic on the binary fraction, so a value that sits just below a sector boundary cannot be rounded up across it by the multiplication.

向零截断到角秒;显示出来的值不会越过星座边界。显示用的舍入不能改变分类,所以 采用截断,并把它定为具名规则:29.9999999° 显示为 29°59’59”,不会显示成下一个 星座的 30°00’00”。角秒数按二进制分数用精确的整数运算向下取整,因此紧贴区间边界 下方的值,不会因为乘法而被进位到边界的另一侧。

Parameters:

longitude_deg (float)

Return type:

float

House placement

House placement over supplied cusp geometry, without calculating positions.

按给定的宫头判断落在哪一宫,不计算盘上对象的位置。

astrology.houses.house_of(longitude_deg, cusps_deg)

Return the house 1-12 containing a tropical longitude.

Intervals are half-open [cusp, next cusp): a longitude exactly on a cusp belongs to the house that starts there. Membership wraps across 0/360. This uses the supplied cusp list only; whether an axis such as the Ascendant coincides with the first cusp is a property of the house system, not of this function.

The intervals are compared in the given angles. Rotating them by a common origin would round a longitude that sits just below a cusp onto the cusp itself and hand it to the next house.

返回该热带黄经所在的宫(1 至 12)。每个区间都是半开的 [宫头, 下一宫头):恰好落在 宫头上的黄经,归入从这个宫头开始的那一宫;区间可以跨过 0/360。本函数只看给定的宫头表, 上升点等轴是否与第一宫头重合,由宫制决定,与本函数无关。

区间直接按给定的角度比较。如果先减去同一个起点,紧贴宫头下方的黄经会被舍入到宫头上, 错判成下一宫。

Parameters:
Return type:

int

Aspects

Find major aspects from longitudes and rates at a given instant.

Each result records the angle measured from the first object to the second, the exact aspect angle used for comparison (the branch), and the signed difference. The motion status tells whether the magnitude of that difference is shrinking or growing. It does not predict later changes in motion or whether the aspect will become exact.

根据同一时刻的黄经和速率判断主要相位。每条结果记录从第一个对象到第二个对象的角度、 用来对照的精确相位角(分支),以及两者的带符号偏差。运动状态说明偏差的绝对值此刻在缩小还是增大, 不预测之后的运动变化,也不预测相位之后会不会变得精确。

class astrology.aspects.AspectMotion(*values)

Whether an aspect is approaching or moving away from its exact angle at this instant.

The relative longitude rate is the second object’s rate minus the first’s. Away from a deviation of 180 degrees, the deviation shrinks in magnitude when the relative rate and the deviation have opposite signs (applying) and grows when they have the same sign (separating). Statuses compare exact floats, with no tolerance. STATIONARY means the relative rate is exactly zero, not that either planet has stopped changing longitude (a station). INDETERMINATE means a rate is missing, or the deviation is 180 degrees with nonzero relative motion: its magnitude has no two-sided derivative there.

相位此刻在接近还是远离精确角度。相对黄经速率是第二个对象的速率减去第一个的速率。 偏差不为 180 度时,相对速率与偏差异号,偏差的绝对值在缩小(入相);同号时在增大(离相)。 直接比较浮点数,不使用容差。STATIONARY 指相对速率恰为零, 不表示某颗行星的黄经速率为零(占星术语中的“留”)。 INDETERMINATE 指缺少速率,或偏差恰为 180 度且存在相对运动,此时偏差的绝对值没有双侧导数。

APPLYING = 'applying'
SEPARATING = 'separating'
EXACT = 'exact'
STATIONARY = 'stationary'
INDETERMINATE = 'indeterminate'
class astrology.aspects.AspectObject(identity, longitude_deg, longitude_rate_deg_per_day)

One object’s longitude in degrees and its rate in degrees per day, if it has one.

Any finite longitude is accepted, including negative values, values above 360 and the largest finite float. The supplied value is stored as a float without wrapping; aspect calculations reduce each longitude around the circle before subtracting, avoiding overflow for extreme finite inputs.

The rate may be None where no meaningful motion exists; it is never borrowed from another object. All rates must use the same day unit, such as the TT day.

一个对象的黄经(度)及其速率(度/日,可为 None)。 黄经接受任何有限值,包括负值、超过 360 度的值及最大的有限浮点值。 传入值转为浮点数保存,不取模;相位计算先约去各黄经中的整圈,再相减,避免极大有限输入溢出。 若无法给出有意义的速率,就用 None, 不借用其他对象的速率。所有速率必须采用相同的日作为时间单位,例如 TT 日。

Parameters:
identity: Body | LunarNode | Axis
longitude_deg: float
longitude_rate_deg_per_day: float | None
class astrology.aspects.AspectHit(first, second, aspect, branch_deg, deviation_deg, orb_limit_deg, motion)

One aspect between two objects; the order of the pair and the branch are kept.

branch_deg is the exact oriented angle from the first object to the second that the separation was measured against: minus or plus the aspect angle for a sextile, square or trine, and the single angle 0 or 180 for a conjunction or opposition. deviation_deg is the separation minus the branch, in (-180, 180]. Swapping the pair flips the deviation, except that 180 is its own mirror, and flips the branch where there are two; the status does not change.

两个对象之间符合规则的一条相位结果,保留对象顺序和分支。branch_deg 是用来对照间距的 精确角度,方向从第一个对象指向第二个:六分、四分、三分相取相位角的负值或正值,合相和对分相只有 0 或 180 这一个角度。deviation_deg 是间距减去分支,取值在 (-180, 180]。交换配对时, 偏差反号,但 180 仍记为 180;有两个分支时,分支也反号。运动状态不变。

Parameters:
first: Body | LunarNode | Axis
second: Body | LunarNode | Axis
aspect: MajorAspect
branch_deg: float
deviation_deg: float
orb_limit_deg: float
motion: AspectMotion
astrology.aspects.aspect_angle(aspect)

Return the exact angle of an aspect in degrees: 0, 60, 90, 120 or 180.

返回相位的精确角度(度):0、60、90、120 或 180。

Parameters:

aspect (MajorAspect)

Return type:

float

astrology.aspects.find_aspects(objects, rules, combination=None)

Return every aspect that holds between pairs of objects, in a fixed order.

Pairs follow the order of objects, then the aspect angle, then the branch (minus before plus), so the order is total. Every matching aspect and branch is returned: broad orbs may give one pair several hits, and none is dropped in favor of a nearer one. A hit holds when the deviation’s magnitude is at most the limit, with the limit itself included. The limit is the rule’s orb, or the combination of the two objects’ orbs when the rule has per-object orbs, which then requires combination. Two lunar nodes never form an aspect: the four identities are one pair of nodes under two definitions and two directions. Axes may pair with any other distinct identity, including an opposite axis; their identities and all matching branches remain separate.

按固定顺序返回对象两两之间符合规则的所有相位。配对按 objects 的顺序排列,再按相位角排序, 同一相位的负分支排在正分支之前。容许度较宽时,同一对对象可能符合多个相位或分支,都会返回, 不会只保留偏差最小的一个。偏差的绝对值不超过容许度上限就算符合,等于上限也算。 上限通常是规则的容许度;规则给对象单独设置容许度时,上限由两个对象的容许度合成, 此时必须给出 combination。两个月交点之间不构成相位:四个标识表示同一对交点的两种定义和两个方向。 四轴可与任一不同身份配对,包括其对轴;各身份及全部命中分支分别保留。

Parameters:
Return type:

tuple[AspectHit, …]

Static cross-chart aspects

See cross-chart aspects and house overlays for usage and the meaning of static aspects.

Static major aspects between two supplied charts.

对两张给定命盘判断静态主要相位。

class astrology.cross_aspects.CrossAspectHit(left_object, right_object, aspect, branch_deg, deviation_deg, orb_limit_deg)

A static hit with distinct left/right roles, even when the object identities match.

Angles are degrees. Branch and signed deviation follow AspectHit geometry; orb_limit_deg is the inclusive limit actually used. There is no motion field: rates at separate birth instants do not define a shared time evolution.

一条静态相位命中,保留左右角色,即使两侧对象标识相同。角度单位为度;分支与带符号偏差 遵循 AspectHit 的几何定义,orb_limit_deg 是实际采用且包含等号的上限。不设运动字段: 两次出生时刻的速率不能定义共同的时间演化。

Parameters:
left_object: Body | LunarNode | Axis
right_object: Body | LunarNode | Axis
aspect: MajorAspect
branch_deg: float
deviation_deg: float
orb_limit_deg: float
class astrology.cross_aspects.CrossChartAspects(chart_left, chart_right, left_objects, right_objects, rules, combination, hits)

Immutable sources, effective selections, explicit rules and all static cross hits.

chart_left and chart_right retain the complete source charts unchanged. Sequences are isolated in tuples; selections follow their source’s position order, then selected axes in ASC/MC/DSC/IC order. Construction recomputes all hits from the two sources, selections and rules and rejects any difference.

不可变的双侧来源、实际参与对象、显式规则与全部静态交叉命中。chart_left 与 chart_right 保留两张完整源盘,不改变它们。 序列复制为元组;天体和交点按各自源盘的位置顺序排列,所选四轴按上升、中天、下降、天底顺序追加。 构造时按两侧来源、选择和规则重算全部命中,拒绝任何差异。

Parameters:
chart_left: NatalChart | MomentChart
chart_right: NatalChart | MomentChart
left_objects: tuple[Body | LunarNode | Axis, ...]
right_objects: tuple[Body | LunarNode | Axis, ...]
rules: tuple[AspectRule, ...]
combination: OrbCombination | None
hits: tuple[CrossAspectHit, ...]
astrology.cross_aspects.cross_chart_aspects(chart_left, chart_right, rules, *, left_objects=None, right_objects=None, combination=None)

Compare each selected left position with every selected right position, without motion.

None selects all bodies/nodes on that side and no axes, independently of the source chart’s aspect selection. Explicit selections may include any axis stored in that side’s chart, even if the axis did not participate in that chart’s own aspects. Read the actual axis fields, never cusps or synthesized opposite axes. An empty selection or rule sequence is valid. Same identities, node-node pairs and the same chart in both roles are allowed. Rules are explicit and never inherited. Object-orb overrides apply by identity on either side and may name only selected objects; a combination is required exactly when overrides exist. Duplicate rules/participants and unavailable objects are rejected.

Selected axes follow bodies/nodes in ASC/MC/DSC/IC order. Axis-axis and opposite-axis pairs are retained, not folded. Every matching branch is returned, ordered by left position, right position, ascending aspect angle, then negative before positive branch. The inclusive limits and signed deviations are in degrees. Both charts must have matching zodiac, center and position frame. Their own-date tropical longitudes are compared without common-epoch conversion or a simultaneous spatial-angle claim. Different dates, locations, house systems, models and version labels are kept, not automatically rejected. Source charts are retained unchanged.

将每个所选左盘位置与每个所选右盘位置比较,不判断运动状态。None 选该侧全部天体和交点,不加入四轴; 显式选择可含该盘任一已存轴,即使未参与盘内相位。直接读取轴字段,不使用宫头或合成对轴。 不继承源盘的相位对象选择;空选择和空规则合法。允许同名对象、跨盘交点配对及同一张盘占两个角色。 规则须显式给出,不继承源盘规则。对象容许度按标识作用于两侧,只能指向所选对象;有覆盖时 必须给合成方式,无覆盖时不能给。拒绝重复规则、重复参与对象及源盘没有的对象。 所选四轴在天体和交点之后按上升、中天、下降、天底顺序排列。保留轴间及对轴配对,不折叠身份。 返回全部命中分支,按左位置、右位置、相位角升序及负分支在前排序。容许度包含等号, 带符号偏差和上限以度计。两盘的黄道、中心和位置坐标约定须一致;比较各自日期的热带黄经, 不转换共同历元,也不声称是同时刻的空间角。保留不同日期、地点、宫制、模型和版本标签, 不因此自动拒绝。源盘保持不变。

Parameters:
Return type:

CrossChartAspects

Fixed-instant transit aspects

See moment charts for fixed-instant comparisons and bilingual output.

Fixed-instant aspects from a moving moment chart to frozen natal degrees.

计算移动时刻盘与固定本命黄经在给定时刻的相位。

class astrology.transit_aspects.TransitAspectHit(moving_object, natal_object, aspect, branch_deg, deviation_deg, orb_limit_deg, motion)

One fixed-instant hit with moving/natal roles and local motion.

Angles and inclusive orb limits are degrees, with the same oriented branch and signed deviation as CrossAspectHit. Identical identities and node-node pairs are allowed. Motion is checked against the retained sources by TransitAspects.

给定时刻的一条命中,区分移动与本命角色,保留局部运动。角度与包含等号的容许度上限 以度计,有向分支及带符号偏差与 CrossAspectHit 相同。允许同名及交点间配对; 运动状态由 TransitAspects 根据保留的来源校验。

Parameters:
moving_object: Body | LunarNode | Axis
natal_object: Body | LunarNode | Axis
aspect: MajorAspect
branch_deg: float
deviation_deg: float
orb_limit_deg: float
motion: AspectMotion
class astrology.transit_aspects.TransitAspects(moving_chart, natal_chart, moving_objects, natal_objects, rules, combination, hits)

Retain a moving MomentChart, fixed NatalChart, explicit rules and every matching hit.

Sequences are copied into tuples; selections follow source order, then axes. Construction checks the complete hit sequence, including local motion, by pure recomputation. Coordinate and zero-rate conventions are in entry.transit_aspects.

保留移动 MomentChart、固定 NatalChart、显式规则及全部命中。序列复制为元组, 选择按源盘顺序排列,四轴随后。构造时以纯规则重算完整命中序列,包括局部运动。 坐标与零速率约定见 entry.transit_aspects。

Parameters:
moving_chart: MomentChart
natal_chart: NatalChart
moving_objects: tuple[Body | LunarNode | Axis, ...]
natal_objects: tuple[Body | LunarNode | Axis, ...]
rules: tuple[AspectRule, ...]
combination: OrbCombination | None
hits: tuple[TransitAspectHit, ...]
astrology.transit_aspects.transit_aspects(moving_chart, natal_chart, rules, *, moving_objects=None, natal_objects=None, combination=None)

Compare a moment’s moving objects with frozen natal degrees at that instant.

Explicit rules, selections, orb combinations and ordering follow cross_chart_aspects; default selections use each source’s bodies/nodes without axes. Empty selections and rules, same identities and node-node pairs are allowed. Raw geometry is identical to that static comparison for the same ordered pairs.

Local motion uses the moment’s rates against zero natal motion, including natal axes. Moving axes have no supplied rate: their non-exact hits are INDETERMINATE, while zero deviation remains EXACT. A local applying label does not promise a later exact event. Stored own-date longitudes are compared without common-epoch conversion. Sources are unchanged; no astronomy or time resolution is performed. Invalid source types raise TypeError; invalid selections/rules or incompatible frames raise ValueError.

在给定时刻比较时刻盘的移动对象与固定本命黄经。显式规则、选择、容许度合成及排序沿用 cross_chart_aspects;默认选择各源盘的天体和交点,不含四轴。允许空选择、空规则、同名 对象与交点间配对;对相同有序配对,原始几何与静态比较完全相同。

局部运动使用时刻盘速率,本命侧含四轴均为零速率。移动四轴没有提供速率,其非精确命中 为 INDETERMINATE,偏差为零仍为 EXACT。局部入相不保证之后会有精确事件。 比较各自日期的已存黄经,不转换共同历元。来源保持不变,不进行天文计算或时刻解析。 来源类型错误抛出 TypeError;选择、规则非法或坐标约定不兼容时抛出 ValueError。

Parameters:
Return type:

TransitAspects

Exact transit hits

See exact transit hits for a UTC-interval search and result fields.

Exact moving-to-fixed-source aspects over a modern UTC interval.

在现代 UTC 区间内搜索移动对象与固定源盘黄经的精确相位。

class astrology.transits.TransitDirection(*values)

Crossing or contact direction supplied by the event search.

事件搜索给出的穿越或相切方向。

INCREASING = 'increasing'
DECREASING = 'decreasing'
TANGENT = 'tangent'
exception astrology.transits.TransitDomainError(message, *, operation, moving_object=None, start_jde_tt=None, end_jde_tt=None, upstream_message=None)

A UTC conversion, TT span or selected event-provider domain was rejected.

Retains the operation, optional moving object and TT endpoints, exact upstream message and chained cause. Native computation failures propagate unchanged.

UTC 转换、TT 区间或所选事件来源的求值域被拒绝。保留操作、可用时的移动对象与 TT 端点、 上游原始错误文本及异常因果链。原生计算失败直接向外抛出,不改成域拒绝。

Parameters:
Return type:

None

class astrology.transits.TransitSource(moving_object, model_kind, model_identity, model_description, domain_start_jde_tt, domain_end_jde_tt, maximum_span_tt_days, capability_description)

One moving object’s effective model and bounded event window.

Bounds and maximum span are in JDE(TT) and TT days. Descriptions are copied from the upstream; these implementation windows are not astronomical accuracy bounds.

一个移动对象实际使用的模型及有界事件求值窗口。端点为 JDE(TT),最长区间以 TT 日计。 说明文字复制自上游;实现求值窗口不是天文精度界。

Parameters:
  • moving_object (Body | LunarNode)

  • model_kind (str)

  • model_identity (int)

  • model_description (str)

  • domain_start_jde_tt (float)

  • domain_end_jde_tt (float)

  • maximum_span_tt_days (float)

  • capability_description (str)

moving_object: Body | LunarNode
model_kind: str
model_identity: int
model_description: str
domain_start_jde_tt: float
domain_end_jde_tt: float
maximum_span_tt_days: float
capability_description: str
class astrology.transits.TransitHit(moving_object, natal_object, aspect, branch_deg, query_longitude_deg, jde_tt, longitude_deg, longitude_rate_deg_per_tt_day, direction)

One queried aspect branch and its unchanged native event values.

Time is JDE(TT); angles are degrees and rate is degrees per TT day. query_longitude_deg is the natal degree plus branch_deg, reduced to [0, 360). longitude_deg is raw and may differ from that level across a wrap. Tangent does not imply a bitwise-zero rate.

一条查询相位分支及未经改写的原生事件值。时刻为 JDE(TT),角度为度,速率为度/TT 日。 query_longitude_deg 是本命度数加 branch_deg 后归入 [0, 360) 的黄经; longitude_deg 保留原值,环绕处可能位于另一侧。 tangent 不意味着速率的位模式恰为零。

Parameters:
moving_object: Body | LunarNode
natal_object: Body | LunarNode | Axis
aspect: MajorAspect
branch_deg: float
query_longitude_deg: float
jde_tt: float
longitude_deg: float
longitude_rate_deg_per_tt_day: float
direction: TransitDirection
class astrology.transits.TransitHits(chart, start_utc, end_utc, start_jde_tt, end_jde_tt, moving_objects, natal_objects, aspects, sources, hits, celestial_version, astrology_version, position_frame='apparent_geocentric_true_ecliptic_of_date', time_policy='modern_utc_frozen_leap_offsets', epoch_policy='fixed_natal_degree_against_moving_of_date_longitude')

Immutable source chart, search configuration, model provenance and ordered hits.

Sequences are isolated as tuples. Construction checks supplied consistency, not the astronomical origin or completeness of a caller-supplied hit list. It performs no native calls. Coordinate and source details are in rule.project.exact_transit_hits and entry.transit_hits.

The source may be a NatalChart or MomentChart. The retained epoch_policy value names the fixed-reference (historically natal) role, not the source’s input kind: both use its fixed stored own-date degrees against moving-of-date degrees.

不可变的源盘、搜索配置、模型溯源及已排序命中。序列复制为元组;构造时检查给定数据的 一致性,不认证天文来源或调用方所给命中列表的完整性,也不调用原生天文库。 坐标及来源详情分别见 rule.project.exact_transit_hits 和 entry.transit_hits。 源盘可以是 NatalChart 或 MomentChart。保留的 epoch_policy 值所指的是固定参考侧 (历史上称本命侧)的角色,不是源盘输入类型;两者都把源盘自身日期的已存度数固定, 与移动对象自身日期的度数比较。

Parameters:
chart: NatalChart | MomentChart
start_utc: datetime
end_utc: datetime
start_jde_tt: float
end_jde_tt: float
moving_objects: tuple[Body | LunarNode, ...]
natal_objects: tuple[Body | LunarNode | Axis, ...]
aspects: tuple[MajorAspect, ...]
sources: tuple[TransitSource, ...]
hits: tuple[TransitHit, ...]
celestial_version: str
astrology_version: str
position_frame: Literal['apparent_geocentric_true_ecliptic_of_date']
time_policy: Literal['modern_utc_frozen_leap_offsets']
epoch_policy: Literal['fixed_natal_degree_against_moving_of_date_longitude']
astrology.transits.transit_hits(chart, *, start_utc, end_utc, moving_objects, natal_objects, aspects)

Find every exact selected moving-to-fixed-source branch in [start_utc, end_utc).

Endpoints must be aware built-in datetimes at or after 1972-01-01 UTC. Selections and aspects are explicit, nonempty and unique; moving bodies/nodes need not be present on the natal chart. Natal axes require explicit selection. No orbs are used. UTC is converted upstream; the half-open search is capped at 3660 TT days and each selected provider’s event domain. A failed query aborts the whole result. Domain/span rejections raise TransitDomainError; native computation failures propagate unchanged. Native astronomy is loaded only by this calculation call. Hits are ordered by TT time, moving order, natal source order, aspect angle, then negative before positive branch. Raw event values, including tangent rates, are preserved, with times reported as multiples of 2^-30 day. Coordinate/source details: rule.project.exact_transit_hits and entry.transit_hits. Missing installed distribution metadata raises importlib.metadata.PackageNotFoundError.

chart may be a NatalChart or MomentChart; natal_objects names its fixed-reference role. Its stored degrees remain fixed regardless of the source input kind. TransitHits.epoch_policy retains its existing value for both source kinds.

搜索 [start_utc, end_utc) 内所选移动对象与固定源盘黄经的全部精确分支。 端点须为有时区的内建 datetime,归一为 UTC 后不早于 1972-01-01。对象及相位须显式、非空且 不重复;移动天体或交点不必出现在本命盘中,本命四轴须显式选择。不使用容许度。 上游将 UTC 转为 TT;半开搜索区间最长 3660 TT 日,并受每个所选事件来源的域限制。 任一查询失败即整次失败。域或区间拒绝抛 TransitDomainError;原生计算失败保持原异常。 只有此计算调用才加载原生天文。按 TT 时刻、移动对象顺序、本命源盘顺序、相位角升序及 负分支在前排序。保留原值,包括相切速率;报告时刻为 2^-30 日的整数倍。 坐标及来源详情分别见 rule.project.exact_transit_hits 和 entry.transit_hits; 已安装分发包元数据缺失时抛出 importlib.metadata.PackageNotFoundError。 chart 可以是 NatalChart 或 MomentChart;natal_objects 命名其固定参考侧的角色, 两种输入都固定源盘的已存度数。TransitHits.epoch_policy 对两种来源保留原值。

Parameters:
Return type:

TransitHits

Solar and lunar returns

See returns for event searches, explicit locations and chart consumers.

Solar and lunar returns to stored natal longitudes. 针对已存本命黄经的日月返照。

astrology.returns.return_hits(natal, body, *, start_utc, end_utc)

Find every solar or lunar return in [start_utc, end_utc), as TransitHits.

body must be SUN or MOON and present on the NatalChart. The same-body conjunction search uses transit_hits, including its UTC, domain and failure contracts. An empty hits tuple is valid. Pass a retained hit to moment_chart with an explicit location and configuration to build its chart. See entry.solar_lunar_returns. Wrong natal/body types raise TypeError; unsupported bodies or a missing natal luminary raise ValueError.

查找 [start_utc, end_utc) 内全部日返照或月返照,返回 TransitHits。body 须为本命盘中 已有的 SUN 或 MOON;同星体合相搜索使用 transit_hits,沿用其 UTC、有效域及失败合同。 hits 可以为空。将保留的命中连同显式地点和配置交给 moment_chart,即可建立返照时刻的盘。 定义见 entry.solar_lunar_returns。 natal 或 body 类型不符时抛 TypeError;星体不受支持或本命盘缺少所选日月时抛 ValueError。

Parameters:
Return type:

TransitHits

Cross-chart house overlays

See the house-overlay example for calculation and the comparison text example for output.

Find which houses in one chart contain the other chart’s selected objects.

查询一张盘中选定的对象落入另一张盘的哪一宫。

class astrology.house_overlays.HouseOverlay(object_owner, house_owner, identity, house)

An object’s house in the other chart.

object_owner identifies the chart the object comes from; house_owner identifies the chart whose houses are used. One must be “left” and the other “right”. identity is a Body, LunarNode or Axis. house is an integer from 1 to 12, not bool. CrossChartHouseOverlays checks the house against the charts; this record alone does not have the geometry needed for that check.

一个对象落入另一张盘的宫位。object_owner 表示对象来自哪张盘,house_owner 表示使用哪张盘的宫位, 两者必须一个为 “left”、另一个为 “right”。identity 为 Body、LunarNode 或 Axis; house 是 1 到 12 的整数,不接受 bool。单条记录没有校验落宫所需的几何数据, 由 CrossChartHouseOverlays 根据两张盘检查宫号是否正确。

Parameters:
object_owner: Literal['left', 'right']
house_owner: Literal['left', 'right']
identity: Body | LunarNode | Axis
house: int
class astrology.house_overlays.CrossChartHouseOverlays(chart_left, chart_right, left_objects, right_objects, placements)

An immutable result containing both charts, selected objects and all placements.

Both charts remain unchanged. Input sequences are copied into tuples. Selected bodies and nodes follow each chart’s position order, then selected axes follow in ASC/MC/DSC/IC order. Placements list left objects in right houses, then right objects in left houses. Construction recomputes the complete placement sequence and rejects any difference.

不可变的结果,包含两张命盘、所选对象和全部落宫记录。两张盘保持不变,传入的序列复制为元组。 所选天体和交点按各盘的位置记录顺序排列,所选四轴随后按上升、中天、下降、天底排列。 落宫记录先列左盘对象在右盘的落宫,再列右盘对象在左盘的落宫。 构造时会重新计算完整落宫序列,拒绝与它不同的记录。

Parameters:
chart_left: NatalChart | MomentChart
chart_right: NatalChart | MomentChart
left_objects: tuple[Body | LunarNode | Axis, ...]
right_objects: tuple[Body | LunarNode | Axis, ...]
placements: tuple[HouseOverlay, ...]
astrology.house_overlays.cross_chart_house_overlays(chart_left, chart_right, *, left_objects=None, right_objects=None)

Find the house of each selected object in the other chart.

left_objects and right_objects select objects from their respective charts. None selects all bodies and nodes in that chart, without axes, independently of its intra-chart aspect selection. Explicit selections may include stored axes. Their longitudes come from the actual axis fields, not cusps or calculated opposites. Bodies and nodes follow chart order, then selected axes follow in ASC/MC/DSC/IC order.

An empty selection skips placements of that chart’s objects, but its houses are still used for the other chart’s objects. Both charts and selections are checked even when output is empty. Same-named objects and the same chart on both sides are allowed. The result retains both charts and lists left objects in right houses before right objects in left houses.

Placement compares stored longitudes with the other chart’s cusps, in degrees, wrapping at 360. A longitude exactly on a cusp belongs to the house starting there. The charts must use the same zodiac, center and position frame. Current public constructors accept only tropical, geocentric positions on the true ecliptic and equinox of each chart’s own date. Different dates, house systems, models and versions are retained. There is no common-epoch conversion or three-dimensional placement.

Invalid types raise TypeError. Duplicate or unavailable selections and incompatible coordinates raise ValueError.

查询每个所选对象落入另一张盘的哪一宫。left_objects 和 right_objects 分别选择左右盘的对象。 None 表示该盘的全部天体和交点,不含四轴,也不沿用盘内相位的对象选择。显式选择可以包含已存轴, 黄经从实际轴字段读取,不用宫头或计算出的对轴代替。天体和交点按盘中顺序排列, 所选四轴随后按上升、中天、下降、天底排列。

空选择表示不查该盘对象的落宫,但仍用它的宫位判断另一张盘对象的落宫。即使输出为空, 两张盘和对象选择仍会接受检查。允许同名对象,也可以把同一张盘传给两边。结果保留两张盘, 先列左盘对象在右盘的落宫,再列右盘对象在左盘的落宫。

落宫直接比较已存黄经与另一张盘的宫头,角度以度计,跨 360 度回绕。 黄经恰好等于宫头时,归入从该宫头开始的宫。两张盘的黄道、中心和位置坐标约定必须一致。 当前公开构造器只接受热带地心位置,以各盘自身日期的真黄道和真春分点为基准。 不同日期、宫制、模型和版本均保留,不转换到共同历元,也不计算三维落宫。

类型错误抛出 TypeError;重复选择、选择盘中没有的对象或坐标约定不一致时,抛出 ValueError。

Parameters:
Return type:

CrossChartHouseOverlays

Chart summaries and lunar phase

See the summary guide for explicit populations, source conventions and errors. The dignity guide covers the house-ruler records.

Oriented longitude difference and Rudhyar’s eight lunation types.

有向黄经差与 Rudhyar 八种月相类型。

class astrology.lunar_phase.LunationType(*values)

Rudhyar’s eight angular categories; each name denotes a range, not an exact event.

Rudhyar 的八种角度分类;每个名称表示一段区间,不表示精确天象事件。

NEW_MOON = 'new_moon'
CRESCENT_MOON = 'crescent_moon'
FIRST_QUARTER = 'first_quarter'
GIBBOUS_MOON = 'gibbous_moon'
FULL_MOON = 'full_moon'
DISSEMINATING_MOON = 'disseminating_moon'
LAST_QUARTER = 'last_quarter'
BALSAMIC_MOON = 'balsamic_moon'
class astrology.lunar_phase.LunarPhaseResult(elongation_deg)

A normalized Moon-minus-Sun angle in degrees, with derived type, direction and rule ID.

Construction requires a finite angle in [0, 360); invalid types/ranges raise TypeError/ValueError. Labels derive from this angle, never from rounded display. This is neither a 3D phase angle nor an illuminated fraction or event search.

归一化的月减日角度(度),附由角度推导的类型、盈亏方向和规则标识。构造要求有限的 [0, 360) 内角度;类型或范围非法时抛出 TypeError 或 ValueError。标签从此角度推导,不由 显示舍入值决定。这不是三维相角、照亮比例或事件搜索。

Parameters:

elongation_deg (float)

elongation_deg: float
property phase: LunationType

Return the type in half-open 45° sectors. 返回半开 45° 区间对应的类型。

property direction: Literal['waxing', 'waning', 'turning']

Label strict (0, 180) as waxing, (180, 360) as waning, and 0/180 as turning.

严格 (0, 180) 为盈、(180, 360) 为亏,0 和 180 为转折点。

property rule_id: str

Return the stable classification rule ID. 返回稳定的分类规则标识。

astrology.lunar_phase.lunar_phase(sun_longitude_deg, moon_longitude_deg)

Return (Moon minus Sun) modulo 360 and its Rudhyar lunation type.

Supply finite degrees, Sun first; whole turns are allowed. The caller must ensure the same instant and coordinate convention. Wrong types (including bool) raise TypeError; nonfinite values raise ValueError. The angle is a float approximation in [0, 360). Sources, boundary policies and numerical details are in the summary guide.

返回(月亮减太阳)模 360 的角度及 Rudhyar 月相类型。输入依次为太阳、月亮黄经, 单位为有限度数,可包含整圈;调用方须保证同一时刻和坐标约定。类型非法(包括 bool) 抛出 TypeError,非有限值抛出 ValueError。返回角度为 [0, 360) 内的浮点近似值。 来源、边界约定及数值细节见 摘要指南。

Parameters:
  • sun_longitude_deg (float)

  • moon_longitude_deg (float)

Return type:

LunarPhaseResult

Equal-count sign statistics and lunar-phase composition from supplied chart values.

从给定命盘值组合等权星座统计与月相。

class astrology.summaries.SignDistribution(placements)

An immutable, nonempty Placement snapshot; each distinct object contributes one count.

Input sequences are copied to tuples; counts include zero for every category, and proportions are count/total. Objects and total derive from the snapshot. Invalid containers/members raise TypeError, empty or duplicate populations ValueError. The caller is responsible for common provenance of low-level placements. Each object has equal weight.

不可变且非空的 Placement 快照,每个不同对象计一次。输入序列复制成元组,计数包含各类的 零值,比例为计数除以总数;对象及总数从快照推导。容器或成员类型非法抛出 TypeError,空集合或 重复对象抛出 ValueError。调用方负责保证低层落点的共同来源;每个对象的权重相同。

Parameters:

placements (tuple[Placement, ...])

placements: tuple[Placement, ...]
property objects: tuple[Body | LunarNode, ...]

Return the counted identities in snapshot order. 返回按快照顺序排列的计数对象。

property total: int

Return the common nonzero denominator. 返回共同的非零分母。

property element_counts: Mapping[Element, int]

Return all four element counts, including zero. 返回四元素计数,包含零。

property modality_counts: Mapping[Modality, int]

Return all three modality counts, including zero. 返回三模式计数,包含零。

property element_proportions: Mapping[Element, float]

Return each element count divided by total. 返回各元素计数除以总数的比例。

property modality_proportions: Mapping[Modality, float]

Return each modality count divided by total. 返回各模式计数除以总数的比例。

astrology.summaries.sign_distribution(placements)

Count an explicit nonempty population, preserving its order; see SignDistribution’s checks.

统计显式提供的非空落点集合,保留输入顺序;校验规则见 SignDistribution。

Parameters:

placements (Sequence[Placement])

Return type:

SignDistribution

astrology.summaries.chart_sign_distribution(chart, *, objects)

Count explicitly selected existing placements in source-chart order.

No default population is inferred. None, strings, wrong enums or invalid chart types raise TypeError; empty/duplicate selections or unavailable objects raise ValueError. The source chart is unchanged, and no missing object is calculated.

按源盘顺序统计显式选择的已有落点。不推断默认统计对象。None、字符串、其他枚举 或错误的命盘类型抛出 TypeError;空选择、重复选择或缺失对象抛出 ValueError。源盘不变,不补算缺失对象。

Parameters:
Return type:

SignDistribution

astrology.summaries.natal_lunar_phase(chart)

Compose lunar phase from this chart’s Sun/Moon in its shared frame.

Wrong chart types raise TypeError; a missing Sun or Moon raises ValueError naming the absent objects. Nothing is recalculated or added to the source chart.

用此盘共同坐标约定下的日月位置组合月相。命盘类型错误抛出 TypeError; 缺太阳或月亮时抛出 ValueError 并列出缺失对象。不重新计算,也不向源盘添加内容。

Parameters:

chart (NatalChart)

Return type:

LunarPhaseResult

Traditional rulership and dignities

See the dignity guide for sign queries, house rulers and dispositor chains.

Lilly 1647 sign rulers, four statuses and supplied-chart rulership results.

Lilly 1647 星座守护、四种尊贵状态及给定命盘的守护关系结果。

class astrology.dignities.DignityStatus(*values)

The four assessed sign-level statuses, without scores. 所判断的四种星座级状态,不计分。

DOMICILE = 'domicile'
EXALTATION = 'exaltation'
DETRIMENT = 'detriment'
FALL = 'fall'
astrology.dignities.sign_ruler(sign)

Return the sign’s ruler in Lilly’s seven-planet set; a non-Sign raises TypeError.

按 Lilly 的传统星座守护表返回守护星;非 Sign 输入抛出 TypeError。

Parameters:

sign (Sign)

Return type:

Body

astrology.dignities.essential_dignities(body, sign)

Return every match in domicile/exaltation/detriment/fall order, or () for none.

Wrong enum types raise TypeError; an outer-planet Body raises ValueError. Assess the whole sign, not exaltation-degree proximity. See the dignity guide.

按入庙、擢升、失势、落陷顺序返回全部命中,无命中则为 ()。枚举类型错误抛出 TypeError, 外行星 Body 抛出 ValueError。判断整个星座,不看离擢升度数多近;详见尊贵指南。

Parameters:
Return type:

tuple[DignityStatus, …]

class astrology.dignities.HouseRuler(house, cusp_sign, placement)

One house’s cusp sign and its traditional ruler’s placement, or None if unavailable.

Wrong types raise TypeError; a house outside 1..12 or a mismatched placement identity raises ValueError.

单个宫位的宫头星座及传统宫主星落点;未计算落点时为 None。类型错误抛出 TypeError,宫号不在 1..12 或落点身份不符时抛出 ValueError。

Parameters:
house: int
cusp_sign: Sign
placement: Placement | None
property ruler: Body

Return the ruler derived from the cusp sign. 返回从宫头星座推出的宫主星。

property statuses: tuple[DignityStatus, ...] | None

Return all statuses, () for no match, or None for an unavailable placement.

返回全部状态;() 表示无命中,None 表示落点未计算。

class astrology.dignities.HouseRulers(chart)

Derive twelve house-ruler records from one retained natal or moment chart.

Use actual cusps, not axes; keep repeated signs and missing ruler placements. Invalid chart types raise TypeError. Repeated houses accesses return new records that compare equal; existing placements and the source chart are retained by identity.

从保留的本命盘或时刻盘推导十二宫主星记录。使用实际宫头,不以轴代替;保留重复 星座及缺失的宫主星落点。命盘类型错误时抛出 TypeError。两次读取 houses 所得元组相等, 但其中的记录不是同一批对象;已有落点及源盘保留原对象。

Parameters:

chart (NatalChart | MomentChart)

chart: NatalChart | MomentChart
property houses: tuple[HouseRuler, ...]

Return twelve records in cusp order, retaining available placements.

按宫头顺序返回十二条记录,保留可用的原落点。

property rule_id: str

Return the named rulership/dignity rule. 返回具名的守护及尊贵规则。

class astrology.dignities.Dispositors(chart, objects)

Immutable rulership paths for explicit roots in a retained chart.

The constructor takes only chart and objects, copying the selection into source-chart order. Non-chart inputs, non-sequences, strings and wrong identities raise TypeError; empty, duplicate or unavailable roots raise ValueError. Available but unselected rulers can be intermediates. See entry.dispositor_chains.

保留源盘、为显式根对象提供不可变的守护路径。构造器只接收 chart 及 objects, 复制选择并按源盘顺序排列。非命盘、非序列、字符串或错误身份抛出 TypeError; 空、重复或不可用的根对象抛出 ValueError。未选作根但盘中已有的守护星可作中间节点。 见 entry.dispositor_chains。

Parameters:
chart: NatalChart | MomentChart
objects: tuple[Body | LunarNode, ...]
edges: Mapping[Body | LunarNode, Body]

Reached object-to-ruler edges, including absent targets. 已到达对象到守护星的边,含缺失目标。

chains: Mapping[Body | LunarNode, tuple[Body | LunarNode, ...]]

Distinct available objects per root, before repetition or absence. 各根的可用对象路径,在重复或缺失前停止。

cycles: tuple[tuple[Body, ...], ...]

Reached nontrivial cycles, rotated and ordered by source order. 已到达的非自环循环,按源盘顺序规范起点及排列。

final_dispositors: tuple[Body, ...]

Reached self-loop endpoints in source order. 按源盘顺序列出的已到达自环终点。

missing_rulers: Mapping[Body | LunarNode, Body]

Each affected root’s absent next ruler. 各受影响根对象缺失的下一颗守护星。

property rule_id: str

Return the project’s chain rule identifier. 返回项目定位星链规则标识。

astrology.dignities.chart_dispositors(chart, *, objects)

Follow Lilly sign rulers from selected chart placements; see Dispositors.

从选定的命盘落点沿 Lilly 星座守护表遍历;详见 Dispositors。

Parameters:
Return type:

Dispositors

Independent knowledge

Field roles are explained in the knowledge record fields.

Chart-independent knowledge records and queries. 独立于命盘的知识记录与查询。

class astrology.knowledge.Catalog(concepts, variants, sources, entries)

Validated immutable catalog records.

Copy all record sequences. Reject duplicate IDs, dangling links, inconsistent config links and aliases shared by different concepts (TypeError/ValueError). Equal display names are allowed and lookup returns every matching identity. Records can retain missing/stale translations without treating them as current. Malformed string IDs raise ValueError; non-string IDs raise TypeError. Unknown well-formed IDs raise KeyError.

经核验的不可变目录记录。复制全部记录序列;重复标识、悬空链接、 不一致的配置链接及不同概念共享别名均抛出 TypeError 或 ValueError。 允许显示名称相同,查询返回所有命中的身份;缺译及旧译可保留,但不算当前译文。 格式不合法的字符串标识抛出 ValueError,非字符串标识抛出 TypeError。 格式正确但未知的标识抛出 KeyError。

Parameters:
concepts: Sequence[Concept]
variants: Sequence[RuleVariant]
sources: Sequence[Source]
entries: Sequence[Entry]
concept(identifier)

Get a concept by exact ID; see Catalog for ID errors. 按精确标识取概念,标识错误规则见 Catalog。

Parameters:

identifier (str)

Return type:

Concept

variant(identifier)

Get a variant by exact ID; see Catalog for ID errors. 按精确标识取变体,标识错误规则见 Catalog。

Parameters:

identifier (str)

Return type:

RuleVariant

source(identifier)

Get an edition record; see Catalog for ID errors. 取来源版本记录,标识错误规则见 Catalog。

Parameters:

identifier (str)

Return type:

Source

entry(identifier)

Get a statement, not a chart conclusion; see Catalog for ID errors.

取陈述而非命盘结论,标识错误规则见 Catalog。

Parameters:

identifier (str)

Return type:

Entry

list_concepts(*, kind=None)

List concepts in corpus order, optionally by kind; reject raw strings.

按语料顺序列概念,可按类别筛选;不接受字符串代替枚举。

Parameters:

kind (ConceptKind | None)

Return type:

tuple[Concept, …]

list_variants(*, concept_id=None)

List definitions, optionally for a concept; see Catalog for ID errors.

列定义,可限定概念;标识错误规则见 Catalog。

Parameters:

concept_id (str | None)

Return type:

tuple[RuleVariant, …]

lookup(name, *, language=None)

Find exact names/aliases after NFC, trim and casefold; no match returns ().

An omitted language searches both. Ambiguous display names return all identities; this is neither fuzzy documentation search nor chart matching. Invalid language raises ValueError, invalid/blank names TypeError/ValueError.

经 NFC、去首尾空白及大小写折叠后精确查询名称与别名,无匹配返回 ()。未选语言则查两种语言; 歧义名称返回所有身份,不做模糊文档搜索或命盘判别。非法语言抛出 ValueError, 非法或空名称抛出 TypeError 或 ValueError。

Parameters:
  • name (str)

  • language (Literal['en', 'zh-CN'] | None)

Return type:

tuple[Concept, …]

filter_entries(*, concept_id=None, source_id=None, prerequisite_status=None, output_eligibility=None)

Apply all requested editorial filters without evaluating prerequisites.

ID errors follow Catalog; raw status strings raise TypeError. Source verification must be inspected on Source, not inferred from this result.

同时应用所选整理筛选,不判断前提。标识错误规则见 Catalog, 字符串状态抛出 TypeError。来源查核状态须查 Source,不从查询结果推断。

Parameters:
Return type:

tuple[Entry, …]

filter_sources(*, verification=None)

Filter editions by their inspection state, not applicability; reject raw strings.

按版本的查核状态筛选,不判断适用;不接受字符串代替枚举。

Parameters:

verification (SourceVerification | None)

Return type:

tuple[Source, …]

citations(entry_id)

Resolve an entry’s citations to editions; see Catalog for ID errors.

将条目引用解析至版本记录,标识错误规则见 Catalog。

Parameters:

entry_id (str)

Return type:

tuple[tuple[Citation, Source], …]

class astrology.knowledge.Citation(source_id, locator, excerpt=None)

Edition-specific locator and optional English excerpt with labeled translation.

The excerpt’s English is source text, not project explanation; Chinese credit and revision identify its translation. Catalog checks the source ID. Invalid values raise TypeError/ValueError.

版本内定位及可选英文原文与具名译文。引文英文属于来源原文,不是项目说明;中文署名及修订 标识其译文。来源标识由 Catalog 核验,非法值抛出 TypeError 或 ValueError。

Parameters:
source_id: str
locator: str
excerpt: LocalizedText | None
class astrology.knowledge.Concept(identifier, kind, name, description, en_aliases=(), zh_aliases=(), related=(), configuration=None)

One stable vocabulary identity; names do not merge different definitions.

Alias and related-ID sequences are copied into immutable tuples. Configuration links refer only to existing request identities, never to an invented algorithm. Invalid types/references raise TypeError/ValueError; cross-record links are checked by Catalog.

一个稳定的词汇身份,同名不合并定义。别名及关联标识序列复制为不可变元组。 配置链接仅指向已有请求标识,不虚构算法。非法类型或引用抛出 TypeError 或 ValueError; 跨记录引用由 Catalog 核验。

Parameters:
identifier: str
kind: ConceptKind
name: LocalizedText
description: LocalizedText
en_aliases: Sequence[str]
zh_aliases: Sequence[str]
related: Sequence[str]
configuration: Body | LunarNode | Axis | HouseSystem | MajorAspect | NodeDefinition | None
class astrology.knowledge.ConceptKind(*values)

Vocabulary categories, not astronomical object classes. 词汇分类,不替代天文对象类型。

BODY = 'body'
SIGN = 'sign'
SIGN_GROUP = 'sign_group'
ELEMENT = 'element'
MODALITY = 'modality'
LUNATION_TYPE = 'lunation_type'
DIGNITY_STATUS = 'dignity_status'
HOUSE_SYSTEM = 'house_system'
NODE_DEFINITION = 'node_definition'
LUNAR_NODE = 'lunar_node'
AXIS = 'axis'
ASPECT = 'aspect'
class astrology.knowledge.Entry(identifier, statement, concept_ids, rule_ids, citations, prerequisites, exceptions, limits, prerequisite_status, output_eligibility)

Project statement, citations and independent editorial states; never a chart match.

All sequences are copied into tuples. Prerequisite completeness does not mean satisfied premises; output eligibility does not mean applicability. Queries always leave chart applicability not_assessed. Catalog checks cross-record links. Invalid values raise TypeError/ValueError even under python -O.

项目陈述、引用及相互独立的整理状态,不表示命盘命中。所有序列复制为元组。 前提完整不等于前提已满足;输出资格不等于适用。查询始终将命盘适用性留为 not_assessed。 Catalog 核验跨记录引用,非法值即使在 python -O 下也抛出 TypeError 或 ValueError。

Parameters:
identifier: str
statement: LocalizedText
concept_ids: Sequence[str]
rule_ids: Sequence[str]
citations: Sequence[Citation]
prerequisites: Sequence[LocalizedText]
exceptions: LocalizedText
limits: LocalizedText
prerequisite_status: PrerequisiteStatus
output_eligibility: OutputEligibility
property chart_applicability: Literal['not_assessed']

Retrieval has not evaluated any chart. 检索未判断任何命盘。

class astrology.knowledge.LocalizedText(en, zh=None, revision=1, zh_revision=None, translation_credit=None)

English canonical text and an optional credited Chinese translation.

Revisions are positive integers; an older Chinese revision is retained as stale. Missing Chinese text returns None, never English fallback. Raise TypeError or ValueError for invalid fields, including inconsistent translation metadata.

英文为基准文本,中文译文可缺失但须署名。修订为正整数;旧译保留并标为过期。 缺译返回 None,不回退为英文;字段或译文元数据不合法时抛出 TypeError 或 ValueError。

Parameters:
  • en (str)

  • zh (str | None)

  • revision (int)

  • zh_revision (int | None)

  • translation_credit (str | None)

en: str
zh: str | None
revision: int
zh_revision: int | None
translation_credit: str | None
status(language)

Return current, stale or missing without substituting text. 返回当前、过期或缺失,不替换文本。

Parameters:

language (Literal['en', 'zh-CN'])

Return type:

TranslationStatus

text(language)

Return the requested text, including stale text or None. 返回所选文本,可能是旧译或 None。

Parameters:

language (Literal['en', 'zh-CN'])

Return type:

str | None

class astrology.knowledge.OutputEligibility(*values)

Editorial eligibility, independent of source checks and chart matching.

整理层面的输出资格,独立于出处查核与命盘判别。

ELIGIBLE = 'eligible'
REFERENCE_ONLY = 'reference_only'
class astrology.knowledge.PrerequisiteStatus(*values)

Whether prerequisites are represented, not satisfied by a chart.

前提是否已表达完整,不表示命盘已满足前提。

COMPLETE = 'complete'
UNRESOLVED = 'unresolved'
class astrology.knowledge.RuleVariant(identifier, name, concept_ids, definition, tradition, limits, configuration=None)

Named definition and scope; a config reference is not executable astronomy.

Concept IDs are isolated tuples; Catalog rejects dangling links. Raise TypeError or ValueError for invalid values. No formula, orb, default or chart evaluation is supplied.

具名定义及范围;配置引用不表示天文算法已实现。概念标识隔离为元组,悬空引用由 Catalog 拒绝。 非法值抛出 TypeError 或 ValueError;不提供公式、容许度、默认值或命盘判断。

Parameters:
identifier: str
name: LocalizedText
concept_ids: Sequence[str]
definition: LocalizedText
tradition: LocalizedText
limits: LocalizedText
configuration: Body | LunarNode | Axis | HouseSystem | MajorAspect | NodeDefinition | None
class astrology.knowledge.Source(identifier, title, author, edition, language, lineage, rights, scope, verification, url)

An edition, lineage and bounded rights/verification record.

Title, author, edition and language preserve bibliographic identity. Scope and rights are editorial records, not a copyright guarantee or chart conclusion. Invalid fields raise TypeError/ValueError.

一个版本、谱系及有限的转载与查核记录。书名、作者、版本与语言保留书目身份。 范围及权限是整理记录,不是版权保证或命盘结论;非法字段抛出 TypeError 或 ValueError。

Parameters:
identifier: str
title: str
author: str
edition: str
language: str
lineage: LocalizedText
rights: LocalizedText
scope: LocalizedText
verification: SourceVerification
url: str
class astrology.knowledge.SourceVerification(*values)

Editorial source inspection, not truth or applicability. 出处查核状态,不代表真实或适用。

VERIFIED = 'verified'
UNVERIFIED = 'unverified'
class astrology.knowledge.TranslationStatus(*values)

Translation coverage of a semantic revision. 译文覆盖语义修订的状态。

CURRENT = 'current'
STALE = 'stale'
MISSING = 'missing'
astrology.knowledge.load_catalog()

Read and validate the packaged corpus on each explicit call; no cache or network.

Resource/JSON errors propagate; invalid records/references raise TypeError, ValueError or KeyError. The returned catalog owns immutable snapshots, not the decoded containers.

每次显式调用均读取并核验包内语料,不使用缓存或网络。资源及 JSON 错误直接传播; 非法记录或引用抛出 TypeError、ValueError 或 KeyError。 返回目录持有不可变快照,不共享解码所得容器。

Return type:

Catalog