Astrod2 aims to replicate the functional specification of Astrod in a more general way. Currently, it focuses only on World Transits.

## Engines

Astrod2 can perform its calculations using the following libraries:

(For recent history, there is no significant difference between the libraries. The only case in which Swisseph, which uses a newer version of the NASA JPL ephemeris, may be more appropriate is for alignments involving Pluto prior to 0AD, where there are significant differences in the predictions of the two libraries.)

## Queries

### Parameters

- Start & end date
- Interval as hours/days/weeks/years (depending on date method; see below)
- Stride as size of interval
- The set or a subset of the Sun and the planets
- The orb of interest (for alignedness and alignment calculations; see below)
- The planetary configurations of interest (for alignment calculations; see below)

### Dates

The following methods to generate date ranges are supported; each have their advantages and limitations. In all cases, they are corrected to the native format of the chosen engine (see above).

- Python datetimes: simplest to work with, support from 1AD onwards only and Gregorian calendar is assumed
- Ephem dates: most powerful, support for Julian/Gregorian switch and BC dates included
- Tuples: allows only year (AD or BC) to be specified, a simple format for long and sparse date ranges
- File: allows a series of dates to be read from a file in any date format specifiable in Python (format string must be supplied)

**AD and BC dates**

There is no year zero. Ephem corrects for this automatically, while the correction is supplied to Swisseph conversions to obtain consistency.

**Julian and Gregorian dates**

These are taken to switch on 15 October 1582. Again, Ephem handles this automatically while Swisseph conversions are corrected to take this into account and supply the correct calendar flag. The upshot of this is that all dates are implicitly Julian before this date and Gregorian after it. This saves a great deal of complexity upfront, but care is needed in subsequent analysis as many systems assume dates to be Gregorian including Python dates and Matplotlib dates.

**Timezones**

All dates are timezone agnostic, including Python datetimes which (unlike Python dates) do support timezones. There is (currently) no concept of timezone or location.

## Functions

### Generate positions

The geocentric longitudinal positions of all planets on the solar ecliptic, the basic positional measure in astrological calculations.

### Generate alignedness

The ‘alignedness’ of all *pairs* of planets, by one of the following metrics:

#### Separation

The angular separation based on the above positions.

#### Alignedness

A numerical metric of the degree of alignedness, of arbitrary magnitude. The following measure are available:

*Linear*, in which alignedness increases linearly from zero at a separation corresponding to the specified orb to a maximum value at exact alignment.*Gaussian*, in which alignedness takes the form a normal distribution with a mean at exact alignment and*3σ*; occurring at a separation corresponding to the the specified orb. The use of 3σ; means that at separations beyond the specified orb there is negligible alignedness.

Note that these measures are heuristic, and have no meaning beyond a helpful way to represent separation. The normal distribution is used for its form and does not represent the distribution of anything.

#### Alignments

The requested alignments occurring between the specified start dates (that have finished within this period; unfinished alignments are *not* counted).

Alignment searches (see below) can search for any combinations of planets, whose separations in that combinations are specified as tuples. Therefore all of the following are possible, as well as arbitrarily many others:

"bodies": ["Jupiter","Saturn","Uranus","Neptune","Pluto"]

"Conjunction": (0,0) "Triple Conjunction": (0,0,0) "Full Conjunction": (0,0,0,0,0,0,0,0,0,0) "Opposition": (0,180) "Square": (0,90) "Semisextile": (0,30) "Sextile": (0,60) "Trine": (0,120) "Quincunx": (0,150) "Grand Cross": (0,90,180,270) "Grand Trine": (0,120,240)

This is a particularly powerful feature of Astrod2. Sets of planets are in general *permuted* to match these patterns and therefore calculation times increase very rapidly for configurations involving greater numbers of planets.

The following are returned:

- Start date
- End date
- Minimum deviation, where deviation is calculated as the
*mean of the angular separations*of the set of planets being analysed. For two planets this is simply separation, while for more complex alignments it is a measure of the closeness of the overall alignment. - The date of minimum deviation

## Output

### Metrics

Angles may be returned as:

- Decimals
- Base 60 (degrees/minutes/seconds)
- Base 60 referenced to the tropical Zodiac (e.g. 15°30’45” Aries), useful for comparision to astrological software

### Format

Output is Python generators written to CSV files.

## Analysis

There are many possible approaches. At present, we are running Astrod in the superb Anaconda framework. This provides Python and Jupyter out of the box, with support for PyEphem through its own package manager:

`conda install ephem`

and installation of Swisseph also straightforward via the package manager pip:

`pip install pyswisseph`

The Jupyter notebooks provide an excellent framework for exploratory data analysis, using also Pandas (data analysis; can readily read and write CSV and Excel files) and Matplotlib (plotting). Many other packages are available depending on need.

Astrod2 has been tested and confirmed to produce the same data as Astrod, and has been tested and verified against Solar Fire and AstroGold on an extensive but *ad hoc* basis. It is recommended that generated data that is to be relied upon is checked, as part of the ongoing testing of the library. Code exists to process the results of the electional search in Solar Fire into CSV format.

## Future work

- Functions for Natal Transits, Retrograde Motion and Signs and Houses.
- The boolean combination of alignment data sets. (Boolean combinations could easily be performed with a small amount of extra processing.)

These capabilities already exist in Astrod and it is hoped to add them to this more sophisticated version of the library. However, at present the focus is on the study of world transits.