def clean_data(): data = acquisition() # we get rid of rows with no price data = data.dropna(subset=["price"]) # we want to analyse AVE prices so this is the only type of train we keep # data["train_type"].value_counts() data = data[data["train_type"] == "AVE"] # As we want the Turista solo plaza H class is for people with a disability we delte all this rows as we want to analyse ordinary tickets to get a more realistic cost for the avg person # data["train_class"].value_counts() data = data[data["train_class"] != "TuristaSólo plaza H"] # we are going to keep only the promo and flexible tickets, the most common type of fares list_values = ["COD.PROMOCIONAL", "Mesa", "Promo +", "Grupos Ida", "4x100"] for col in list_values: data = data[data["fare"] != col] # As we have decided to analyze only trips with origin in Madrid we drop the rest data = data[data["origin"] == "MADRID"] # data["destination"].value_counts() return data
pylab.draw() #Do acquisition #Get 11ms of acquisition samples for fine frequency estimation samplesPerCode = int( round(settings.samplingFreq / (settings.codeFreqBasis / settings.codeLength))) acqSamples = getSamples.int8(settings.fileName, 11 * samplesPerCode, settings.skipNumberOfBytes) if settings.skipAcquisition: print "\nLoading old acquisition results ...", acqResults = pickle.load(open("acqResults.pickle", "rb")) print "done" else: print "\nAcquiring satellites ...", acqResults = acquisition(acqSamples, settings) pickle.dump(acqResults, open("acqResults.pickle", "wb")) # print "done" if settings.plotAcquisition: acqFigure = plotAcquisition(acqResults, settings) pylab.draw() #Do tracking #Find if any satellites were acquired acqSuccessful = False #for i in settings.acqSatelliteList: for i in range(32 - 1, -1, -1): if acqResults[i][0] > settings.acqThreshold: acqSuccessful = True else: #if satellite wasn't found, pop it off the list acqResults.pop(i)
if settings.plotSignal: print "Plotting data", settings.fileName probeFigure = probeData(settings) pylab.draw() #Do acquisition #Get 11ms of acquisition samples for fine frequency estimation samplesPerCode = int(round(settings.samplingFreq / (settings.codeFreqBasis / settings.codeLength))) acqSamples = getSamples.int8(settings.fileName,11*samplesPerCode,settings.skipNumberOfBytes) if settings.skipAcquisition: print "\nLoading old acquisition results ...", acqResults = pickle.load(open("acqResults.pickle","rb")) print "done" else: print "\nAcquiring satellites ...", acqResults = acquisition(acqSamples,settings) pickle.dump(acqResults,open("acqResults.pickle","wb")) # print "done" if settings.plotAcquisition: acqFigure = plotAcquisition(acqResults,settings) pylab.draw() #Do tracking #Find if any satellites were acquired acqSuccessful = False #for i in settings.acqSatelliteList: for i in range(32-1,-1,-1): if acqResults[i][0] > settings.acqThreshold: acqSuccessful = True else: #if satellite wasn't found, pop it off the list acqResults.pop(i)
threshold = 0.05 if len(sys.argv) > 1: threshold = float(sys.argv[1]) firstCfg = Config("First") secondCfg = Config("Second") ### Display title print print "\t\t\t\tProgramme" + Color.BOLD + " MAGELLI" + Color.NORMAL ### ETAPE 1: apprentissage sur un court texte print print "-" * 70 print Color.BOLD + "Entrez un texte de votre choix et terminez en tapant deux fois Entrée :" + Color.NORMAL freq_bs = acquisition(firstCfg) print Color.CYAN + "Fréquence des BACKSPACE: " + str(freq_bs) + Color.NORMAL print "-" * 70 ### ETAPE 2: écriture d'un deuxième texte (identique ou non) print Color.BOLD + "Entrez un deuxième texte (identique ou non) et terminez en tapant deux fois Entrée :" + Color.NORMAL freq_bs = acquisition(secondCfg) print Color.CYAN + "Fréquence des BACKSPACE: " + str(freq_bs) + Color.NORMAL print "-" * 70 print ### ETAPE 3: comparaison des deux (sensibilité variable) inter = firstCfg.intersection(secondCfg) sum = 0 i = 0
def postProcessing(*args, **kwargs): nargin = len(args) ## Initialization ========================================================= print 'Starting processing...' if nargin == 1: settings = args[0] fileNameStr = settings.fileName elif nargin == 2: fileNameStr, settings = args if ~isinstance(fileNameStr, str): raise TypeError('File name must be a string') else: raise Exception('Incorrect number of arguments') try: with open(fileNameStr, 'rb') as fid: # If success, then process the data # Move the starting point of processing. Can be used to start the # signal processing at any point in the data record (e.g. good for long # records or for signal processing in blocks). fid.seek(settings.skipNumberOfBytes, 0) ## Acquisition ============================================================ # Do acquisition if it is not disabled in settings or if the variable # acqResults does not exist. if not settings.skipAcquisition or 'acqResults' not in globals(): # Find number of samples per spreading code samplesPerCode = long( round(settings.samplingFreq / (settings.codeFreqBasis / settings.codeLength))) # frequency estimation data = np.fromfile(fid, settings.dataType, 11 * samplesPerCode) print ' Acquiring satellites...' acqResults = acquisition.acquisition(data, settings) plotAcquisition.plotAcquisition(acqResults) ## Initialize channels and prepare for the run ============================ # Start further processing only if a GNSS signal was acquired (the # field FREQUENCY will be set to 0 for all not acquired signals) if np.any(acqResults.carrFreq): channel = preRun.preRun(acqResults, settings) preRun.showChannelStatus(channel, settings) else: # No satellites to track, exit print 'No GNSS signals detected, signal processing finished.' trackResults = None ## Track the signal ======================================================= startTime = datetime.datetime.now() print ' Tracking started at %s' % startTime.strftime('%X') try: trackResults = np.load('trackingResults_python.npy') except IOError: trackResults, channel = tracking.tracking( fid, channel, settings) np.save('trackingResults_python', trackResults) print ' Tracking is over (elapsed time %s s)' % ( datetime.datetime.now() - startTime).total_seconds() # Auto save the acquisition & tracking results to a file to allow # running the positioning solution afterwards. print ' Saving Acq & Tracking results to file "trackingResults.mat"' ## Calculate navigation solutions ========================================= print ' Calculating navigation solutions...' try: navSolutions = np.load('navSolutions_python.npy') except IOError: navSolutions, eph = postNavigation.postNavigation( trackResults, settings) np.save('navSolutions_python', navSolutions) print ' Processing is complete for this data block' # return # savemat('trackingResults_from_python', # {'trackResults': trackResults, # 'settings': settings, # 'acqResults': acqResults, # 'channel': channel, # 'navSolutions': navSolutions}) ## Plot all results =================================================== print ' Plotting results...' # TODO # turn off tracking plots for now if not settings.plotTracking: plotTracking.plotTracking(range(settings.numberOfChannels), trackResults, settings) plotNavigation.plotNavigation(navSolutions, settings) print 'Post processing of the signal is over.' except IOError as e: # Error while opening the data file. print 'Unable to read file "%s": %s.' % (settings.fileName, e)
threshold = 0.05 if len(sys.argv) > 1 : threshold = float(sys.argv[1]) firstCfg = Config("First") secondCfg = Config("Second") ### Display title print print "\t\t\t\tProgramme" + Color.BOLD + " MAGELLI" + Color.NORMAL ### ETAPE 1: apprentissage sur un court texte print print "-"*70 print Color.BOLD + "Entrez un texte de votre choix et terminez en tapant deux fois Entrée :" + Color.NORMAL freq_bs = acquisition(firstCfg) print Color.CYAN + "Fréquence des BACKSPACE: " + str(freq_bs) + Color.NORMAL print "-"*70 ### ETAPE 2: écriture d'un deuxième texte (identique ou non) print Color.BOLD + "Entrez un deuxième texte (identique ou non) et terminez en tapant deux fois Entrée :" + Color.NORMAL freq_bs = acquisition(secondCfg) print Color.CYAN + "Fréquence des BACKSPACE: " + str(freq_bs) + Color.NORMAL print "-"*70 print ### ETAPE 3: comparaison des deux (sensibilité variable) inter = firstCfg.intersection(secondCfg) sum = 0 i = 0
analysis.male_female_ratio(df) analysis.more_even_country(df) analysis.profitable_work_field(df) analysis.education_ratio(df) else: print('Not a valid number, try again with a choice from 1 to 6!') if __name__ == '__main__': parser = argparse.ArgumentParser(description='Prepare yourself for an analysis of the billionaires of 2018:') requiredNamed = parser.add_argument_group('required named arguments') requiredNamed.add_argument('-a', '--analysis', dest='type_of_analysis', default=None, choices=[1, 2, 3, 4, 5, 6], type=int, help="""1 - To know which country has maximum numbers of billionaires; 2 - To get the male to female ratio based on the total of dollars; 3 - To know which country has the greatest share in terms of total money held by its billionaires; 4 - To get the top 15 most profitable fields of work; 5 - To get the percentage of billionaires with studies; 6 - To get all the above""", required=True) requiredNamed.add_argument('-e', '--email', dest='want_results', default=None, required=True, choices=['y', 'n'], type=str, help="""y - To receive an email with your results; n - Otherwise""") args = parser.parse_args() print('Prepare yourself for an analysis of the billionaires of 2018!') acquisition('df') cleaning('df') webscraping('df') df = pd.read_csv('df') main(args.type_of_analysis) converting.extra_analysis() converting.add_pdf(args.type_of_analysis) sending_email(args.want_results)