Skip to content

Commit

Permalink
Adds Nakshatras, bump version.
Browse files Browse the repository at this point in the history
  • Loading branch information
lfborjas committed Sep 15, 2020
1 parent cfa0861 commit 02f77c2
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 10 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Haskell bindings for the [Swiss Ephemeris](https://www.astro.com/swisseph/swephi

See the tests in the `spec` folder for thorough example usage, but here's a simple "main" that demonstrates the current abilities, inspired by the [sample program in the official library](https://www.astro.com/swisseph/swephprg.htm#_Toc46406771):

**NOTE:** this library is under very active development, as such, most releases in v1.x will probably show a fastly evolving API, which is reflected by the fact that new versions have been increasing the major version numbers (in [PVP](https://pvp.haskell.org/), unlike semver, the first _two_ components of the version correspond to the major version.)

```haskell
import SwissEphemeris

Expand Down
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: swiss-ephemeris
version: 1.1.0.0
version: 1.2.0.0
github: "lfborjas/swiss-ephemeris"
license: GPL-2
author: "Luis Borjas Reyes"
Expand Down
10 changes: 6 additions & 4 deletions src/SwissEphemeris.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ module SwissEphemeris
SiderealTime (..),
HouseCusp,
-- fundamental enumerations
SplitDegreesOption (..),
Planet (..),
HouseSystem (..),
ZodiacSignName (..),
NakshatraName (..),
-- coordinate/position systems
EclipticPosition (..),
EquatorialPosition (..),
Expand Down Expand Up @@ -257,8 +259,8 @@ calculateHousePositionSimple sys time loc pos = do
case obliquityAndNutation of
Left e -> return $ Left e
Right on -> do
siderealTime <- calculateSiderealTime time on
let armc' = (unSidereal $ siderealTime) * 15 + geoLng loc
SiderealTime siderealTime <- calculateSiderealTime time on
let armc' = siderealTime * 15 + geoLng loc
calculateHousePosition sys armc' loc on pos

-- | If you happen to have the correct ARMC for a time and place (obtained from calculateCusps)
Expand Down Expand Up @@ -316,10 +318,10 @@ deltaTime jt = do
return $ realToFrac deltaT

-- | Given a longitude, return the degrees it's from its nearest sign,
-- minutes, seconds, with seconds rounded. Convenience alias for `splitDegrees`,
-- minutes, and seconds; with seconds rounded. Convenience alias for `splitDegrees`,
-- when wanting to display e.g. a table in a horoscope.
splitDegreesZodiac :: Double -> LongitudeComponents
splitDegreesZodiac = splitDegrees [SplitZodiacal, RoundSeconds]
splitDegreesZodiac = splitDegrees $ defaultSplitDegreesOptions <> [SplitZodiacal, RoundSeconds]

-- | Given a `Double` representing an ecliptic longitude, split it according to any
-- options from `SplitDegreesOption`:
Expand Down
36 changes: 33 additions & 3 deletions src/SwissEphemeris/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,38 @@ data ZodiacSignName
| Pisces
deriving (Eq, Show, Enum, Generic)

-- | Nakshatras, provided for thoroughness, please excuse the misspellings!
-- | Nakshatras, provided for thoroughness, please excuse any misspellings!
-- List from: https://en.wikipedia.org/wiki/List_of_Nakshatras
-- note that the underlying library uses 27 nakshatras, so Abhijit is
-- omitted.
data NakshatraName
= Ashvini
| Bharani
| Krittika
| Rohini
| Mrigashirsha
| Ardra
| Punarvasu
| Pushya
| Ashlesha
| Magha
| PurvaPhalghuni
| UttaraPhalguni
| Hasta
| Chitra
| Swati
| Vishakha
| Anuradha
| Jyeshtha
| Mula
| PurvaAshadha
| UttaraAshadha
| Sravana
| Dhanishta
| Shatabhisha
| PurvaBhadrapada
| UttaraBhadrapada
| Revati
deriving (Eq, Show, Enum, Generic)

-- | Options to split a `Double` representing degrees:
Expand All @@ -82,7 +110,7 @@ data NakshatraName
-- RoundDegrees -- round at the degrees granularity.
-- SplitZodiacal -- relative to zodiac signs.
-- SplitNakshatra -- relative to nakshatra.
-- KeepSign -- when rounding, don't round if it'll move it to the next zodiac sector.
-- KeepSign -- when rounding, don't round if it'll move it to the next zodiac/nakshatra sector.
-- KeepDegrees -- when rounding, don't round if it'll move it to the next degree.
data SplitDegreesOption
= RoundSeconds
Expand All @@ -102,7 +130,7 @@ newtype JulianTime = JulianTime {unJulianTime :: Double}
deriving (Show, Eq, Ord)

-- | Represents an instant in sidereal time
newtype SiderealTime = SiderealTime {unSidereal :: Double}
newtype SiderealTime = SiderealTime {unSiderealTime :: Double}
deriving (Show, Eq, Ord)

-- | The cusp of a given "house" or "sector". It is an ecliptic longitude.
Expand Down Expand Up @@ -218,6 +246,8 @@ splitOptionToFlag SplitNakshatra = splitNakshatra
splitOptionToFlag KeepSign = splitKeepSign
splitOptionToFlag KeepDegrees = splitKeepDeg

-- | Convenient defaults when using `splitDegrees`:
-- Omit rounding if it would bring it over the next sign or degree.
defaultSplitDegreesOptions :: [SplitDegreesOption]
defaultSplitDegreesOptions = [KeepSign, KeepDegrees]

Expand Down
4 changes: 2 additions & 2 deletions swiss-ephemeris.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ cabal-version: 1.12
--
-- see: https://github.com/sol/hpack
--
-- hash: 25f7b59663125c750ee70fd238ed152f8c7496541d173c1e07bcb3944b332ee1
-- hash: e7dc9c3e02181a082342d7937373cda9b8b1506c04be5e776bed3635ada3df69

name: swiss-ephemeris
version: 1.1.0.0
version: 1.2.0.0
synopsis: Haskell bindings for the Swiss Ephemeris C library
description: Please see the README on GitHub at <https://github.com/lfborjas/swiss-ephemeris#readme>
category: Data, Astrology
Expand Down

0 comments on commit 02f77c2

Please sign in to comment.