예제 #1
0
def main(input_file, output_directory):

    f1 = '/Users/Will/Documents/FDL/results/parsed_clima_initial.csv'
    f2 = '/Users/Will/Documents/FDL/results/parsed_clima_final.csv'

    print('Read clima into dataframe ...')
    # synthetic feature
    clima_dataframe = pd.read_csv(input_file)
    clima_dataframe['atm'] = clima_dataframe['P'] * 0.986923
    print(clima_dataframe)
    print('Make plot...')

    pressure = Axis('P', 'Pressure', 'bar')
    atmospheres = Axis('atm', 'Pressure', 'atm')
    altitude = Axis('ALT', 'Altitude', 'km')
    temperature = Axis('T', 'Temperature', 'K')

    #plot_clima_profile(clima_dataframe, xaxis=pressure, yaxis=altitude, output_directory=output_directory)
    plot_clima_profile(clima_dataframe,
                       xaxis=atmospheres,
                       yaxis=altitude,
                       output_directory=output_directory)
    plot_clima_profile(clima_dataframe,
                       xaxis=temperature,
                       yaxis=altitude,
                       output_directory=output_directory)
예제 #2
0
    def __init__(self, widget, plotbackground, height, width):
        """ Creates the graph object. You have to pack or grid it yourself. You
            can add bindings onto it however you want. """

        # default axis size
        self.axisSize = 50

        self.graphwidth = width - self.axisSize
        self.graphheight = height - self.axisSize
        self.ylogscale = 0  # can be changed with a call to yaxis_configure

        self.graphframe = Frame(widget)

        self.graph = Canvas(self.graphframe,
                            bg=plotbackground,
                            borderwidth=0,
                            highlightthickness=0,
                            height=self.graphheight,
                            width=self.graphwidth,
                            cursor='crosshair')
        self.graph.grid(row=0, column=1, sticky=N + W)

        # add the 2 axis
        # flip = 1 so positive numbers go up, not down
        self.yaxis = Axis(self.graphframe,
                          lowestValue=None,
                          highestValue=None,
                          height=self.graphheight,
                          width=self.axisSize,
                          side="left",
                          flip=1,
                          logscale=self.ylogscale)
        self.yaxis.grid(row=0, column=0, sticky=N + W + E + S)

        self.xaxis = Axis(self.graphframe,
                          lowestValue=None,
                          highestValue=None,
                          width=self.graphwidth,
                          height=self.axisSize,
                          side="bottom")
        self.xaxis.grid(row=1, column=1, sticky=N + W + E + S)

        # Make sure the main image will collapse before anything else
        self.graphframe.grid_rowconfigure(0, weight=1)
        self.graphframe.grid_columnconfigure(1, weight=1)

        # allow the graph to be resized
        self.graphframe.bind("<Configure>", self.resize)
예제 #3
0
def plot_fluxes(df):

    # find min/max of a set of c
    gases = ['CH4', 'CO', 'O2', 'H2', 'O', 'O3']
    gases = ['CO', 'O2', 'H2O', 'H2']
    gases = ['O2']
    gases = ['CH4']

    maximum = find_set_maximum(df, gases)
    minimum = find_set_minimum(df, gases)
    print(minimum, maximum)

    for g in gases:
        gas = Axis(g, 'Flux', 'molecules s$^{-1}$ cm$^{-2}$')
        plot_profile(df, gas, altitude)

    plt.legend()
    plt.xlim(xmin=minimum, xmax=maximum)
    plt.savefig('fluxes.pdf')

    plt.xscale('symlog')
    plt.savefig('fluxes_symlog.pdf')

    plt.xscale('log')
    plt.savefig('fluxes_log.pdf')

    # clear plot
    plt.clf()
예제 #4
0
def main():

    dd = DataDecoder()
    level = LevelFilter()
    fil = LowPassFilter()
    serv = UdpServer()

    fig = plt.figure()

    dd.on_data.add(fil)
    fil.on_data.add(level)

    rows = 3
    cols = 1
    i = 1
    for f in ('x', 'y', 'z'):
        ax = Axis(fig, [rows, cols, i], dt=1, maxt=100)
        dd.on_data.add(ax)

        line = PlotLine(f, color='b')
        dd.on_data.add(line)
        ax.add_line(line)

        linef = PlotLine(f, color='r')
        fil.on_data.add(linef)
        ax.add_line(linef)

        linef = PlotLine(f, color='g')
        level.on_data.add(linef)
        ax.add_line(linef)

        i = i + 1
        pass

    dd_saver = DataSaver('dd')
    dd.on_data.add(dd_saver)
    fil_saver = DataSaver('fil')
    fil.on_data.add(fil_saver)
    lev_saver = DataSaver('lev')
    level.on_data.add(lev_saver)

    serv.on_read.add(dd)

    plt.ion()
    plt.plot()
    plt.draw()

    tk_win = fig.canvas._master
    tksupport.install(tk_win)

    def close_ev():
        while True:
            print 'bye'

    fig.canvas.mpl_connect('close_event', close_ev)

    reactor.run()

    pass
예제 #5
0
def read(name, filein):

    tmp = filein[name]

    axlist = []
    axes = []
    for ax in tmp.dimensions:
        try:
            axes.append(
                Axis(ax,
                     filein[ax][:],
                     name=filein[ax].long_name,
                     units=filein[ax].units))
        except AttributeError:
            axes.append(Axis(ax, filein[ax][:], units=filein[ax].units))
        except:
            raise

        axlist.append(ax)

    try:
        varout = Variable(name,
                          data=tmp[:],
                          name=tmp.long_name,
                          units=tmp.units,
                          axes=axes,
                          axlist=axlist)
    except AttributeError:
        varout = Variable(name,
                          data=tmp[:],
                          units=tmp.units,
                          axes=axes,
                          axlist=axlist)
    except:
        raise

    return varout
예제 #6
0
def plot_mixing_ratios(df):

    gases = ['CH4', 'CO', 'O2', 'H2']
    gases = ['CO', 'O2', 'H2O', 'H2']
    gases = ['O2']
    maximum = find_set_maximum(df, gases)
    minimum = find_set_minimum(df, gases)
    print(minimum, maximum)

    for g in gases:
        gas = Axis(g, 'Mixing ratio')
        plot_profile(df, gas, altitude)
    plt.legend()
    plt.xlim(xmin=minimum, xmax=maximum)
    plt.savefig('mixing_ratios.pdf')
    plt.xscale('log')
    plt.savefig('mixing_ratios_log.pdf')

    # clear plot
    plt.clf()
예제 #7
0
#!/usr/bin/env python3

from Axis import Axis
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np

pressure = Axis('P', 'Pressure', 'bar')
altitude = Axis('Z', 'Altitude', 'km')
temperature = Axis('T', 'Temperature', 'K')


#_____________________________________________________________________________
def main(input_file):

    base_dir = '/Users/Will/Documents/FDL/results/docker_image'

    flux_path = base_dir + '/parsed_photochem_fluxes.csv'
    mix_path = base_dir + '/parsed_photochem_mixing_ratios.csv'

    flux_dataframe = pd.read_csv(flux_path)
    mix_dataframe = pd.read_csv(mix_path)

    # convert cm to km
    mix_dataframe['Z'] = mix_dataframe['Z'] / 1e5
    flux_dataframe['Z'] = flux_dataframe['Z'] / 1e5

    sum_fluxes(flux_dataframe, [])
    plot_mixing_ratios(mix_dataframe)
    plot_fluxes(flux_dataframe)
예제 #8
0
# threshold boundaries for HSV space skin segmentation
lower = np.array([0, 0, 0], dtype="uint8")
upper = np.array([255, 255, 255], dtype="uint8")

# video recording
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('COS429.avi', fourcc, 20.0, (640, 480))

# Choose the segmentation algorithm
option = int(
    raw_input(
        "What skin segmentation algorithm would you like to use?\n1) OTSU Thresholding \n2) HSV Skin Sample Segmentation\n"
    ))

ax = Axis()
curr_time = time.time()
ct = 1

print "Press c to use current frame for calibration"
while (True):
    # Capture frame-by-frameqq
    ret, BGR_frame = cap.read()
    BGR_frame = cv2.flip(BGR_frame, 1)  #vertical flip

    # thresholding to find hand
    if option == 1:
        BGR_frame = pre.deNoise(BGR_frame)
        gray_frame = pre.im2Gray(BGR_frame)
        skinMask = pre.thresholdHand(gray_frame)