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


Python ephemeris.Ephemeris类代码示例

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


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

示例1: shutdown

def shutdown(rc):
    """Exits the script, but first flushes all logging handles, etc."""
    
    # Close the Ephemeris so it can do necessary cleanups.
    Ephemeris.closeEphemeris()
    
    logging.shutdown()
    
    sys.exit(rc)
开发者ID:philsong,项目名称:pricechartingtool,代码行数:9,代码来源:calculatePlanetDirectAndRetrograde.py

示例2: shutdown

def shutdown(rc):
    """Exits the script, but first flushes all logging handles, etc."""

    global taskQueue
    global numProcesses
    
    Ephemeris.closeEphemeris()

    # Tell spawned processes to end.
    for i in range(numProcesses):
        taskQueue.put("STOP")
    
    logging.shutdown()
    sys.exit(rc)
开发者ID:philsong,项目名称:pricechartingtool,代码行数:14,代码来源:generatePcdFilesWithAspectLines.py

示例3: getPlanetsForDatetimeAndTimezone

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,代码行数:48,代码来源:calculatePlanetLocationsAndDifferences.py

示例4: formatToDateAndDetailedTimeStr

def formatToDateAndDetailedTimeStr(datetimeObj):
    """Returns a string representation of a datetime.datetime object.
    Normally we wouldn't need to do this, but the datetime.strftime()
    does not work on years less than 1900. 

    Arguments:
    datetimeObj - datetime.datetime object with a tzinfo defined.

    Returns:
    String holding the info about the datetime.datetime object, in 
    the datetime.strftime() format:  "%Y-%m-%d %H:%M:%S %Z%z"
    """

    # Timezone name string, extracted from datetime.tzname().
    # This accounts for the fact that datetime.tzname() can return None.
    tznameStr = datetimeObj.tzname()
    if tznameStr == None:
        tznameStr = ""

    # Return the formatted string.
    return "{:04}-{:02}-{:02} {:02}:{:02} {}{}".\
        format(datetimeObj.year,
               datetimeObj.month,
               datetimeObj.day,
               datetimeObj.hour,
               datetimeObj.minute,
               tznameStr,
               Ephemeris.getTimezoneOffsetFromDatetime(datetimeObj))
开发者ID:philsong,项目名称:pricechartingtool,代码行数:28,代码来源:createGenericEphemerisSpreadsheet.py

示例5: getFieldValue

    def getFieldValue(dt, planetParams, fieldName):
        """Creates the PlanetaryInfo object for the given
        planetParamsList and returns the value of the field
        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
开发者ID:philsong,项目名称:pricechartingtool,代码行数:34,代码来源:createGenericEphemerisSpreadsheet.py

示例6: __init__

    def __init__(self, config_file_path):
        print("PyG V 0.0.1 .. ")
        # Déclaration des variables d'analyse

        self.coord_pivot = [0.0, 0.0, 0.0]
        self.coord_mobile = [0.0, 0.0, 0.0]
        self.seuil_snr = 0
        self.seuil_elev_sat = 0
        self.nav_data_file = ""
        self.obs_data_file = []
        self.obs = [] # Tableau contient les observations par cube
        self.dd = [] # Structure contient les DD par cube

        self.parseConfigFile(config_file_path)


        self.eph = Ephemeris(self.nav_data_file)

        # Instanciation des Geocubes en utilisant la liste des paths renseignée dans le fichier de conf.
        for i in range(0,len(self.obs_data_file)):
            self.obs.append(Geocube(self.obs_data_file[i]))

        #self.cleanObservations()
        print("SEUIL SNR: "+str(self.seuil_snr)+"\n")
        print("SEUIL ELEVATION SATELLITE: " + str(self.seuil_elev_sat) + "\n")
        print("OBS FILE LIST: "+ str(self.obs_data_file) +"\n")
        self.buildDoubleDifferences()
开发者ID:mohamedamjad,项目名称:UBLOXlib,代码行数:27,代码来源:analyzer.py

示例7: processPCDD

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,代码行数:58,代码来源:printPriceTimeInfoDatetimes.py

示例8: processPCDD

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,代码行数:101,代码来源:printGenericPriceBarInfo.py

示例9: getLongitudeAspectTimestamps


#.........这里部分代码省略.........
    for planetTuple in planet1ParamsList + planet2ParamsList:
        if len(planetTuple) != 3:
            log.error("Input error: " + \
                      "Not enough values given in planet tuple.")
            return None

        planetName = planetTuple[0]
        centricityType = planetTuple[1]
        longitudeType = planetTuple[2]
            
        loweredCentricityType = centricityType.lower()
        if loweredCentricityType != "geocentric" and \
            loweredCentricityType != "topocentric" and \
            loweredCentricityType != "heliocentric":

            log.error("Invalid input: Centricity type is invalid.  " + \
                  "Value given was: {}".format(centricityType))
            return None

        # Check inputs for longitude type.
        loweredLongitudeType = longitudeType.lower()
        if loweredLongitudeType != "tropical" and \
            loweredLongitudeType != "sidereal":

            log.error("Invalid input: Longitude type is invalid.  " + \
                  "Value given was: {}".format(longitudeType))
            return None
            
    # Field name we are getting.
    fieldName = "longitude"
        
    # Initialize the Ephemeris with the birth location.
    log.debug("Setting ephemeris location ...")
    Ephemeris.setGeographicPosition(locationLongitude,
                                    locationLatitude,
                                    locationElevation)

    # Set the step size.
    stepSizeTd = datetime.timedelta(days=1)
    for planetTuple in planet1ParamsList + planet2ParamsList:
        planetName = planetTuple[0]
            
        if Ephemeris.isHouseCuspPlanetName(planetName) or \
           Ephemeris.isAscmcPlanetName(planetName):
                
            # House cusps and ascmc planets need a smaller step size.
            stepSizeTd = datetime.timedelta(hours=1)
        elif planetName == "Moon":
            # Use a smaller step size for the moon so we can catch
            # smaller aspect sizes.
            stepSizeTd = datetime.timedelta(hours=3)
        
    log.debug("Step size is: {}".format(stepSizeTd))
        
    # Desired angles.  We need to check for planets at these angles.
    desiredAngleDegList = []

    desiredAngleDeg1 = Util.toNormalizedAngle(degreeDifference)
    desiredAngleDegList.append(desiredAngleDeg1)
    if Util.fuzzyIsEqual(desiredAngleDeg1, 0):
        desiredAngleDegList.append(360)
        
    if uniDirectionalAspectsFlag == False:
        desiredAngleDeg2 = \
            360 - Util.toNormalizedAngle(degreeDifference)
        if desiredAngleDeg2 not in desiredAngleDegList:
开发者ID:philsong,项目名称:pricechartingtool,代码行数:67,代码来源:calculatePlanetHeliocentricConjunctions.py

示例10: getOnePlanetLongitudeAspectTimestamps


#.........这里部分代码省略.........
              format(planet1Params))
    log.debug("fixedDegree passed in is: {}".\
              format(fixedDegree))

    # Check inputs of planet parameters.
    planetName = planet1Params[0]
    centricityType = planet1Params[1]
    longitudeType = planet1Params[2]

    # Check inputs for centricity type.
    loweredCentricityType = centricityType.lower()
    if loweredCentricityType != "geocentric" and \
        loweredCentricityType != "topocentric" and \
        loweredCentricityType != "heliocentric":

        log.error("Invalid input: Centricity type is invalid.  " + \
                  "Value given was: {}".format(centricityType))
        return None
        
    # Check inputs for longitude type.
    loweredLongitudeType = longitudeType.lower()
    if loweredLongitudeType != "tropical" and \
        loweredLongitudeType != "sidereal":

        log.error("Invalid input: Longitude type is invalid.  " + \
                  "Value given was: {}".format(longitudeType))
        return None

    # Field name we are getting.
    fieldName = "longitude"
        
    # Initialize the Ephemeris with the birth location.
    log.debug("Setting ephemeris location ...")
    Ephemeris.setGeographicPosition(locationLongitude,
                                    locationLatitude,
                                    locationElevation)

    # Set the step size.
    stepSizeTd = datetime.timedelta(days=1)

    planetName = planet1Params[0]
        
    if Ephemeris.isHouseCuspPlanetName(planetName) or \
        Ephemeris.isAscmcPlanetName(planetName):
                
        # House cusps and ascmc planets need a smaller step size.
        stepSizeTd = datetime.timedelta(hours=1)
    elif planetName == "Moon":
        # Use a smaller step size for the moon so we can catch
        # smaller aspect sizes.
        stepSizeTd = datetime.timedelta(hours=3)
        
    log.debug("Step size is: {}".format(stepSizeTd))
        
    # Desired angles.  We need to check for planets at these angles.
    desiredAngleDegList = []
        
    desiredAngleDeg1 = Util.toNormalizedAngle(degreeDifference)
    desiredAngleDegList.append(desiredAngleDeg1)
    if Util.fuzzyIsEqual(desiredAngleDeg1, 0):
        desiredAngleDegList.append(360)
        
    if uniDirectionalAspectsFlag == False:
        desiredAngleDeg2 = \
            360 - Util.toNormalizedAngle(degreeDifference)
        if desiredAngleDeg2 not in desiredAngleDegList:
开发者ID:philsong,项目名称:pricechartingtool,代码行数:67,代码来源:createGenericEphemerisSpreadsheet.py

示例11: shutdown

    shutdown(1)
else:
    log.debug("options.outputPcdFile == {}".format(options.outputPcdFile))
    outputPcdFile = os.path.abspath(options.outputPcdFile)
    log.debug("outputPcdFile == {}".format(outputPcdFile))

    if os.path.exists(outputPcdFile) and os.path.isfile(outputPcdFile):
        log.debug("The outputPcdFile path exists, and it is a file.")
    else:
        log.error("The output PCD file either does not exist or is not a file.")
        shutdown(1)
        
##############################################################################

# Initialize Ephemeris (required).
Ephemeris.initialize()

# Set application details so the we can use QSettings default
# constructor later.
appAuthor = "Ryan Luu"
appName = "PriceChartingTool"
QCoreApplication.setOrganizationName(appAuthor)
QCoreApplication.setApplicationName(appName)

# Create the Qt application.
app = QApplication(sys.argv)
app.setApplicationName(appName)

# Open the input PriceChartDocument files.
log.info("Loading input template PriceChartDocument '{}' ...".\
         format(inputTemplatePcdFile))
开发者ID:philsong,项目名称:pricechartingtool,代码行数:31,代码来源:copyAndAppendArtifacts.py

示例12: range

            rv = ""
            for i in range(len(fieldValues)):
                rv += ","

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


##############################################################################

#if __name__ == "__main__":
    
# Initialize Ephemeris (required).
Ephemeris.initialize()

# Set the Location (required).
Ephemeris.setGeographicPosition(locationLongitude,
                                locationLatitude,
                                locationElevation)

# Get the pricebar data as a list of PriceBar objects.

# List of PriceBar objects.
priceBars = []

inputFilename = priceBarDataCsvFilename
linesToSkip = priceBarDataCsvFileLinesToSkip
try: 
    with open(inputFilename, "r") as f:
开发者ID:philsong,项目名称:pricechartingtool,代码行数:31,代码来源:createFullSpreadsheetForTacSystem.py

示例13: filterOutNonsensicalValues

def filterOutNonsensicalValues(planetaryInfo):
    """Here we will do some filtering on the given PlanetaryInfo
    object.  We will be setting some values to None so that the
    field will end up being blank on the table, where it makes
    sense to do so.
    
    Returns:
    PlanetaryInfo with some fields set to None.
    """
    
    p = planetaryInfo
    
    tropical = "tropical"
    sidereal = "sidereal"
    
    if Ephemeris.isHouseCuspPlanetName(p.name) or \
           Ephemeris.isAscmcPlanetName(p.name):
        
        p.geocentric[tropical]['longitude_speed'] = None
        p.geocentric[tropical]['declination'] = None
        p.geocentric[tropical]['declination_speed'] = None
        p.geocentric[tropical]['latitude'] = None
        p.geocentric[tropical]['latitude_speed'] = None
        p.geocentric[sidereal]['longitude_speed'] = None
        p.geocentric[sidereal]['declination'] = None
        p.geocentric[sidereal]['declination_speed'] = None
        p.geocentric[sidereal]['latitude'] = None
        p.geocentric[sidereal]['latitude_speed'] = None
        
        p.heliocentric[tropical]['longitude'] = None
        p.heliocentric[tropical]['longitude_speed'] = None
        p.heliocentric[tropical]['declination'] = None
        p.heliocentric[tropical]['declination_speed'] = None
        p.heliocentric[tropical]['latitude'] = None
        p.heliocentric[tropical]['latitude_speed'] = None
        
        p.heliocentric[sidereal]['longitude'] = None
        p.heliocentric[sidereal]['longitude_speed'] = None
        p.heliocentric[sidereal]['declination'] = None
        p.heliocentric[sidereal]['declination_speed'] = None
        p.heliocentric[sidereal]['latitude'] = None
        p.heliocentric[sidereal]['latitude_speed'] = None
        
    elif p.name == "Sun":
        
        p.heliocentric[tropical]['longitude'] = None
        p.heliocentric[tropical]['longitude_speed'] = None
        p.heliocentric[tropical]['declination'] = None
        p.heliocentric[tropical]['declination_speed'] = None
        p.heliocentric[tropical]['latitude'] = None
        p.heliocentric[tropical]['latitude_speed'] = None
        
        p.heliocentric[sidereal]['longitude'] = None
        p.heliocentric[sidereal]['longitude_speed'] = None
        p.heliocentric[sidereal]['declination'] = None
        p.heliocentric[sidereal]['declination_speed'] = None
        p.heliocentric[sidereal]['latitude'] = None
        p.heliocentric[sidereal]['latitude_speed'] = None
        
    elif p.name == "MeanNorthNode" or \
             p.name == "TrueNorthNode" or \
             p.name == "MeanLunarApogee" or \
             p.name == "OsculatingLunarApogee" or \
             p.name == "InterpolatedLunarApogee" or \
             p.name == "InterpolatedLunarPerigee":
        
        if p.name == "MeanNorthNode" or \
               p.name == "TrueNorthNode":

            p.geocentric[tropical]['latitude'] = None
            p.geocentric[tropical]['latitude_speed'] = None
            
            p.geocentric[sidereal]['latitude'] = None
            p.geocentric[sidereal]['latitude_speed'] = None
            
        p.heliocentric[tropical]['longitude'] = None
        p.heliocentric[tropical]['longitude_speed'] = None
        p.heliocentric[tropical]['declination'] = None
        p.heliocentric[tropical]['declination_speed'] = None
        p.heliocentric[tropical]['latitude'] = None
        p.heliocentric[tropical]['latitude_speed'] = None
        
        p.heliocentric[sidereal]['longitude'] = None
        p.heliocentric[sidereal]['longitude_speed'] = None
        p.heliocentric[sidereal]['declination'] = None
        p.heliocentric[sidereal]['declination_speed'] = None
        p.heliocentric[sidereal]['latitude'] = None
        p.heliocentric[sidereal]['latitude_speed'] = None
        
    elif p.name == "Earth":
        
        p.geocentric[tropical]['longitude'] = None
        p.geocentric[tropical]['longitude_speed'] = None
        p.geocentric[tropical]['declination'] = None
        p.geocentric[tropical]['declination_speed'] = None
        p.geocentric[tropical]['latitude'] = None
        p.geocentric[tropical]['latitude_speed'] = None
        
        p.geocentric[sidereal]['longitude'] = None
        p.geocentric[sidereal]['longitude_speed'] = None
#.........这里部分代码省略.........
开发者ID:philsong,项目名称:pricechartingtool,代码行数:101,代码来源:swingFileToCsvFiles.py

示例14: main


#.........这里部分代码省略.........
    #        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
开发者ID:philsong,项目名称:pricechartingtool,代码行数:101,代码来源:get3PlanetCycleHitDates.py

示例15: processPCDD

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,代码行数:67,代码来源:printBirthInfo.py


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