Example #1
0
def launchEDA():
    form = UploadForm()
    form_EDA = EDAForm()
    if form.validate_on_submit() and 'file' in request.files:
        day = datetime.now().strftime("%A")
        date = datetime.now().strftime("%d")
        month = datetime.now().strftime("%B")
        year = datetime.now().strftime("%Y")
        time = datetime.now().strftime("%H:%M")
        file = request.files.get('file')
        # secure_filename secures any filename before storing into the system
        filename = secure_filename(file.filename)
        # Convert the FileStorage object from the request into a pandas dataframe and parse through the data to
        # get a clean and pandas friendly .csv, then upload it.
        df = pd.read_csv(file)
        df['DATETIME'] = pd.to_datetime(df['DATETIME'])
        plot, plot2 = flapAsymPlot(df)
        plotTitle = plot.title.text
        plotTitle2 = plot2.title.text
        script, div = components(plot)
        script2, div2 = components(plot2)

        if file.filename == '':
            flash('No selected file', 'warning')
            return render_template('flapapp.html',
                                   active='active',
                                   edaLaunchable='true',
                                   title='Flap Event Analysis - Create Report',
                                   form=form,
                                   form_EDA=form_EDA,
                                   username=current_user.username,
                                   day=day,
                                   date=date,
                                   month=month,
                                   year=year,
                                   time=time)

        flash(f'The file {file.filename} was successfully uploaded!',
              'success')
        return render_template('flapapp.html',
                               active='active',
                               edaLaunchable='true',
                               title='Flap Event Analysis - Create Report',
                               div=div,
                               script=script,
                               plotTitle=plotTitle,
                               div2=div2,
                               script2=script2,
                               plotTitle2=plotTitle2,
                               form=form,
                               form_EDA=form_EDA,
                               filename=filename,
                               username=current_user.username,
                               day=day,
                               date=date,
                               month=month,
                               year=year,
                               time=time)

    return redirect(url_for('flapapp'))
Example #2
0
def raw():
    form = UploadForm()
    form_EDA = EDAForm()

    if form.validate_on_submit() and 'file' in request.files:
        day = datetime.now().strftime("%A")
        date = datetime.now().strftime("%d")
        month = datetime.now().strftime("%B")
        year = datetime.now().strftime("%Y")
        time = datetime.now().strftime("%H:%M")
        file = request.files.get('file')
        # secure_filename secures any filename before storing into the system
        filename = secure_filename(file.filename)
        # Convert the FileStorage object from the request into a pandas dataframe and parse through the data to
        # get a clean and pandas friendly .csv, then upload it.
        dfdr_df = DfdrConverter(file, app.config['UPLOAD_FOLDER'], filename,
                                ';')
        dfdr_df.dfdr_tidy()
        clean_dfdr = Clean_dfdr(ac_reg=dfdr_df.ac_reg,
                                flight_no=dfdr_df.flight_no,
                                datetime=dfdr_df.datetime)
        db.session.add(clean_dfdr)
        db.session.commit()
        if file.filename == '':
            flash('No selected file', 'warning')
            return render_template('flapapp.html',
                                   active='active',
                                   edaLaunchable='true',
                                   title='Flap Event Analysis - Create Report',
                                   form=form,
                                   form_EDA=form_EDA,
                                   username=current_user.username,
                                   day=day,
                                   date=date,
                                   month=month,
                                   year=year,
                                   time=time)

        flash(f'The file {file.filename} was successfully uploaded!',
              'success')
        return render_template('flapapp.html',
                               active='active',
                               edaLaunchable='true',
                               title='Flap Event Analysis - Create Report',
                               form=form,
                               form_EDA=form_EDA,
                               filename=filename,
                               username=current_user.username,
                               day=day,
                               date=date,
                               month=month,
                               year=year,
                               time=time)

    return redirect(url_for('flapapp'))
Example #3
0
def flapapp():
    # not passing in the data explicitly as Flask-WTF handles passing form data for us
    form = UploadForm()
    form_EDA = EDAForm()
    form_EDA.registration.choices = [g.ac_reg for g in Clean_dfdr.query.order_by('ac_reg').all()]
    form_EDA.flight_no.choices = [g.flight_no for g in Clean_dfdr.query.order_by('flight_no').all()]
    form_EDA.date.choices = [g.datetime for g in Clean_dfdr.query.order_by('datetime').all()]
    day = datetime.now().strftime("%A")
    date = datetime.now().strftime("%d")
    month = datetime.now().strftime("%B")
    year = datetime.now().strftime("%Y")
    time = datetime.now().strftime("%H:%M")

    return render_template('flapapp.html', active='active', title='Flap Event Analysis - Create Report', form=form, form_EDA=form_EDA, username=current_user.username, day=day, date=date, month=month, year=year, time=time)
Example #4
0
def launchEDA():
    form = UploadForm()
    form_EDA = EDAForm()
    form_EDA.registration.choices = [ (g.ac_reg) for g in Clean_dfdr.query.order_by('ac_reg').all()]
    form_EDA.flight_no.choices = [g.flight_no for g in Clean_dfdr.query.order_by('flight_no').all()]
    form_EDA.date.choices = [g.datetime for g in Clean_dfdr.query.order_by('datetime').all()]
    if form_EDA.validate_on_submit():
        if not form_EDA.download.data:
            day = datetime.now().strftime("%A")
            date = datetime.now().strftime("%d")
            month = datetime.now().strftime("%B")
            year = datetime.now().strftime("%Y")
            time = datetime.now().strftime("%H:%M")
            # Convert the FileStorage object from the request into a pandas dataframe and parse through the data to
            # get a clean and pandas friendly .csv, then upload it.
            if form_EDA.EDA_type.data == 'Asym':
                plot, plot2 = flapAsymPlot(registration=form_EDA.registration.data, flight_no=form_EDA.flight_no.data, date=form_EDA.date.data, output_folder=app.config['UPLOAD_FOLDER'])
                plotTitle = plot.title.text
                plotTitle2 = plot2.title.text
                script, div = components(plot)
                script2, div2 = components(plot2)
                flash(f'Below is your exploratory Flap Asymmetry analysis!', 'success')
                return render_template('flapapp.html', active='active', edaLaunchable='true', title='Flap Event Analysis - Create Report',
                                    div=div, script=script, plotTitle=plotTitle, div2=div2, script2=script2, plotTitle2=plotTitle2,
                                    form=form, form_EDA=form_EDA, username=current_user.username, day=day, date=date, month=month, year=year, time=time)
            else:
                plot, plot2 = stabTrimPlot(registration=form_EDA.registration.data, flight_no=form_EDA.flight_no.data, date=form_EDA.date.data, output_folder=app.config['UPLOAD_FOLDER'])
                plotTitle = plot.title.text
                plotTitle2 = plot2.title.text
                script, div = components(plot)
                script2, div2 = components(plot2)

                flash(f'Below is your exploratory Stabilizer Trim Event analysis!', 'success')
                return render_template('flapapp.html', active='active', edaLaunchable='true', title='Flap Event Analysis - Create Report',
                                    div=div, script=script, plotTitle=plotTitle,  div2=div2, script2=script2, plotTitle2=plotTitle2,
                                    form=form, form_EDA=form_EDA, username=current_user.username, day=day, date=date, month=month, year=year, time=time)
        elif not form_EDA.submit.data:
            clean_dfdr_path = 'uploads\\' + form_EDA.registration.data + '_' + form_EDA.flight_no.data + '_' + form_EDA.date.data + '\\DFDR_Converter\\dfdr_data_tidy.csv'
            return send_file(clean_dfdr_path, as_attachment=True)

    return redirect(url_for('flapapp'))
Example #5
0
def flapapp():
    # not passing in the data explicitly as Flask-WTF handles passing form data for us
    form = UploadForm()
    form_EDA = EDAForm()
    day = datetime.now().strftime("%A")
    date = datetime.now().strftime("%d")
    month = datetime.now().strftime("%B")
    year = datetime.now().strftime("%Y")
    time = datetime.now().strftime("%H:%M")

    return render_template('flapapp.html',
                           active='active',
                           title='Flap Event Analysis - Create Report',
                           form=form,
                           form_EDA=form_EDA,
                           username=current_user.username,
                           day=day,
                           date=date,
                           month=month,
                           year=year,
                           time=time)