From 02f77c27c5cd86fb86555fc0df0482d5c4be8c2e Mon Sep 17 00:00:00 2001 From: Luis Borjas Reyes Date: Mon, 14 Sep 2020 22:15:34 -0400 Subject: [PATCH] Adds Nakshatras, bump version. --- README.md | 2 ++ package.yaml | 2 +- src/SwissEphemeris.hs | 10 ++++++---- src/SwissEphemeris/Internal.hs | 36 +++++++++++++++++++++++++++++++--- swiss-ephemeris.cabal | 4 ++-- 5 files changed, 44 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 61539ab..f3e32d4 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/package.yaml b/package.yaml index 9261496..d9159d9 100644 --- a/package.yaml +++ b/package.yaml @@ -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" diff --git a/src/SwissEphemeris.hs b/src/SwissEphemeris.hs index fdcd5a6..4ee981e 100644 --- a/src/SwissEphemeris.hs +++ b/src/SwissEphemeris.hs @@ -22,9 +22,11 @@ module SwissEphemeris SiderealTime (..), HouseCusp, -- fundamental enumerations + SplitDegreesOption (..), Planet (..), HouseSystem (..), ZodiacSignName (..), + NakshatraName (..), -- coordinate/position systems EclipticPosition (..), EquatorialPosition (..), @@ -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) @@ -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`: diff --git a/src/SwissEphemeris/Internal.hs b/src/SwissEphemeris/Internal.hs index 3d864ad..ad3cafe 100644 --- a/src/SwissEphemeris/Internal.hs +++ b/src/SwissEphemeris/Internal.hs @@ -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: @@ -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 @@ -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. @@ -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] diff --git a/swiss-ephemeris.cabal b/swiss-ephemeris.cabal index 9515c4f..0634755 100644 --- a/swiss-ephemeris.cabal +++ b/swiss-ephemeris.cabal @@ -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 category: Data, Astrology