def getMoonPhase( n ): if not isinstance( n, RPNDateTime ): raise ValueError( '\'moon_phase\' expects a date-time argument' ) datetime = n.to( 'utc' ).format( ) previous = RPNDateTime.convertFromEphemDate( ephem.previous_new_moon( datetime ) ).getLocalTime( ) next = RPNDateTime.convertFromEphemDate( ephem.next_new_moon( datetime ) ).getLocalTime( ) cycle = next - previous current = n - previous return current.total_seconds( ) / cycle.total_seconds( )
def getEphemTime( n, func ): '''Returns a pyephem date-time value from an RPNDateTime value.''' if not isinstance( n, RPNDateTime ): raise ValueError( 'expected a date-time argument' ) result = RPNDateTime.convertFromEphemDate( func( n.format( ) ) ) return result.getLocalTime( )
def getAntitransitTime( body, location, date ): if isinstance( location, str ): location = getLocation( location ) if not isinstance( body, ephem.Body ) or not isinstance( location, RPNLocation ) or \ not isinstance( date, RPNDateTime ): raise ValueError( 'expected an astronomical object, a locaton and a date-time' ) location.observer.date = date.to( 'utc' ).format( ) location.observer.horizon = '0' ephemSetting = location.observer.next_setting( body ) setting = RPNDateTime.convertFromEphemDate( ephemSetting ).getLocalTime( ) rising = RPNDateTime.convertFromEphemDate( location.observer.next_rising( body, start=ephemSetting ) ).getLocalTime( ) return subtract( rising, setting )
def getPreviousSetting( body, location, date ): if isinstance( location, str ): location = getLocation( location ) if not isinstance( body, ephem.Body ) or not isinstance( location, RPNLocation ) or not isinstance( date, RPNDateTime ): raise ValueError( 'expected an astronomical object, a locaton and a date-time' ) old_horizon = location.observer.horizon location.observer.date = date.to( 'utc' ).format( ) location.observer.horizon = '0' result = RPNDateTime.convertFromEphemDate( location.observer.previous_setting( body ) ).getLocalTime( ) location.observer.horizon = old_horizon return result
def getNextDusk( location, date, horizon = -6 ): if isinstance( location, str ): location = getLocation( location ) if not isinstance( location, RPNLocation ) or not isinstance( date, RPNDateTime ): raise ValueError( 'expected locaton and date-time arguments' ) old_horizon = location.observer.horizon location.observer.date = date.to( 'utc' ).format( ) location.observer.horizon = str( horizon ) result = RPNDateTime.convertFromEphemDate( location.observer.next_setting( ephem.Sun( ), use_center=True ) ).getLocalTime( ) location.observer.horizon = old_horizon return result
def getWinterSolstice( n ): '''Returns the date of the next winter solstice after n.''' result = RPNDateTime.convertFromEphemDate( ephem.next_solstice( str( n ) + '-07-01' ) ) return result.getLocalTime( )
def getAutumnalEquinox( n ): '''Returns the date of the next autumnal equinox after n.''' result = RPNDateTime.convertFromEphemDate( ephem.next_equinox( str( n ) + '-07-01' ) ) return result.getLocalTime( )
def getWinterSolstice( n ): result = RPNDateTime.convertFromEphemDate( ephem.next_solstice( str( n ) + '-07-01' ) ) return result.getLocalTime( )
def getAutumnalEquinox( n ): result = RPNDateTime.convertFromEphemDate( ephem.next_equinox( str( n ) + '-07-01' ) ) return result.getLocalTime( )
def getSummerSolstice( n ): result = RPNDateTime.convertFromEphemDate( ephem.next_solstice( str( n ) ) ) return result.getLocalTime( )
def getVernalEquinox( n ): result = RPNDateTime.convertFromEphemDate( ephem.next_equinox( str( n ) ) ) return result.getLocalTime( )