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


Python Ephemeris.datetimeToDayStr方法代码示例

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


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

示例1: processPCDD

# 需要导入模块: from ephemeris import Ephemeris [as 别名]
# 或者: from ephemeris.Ephemeris import datetimeToDayStr [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

    # List of tuples of the form (datetime.datetime, price).
    priceTimeInfoTupleList = []

    # Counting the number of PriceBarChartPriceTimeInfoArtifact objects.
    numPriceTimeInfoArtifacts = 0

    # Scene used for datetime and price conversions.
    scene = PriceBarChartGraphicsScene()
    
    artifacts = pcdd.priceBarChartArtifacts

    for artifact in artifacts:
        if isinstance(artifact, PriceBarChartPriceTimeInfoArtifact):
            numPriceTimeInfoArtifacts += 1

            infoPointF = artifact.getInfoPointF()
            dt = scene.sceneXPosToDatetime(infoPointF.x())
            price = scene.sceneYPosToPrice(infoPointF.y())

            priceTimeInfoTupleList.append((dt, price))

    # Sort by timestamp, because when obtained they might not be in order:
    sortedPriceTimeInfoTupleList = sorted(priceTimeInfoTupleList,
                                          key=lambda tup: tup[0])

    # Print out the timestamps and price.
    for tup in sortedPriceTimeInfoTupleList:
        dt = tup[0]
        price = tup[1]
        log.info("{},{}".format(Ephemeris.datetimeToDayStr(dt), price))
    
    rv = 1
    return rv
开发者ID:philsong,项目名称:pricechartingtool,代码行数:60,代码来源:printPriceTimeInfoDatetimes.py

示例2: getPlanetsForDatetimeAndTimezone

# 需要导入模块: from ephemeris import Ephemeris [as 别名]
# 或者: from ephemeris.Ephemeris import datetimeToDayStr [as 别名]
def getPlanetsForDatetimeAndTimezone(dt, locTuple):
    """Returns a string with the planet longitude position for the given
    datetime and timezone.
    """

    locName = locTuple[0]
    locLongitude = locTuple[1]
    locLatitude = locTuple[2]
    locElevation = locTuple[3]

    # Set the Location (required).
    Ephemeris.setGeographicPosition(locLongitude,
                                    locLatitude,
                                    locElevation)

    longitudeType = "tropical"
    fieldName = "longitude"

    rv = "For datetime: " + Ephemeris.datetimeToDayStr(dt) + \
         ", location: " + locName + endl

    
    for planetName in geocentricPlanetNames:
        pi = Ephemeris.getPlanetaryInfo(planetName, dt)

        longitude = pi.geocentric[longitudeType][fieldName]
                           
        # Format differently for lunation phase of G.MoSu.
        if planetName == "MoSu":
            rv += "  {: <14}".format("G." + planetName + ": ") + \
                  "{:>.3f}".format(longitude) + \
                  "    Phase (of max 30): {:.2f}".format(longitude / 12.0) + \
                  endl
        else:
            rv += "  {: <14}".format("G." + planetName + ": ") + \
                  "{:>.3f}".format(longitude) + \
                  endl

    rv += endl
        
    for planetName in heliocentricPlanetNames:
        pi = Ephemeris.getPlanetaryInfo(planetName, dt)

        rv += "  {: <14}".format("H." + planetName + ": ") + \
              "{:>.3f}".format(pi.heliocentric[longitudeType][fieldName]) + \
              endl
        
    return rv
开发者ID:philsong,项目名称:pricechartingtool,代码行数:50,代码来源:calculatePlanetLocationsAndDifferences.py

示例3: getPlanetDiffsForDatetimes

# 需要导入模块: from ephemeris import Ephemeris [as 别名]
# 或者: from ephemeris.Ephemeris import datetimeToDayStr [as 别名]
def getPlanetDiffsForDatetimes(dt1,
                               loc1Tuple,
                               dt2,
                               loc2Tuple):
    """Returns a string with the planet longitude differences between the given
    datetimes and location.
    """

    loc1Name = loc1Tuple[0]
    loc1Longitude = loc1Tuple[1]
    loc1Latitude = loc1Tuple[2]
    loc1Elevation = loc1Tuple[3]

    loc2Name = loc2Tuple[0]
    loc2Longitude = loc2Tuple[1]
    loc2Latitude = loc2Tuple[2]
    loc2Elevation = loc2Tuple[3]


    longitudeType = "tropical"
    fieldName = "longitude"

    rv = "Between datetime: " + Ephemeris.datetimeToDayStr(dt1) + \
         ", location: " + loc1Name + " and " + endl
    rv += "        datetime: " + Ephemeris.datetimeToDayStr(dt2) + \
         ", location: " + loc2Name + endl


    calendarDayDiff = dt2 - dt1
    rv += "  Diff calendar days: {}".format(calendarDayDiff) + endl
    
    for planetName in geocentricPlanetNames:

        longitudeDiff = getLongitudeDiffBetweenDatetimes(planetName,
                                                         "geocentric",
                                                         dt1,
                                                         loc1Tuple,
                                                         dt2,
                                                         loc2Tuple)
        longitudeDiffFullRevs = int(longitudeDiff // 360)
        longitudeDiffMod360 = longitudeDiff % 360
        
        # Format differently for lunation phase of G.MoSu.
        if planetName == "MoSu":
            rv += "  {: <16}".format("Diff G." + planetName + ": ") + \
                  "{:>10.3f}".format(longitudeDiff) + \
                  "    or  {:>4} rev + {:>7.3f} deg".format(longitudeDiffFullRevs,
                                                            longitudeDiffMod360) + \
                  "     PhaseCountTotal: {:.2f}, Phase (of max 30): {:.2f}".\
                  format(longitudeDiff / 12.0, longitudeDiffMod360 / 12.0) + \
                  endl
        else:
            rv += "  {: <16}".format("Diff G." + planetName + ": ") + \
                  "{:>10.3f}".format(longitudeDiff) + \
                  "    or  {:>4} rev + {:>7.3f} deg".format(longitudeDiffFullRevs,
                                                            longitudeDiffMod360) + \
                  endl
            
    rv += endl
        
    for planetName in heliocentricPlanetNames:

        longitudeDiff = getLongitudeDiffBetweenDatetimes(planetName,
                                                         "heliocentric",
                                                         dt1,
                                                         loc1Tuple,
                                                         dt2,
                                                         loc2Tuple)
        longitudeDiffFullRevs = int(longitudeDiff // 360)
        longitudeDiffMod360 = longitudeDiff % 360
        
        rv += "  {: <16}".format("Diff H." + planetName + ": ") + \
              "{:>10.3f}".format(longitudeDiff) + \
              "    or  {:>4} rev + {:>7.3f} deg".format(longitudeDiffFullRevs,
                                                        longitudeDiffMod360) + \
              endl
        
    return rv
开发者ID:philsong,项目名称:pricechartingtool,代码行数:80,代码来源:calculatePlanetLocationsAndDifferences.py


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