本文整理汇总了Python中ephemeris.Ephemeris.datetimeToStr方法的典型用法代码示例。如果您正苦于以下问题:Python Ephemeris.datetimeToStr方法的具体用法?Python Ephemeris.datetimeToStr怎么用?Python Ephemeris.datetimeToStr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ephemeris.Ephemeris
的用法示例。
在下文中一共展示了Ephemeris.datetimeToStr方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: open
# 需要导入模块: from ephemeris import Ephemeris [as 别名]
# 或者: from ephemeris.Ephemeris import datetimeToStr [as 别名]
for planetName in geocentricPlanetNames:
listOfTuplesForPlanet = results[planetName]
for tup in listOfTuplesForPlanet:
planetName = tup[0]
jd = tup[1]
dt = tup[2]
retroOrDirect = tup[3]
geoTropLongitudeOfPlanet = tup[4]
geoSidLongitudeOfPlanet = tup[5]
# Assemble the line that will go into the CSV file.
line = ""
line += "{}".format(planetName) + ","
line += "{}".format(jd) + ","
line += "{}".format(Ephemeris.datetimeToStr(dt)) + ","
line += "{}".format(retroOrDirect) + ","
line += "{}".format(geoTropLongitudeOfPlanet) + ","
line += "{}".format(geoSidLongitudeOfPlanet) + ","
# Remove last trailing comma.
line = line[:-1]
# Append to the output lines.
outputLines.append(line)
# Write outputLines to output file.
with open(outputFilename, "w", encoding="utf-8") as f:
log.info("Writing to output file '{}' ...".format(outputFilename))
示例2: getGeocentricPlanetDirectRetrogradeInfo
# 需要导入模块: from ephemeris import Ephemeris [as 别名]
# 或者: from ephemeris.Ephemeris import datetimeToStr [as 别名]
def getGeocentricPlanetDirectRetrogradeInfo(planetName):
"""
Returns a list of tuples, each tuple containing:
(planetName,
julianDay,
datetime,
"R" or "D",
geoTropLongitudeOfPlanet,
geoSidLongitudeOfPlanet)
"""
# Return value.
rv = []
prevDt = None
currDt = copy.deepcopy(startDt)
prevTropLongitudeSpeed = None
currTropLongitudeSpeed = None
currTropLongitude = None
currSidLongitude = None
while currDt <= endDt:
dt = currDt
pi = Ephemeris.getPlanetaryInfo(planetName, dt)
log.debug("Just obtained planetaryInfo for planet '{}', timestamp: {}".\
format(planetName, Ephemeris.datetimeToStr(dt)))
# Get the geocentric longitude and geocentric longitude speed.
tropLongitudeSpeed = pi.geocentric['tropical']['longitude_speed']
tropLongitude = pi.geocentric['tropical']['longitude']
sidLongitude = pi.geocentric['sidereal']['longitude']
# Store new current planet values.
currTropLongitudeSpeed = tropLongitudeSpeed
currTropLongitude = tropLongitude
currSidLongitude = sidLongitude
log.debug("prevTropLongitudeSpeed={}, currTropLongitudeSpeed={}".\
format(prevTropLongitudeSpeed, currTropLongitudeSpeed))
# We need two data points to proceed.
if prevTropLongitudeSpeed != None and \
currTropLongitudeSpeed != None and \
prevDt != None:
# Check to see if we passed over 0 degrees.
if prevTropLongitudeSpeed < 0.0 and currTropLongitudeSpeed >= 0.0:
# Crossed over from negative to positive!
log.debug("Crossed over from negative to positive!")
# 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
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,
#.........这里部分代码省略.........
示例3: getEphemerisDataLineForDatetime
# 需要导入模块: from ephemeris import Ephemeris [as 别名]
# 或者: from ephemeris.Ephemeris import datetimeToStr [as 别名]
def getEphemerisDataLineForDatetime(dt):
"""Obtains the line of CSV text of planetary position data.
Arguments:
dt - datetime.datetime object with the timestamp seeked.
Returns:
str in CSV format. Since there are a lot of fields, please See the
section of code where we write the header info str for the format.
"""
# Return value.
rv = ""
planetaryInfos = getPlanetaryInfosForDatetime(dt)
log.debug("Just obtained planetaryInfos for timestamp: {}".\
format(Ephemeris.datetimeToStr(dt)))
# Planet geocentric longitude 15-degree axis points.
for planetName in geocentricPlanetNames:
for pi in planetaryInfos:
if pi.name == planetName:
lon = pi.geocentric['tropical']['longitude']
rv += "{:.3f},".format(lon % 15.0)
# Planet geocentric longitude.
for planetName in geocentricPlanetNames:
for pi in planetaryInfos:
if pi.name == planetName:
lon = pi.geocentric['tropical']['longitude']
rv += "{:.3f},".format(lon)
# Planet geocentric longitude in zodiac str format.
for planetName in geocentricPlanetNames:
for pi in planetaryInfos:
if pi.name == planetName:
lon = pi.geocentric['tropical']['longitude']
valueStr = \
AstrologyUtils.\
convertLongitudeToStrWithRasiAbbrev(lon)
rv += valueStr + ","
# Planet heliocentric longitude 15-degree axis points.
for planetName in heliocentricPlanetNames:
for pi in planetaryInfos:
if pi.name == planetName:
lon = pi.heliocentric['tropical']['longitude']
rv += "{:.3f},".format(lon % 15.0)
# Planet heliocentric longitude.
for planetName in heliocentricPlanetNames:
for pi in planetaryInfos:
if pi.name == planetName:
lon = pi.heliocentric['tropical']['longitude']
rv += "{:.3f},".format(lon)
# Planet heliocentric longitude in zodiac str format.
for planetName in heliocentricPlanetNames:
for pi in planetaryInfos:
if pi.name == planetName:
lon = pi.heliocentric['tropical']['longitude']
valueStr = \
AstrologyUtils.\
convertLongitudeToStrWithRasiAbbrev(lon)
rv += valueStr + ","
# Planet declination.
for planetName in declinationPlanetNames:
for pi in planetaryInfos:
if pi.name == planetName:
declination = pi.geocentric['tropical']['declination']
rv += "{:.3f},".format(declination)
# Planet geocentric latitude.
for planetName in geocentricLatitudePlanetNames:
for pi in planetaryInfos:
if pi.name == planetName:
latitude = pi.geocentric['tropical']['latitude']
rv += "{:.3f},".format(latitude)
# Planet heliocentric latitude.
for planetName in heliocentricLatitudePlanetNames:
for pi in planetaryInfos:
if pi.name == planetName:
latitude = pi.heliocentric['tropical']['latitude']
rv += "{:.3f},".format(latitude)
# Remove trailing comma.
rv = rv[:-1]
return rv
示例4: getEarliestTimestampFromData
# 需要导入模块: from ephemeris import Ephemeris [as 别名]
# 或者: from ephemeris.Ephemeris import datetimeToStr [as 别名]
headerLine += "CycleHit2P,CycleHit3P,"
headerLine += tacEphemerisHeaderFields + ","
headerLine += genericEphemerisHeaderFields + ","
# Remove the trailing comma.
headerLine = headerLine[:-1]
# Get the earliest date.
earliestDt = getEarliestTimestampFromData(priceBars,
tacEphemerisData,
cycleHitDates2PlanetSystem,
cycleHitDates3PlanetSystem,
tacEphemerisData)
log.debug("Earliest timestamp in all the files is: {}".\
format(Ephemeris.datetimeToStr(earliestDt)))
latestDt = getLatestTimestampFromData(priceBars,
tacEphemerisData,
cycleHitDates2PlanetSystem,
cycleHitDates3PlanetSystem,
tacEphemerisData)
log.debug("Latest timestamp in all the files is: {}".\
format(Ephemeris.datetimeToStr(latestDt)))
startDt = earliestDt
endDt = latestDt
# Initialize the currDt to the start date. Manually set the hour and
示例5: processPCDD
# 需要导入模块: from ephemeris import Ephemeris [as 别名]
# 或者: from ephemeris.Ephemeris import datetimeToStr [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))
#.........这里部分代码省略.........
示例6: Ephemeris
# 需要导入模块: from ephemeris import Ephemeris [as 别名]
# 或者: from ephemeris.Ephemeris import datetimeToStr [as 别名]
#if __name__ == "__main__":
# Initialize Ephemeris (required).
Ephemeris.initialize()
# Set the Location (required).
Ephemeris.setGeographicPosition(locationLongitude,
locationLatitude,
locationElevation)
# Log the parameters that are being used.
log.info("Location used is: {} (lat={}, lon={})".\
format(locationName, locationLatitude, locationLongitude))
log.info("Timezone used is: {}".format(timezone.zone))
log.info("Start timestamp: {}".format(Ephemeris.datetimeToStr(startDt)))
log.info("End timestamp: {}".format(Ephemeris.datetimeToStr(endDt)))
# Compile the header line text.
headerLine = ""
headerLine += "Date" + ","
headerLine += "Day of week" + ","
headerLine += "Day count" + ","
headerLine += "Week count" + ","
headerLine += "Month count" + ","
# Planet geocentric longitude mod 15.
for planetName in geocentricPlanetNames:
headerLine += "G." + planetName + "%15" + ","
# Planet geocentric longitude.
示例7: processPCDD
# 需要导入模块: from ephemeris import Ephemeris [as 别名]
# 或者: from ephemeris.Ephemeris import datetimeToStr [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()
#.........这里部分代码省略.........
示例8: getLongitudeAspectTimestamps
# 需要导入模块: from ephemeris import Ephemeris [as 别名]
# 或者: from ephemeris.Ephemeris import datetimeToStr [as 别名]
#.........这里部分代码省略.........
pi = Ephemeris.getPlanetaryInfo(planetName, dt)
fieldValue = None
if centricityType.lower() == "geocentric":
fieldValue = pi.geocentric[longitudeType][fieldName]
elif centricityType.lower() == "topocentric":
fieldValue = pi.topocentric[longitudeType][fieldName]
elif centricityType.lower() == "heliocentric":
fieldValue = pi.heliocentric[longitudeType][fieldName]
else:
log.error("Unknown centricity type: {}".\
format(centricityType))
fieldValue = None
unAveragedFieldValues.append(fieldValue)
log.debug("unAveragedFieldValues is: {}".\
format(unAveragedFieldValues))
# Average the field values.
total = 0.0
for v in unAveragedFieldValues:
total += v
averagedFieldValue = total / len(unAveragedFieldValues)
log.debug("averagedFieldValue is: {}".\
format(averagedFieldValue))
return averagedFieldValue
log.debug("Stepping through timestamps from {} to {} ...".\
format(Ephemeris.datetimeToStr(startDt),
Ephemeris.datetimeToStr(endDt)))
currDiff = None
prevDiff = None
while steps[-1] < endDt:
currDt = steps[-1]
prevDt = steps[-2]
log.debug("Looking at currDt == {} ...".\
format(Ephemeris.datetimeToStr(currDt)))
longitudesP1[-1] = \
Util.toNormalizedAngle(\
getFieldValue(currDt, planet1ParamsList, fieldName))
longitudesP2[-1] = \
Util.toNormalizedAngle(\
getFieldValue(currDt, planet2ParamsList, fieldName))
log.debug("{} {} is: {}".\
format(planet1ParamsList, fieldName,
longitudesP1[-1]))
log.debug("{} {} is: {}".\
format(planet2ParamsList, fieldName,
longitudesP2[-1]))
currDiff = Util.toNormalizedAngle(\
longitudesP1[-1] - longitudesP2[-1])
log.debug("prevDiff == {}".format(prevDiff))
log.debug("currDiff == {}".format(currDiff))
示例9: getLongitudeDiffBetweenDatetimes
# 需要导入模块: from ephemeris import Ephemeris [as 别名]
# 或者: from ephemeris.Ephemeris import datetimeToStr [as 别名]
def getLongitudeDiffBetweenDatetimes(planetName,
centricityType,
dt1,
loc1Tuple,
dt2,
loc2Tuple):
startTimestamp = dt1
endTimestamp = dt2
loc1Name = loc1Tuple[0]
loc1Longitude = loc1Tuple[1]
loc1Latitude = loc1Tuple[2]
loc1Elevation = loc1Tuple[3]
loc2Name = loc2Tuple[0]
loc2Longitude = loc2Tuple[1]
loc2Latitude = loc2Tuple[2]
loc2Elevation = loc2Tuple[3]
# maxErrorTd - datetime.timedelta object holding the maximum
# time difference between the exact planetary
# timestamp for the phenomena, and the one
# calculated. This would define the accuracy of
# the calculations.
#
maxErrorTd = datetime.timedelta(seconds=4)
# Size of a circle, in degrees.
#
# Here we define our own value instead of using the value in
# AstrologyUtils.degreesInCircle because it is possible we may
# want to test different sizes of a 'circle'.
circleSizeInDegrees = 360.0
# All references to longitude_speed need to
# be from tropical zodiac measurements! If I use
# sidereal zodiac measurements for getting the
# longitude_speed, then the measurements from the
# Swiss Ephemeris do not yield the correct values.
# I use the following variable in these locations.
zodiacTypeForLongitudeSpeed = "tropical"
tropicalZodiacFlag = True
# Text to set in the text item.
text = ""
# Total number of degrees elapsed.
totalDegrees = 0
Ephemeris.setGeographicPosition(loc1Longitude,
loc1Latitude,
loc1Elevation)
# List of PlanetaryInfo objects for this particular
# planet, sorted by timestamp.
planetData = []
# Step size to use in populating the data list with
# PlanetaryInfos.
#
# The step size should cause the planet to move less
# than 120 degrees in all cases, and idealy much less
# than this, that way we can easily narrow down when
# the planet passes the 0 degree or 360 degree
# threshold, and also so it is easier to narrow down
# when retrograde periods happen. If the step size is
# too large, it is possible that we would miss a whole
# time window of retrograde movement, so discretion
# has to be used in determining what to use for this value.
#
# Here we will set it to 1 day for the default case,
# but if the planet name is a house cusp then shrink
# the step size so we will get the correct resolution.
# Also, if the planet name is an outer planet with a
# large period, we can increase the step size slightly
# to improve performance.
stepSizeTd = datetime.timedelta(days=1)
if Ephemeris.isHouseCuspPlanetName(planetName) or \
Ephemeris.isAscmcPlanetName(planetName):
stepSizeTd = datetime.timedelta(hours=1)
elif planetName == "Jupiter" or \
planetName == "Saturn" or \
planetName == "Neptune" or \
planetName == "Uranus" or \
planetName == "Pluto":
stepSizeTd = datetime.timedelta(days=5)
log.debug("Stepping through from {} to {} ...".\
format(Ephemeris.datetimeToStr(startTimestamp),
Ephemeris.datetimeToStr(endTimestamp)))
# Current datetime as we step through all the
#.........这里部分代码省略.........
示例10: main
# 需要导入模块: from ephemeris import Ephemeris [as 别名]
# 或者: from ephemeris.Ephemeris import datetimeToStr [as 别名]
#.........这里部分代码省略.........
# addVerticalLine(pcdd, dt,
# highPrice, lowPrice, tag, color)
# Calculate the minimum, maximum and average length of time
# between the cycle hit timestamps.
prevDt = None
currDt = None
minimumDiffTd = None
maximumDiffTd = None
averageDiffTd = None
totalDiffTd = datetime.timedelta(0)
for i in range(len(cycleHitTimestamps)):
currDt = cycleHitTimestamps[i]
# We skip calculating the timedelta for the first point
# because we need two timestamps to calcate the timedelta.
if i != 0 and prevDt != None:
diffTd = currDt - prevDt
# Update values if a new minimum or maximum is seen.
if minimumDiffTd == None:
minimumDiffTd = diffTd
elif diffTd < minimumDiffTd:
minimumDiffTd = diffTd
if maximumDiffTd == None:
maximumDiffTd = diffTd
elif diffTd > maximumDiffTd:
maximumDiffTd = diffTd
# Add the diffTd to the total for the average calculation later.
totalDiffTd += diffTd
# Update for next iteration.
prevDt = currDt
currDt = None
# Calculate the average.
if len(cycleHitTimestamps) > 1:
# Convert the timedelta to seconds.
totalDiffSecs = \
(totalDiffTd.microseconds + \
(totalDiffTd.seconds + (totalDiffTd.days * 24 * 3600)) * 10**6) \
/ 10**6
# Compute the average.
averageDiffSec = totalDiffSecs / (len(cycleHitTimestamps) - 1)
log.debug("totalDiffSecs == {}".format(totalDiffSecs))
log.debug("averageDiffSec == {}".format(averageDiffSec))
# Turn the average number of seconds to a timedelta.
averageDiffTd = datetime.timedelta(seconds=averageDiffSec)
# Print information about parameters and cycle hit timestamps that
# were found.
log.info("----------------------------------------------------")
log.info("Ephemeris CSV filename: '{}'".format(inputCsvFilename))
log.info("Ephemeris CSV data column number: {}".format(columnNumber))
log.info("Ephemeris earliest timestamp: {}".\
format(ephemerisEarliestTimestamp))
log.info("Ephemeris latest timestamp: {}".\
format(ephemerisLatestTimestamp))
log.info("Modulus amount: {}".format(modulusAmt))
log.info("Modded hit value: {}".format(moddedHitValue))
log.info("startDt parameter: {}".format(startDt))
log.info("endDt parameter: {}".format(endDt))
#log.info("modifyPcddFlag: {}".format(modifyPcddFlag))
#log.info("highPrice: {}".format(highPrice))
#log.info("lowPrice: {}".format(lowPrice))
log.info("Number of cycle hit points: {}".format(len(cycleHitTimestamps)))
log.info("Smallest timedelta between cycle hit points: {}".\
format(minimumDiffTd))
log.info("Largest timedelta between cycle hit points: {}".\
format(maximumDiffTd))
log.info("Average timedelta between cycle hit points: {}".\
format(averageDiffTd))
# Print the cycle turn points to debug.
if printCycleTurnPointsFlag == True:
log.debug("----------------------------------------------------")
log.debug("Cycle hit points:")
log.debug("----------------------------------------------------")
for dt in cycleHitTimestamps:
log.debug("{} {}".format(Ephemeris.datetimeToStr(dt), tag))
log.debug("----------------------------------------------------")
if modifyPcddFlag == True:
# Save changes.
rv = 0
else:
# Don't save changes.
rv = 1
return rv
示例11: processPCDD
# 需要导入模块: from ephemeris import Ephemeris [as 别名]
# 或者: from ephemeris.Ephemeris import datetimeToStr [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
示例12: getOnePlanetLongitudeAspectTimestamps
# 需要导入模块: from ephemeris import Ephemeris [as 别名]
# 或者: from ephemeris.Ephemeris import datetimeToStr [as 别名]
#.........这里部分代码省略.........
desired.
"""
log.debug("planetParams passed in is: {}".\
format(planetParams))
t = planetParams
planetName = t[0]
centricityType = t[1]
longitudeType = t[2]
pi = Ephemeris.getPlanetaryInfo(planetName, dt)
log.debug("Planet {} has geo sid longitude: {}".\
format(planetName,
pi.geocentric["sidereal"]["longitude"]))
fieldValue = None
if centricityType.lower() == "geocentric":
fieldValue = pi.geocentric[longitudeType][fieldName]
elif centricityType.lower() == "topocentric":
fieldValue = pi.topocentric[longitudeType][fieldName]
elif centricityType.lower() == "heliocentric":
fieldValue = pi.heliocentric[longitudeType][fieldName]
else:
log.error("Unknown centricity type: {}".\
format(centricityType))
fieldValue = None
return fieldValue
log.debug("Stepping through timestamps from {} to {} ...".\
format(Ephemeris.datetimeToStr(startDt),
Ephemeris.datetimeToStr(endDt)))
currDiff = None
prevDiff = None
while steps[-1] < endDt:
currDt = steps[-1]
prevDt = steps[-2]
log.debug("Looking at currDt == {} ...".\
format(Ephemeris.datetimeToStr(currDt)))
longitudesP1[-1] = \
Util.toNormalizedAngle(\
getFieldValue(currDt, planet1Params, fieldName))
longitudesP2[-1] = fixedDegree
log.debug("{} {} is: {}".\
format(planet1Params, fieldName,
longitudesP1[-1]))
log.debug("fixedDegree is: {}".format(longitudesP2[-1]))
currDiff = Util.toNormalizedAngle(\
longitudesP1[-1] - longitudesP2[-1])
log.debug("prevDiff == {}".format(prevDiff))
log.debug("currDiff == {}".format(currDiff))
if prevDiff != None and \
longitudesP1[-2] != None and \
示例13: processSwingFileData
# 需要导入模块: from ephemeris import Ephemeris [as 别名]
# 或者: from ephemeris.Ephemeris import datetimeToStr [as 别名]
#.........这里部分代码省略.........
scanVar = scanVars[i]
scanVarsStr += "{}".format(scanVar)
if i != len(scanVars) - 1:
scanVarsStr += ","
scanVarsStr += "]"
# Get the timestamp of the earliest PriceBar.
earliestPriceBarTimestamp = None
latestPriceBarTimestamp = None
if len(swingFileData.priceBars) > 0:
earliestPriceBarTimestamp = swingFileData.priceBars[0].timestamp
latestPriceBarTimestamp = swingFileData.priceBars[-1].timestamp
# Before we start doing any tagging ourselves, count how many
# PriceBars are already tagged.
count = 0
originalPriceBarsLen = len(swingFileData.priceBars)
for pb in swingFileData.priceBars:
if len(pb.tags) > 0:
count += 1
pb.clearTags()
if count > 0:
log.warn("Before scanning, tagging, and extracting, " + \
"{} out of {} PriceBars already have tags.".\
format(count, originalPriceBarsLen))
log.info("Scanning for highs and lows among {} PriceBars ...".\
format(originalPriceBarsLen))
# Start scanning.
for pb in swingFileData.priceBars:
log.debug("=============================================")
log.debug("Looking at PriceBar with timestamp: {}".\
format(Ephemeris.datetimeToStr(pb.timestamp)))
for scanVar in scanVars:
log.debug("---------------------------------------------")
log.debug("Currently looking at tag: {}".format(scanVar['tag']))
# Calculate the required window size for this scanVar.
requiredWindowSize = (scanVar['param'] * 2) + 1
log.debug("requiredWindowSize == {}".format(requiredWindowSize))
# Alias for the window.
window = scanVar['window']
log.debug("Before appending PriceBar, len(window) == {}".\
format(len(window)))
# Index into the window, pointing to the PriceBar
# currently being inspected for a high or low.
currIndex = scanVar['param']
log.debug("currIndex == {}".format(currIndex))
# Append the PriceBar.
window.append(pb)
# If the size of the window is now larger than the
# required size, then shrink it appropriately.
while len(window) > requiredWindowSize:
# Drop the PriceBar at the beginning of the window.
window = window[1:]
# If the size of the window is not large enough, don't do
# any checks for a high or low yet.
if len(window) < requiredWindowSize:
continue