Exemple #1
0
def start():
    mapper = Mapper()
    reducer = Reducer()

    # Produce a list of all the airports in a csv file with the headings 'Airport Code', and 'Null'
    mapper.setInputFile("./inputFiles/Top30_airports_LatLong.csv")
    mapper.setMapFunction(NoOfFlightsFromAirportsUserCode.mapUnusedAirports)
    reducer.setRedFunction(NoOfFlightsFromAirportsUserCode.redUnusedAirports)
    reducer.setOutputFile("./results/Airports.csv")
    unusedAirports = mapper.run()
    reducer.run(unusedAirports, 'w')

    # Produce a list of all the airports used in the passenger data file in a csv file with the headings 'Airport Code', and 'Number of flights from that airport'
    mapper.setInputFile("./inputFiles/PassengerData.csv")
    mapper.setMapFunction(NoOfFlightsFromAirportsUserCode.mapUsedAirports)
    reducer.setRedFunction(NoOfFlightsFromAirportsUserCode.redUsedAirports)
    usedAirports = mapper.run()
    reducer.run(usedAirports, 'a')

    # Combine the two above results to give a list of all flights from each airport, including those that aren't used
    # Heading titles: 'Airport code', 'No. of flights from that airport'
    mapper.setMapFunction(NoOfFlightsFromAirportsUserCode.mapMakePairs)
    mapper.setInputFile("./results/Airports.csv")
    reducer.setOutputFile("./results/NumberOfFlightsFromEachAirport.csv")
    allAirports = mapper.run()
    reducer.setRedFunction(NoOfFlightsFromAirportsUserCode.redCountFlights)
    reducer.run(allAirports, 'w')

    print(":: Task 1 complete")
def start():
    mapper = Mapper()
    reducer = Reducer()

    mapper.setInputFile("./inputFiles/PassengerData.csv")
    mapper.setMapFunction(CalcDistanceUserCode.mapCalcFlightDistances)
    reducer.setRedFunction(CalcDistanceUserCode.redCalcFlightDistance)
    reducer.setOutputFile("./results/FlightDistances.csv")
    flightDistances = mapper.run()
    reducer.run(flightDistances, 'w')

    mapper.setInputFile("./results/FlightDistances.csv")
    mapper.setMapFunction(CalcDistanceUserCode.mapTotalPassengerDistance)
    reducer.setRedFunction(CalcDistanceUserCode.redTotalPassengerDistance)
    reducer.setOutputFile(
        "./results/TotalDistanceTravelledByEachPassenger.csv")
    passengerDistance = mapper.run()
    reducer.run(passengerDistance, 'w')

    mapper.setInputFile("./results/FlightDistances.csv")
    mapper.setMapFunction(CalcDistanceUserCode.mapDistaces)
    reducer.setRedFunction(CalcDistanceUserCode.redDistances)
    reducer.setOutputFile("./results/DistanceOfEachFlight.csv")
    distances = mapper.run()
    reducer.run(distances, 'w')

    print(":: Task 4 complete")
Exemple #3
0
def start():
    mapper = Mapper()
    reducer = Reducer()

    mapper.setInputFile("./inputFiles/AComp_Passenger_data.csv")
    mapper.setMapFunction(StripErrorsUserCode.mapDuplicates)
    reducer.setRedFunction(StripErrorsUserCode.redWrite)
    reducer.setOutputFile("./inputFiles/PassengerData.csv")
    pairs = mapper.run()
    reducer.run(pairs, 'w')

    mapper.setInputFile("./inputFiles/PassengerData.csv")
    mapper.setMapFunction(StripErrorsUserCode.mapSpelling)
    pairs = mapper.run()
    reducer.run(pairs, 'w')
Exemple #4
0
def main(args):
    # data = make_circles(100, shuffle=True)[0]
    # data = ReadPlyFile('data/bun000.ply').get_data()
    data = ReadPlyFile('data/drill_1.6mm_0_cyb.ply').get_data()

    # data = ReadPlyFile('data/dragonStandRight_0.ply').get_data()

    # print(len(data))

    def filter_norm(point):
        return np.linalg.norm(point - np.array(data).min(0))

    def filter_x(point):
        return point[0]

    mapper = Mapper(data,
                    resolution=0.2,
                    overlap=0.4,
                    cluster_alg='kmeans',
                    max_clusters=5,
                    filter=filter_norm)
    graph = mapper.run()

    print(graph)

    viz = Visualization(graph)
    viz.draw(36, 3000)

    persistence = Persistence(graph)
    persistence.draw()
def start():
    mapper = Mapper()
    reducer = Reducer()

    # Produce a list of all the airports in a csv file with the headings 'Airport Code', and 'Null'
    mapper.setInputFile("./inputFiles/PassengerData.csv")
    mapper.setMapFunction(PassengersOnEachFlightUserCode.mapPassengerToFlight)
    reducer.setRedFunction(PassengersOnEachFlightUserCode.redCountPassengers)
    reducer.setOutputFile("./results/NumberOfPassengersOnEachFlight.csv")
    noPassengers = mapper.run()
    reducer.run(noPassengers, 'w')

    print(":: Task 2 complete")
def start():
    mapper = Mapper()
    reducer = Reducer()

    # Produce a list of all the airports in a csv file with the headings 'Airport Code', and 'Null'
    mapper.setInputFile("./inputFiles/PassengerData.csv")
    mapper.setMapFunction(FlightInformationUserCode.mapReOrder)
    reducer.setRedFunction(FlightInformationUserCode.redCalcFlightInfo)
    reducer.setOutputFile(
        "./results/ListOfFlightsWithDurationAndAllPassengers.csv")
    noPassengers = mapper.run()
    reducer.run(noPassengers, 'w')

    print(":: Task 3 complete")