当前位置: 首页>>代码示例>>Python>>正文


Python Ephemeris.datetimeToJulianDay方法代码示例

本文整理汇总了Python中ephemeris.Ephemeris.datetimeToJulianDay方法的典型用法代码示例。如果您正苦于以下问题:Python Ephemeris.datetimeToJulianDay方法的具体用法?Python Ephemeris.datetimeToJulianDay怎么用?Python Ephemeris.datetimeToJulianDay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ephemeris.Ephemeris的用法示例。


在下文中一共展示了Ephemeris.datetimeToJulianDay方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getGeocentricPlanetDirectRetrogradeInfo

# 需要导入模块: from ephemeris import Ephemeris [as 别名]
# 或者: from ephemeris.Ephemeris import datetimeToJulianDay [as 别名]

#.........这里部分代码省略.........
                    # Check the timestamp between.
                    diffTd = t2 - t1
                    halfDiffTd = \
                        datetime.\
                        timedelta(days=(diffTd.days / 2.0),
                                  seconds=(diffTd.seconds / 2.0),
                                  microseconds=(diffTd.microseconds / 2.0))
                    testDt = t1 + halfDiffTd
                    
                    pi = Ephemeris.getPlanetaryInfo(planetName, testDt)
                    
                    testTropLongitudeSpeed = \
                        pi.geocentric['tropical']['longitude_speed']
                    testTropLongitude = pi.geocentric['tropical']['longitude']
                    testSidLongitude = pi.geocentric['sidereal']['longitude']

                    if testTropLongitudeSpeed >= 0.0:
                        t2 = testDt
                        
                        # Update the curr values as the later boundary.
                        currDt = t2
                        currTropLongitudeSpeed = testTropLongitudeSpeed
                        currTropLongitude = testTropLongitude
                        currSidLongitude = testSidLongitude
                    else:
                        t1 = testDt

                    currErrorTd = t2 - t1
                        
                # Broke out of while loop, meaning we have a timestamp
                # within our threshold.
                # Create a tuple to add to our list.
                tup = (planetName,
                       Ephemeris.datetimeToJulianDay(currDt),
                       currDt,
                       directStr,
                       currTropLongitude,
                       currSidLongitude)

                # Append to the list.
                rv.append(tup)
                
            elif prevTropLongitudeSpeed > 0.0 and currTropLongitudeSpeed <= 0.0:
                # Crossed over from positive to negative!
                log.debug("Crossed over from positive to negative!")
                
                # This is the upper-bound of the error timedelta.
                t1 = prevDt
                t2 = currDt
                currErrorTd = t2 - t1
                
                # Refine the timestamp until it is less than the
                # desired threshold.
                while currErrorTd > maxErrorTd:
                    log.debug("Refining between {} and {}".\
                              format(Ephemeris.datetimeToStr(t1),
                                     Ephemeris.datetimeToStr(t2)))
                    
                    # Check the timestamp between.
                    diffTd = t2 - t1
                    halfDiffTd = \
                        datetime.\
                        timedelta(days=(diffTd.days / 2.0),
                                  seconds=(diffTd.seconds / 2.0),
                                  microseconds=(diffTd.microseconds / 2.0))
                    testDt = t1 + halfDiffTd
开发者ID:philsong,项目名称:pricechartingtool,代码行数:70,代码来源:calculatePlanetDirectAndRetrograde.py

示例2: getTimestampInfoDataLine

# 需要导入模块: from ephemeris import Ephemeris [as 别名]
# 或者: from ephemeris.Ephemeris import datetimeToJulianDay [as 别名]
def getTimestampInfoDataLine(dt):
    """Takes the timestamp described by the given datetime.datetime,
    and returns a str in CSV format, describing this timestamp.

    Arguments:
    
    dt - datetime.datetime object holding the timestamp of which to
         get information on.

    Returns:
    str in CSV format, holding the information regarding this timestamp.
    The data in this string is:
    
        jd,day,date,time,timezone
        
    """

    # Return value.
    rv = ""
    
    # Field: jd
    rv += "{}".format(Ephemeris.datetimeToJulianDay(dt))
    rv += ","
    
    # Timezone name string, extracted from datetime.tzname().
    # This accounts for the fact that datetime.tzname() can return None.
    datetimeObj = dt
    tznameStr = datetimeObj.tzname()
    if tznameStr == None:
        tznameStr = ""
    dayOfWeekStr = datetimeObj.ctime()[0:3]
    offsetStr = \
        Ephemeris.getTimezoneOffsetFromDatetime(datetimeObj)
    
    # Field: day
    rv += dayOfWeekStr
    rv += ","
    
    # Field: date
    rv += "{:04}-{:02}-{:02}".\
          format(datetimeObj.year,
                 datetimeObj.month,
                 datetimeObj.day)
    #rv += "{:02}/{:02}/{:04}".\
    #      format(datetimeObj.month,
    #             datetimeObj.day,
    #             datetimeObj.year)
    rv += ","
    
    # Field: time
    rv += "{:02}:{:02}:{:02}".\
          format(datetimeObj.hour,
                 datetimeObj.minute,
                 datetimeObj.second)
    rv += ","
    
    # Field: timezone.
    rv += "{}{}".format(tznameStr, offsetStr)
    rv += ","

    # Remove trailing comma.
    rv = rv[:-1]

    return rv
开发者ID:philsong,项目名称:pricechartingtool,代码行数:66,代码来源:createFullSpreadsheetForTacSystem.py

示例3: processPCDD

# 需要导入模块: from ephemeris import Ephemeris [as 别名]
# 或者: from ephemeris.Ephemeris import datetimeToJulianDay [as 别名]
def processPCDD(pcdd, tag):
    """Module for printing generic information about the PriceBars in a
    PriceChartDocumentData object.  The generic information that is
    printed includes:
 
     - Earliest pricebar timestamp as a datetime.datetime and a julian day.
     - Latest   pricebar timestamp as a datetime.datetime and a julian day.
     - highest  pricebar high price.
     - lowest   pricebar low price.

    Arguments:
    pcdd - PriceChartDocumentData object that will be modified.
    tag  - str containing the tag.  The value of this field
           may be "" if a tag is not specified by the user.
           This implementation doesn't use this field.
           
    Returns:
    0 if the changes are to be saved to file.
    1 if the changes are NOT to be saved to file.
    This implementation always returns 1.
    """

    # Return value.
    rv = 1

    # Get the number of PriceBars.
    numPriceBars = len(pcdd.priceBars)
    
    # Get the earliest and latest PriceBar.
    earliestPriceBar = None
    latestPriceBar = None
    lowestPrice = None
    highestPrice = None
    lowestClosePrice = None
    highestClosePrice = None

    for pb in pcdd.priceBars:
        if earliestPriceBar == None:
            earliestPriceBar = pb
        elif pb.timestamp < earliestPriceBar.timestamp:
            earliestPriceBar = pb

        if latestPriceBar == None:
            latestPriceBar = pb
        elif pb.timestamp > latestPriceBar.timestamp:
            latestPriceBar = pb

        if lowestPrice == None:
            lowestPrice = pb.low
        elif pb.low < lowestPrice:
            lowestPrice = pb.low

        if highestPrice == None:
            highestPrice = pb.high
        elif pb.high > highestPrice:
            highestPrice = pb.high
            
        if lowestClosePrice == None:
            lowestClosePrice = pb.close
        elif pb.close < lowestClosePrice:
            lowestClosePrice = pb.close

        if highestClosePrice == None:
            highestClosePrice = pb.close
        elif pb.close > highestClosePrice:
            highestClosePrice = pb.close
            
    log.info("")
    log.info("Number of PriceBars: {}".format(numPriceBars))

    if numPriceBars > 0:

        # Make sure we got values for everything.
        if earliestPriceBar == None or \
               latestPriceBar == None or \
               lowestPrice == None or \
               highestPrice == None or \
               lowestClosePrice == None or \
               highestClosePrice == None:
            
            log.error("PriceBars existed, but we are missing some set values.")
            rv = 1
            return rv
        
        # Convert the datetimes to julian day.
        earliestPriceBarJd = \
            Ephemeris.datetimeToJulianDay(earliestPriceBar.timestamp)
        latestPriceBarJd = \
            Ephemeris.datetimeToJulianDay(latestPriceBar.timestamp)

        # Print the information to log.
        log.info("EarliestPriceBar datetime   == {}".\
                 format(Ephemeris.datetimeToStr(earliestPriceBar.timestamp)))
        log.info("LatestPriceBar   datetime   == {}".\
                 format(Ephemeris.datetimeToStr(latestPriceBar.timestamp)))
        log.info("EarliestPriceBar julian day == {}".format(earliestPriceBarJd))
        log.info("LatestPriceBar   julian day == {}".format(latestPriceBarJd))
        log.info("Lowest  PriceBar LOW   price == {}".format(highestPrice))
        log.info("Highest PriceBar HIGH  price == {}".format(highestPrice))
        log.info("Lowest  PriceBar CLOSE price == {}".format(highestPrice))
#.........这里部分代码省略.........
开发者ID:philsong,项目名称:pricechartingtool,代码行数:103,代码来源:printGenericPriceBarInfo.py

示例4:

# 需要导入模块: from ephemeris import Ephemeris [as 别名]
# 或者: from ephemeris.Ephemeris import datetimeToJulianDay [as 别名]
                # - planetName1SiderealLongitude_Degrees
                # - planetName2SiderealLongitude_Degrees
                # - planetName1SiderealLongitude_ZodiacSignFormat
                # - planetName2SiderealLongitude_ZodiacSignFormat
                # - planetName1SiderealLongitudeLongitudeSpeed
                # - planetName2SiderealLongitudeLongitudeSpeed
                resultList = []

                # Create a tuple for each timestamp that was found
                # that was a conjunction.
                for dt in conjunctionTimestamps:
                    pi1 = Ephemeris.getPlanetaryInfo(planetName1, dt)
                    pi2 = Ephemeris.getPlanetaryInfo(planetName2, dt)
                    
                    tup = (comboPlanetName,
                           Ephemeris.datetimeToJulianDay(dt),
                           dt,
                           desiredAspectDegree,
                           pi1.heliocentric["tropical"]["longitude"],
                           pi2.heliocentric["tropical"]["longitude"],
                           pi1.heliocentric["tropical"]["longitude_speed"],
                           pi2.heliocentric["tropical"]["longitude_speed"],
                           pi1.heliocentric["sidereal"]["longitude"],
                           pi2.heliocentric["sidereal"]["longitude"],
                           pi1.heliocentric["sidereal"]["longitude_speed"],
                           pi2.heliocentric["sidereal"]["longitude_speed"])

                    resultList.append(tup)
                    
                results[comboPlanetName] = resultList
                
开发者ID:philsong,项目名称:pricechartingtool,代码行数:32,代码来源:calculatePlanetHeliocentricConjunctions.py

示例5: processPCDD

# 需要导入模块: from ephemeris import Ephemeris [as 别名]
# 或者: from ephemeris.Ephemeris import datetimeToJulianDay [as 别名]
def processPCDD(pcdd, tag):
    """Module for drawing two veritcal lines (line segments) at 1/3
    and 2/3 of the way through the price chart.  The lines will have a
    tag str matching the given tag parameter.

    Arguments:
    pcdd - PriceChartDocumentData object that will be modified.
    tag  - str containing the tag.  

    Returns:
    0 if the changes are to be saved to file.
    1 if the changes are NOT to be saved to file.
    """

    # Return value.
    rv = 0

    # Check input.
    if tag == None or tag == "":
        log.error("Must specify a non-empty tag str value.")
        rv = 1
        return rv


    # Get the earliest and latest PriceBar.
    earliestPriceBar = None
    latestPriceBar = None
    lowestPrice = None
    highestPrice = None
    
    for pb in pcdd.priceBars:
        if earliestPriceBar == None:
            earliestPriceBar = pb
        elif pb.timestamp < earliestPriceBar.timestamp:
            earliestPriceBar = pb

        if latestPriceBar == None:
            latestPriceBar = pb
        elif pb.timestamp > latestPriceBar.timestamp:
            latestPriceBar = pb

        if lowestPrice == None:
            lowestPrice = pb.low
        elif pb.low < lowestPrice:
            lowestPrice = pb.low

        if highestPrice == None:
            highestPrice = pb.high
        elif pb.high > highestPrice:
            highestPrice = pb.high
            
    if earliestPriceBar == None or \
           latestPriceBar == None or \
           lowestPrice == None or \
           highestPrice == None:
        
        log.info("No pricebars were found in the document.  " + \
                 "Not doing anything.")
        rv = 1
        return rv

    # Convert the datetimes to julian day.
    earliestPriceBarJd = \
        Ephemeris.datetimeToJulianDay(earliestPriceBar.timestamp)
    latestPriceBarJd = \
        Ephemeris.datetimeToJulianDay(latestPriceBar.timestamp)

    log.debug("earliestPriceBar.timestamp == {}".\
              format(Ephemeris.datetimeToStr(earliestPriceBar.timestamp)))
    log.debug("latestPriceBar.timestamp == {}".\
              format(Ephemeris.datetimeToStr(latestPriceBar.timestamp)))

    log.debug("earliestPriceBarJd == {}".format(earliestPriceBarJd))
    log.debug("latestPriceBarJd == {}".format(latestPriceBarJd))

    diff = latestPriceBarJd - earliestPriceBarJd

    jdLine1 = earliestPriceBarJd + (diff / 3)
    jdLine2 = earliestPriceBarJd + ((diff / 3) * 2)

    dtLine1 = Ephemeris.julianDayToDatetime(jdLine1)
    dtLine2 = Ephemeris.julianDayToDatetime(jdLine2)

    log.debug("Creating scene...")

    # Scene for conversion functions.
    scene = PriceBarChartGraphicsScene()

    log.debug("Converting dt to x...")

    line1X = scene.datetimeToSceneXPos(dtLine1)
    line2X = scene.datetimeToSceneXPos(dtLine2)
    
    log.debug("Converting price to y...")

    lowY = scene.priceToSceneYPos(lowestPrice)
    highY = scene.priceToSceneYPos(highestPrice)
    
    log.debug("Creating line1 artifact ...")
    line1Artifact = PriceBarChartLineSegmentArtifact()
#.........这里部分代码省略.........
开发者ID:philsong,项目名称:pricechartingtool,代码行数:103,代码来源:testingAdd2VerticalLines.py

示例6: processPCDD

# 需要导入模块: from ephemeris import Ephemeris [as 别名]
# 或者: from ephemeris.Ephemeris import datetimeToJulianDay [as 别名]
def processPCDD(pcdd, tag):
    """
    Module for printing information about the BirthInfo in a
    PriceChartDocumentData object.  BirthInfo printed includes:
 
     - Birth location name.
     - Birth country name.
     - Birth location coordinates.
     - Birth timestamp as a UTC datetime.datetime
     - Birth timestamp as a julian day.

    Arguments:
    pcdd - PriceChartDocumentData object that will be modified.
    tag  - str containing the tag.  The value of this field
           may be "" if a tag is not specified by the user.
           This implementation doesn't use this field.
           
    Returns:
    0 if the changes are to be saved to file.
    1 if the changes are NOT to be saved to file.
    This implementation always returns 1.
    """

    # Return value.
    rv = 1

    birthInfo = pcdd.birthInfo

    # Convert longitude from a float value to degrees,
    # minutes, seconds and East/West polarity.
    (lonDegrees, lonMinutes, lonSeconds, lonPolarity) = \
        GeoInfo.longitudeToDegMinSec(birthInfo.longitudeDegrees)
    
    # Convert latitude from a float value to degrees, minutes,
    # seconds and North/South polarity.
    (latDegrees, latMinutes, latSeconds, latPolarity) = \
        GeoInfo.latitudeToDegMinSec(birthInfo.latitudeDegrees)
    
    log.info("")
    log.info("Birth location name: {}".format(birthInfo.locationName))
    log.info("Birth location country: {}".format(birthInfo.countryName))
    log.info("Birth location longitude: {} {} {}' {} ({})".\
             format(lonDegrees,
                    lonPolarity,
                    lonMinutes,
                    lonSeconds,
                    birthInfo.longitudeDegrees))
    log.info("Birth location latitude:  {} {} {}' {} ({})".\
             format(latDegrees,
                    latPolarity,
                    latMinutes,
                    latSeconds,
                    birthInfo.latitudeDegrees))

    birthLocalizedDatetime = birthInfo.getBirthLocalizedDatetime()
    birthUtcDatetime = birthInfo.getBirthUtcDatetime()
    birthJd = Ephemeris.datetimeToJulianDay(birthUtcDatetime)
    log.info("Birth timestamp (localized):  {}".\
             format(Ephemeris.datetimeToStr(birthLocalizedDatetime)))
    log.info("Birth timestamp (UTC):        {}".\
             format(Ephemeris.datetimeToStr(birthUtcDatetime)))
    log.info("Birth timestamp (julian day): {}".\
             format(birthJd))
    log.info("")

    rv = 1
    return rv
开发者ID:philsong,项目名称:pricechartingtool,代码行数:69,代码来源:printBirthInfo.py


注:本文中的ephemeris.Ephemeris.datetimeToJulianDay方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。