本文整理汇总了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
示例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
示例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