Ejemplo n.º 1
0
    def buildGUI(self):
        self.setWindowTitle('Traj Space')
        app_icon = QtGui.QIcon()
        app_icon.addFile(
            os.path.join('supra', 'GUI', 'Images', 'BAM_no_wave.png'),
            QtCore.QSize(16, 16))
        self.setWindowIcon(app_icon)

        p = self.palette()
        p.setColor(self.backgroundRole(), Qt.black)
        self.setPalette(p)

        theme(self)

        layout = QGridLayout()
        self.setLayout(layout)

        self.pvh_graph = MatplotlibPyQT()
        # self.pvh_graph.ax1 = self.pvh_graph.figure.add_subplot(611)
        self.pvh_graph.ax2 = self.pvh_graph.figure.add_subplot(411)
        self.pvh_graph.ax3 = self.pvh_graph.figure.add_subplot(412)
        # self.pvh_graph.ax4 = self.pvh_graph.figure.add_subplot(513)
        self.pvh_graph.ax5 = self.pvh_graph.figure.add_subplot(413)
        self.pvh_graph.ax6 = self.pvh_graph.figure.add_subplot(414)
        layout.addWidget(self.pvh_graph, 1, 1, 100, 1)
        export_raw = createButton("Export Overpressures and Periods",
                                  layout,
                                  101,
                                  1,
                                  self.exportraw,
                                  args=[])

        run_button = createButton("Make Plots",
                                  layout,
                                  1,
                                  3,
                                  self.calculate,
                                  args=[])
        _, self.N_edits = createLabelEditObj("Number of Windows",
                                             layout,
                                             2,
                                             width=1,
                                             h_shift=1,
                                             tool_tip='',
                                             validate='int',
                                             default_txt='100')
        _, self.l_edits = createLabelEditObj("Percent Overlap",
                                             layout,
                                             3,
                                             width=1,
                                             h_shift=1,
                                             tool_tip='',
                                             validate='float',
                                             default_txt='0.5')
        self.h_space_tog = createToggle("Height Space",
                                        layout,
                                        4,
                                        width=1,
                                        h_shift=2,
                                        tool_tip='')
        self.h_space_tog.setChecked(True)
        self.auto_gain = createToggle("Auto Gain Limits",
                                      layout,
                                      5,
                                      width=1,
                                      h_shift=2,
                                      tool_tip='')
        _, self.gain_edits = createLabelEditObj("Gain Cutoff",
                                                layout,
                                                6,
                                                width=1,
                                                h_shift=1,
                                                tool_tip='',
                                                validate='float',
                                                default_txt='5')
        self.auto_gain.setChecked(True)
        ro_button = createButton("Calculate Relaxation Radii",
                                 layout,
                                 7,
                                 3,
                                 self.geminusify,
                                 args=[])
        _, self.min_height_edits = createLabelEditObj("Minimum Height [km]",
                                                      layout,
                                                      8,
                                                      width=1,
                                                      h_shift=1,
                                                      tool_tip='',
                                                      validate='float',
                                                      default_txt='17')
        _, self.max_height_edits = createLabelEditObj("Maximum Height [km]",
                                                      layout,
                                                      9,
                                                      width=1,
                                                      h_shift=1,
                                                      tool_tip='',
                                                      validate='float',
                                                      default_txt='40')
        self.branchselector = createToggle("Use Branch 2",
                                           layout,
                                           10,
                                           width=1,
                                           h_shift=2,
                                           tool_tip='')
        self.branchselector.setChecked(True)
        _, self.min_time_edits = createLabelEditObj("Minimum Time [s]",
                                                    layout,
                                                    11,
                                                    width=1,
                                                    h_shift=1,
                                                    tool_tip='',
                                                    validate='float',
                                                    default_txt='300')
        _, self.max_time_edits = createLabelEditObj("Maximum Time [s]",
                                                    layout,
                                                    12,
                                                    width=1,
                                                    h_shift=1,
                                                    tool_tip='',
                                                    validate='float',
                                                    default_txt='600')
        self.stat_bandpass = createToggle("Use Station Bandpass",
                                          layout,
                                          13,
                                          width=1,
                                          h_shift=2,
                                          tool_tip='')
        _, self.bin_edits = createLabelEditObj("Size of Bins [m]",
                                               layout,
                                               14,
                                               width=1,
                                               h_shift=1,
                                               tool_tip='',
                                               validate='float',
                                               default_txt='100')
        self.bin_edits.editingFinished.connect(self.binify)

        self.ro_graph = MatplotlibPyQT()
        self.ro_graph.ax = self.ro_graph.figure.add_subplot(111)
        layout.addWidget(self.ro_graph, 15, 2, 90, 2)
        export_ro = createButton("Export Relaxation Radii Curve",
                                 layout,
                                 105,
                                 3,
                                 self.exportro,
                                 args=[])
Ejemplo n.º 2
0
    def buildGUI(self):
        self.setWindowTitle('Ray-Trace Viewer')
        app_icon = QtGui.QIcon()
        app_icon.addFile(
            os.path.join('supra', 'GUI', 'Images', 'BAM_no_wave.png'),
            QtCore.QSize(16, 16))
        self.setWindowIcon(app_icon)

        p = self.palette()
        p.setColor(self.backgroundRole(), Qt.black)
        self.setPalette(p)

        theme(self)

        layout = QGridLayout()
        self.setLayout(layout)

        self.glm_graph = MatplotlibPyQT()

        self.glm_graph.ax = self.glm_graph.figure.add_subplot(111)

        layout.addWidget(self.glm_graph, 1, 1, 15, 1)

        # self.hvt_graph = MatplotlibPyQT()
        # self.hvt_graph.ax = self.hvt_graph.figure.add_subplot(111)
        # layout.addWidget(self.hvt_graph, 16, 1, 15, 1)

        # stn_name_list = []
        # for stn in self.bam.stn_list:
        #     stn_name_list.append("{:}-{:}".format(stn.metadata.network, stn.metadata.code))

        # _, self.source_height = createLabelEditObj('Source Height Along Trajectory [m]', layout, 1, width=1, h_shift=1, tool_tip='', validate='float')
        # _, self.station_combo = createComboBoxObj('Station', layout, 2, items=stn_name_list, width=1, h_shift=1, tool_tip='')
        # self.trajmode = createToggle("Plot Trajectory?", layout, 3, width=1, h_shift=2, tool_tip='')
        # self.netmode = createToggle("Run Ray Net?", layout, 9, width=1, h_shift=2, tool_tip='')

        # self.run_trace_button = createButton("Run", layout, 4, 3, self.runRayTrace)
        # self.clear_trace_button = createButton("Clear", layout, 5, 3, self.clearRayTrace)
        # # _, self.ray_frac = createLabelEditObj('Fraction of Rays to Show', layout, 5, width=1, h_shift=1, tool_tip='', validate='int', default_txt='50')

        # _, self.horizontal_tol = createLabelEditObj('Horizontal Tolerance', layout, 6, width=1, h_shift=1, tool_tip='', validate='float', default_txt='330')
        # _, self.vertical_tol = createLabelEditObj('Vertical Tolerance', layout, 7, width=1, h_shift=1, tool_tip='', validate='float', default_txt='3000')

        # self.pertstog = createToggle("Use Pertubations", layout, 8, width=1, h_shift=2, tool_tip='')
        # _, self.source_lat = createLabelEditObj('Source Latitude', layout, 10, width=1, h_shift=1, tool_tip='', validate='float')
        # _, self.source_lon = createLabelEditObj('Source Longitude', layout, 11, width=1, h_shift=1, tool_tip='', validate='float')

        # self.save_ray = createButton("Export Ray", layout, 12, 3, self.exportRay)

        self.load_glm_label, self.load_glm_edits, self.load_glm_buton = createFileSearchObj(
            'Load GLM: ', layout, 13, width=1, h_shift=1)
        self.load_glm_buton.clicked.connect(
            partial(fileSearch, ['CSV (*.csv)'], self.load_glm_edits))
        self.load_glm_buton.clicked.connect(self.procGLM)

        self.for_met_sim = createButton("Save For MetSim", layout, 13, 2,
                                        self.saveMetSim)

        # self.draw_stat = createButton("Draw Station", layout, 14, 3, self.drawStat)
        # self.draw_src  = createButton("Draw Source", layout, 15, 3, self.drawSrc)
        # self.draw_traj = createButton("Draw Trajectory", layout, 16, 3, self.drawTraj)

        # _, self.draw_beam = createLabelEditObj('Beam Azimuth', layout, 17, width=1, h_shift=1, tool_tip='', validate='float')
        # self.draw_beam_button = createButton("Draw", layout, 17, 4, self.drawBeam)

        # self.hvt_graph.ax.set_xlabel("Time after Source [s]")
        # self.hvt_graph.ax.set_ylabel("Height [km]")

        traj = self.bam.setup.trajectory

        # define line bottom boundary
        max_height = traj.pos_i.elev
        min_height = traj.pos_f.elev

        points = traj.trajInterp2(div=50, min_p=min_height, max_p=max_height)

        for pp, p in enumerate(points):
            if pp == 0:
                self.glm_graph.ax.scatter(p[1],
                                          p[0],
                                          c="g",
                                          label="Source Trajectory")
            else:
                self.glm_graph.ax.scatter(p[1], p[0], c="g")

        self.glm_graph.ax.legend()
Ejemplo n.º 3
0
    def buildGUI(self):

        self.setWindowTitle('Bandpass Optimizer')

        app_icon = QtGui.QIcon()
        app_icon.addFile(
            os.path.join('supra', 'GUI', 'Images', 'BAM_no_wave.png'),
            QtCore.QSize(16, 16))
        self.setWindowIcon(app_icon)

        p = self.palette()
        p.setColor(self.backgroundRole(), Qt.black)
        self.setPalette(p)

        theme(self)

        layout = QGridLayout()
        self.setLayout(layout)

        self.bandpass_view = pg.GraphicsLayoutWidget()
        self.bandpass_canvas = self.bandpass_view.addPlot()

        self.bp_button = createButton('Bandpass', layout, 4, 2, self.bandpass)
        self.save_button = createButton('Save', layout, 4, 3,
                                        self.bandpassSave)

        layout.addWidget(self.bandpass_view, 1, 1, 1, 2)

        _, self.low_bandpass_edits = createLabelEditObj('Low Bandpass',
                                                        layout,
                                                        2,
                                                        width=1,
                                                        h_shift=0,
                                                        tool_tip='',
                                                        validate='float',
                                                        default_txt='2')
        _, self.high_bandpass_edits = createLabelEditObj('High Bandpass',
                                                         layout,
                                                         3,
                                                         width=1,
                                                         h_shift=0,
                                                         tool_tip='',
                                                         validate='float',
                                                         default_txt='8')

        self.stream = self.stn.stream.select(
            channel="{:}".format(self.channel))

        st = self.stn.stream.select(channel="{:}".format(self.channel))[0]
        self.orig_trace = st.copy()
        stn = self.stn

        delta = self.orig_trace.stats.delta
        start_datetime = self.orig_trace.stats.starttime.datetime
        end_datetime = self.orig_trace.stats.endtime.datetime

        stn.offset = (start_datetime -
                      self.bam.setup.fireball_datetime).total_seconds()

        self.current_waveform_delta = delta
        self.current_waveform_time = np.arange(0, self.orig_trace.stats.npts / self.orig_trace.stats.sampling_rate, \
             delta)

        time_data = np.copy(self.current_waveform_time)

        self.orig_trace.detrend()

        resp = stn.response
        if resp is not None:
            self.orig_trace = self.orig_trace.remove_response(inventory=resp,
                                                              output="DISP")
        # st.remove_sensitivity(resp)

        waveform_data = self.orig_trace.data

        self.orig_data = np.copy(waveform_data)

        waveform_data = waveform_data[:len(time_data)]
        time_data = time_data[:len(waveform_data)] + stn.offset

        self.current_waveform_processed = waveform_data

        # Init the butterworth bandpass filter
        butter_b, butter_a = butterworthBandpassFilter(2, 8, \
            1.0/self.current_waveform_delta, order=6)

        # Filter the data
        waveform_data = scipy.signal.filtfilt(butter_b, butter_a,
                                              np.copy(waveform_data))

        self.current_station_waveform = pg.PlotDataItem(x=time_data,
                                                        y=waveform_data,
                                                        pen='w')
        self.bandpass_canvas.addItem(self.current_station_waveform)
        self.bandpass_canvas.setXRange(self.t_arrival - 100,
                                       self.t_arrival + 100,
                                       padding=1)
        self.bandpass_canvas.setLabel(
            'bottom',
            "Time after {:} s".format(self.bam.setup.fireball_datetime))
        self.bandpass_canvas.setLabel('left', "Signal Response")

        self.bandpass_canvas.plot(x=[-10000, 10000],
                                  y=[0, 0],
                                  pen=pg.mkPen(color=(100, 100, 100)))

        self.noise_selector = pg.LinearRegionItem(values=[0, 10],
                                                  brush=(255, 0, 0, 100))

        self.signal_selector = pg.LinearRegionItem(values=[200, 210],
                                                   brush=(0, 255, 0, 100))

        self.bandpass_canvas.addItem(self.noise_selector)
        self.bandpass_canvas.addItem(self.signal_selector)

        self.bandpass_graph = MatplotlibPyQT()
        self.bandpass_graph.ax1 = self.bandpass_graph.figure.add_subplot(211)
        self.bandpass_graph.ax2 = self.bandpass_graph.figure.add_subplot(212)
        layout.addWidget(self.bandpass_graph, 1, 4, 1, 2)
Ejemplo n.º 4
0
    def buildGUI(self):
        self.setWindowTitle('Luminous Efficiency')
        app_icon = QtGui.QIcon()
        app_icon.addFile(
            os.path.join('supra', 'GUI', 'Images', 'BAM_no_wave.png'),
            QtCore.QSize(16, 16))
        self.setWindowIcon(app_icon)

        p = self.palette()
        p.setColor(self.backgroundRole(), Qt.black)
        self.setPalette(p)

        theme(self)

        main_layout = QGridLayout()
        self.light_curve = MatplotlibPyQT()
        self.light_curve.ax = self.light_curve.figure.add_subplot(111)
        main_layout.addWidget(self.light_curve, 1, 101, 1, 100)

        self.lum_curve = MatplotlibPyQT()
        self.lum_curve.ax = self.lum_curve.figure.add_subplot(111)
        main_layout.addWidget(self.lum_curve, 1, 202, 1, 100)

        self.lightCurve()

        self.sources_table = QScrollArea()
        # self.sources_layout.addWidget(self.sources_table)
        self.sources_table.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self.sources_table.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)

        self.sources_table.setWidgetResizable(True)

        container = QWidget()
        container.setStyleSheet("""
            QWidget {
                background-color: rgb(0, 0, 0);
                }
            """)
        self.sources_table.setWidget(container)
        self.sources_table_layout = QVBoxLayout(container)
        self.sources_table_layout.setSpacing(10)

        main_layout.addWidget(self.sources_table, 1, 1, 1, 100)
        l, self.tau_edits, b = createFileSearchObj("Tau Curve File",
                                                   main_layout,
                                                   3,
                                                   width=1,
                                                   h_shift=0,
                                                   tool_tip='')
        b.clicked.connect(partial(fileSearch, ['CSV (*.csv)'], self.tau_edits))

        self.redraw_button = createButton("Plot",
                                          main_layout,
                                          2,
                                          1,
                                          self.redraw,
                                          args=[])
        self.cla_button = createButton("Clear All",
                                       main_layout,
                                       2,
                                       2,
                                       self.clearEnergy,
                                       args=[])

        self.setLayout(main_layout)
Ejemplo n.º 5
0
    def __init__(self, setup, pack, bam):

        QWidget.__init__(self)

        self.buildGUI()

        # Take important values from main window class
        stn, self.current_station, self.pick_list, self.channel = pack

        # The first pick created is the one all times are based around (reference time)
        nom_pick = self.pick_list[0]

        main_layout = QGridLayout()

        # Pass setup value
        self.setup = setup
        self.bam = bam

        ###########
        # Build GUI
        ###########

        self.height_plot = MatplotlibPyQT()

        main_layout.addWidget(self.height_plot, 1, 1, 1, 100)

        export_button = QPushButton('Export')
        main_layout.addWidget(export_button, 3, 1, 1, 25)
        export_button.clicked.connect(self.export)

        X = []
        Y = []
        Y_M = []

        # Create a local coordinate system with the bottom of the trajectory as the reference
        A = self.setup.trajectory.pos_i
        B = self.setup.trajectory.pos_f

        A.pos_loc(B)
        B.pos_loc(B)

        # All points are placed here
        self.dots_x = []
        self.dots_y = []

        #########################
        # Light Curve Plot
        #########################
        if len(self.setup.light_curve_file) > 0 and hasattr(
                self.setup, "light_curve_file"):
            self.height_plot.ax1 = self.height_plot.figure.add_subplot(211)
            self.height_plot.ax2 = self.height_plot.figure.add_subplot(
                212, sharex=self.height_plot.ax1)
            # lc_plot = MatplotlibPyQT()
            # main_layout.addWidget(lc_plot, 1, 1, 1, 100)
            # self.light_curve_view = pg.GraphicsLayoutWidget()
            # self.light_curve_canvas = self.light_curve_view.addPlot()

            light_curve = readLightCurve(self.setup.light_curve_file)

            light_curve_list = processLightCurve(light_curve)

            for L in light_curve_list:
                self.height_plot.ax1.scatter(L.h, L.I, label=L.station)
                # light_curve_curve = pg.ScatterPlotItem(x=L.M, y=L.t)
                # self.light_curve_canvas.addItem(light_curve_curve)

            self.height_plot.ax1.legend()
            # plt.gca().invert_yaxis()

            # main_layout.addWidget(self.light_curve_view, 1, 101, 1, 10)

            # blank_spacer = QWidget()
            # main_layout.addWidget(blank_spacer, 2, 101, 2, 10)

            self.height_plot.ax1.set_xlim((-10, 100))
            self.height_plot.ax1.set_xlabel("Height [km]")
            self.height_plot.ax1.set_ylabel("Intensity")
        else:
            self.height_plot.ax2 = self.height_plot.figure.add_subplot(111)

        #########################
        # Station Plot
        #########################

        try:

            # Bandpass the waveform from 2 - 8 Hz (not optimal, but does a good job
            # in showing arrivals clearly for most cases)
            st, resp, gap_times = procStream(
                stn, ref_time=self.setup.fireball_datetime)
            st = findChn(st, self.channel)
            waveform_data, time_data = procTrace(st, ref_datetime=self.setup.fireball_datetime,\
                    resp=resp, bandpass=[2, 8])

            # Scale the data so that the maximum is brought out to SCALE_LEN

            SCALE_LEN = 10  # km
            max_val = 0
            for ii in range(len(waveform_data)):
                wave = waveform_data[ii]
                for point in wave:
                    if abs(point) > max_val:
                        max_val = abs(point)

            scaling = SCALE_LEN / max_val

            # Plot all waveform data segments (for gaps in data)
            for ii in range(len(waveform_data)):
                self.height_plot.ax2.plot(waveform_data[ii] * scaling,
                                          time_data[ii] - nom_pick.time)

        except ValueError:
            print("Could not filter waveform!")

        #########################
        # Light Curve Plot
        #########################

        if len(self.setup.light_curve_file) > 0 or not hasattr(
                self.setup, "light_curve_file"):

            light_curve = readLightCurve(self.setup.light_curve_file)

            light_curve_list = processLightCurve(light_curve)

            for L in light_curve_list:
                self.height_plot.ax1.scatter(L.h, L.I, label=L.station)
                # light_curve_curve = pg.ScatterPlotItem(x=L.M, y=L.t)
                # self.light_curve_canvas.addItem(light_curve_curve)

            self.height_plot.ax1.legend()

            # plt.gca().invert_yaxis()

            # main_layout.addWidget(self.light_curve_view, 1, 101, 1, 10)

            # blank_spacer = QWidget()
            # main_layout.addWidget(blank_spacer, 2, 101, 2, 10)

        ########################
        # Generate Hyperbola
        ########################

        # D_0 = A

        # stn.metadata.position.pos_loc(B)

        # theta = self.setup.trajectory.zenith.rad
        # h_0 = A.z

        # h = np.arange(0, 100000)
        # v = self.setup.trajectory.v
        # k = stn.metadata.position - D_0
        # n = Position(0, 0, 0)
        # n.x, n.y, n.z = self.setup.trajectory.vector.x, self.setup.trajectory.vector.y, self.setup.trajectory.vector.z
        # n.pos_geo(B)
        # c = 350

        # T = (h - h_0)/(-v*np.cos(theta)) + (k - n*((h - h_0)/(-np.cos(theta)))).mag()/c - nom_pick.time

        # # estimate_plot = pg.PlotDataItem(x=h, y=T)
        # # self.height_canvas.addItem(estimate_plot, update=True)

        # self.height_plot.ax2.scatter(h/1000, T)

        #######################
        # Plot nominal points
        #######################
        # base_points = pg.ScatterPlotItem()
        angle_off = []
        no_wind_points = []
        u = np.array([
            self.setup.trajectory.vector.x, self.setup.trajectory.vector.y,
            self.setup.trajectory.vector.z
        ])
        for i in range(len(self.setup.fragmentation_point)):

            f_time = stn.times.fragmentation[i][0][0]

            X = self.setup.fragmentation_point[i].position.elev
            Y = f_time - nom_pick.time

            self.dots_x.append(X)
            self.dots_y.append(Y)

            travel_dis = self.setup.fragmentation_point[
                i].position.pos_distance(stn.metadata.position)

            travel_time = travel_dis / 330

            no_wind_points.append([self.setup.fragmentation_point[i].position.elev, \
                         travel_time - nom_pick.time + self.setup.fragmentation_point[i].time])

            az = stn.times.fragmentation[i][0][1]
            tf = stn.times.fragmentation[i][0][2]

            az = np.radians(az)
            tf = np.radians(180 - tf)
            v = np.array([
                np.sin(az) * np.sin(tf),
                np.cos(az) * np.sin(tf), -np.cos(tf)
            ])

            angle_off.append(
                np.degrees(
                    np.arccos(
                        np.dot(u / np.sqrt(u.dot(u)), v / np.sqrt(v.dot(v))))))

            print(
                "Points", X, Y,
                np.degrees(
                    np.arccos(
                        np.dot(u / np.sqrt(u.dot(u)), v / np.sqrt(v.dot(v))))))

            # base_points.addPoints(x=[X], y=[Y], pen=(255, 0, 238), brush=(255, 0, 238), symbol='o')

        ptb_colors = [(0, 255, 26, 150), (3, 252, 176, 150), (252, 3, 3, 150),
                      (176, 252, 3, 150), (255, 133, 3, 150),
                      (149, 0, 255, 150), (76, 128, 4, 150), (82, 27, 27, 150),
                      (101, 128, 125, 150), (5, 176, 249, 150)]

        # base_points.setZValue(1)
        # self.height_canvas.addItem(base_points, update=True)

        #########################
        # Plot Precursor Points
        #########################

        # pre_points = pg.ScatterPlotItem()

        for i in range(len(self.setup.fragmentation_point)):

            X = self.setup.fragmentation_point[i].position.elev

            # Distance between frag point and the ground below it
            v_dist = X - stn.metadata.position.elev

            # Horizontal distance betweent the new ground point and the stn
            h_dist = self.setup.fragmentation_point[
                i].position.ground_distance(stn.metadata.position)

            # Speed of wave in air
            v_time = v_dist / 310

            # Speed of wave in ground
            h_time = h_dist / 3100

            # Total travel time
            Y = v_time + h_time - nom_pick.time

            self.height_plot.ax2.scatter(np.array(X) / 1000,
                                         np.array(Y),
                                         c='y')
            # pre_points.addPoints(x=[X], y=[Y], pen=(210, 235, 52), brush=(210, 235, 52), symbol='o')

        # self.height_canvas.addItem(pre_points, update=True)

        #########################
        # Perturbation points
        #########################
        # prt_points = pg.ScatterPlotItem()
        for i in range(len(self.setup.fragmentation_point)):
            data, remove = self.obtainPerts(stn.times.fragmentation, i)
            azdata, remove = self.obtainPerts(stn.times.fragmentation, i, pt=1)
            tfdata, remove = self.obtainPerts(stn.times.fragmentation, i, pt=2)
            Y = []
            X = self.setup.fragmentation_point[i].position.elev
            for pt, az, tf in zip(data, azdata, tfdata):

                Y = (pt - nom_pick.time)

                self.dots_x.append(X)
                self.dots_y.append(Y)

                az = np.radians(az)
                tf = np.radians(180 - tf)
                v = np.array([
                    np.sin(az) * np.sin(tf),
                    np.cos(az) * np.sin(tf), -np.cos(tf)
                ])

                angle_off.append(
                    np.degrees(
                        np.arccos(
                            np.dot(u / np.sqrt(u.dot(u)),
                                   v / np.sqrt(v.dot(v))))))

        colour_angle = abs(90 - np.array(angle_off))
        sc = self.height_plot.ax2.scatter(np.array(self.dots_x) / 1000,
                                          np.array(self.dots_y),
                                          c=colour_angle,
                                          cmap='viridis_r')
        cbar = self.height_plot.figure.colorbar(sc,
                                                orientation="horizontal",
                                                pad=0.2)
        cbar.ax.set_xlabel("Difference from 90 deg [deg]")
        no_wind_points = np.array(no_wind_points)
        self.height_plot.ax2.scatter(no_wind_points[:, 0] / 1000,
                                     no_wind_points[:, 1],
                                     c='w')

        for pick in self.pick_list:
            if pick.group == 0:
                self.height_plot.ax2.axhline(pick.time - nom_pick.time, c='g')
                # self.height_canvas.addItem(pg.InfiniteLine(pos=(0, pick.time - nom_pick.time), angle=0, pen=QColor(0, 255, 0)))
            else:
                self.height_plot.ax2.axhline(pick.time - nom_pick.time, c='b')
                # self.height_canvas.addItem(pg.InfiniteLine(pos=(0, pick.time - nom_pick.time), angle=0, pen=QColor(0, 0, 255)))

        self.dots = np.array([self.dots_x, self.dots_y])

        #####################
        # Angle Calculation
        #####################

        u = np.array([
            self.setup.trajectory.vector.x, self.setup.trajectory.vector.y,
            self.setup.trajectory.vector.z
        ])

        angle_off = []
        X = []
        for i in range(len(self.setup.fragmentation_point)):
            az = stn.times.fragmentation[i][0][1]
            tf = stn.times.fragmentation[i][0][2]

            az = np.radians(az)
            tf = np.radians(180 - tf)
            v = np.array([
                np.sin(az) * np.sin(tf),
                np.cos(az) * np.sin(tf), -np.cos(tf)
            ])

            angle_off.append(
                np.degrees(
                    np.arccos(
                        np.dot(u / np.sqrt(u.dot(u)), v / np.sqrt(v.dot(v))))))
            X.append(self.setup.fragmentation_point[i].position.elev)
        angle_off = np.array(angle_off)

        ###############################
        # Find optimal ballistic angle
        ###############################
        try:
            best_indx = np.nanargmin(abs(angle_off - 90))
            print(
                "Optimal Ballistic Height {:.2f} km with angle of {:.2f} deg".
                format(X[best_indx] / 1000, angle_off[best_indx]))

            self.height_plot.ax2.axvline(X[best_indx] / 1000, c='b')
            # self.angle_canvas.addItem(pg.InfiniteLine(pos=(X[best_indx], 0), angle=90, pen=QColor(0, 0, 255)))
            # self.height_canvas.addItem(pg.InfiniteLine(pos=(X[best_indx], 0), angle=90, pen=QColor(0, 0, 255)))
            # self.angle_canvas.scatterPlot(x=X, y=angle_off, pen=(255, 255, 255), symbol='o', brush=(255, 255, 255))

            best_arr = []
            angle_arr = []

        except ValueError:
            best_indx = None

        angle_off = 0
        height = None
        for i in range(len(self.setup.fragmentation_point)):
            for j in range(len(stn.times.fragmentation[i][1])):
                az = stn.times.fragmentation[i][1][j][1]
                tf = stn.times.fragmentation[i][1][j][2]
                az = np.radians(az)
                tf = np.radians(180 - tf)
                v = np.array([
                    np.sin(az) * np.sin(tf),
                    np.cos(az) * np.sin(tf), -np.cos(tf)
                ])

                angle_off_new = np.degrees(
                    np.arccos(
                        np.dot(u / np.sqrt(u.dot(u)), v / np.sqrt(v.dot(v)))))

                # self.angle_canvas.scatterPlot(x=[self.setup.fragmentation_point[i].position.elev], y=[angle_off_new], symbol='o')

                if abs(angle_off_new - 90) < abs(
                        angle_off - 90) and not np.isnan(angle_off_new):
                    angle_off = angle_off_new

                    height = self.setup.fragmentation_point[i].position.elev

        if height is not None:
            # self.angle_canvas.addItem(pg.InfiniteLine(pos=(height, 0), angle=90, pen=QColor(0, 0, 255)))
            self.height_plot.ax2.axvline(height / 1000, c='b')
            # self.height_canvas.addItem(pg.InfiniteLine(pos=(height, 0), angle=90, pen=QColor(0, 0, 255)))

        # self.angle_canvas.addItem(pg.InfiniteLine(pos=(0, 90), angle=0, pen=QColor(255, 0, 0)))

        ########################
        # Fit Hyperbola
        ########################

        try:
            x_vals = []
            y_vals = []

            for pp, point in enumerate(self.dots_y):
                if not np.isnan(point):
                    y_vals.append(point)
                    x_vals.append(self.dots_x[pp])

            x_vals, y_vals = np.array(x_vals), np.array(y_vals)

            def hypfunc(x, a, b, h, k):
                return b * np.sqrt(1 + ((x - h) / a)**2) + k

            def invhypfunc(x, a, b, h, k):
                return a * np.sqrt(((x - k) / b)**2 - 1) + h

            # Hyperbola in the form y = kx (since we invert the x values)
            from scipy.optimize import curve_fit

            popt, pcov = curve_fit(hypfunc, x_vals, y_vals)

            h = np.linspace(0, 100000, 1000)

            self.height_plot.ax2.plot(h / 1000, hypfunc(h, *popt), c='m')
        except TypeError:
            print("Could not generate hyperbola fit!")
        except RuntimeError:
            print("Optimal hyperbola not found!")
        except ValueError:
            print("No Arrivals!")

        ########################
        # Overpressure vs Time
        ########################
        try:
            st, resp, gap_times = procStream(
                stn, ref_time=self.setup.fireball_datetime)
            st = findChn(st, self.channel)
            waveform_data, time_data = procTrace(st, ref_datetime=self.setup.fireball_datetime,\
                    resp=resp, bandpass=[2, 8])

        except ValueError:
            print("Could not filter waveform!")

        # waveform_peaks = []
        # time_peaks = []
        # N = 10

        # for wave, time_pack in zip(waveform_data, time_data):
        #     for ii in range(0, len(wave), N):
        #         peak = np.nanmax(np.abs(wave[ii:ii+N]))

        #         time_peak = np.mean(time_pack[ii:ii+N] - nom_pick.time)

        #         waveform_peaks.append(peak)
        #         time_peaks.append(time_peak)

        # ##################
        # # Relate Time to Height
        # ##################

        # height_peaks = invhypfunc(time_peaks, *popt)

        # ##################
        # # Get Bounds for Heights
        # ##################
        # min_height = 17000
        # max_height = 40000
        # h_indicies = np.where(np.logical_and(height_peaks>=min_height, height_peaks<=max_height))

        # new_heights = []
        # new_press = []
        # for hh in h_indicies[0]:

        #     new_heights.append(height_peaks[hh])
        #     new_press.append(waveform_peaks[hh])

        # plt.subplot(3, 1, 1)

        # plt.plot(new_heights, new_press)
        # plt.xlabel("Height [m]")
        # plt.ylabel("Overpressure [Pa]")

        # spacer = 5*60
        # shifter = 10
        # periods = []
        # period_times = []

        # for wave, time_pack in zip(waveform_data, time_data):
        #     for ii in range(len(wave)//shifter):

        #         temp_waveform = wave[shifter*ii:shifter*ii+spacer]
        #         temp_time = time_pack[shifter*ii:shifter*ii+spacer]

        #         period = findDominantPeriodPSD(temp_waveform, st.stats.sampling_rate)

        #         periods.append(period)
        #         period_times.append(time_pack[shifter*ii])

        # plt.subplot(3, 1, 2)
        # height_periods = invhypfunc(period_times, *popt)
        # h_indicies = np.where(np.logical_and(height_periods>=min_height, height_periods<=max_height))

        # new_heights = []
        # new_period = []
        # for hh in h_indicies[0]:

        #     new_heights.append(height_periods[hh])
        #     new_period.append(periods[hh])

        # plt.plot(new_heights, new_period)
        # plt.xlabel("Height [m]")
        # plt.ylabel("Dominant Period [s]")

        # plt.subplot(3, 1, 3)
        # ws_list = []
        # lin_list = []
        # h_list = []
        # N_times=1
        # ws_list_p = []
        # lin_list_p = []
        # h_list_p = []
        # for ii in range(len(new_heights)//N_times):
        #     ws, lin = self.periodSearch(new_heights[ii*N_times], stn, new_period[ii*N_times])
        #     print("Phase 1: {:}/{:}".format(ii+1, len(new_heights)//N_times))
        #     ws_list_p.append(ws)
        #     lin_list_p.append(lin)
        #     h_list_p.append(new_heights[ii*N_times])
        # plt.scatter(h_list_p, ws_list_p, label='Period Weak-Shock', alpha=0.4)
        # plt.scatter(h_list_p,lin_list_p, label='Period Linear', alpha=0.4)
        # # for ii in range(len(new_heights)//N_times):
        # #     ws, lin = self.presSearch(new_heights[ii*N_times], stn, new_press[ii*N_times])
        # #     print("Phase 2: {:}/{:}".format(ii+1, len(new_heights)//N_times))
        # #     ws_list.append(ws)
        # #     lin_list.append(lin)
        # #     h_list.append(new_heights[ii*N_times])
        # # plt.scatter(h_list, ws_list, label='Pressure Weak-Shock', alpha=0.4)
        # # plt.scatter(h_list,lin_list, label='Pressure Linear', alpha=0.4)

        # plt.xlabel("Height [m]")
        # plt.ylabel("Relaxation Radius [m]")
        # plt.legend()
        # plt.show()

        # fit_hyper = pg.PlotDataItem(x=h, y=hypfunc(h, *popt))
        # self.height_canvas.addItem(fit_hyper, update=True, pen='m')

        #####################
        # Build plot window
        #####################

        # 25 deg tolerance window
        # phigh = pg.PlotCurveItem([np.nanmin(X), np.nanmax(X)], [65, 65], pen = 'g')
        # plow = pg.PlotCurveItem([np.nanmin(X), np.nanmax(X)], [115, 115], pen = 'g')
        # pfill = pg.FillBetweenItem(phigh, plow, brush = (0, 0, 255, 100))
        # self.angle_canvas.addItem(phigh)
        # self.angle_canvas.addItem(plow)
        # self.angle_canvas.addItem(pfill)

        # Build axes
        # self.height_canvas.setTitle('Fragmentation Height Prediction of Given Pick', color=(0, 0, 0))
        # self.angle_canvas.setTitle('Angles of Initial Acoustic Wave Path', color=(0, 0, 0))
        # self.height_canvas.setLabel('left', 'Difference in Time from {:.2f}'.format(nom_pick.time), units='s')
        # self.angle_canvas.setLabel('left', 'Angle Away from Trajectory of Initial Acoustic Wave Path', units='deg')
        # self.height_canvas.setLabel('bottom', 'Height of Solution', units='m')
        # self.angle_canvas.setLabel('bottom', 'Height of Solution', units='m')
        tol = 5  #seconds

        self.height_plot.ax2.set_xlim((-10, 100))
        self.height_plot.ax2.set_ylim(
            (np.min([0, np.nanmin(self.dots_y)]) - tol,
             tol + np.max([0, np.nanmax(self.dots_y)])))
        # print(len(X), len(Y))
        # self.height_plot.ax2.scatter(np.array(X)/1000, np.array(Y), c='m')

        self.height_plot.ax2.set_xlabel("Height [km]")
        self.height_plot.ax2.set_ylabel("Time after {:.2f} [s]".format(
            nom_pick.time))

        # self.height_plot.ax1.show()
        # self.height_plot.ax2.show()
        self.height_plot.figure.tight_layout()
        self.height_plot.figure.subplots_adjust(hspace=0)
        self.height_plot.show()
        # self.height_canvas.setLimits(xMin=B.elev, xMax=A.elev, yMin=-40, yMax=100, minXRange=1000, maxXRange=33000, minYRange=2, maxYRange=140)

        # Fonts
        # font= QFont()
        # font.setPixelSize(20)
        # self.height_canvas.getAxis("bottom").tickFont = font
        # self.height_canvas.getAxis("left").tickFont = font
        # self.height_canvas.getAxis('bottom').setPen((255, 255, 255))
        # self.height_canvas.getAxis('left').setPen((255, 255, 255))
        # self.angle_canvas.getAxis("bottom").tickFont = font
        # self.angle_canvas.getAxis("left").tickFont = font
        # self.angle_canvas.getAxis('bottom').setPen((255, 255, 255))
        # self.angle_canvas.getAxis('left').setPen((255, 255, 255))
        self.setLayout(main_layout)
Ejemplo n.º 6
0
    def buildGUI(self):

        self._main = QWidget()
        self.setCentralWidget(self._main)
        layout = QGridLayout(self._main)

        self.raw_traces = [None] * N_ELEMENTS

        self.stat_graph = MatplotlibPyQT()
        self.sum_graph = MatplotlibPyQT()
        self.mseed_browser_label = [None] * N_ELEMENTS
        self.mseed_browser_edits = [None] * N_ELEMENTS
        self.mseed_browser_buton = [None] * N_ELEMENTS
        self.stat_shifter_label = [None] * N_ELEMENTS
        self.stat_shifter_edits = [None] * N_ELEMENTS

        self.stat_graph.ax = []
        for i in range(N_ELEMENTS):
            if i == 0:
                self.stat_graph.ax.append(
                    self.stat_graph.figure.add_subplot(N_ELEMENTS, 1, i + 1))
            else:

                self.stat_graph.ax.append(
                    self.stat_graph.figure.add_subplot(
                        N_ELEMENTS, 1, i + 1, sharex=self.stat_graph.ax[0]))

        layout.addWidget(self.stat_graph, 0, 4, N_ELEMENTS * 4, 1)

        self.sum_graph.ax = self.sum_graph.figure.add_subplot(
            1, 1, 1, sharex=self.stat_graph.ax[0])
        layout.addWidget(self.sum_graph, N_ELEMENTS * 4 + 1, 4)

        for ii in range(N_ELEMENTS):
            self.mseed_browser_label[ii], self.mseed_browser_edits[
                ii], self.mseed_browser_buton[ii] = createFileSearchObj(
                    'mSeed File: {:}'.format(ii + 1),
                    layout,
                    2 * ii,
                    width=1,
                    h_shift=0)
            _, self.stat_shifter_edits[ii] = createLabelEditObj(
                'Shift [s]',
                layout,
                2 * ii + 1,
                width=1,
                h_shift=0,
                tool_tip='',
                validate='float',
                default_txt='0')

            self.mseed_browser_buton[ii].clicked.connect(
                partial(fileSearch, ['mSeed File (*.mseed)'],
                        self.mseed_browser_edits[ii]))

        self.stackRaw_button = createButton("Raw Stack", layout,
                                            2 * N_ELEMENTS + 2, 2,
                                            self.stackRaw)
        self.stack_button = createButton("Stack", layout, 2 * N_ELEMENTS + 2,
                                         1, self.stack)
        self.read = createButton("Read", layout, 2 * N_ELEMENTS + 2, 0,
                                 self.read)
Ejemplo n.º 7
0
    def buildGUI(self):
        self.setWindowTitle('Geminus (Silber 2014)')

        app_icon = QIcon()
        app_icon.addFile(
            os.path.join('supra', 'GUI', 'Images', 'BAM_no_wave.png'),
            QSize(16, 16))
        self.setWindowIcon(app_icon)

        p = self.palette()
        p.setColor(self.backgroundRole(), Qt.black)
        self.setPalette(p)

        layout = QHBoxLayout()
        self.setLayout(layout)

        graph_layout = QVBoxLayout()
        layout.addLayout(graph_layout)

        right_panels = QVBoxLayout()
        layout.addLayout(right_panels)

        input_panels = QGridLayout()
        right_panels.addLayout(input_panels)

        output_panels = QGridLayout()
        right_panels.addLayout(output_panels)

        stn_name_list = []
        for stn in self.bam.stn_list:
            stn_name_list.append("{:}-{:}".format(stn.metadata.network,
                                                  stn.metadata.code))

        control_panel = QGridLayout()
        input_panels.addLayout(control_panel, 6, 1, 3, 3)

        _, self.source_height = createLabelEditObj(
            'Source Height Along Trajectory [m]',
            input_panels,
            1,
            width=1,
            h_shift=0,
            tool_tip='')
        _, self.station_combo = createComboBoxObj('Station',
                                                  input_panels,
                                                  2,
                                                  items=stn_name_list,
                                                  width=1,
                                                  h_shift=0,
                                                  tool_tip='')

        _, self.blast_radius = createLabelEditObj('Blast Radius [m]',
                                                  input_panels,
                                                  3,
                                                  width=1,
                                                  h_shift=0,
                                                  tool_tip='')
        _, self.dom_period = createLabelEditObj('Dominant Period [s]',
                                                input_panels,
                                                4,
                                                width=1,
                                                h_shift=0,
                                                tool_tip='')
        _, self.over_pres = createLabelEditObj('Overpressure [Pa]',
                                               input_panels,
                                               5,
                                               width=1,
                                               h_shift=0,
                                               tool_tip='')
        self.vary_period = createToggle('Vary Period',
                                        control_panel,
                                        1,
                                        width=1,
                                        h_shift=1,
                                        tool_tip='')
        self.add_winds = createToggle('Include Winds',
                                      control_panel,
                                      2,
                                      width=1,
                                      h_shift=1,
                                      tool_tip='')
        self.doppler = createToggle('Doppler Shift',
                                    control_panel,
                                    3,
                                    width=1,
                                    h_shift=1,
                                    tool_tip='')
        self.overpressure_run = createButton("Run Blast Radius Simulation",
                                             control_panel,
                                             4,
                                             1,
                                             self.overpressure,
                                             args=["normal"])
        self.overpressure_period_finder = createButton("Run Period Search",
                                                       control_panel,
                                                       4,
                                                       2,
                                                       self.overpressure,
                                                       args=["period"])
        self.overpressure_pres_finder = createButton("Run Overpressure Search",
                                                     control_panel,
                                                     4,
                                                     3,
                                                     self.overpressure,
                                                     args=["pres"])
        self.pro_sim = createButton("Period vs. Blast Radius",
                                    control_panel,
                                    5,
                                    1,
                                    self.overpressure,
                                    args=["pro"])
        self.proE_sim = createButton("Period vs. Energy",
                                     control_panel,
                                     5,
                                     2,
                                     self.overpressure,
                                     args=["proE"])
        self.infra_curve = createButton("Infrasound Curve", control_panel, 5,
                                        3, self.infraCurve)
        self.clear_infra = createButton("Clear Curve", control_panel, 6, 1,
                                        self.clearInfra)
        self.save_energy = createButton("Save Energy", control_panel, 6, 2,
                                        self.saveInfra)

        self.vary_period.setChecked(True)
        self.add_winds.setChecked(True)
        self.doppler.setChecked(True)

        self.overpressure_plot = MatplotlibPyQT()
        self.overpressure_plot.ax = self.overpressure_plot.figure.add_subplot(
            111)
        graph_layout.addWidget(self.overpressure_plot)

        theme(self)
Ejemplo n.º 8
0
    def buildGUI(self):
        self.setWindowTitle('Ray-Trace Viewer')
        app_icon = QtGui.QIcon()
        app_icon.addFile(
            os.path.join('supra', 'GUI', 'Images', 'BAM_no_wave.png'),
            QtCore.QSize(16, 16))
        self.setWindowIcon(app_icon)

        p = self.palette()
        p.setColor(self.backgroundRole(), Qt.black)
        self.setPalette(p)

        theme(self)

        layout = QGridLayout()
        self.setLayout(layout)

        self.rtv_graph = MatplotlibPyQT()

        self.rtv_graph.ax = self.rtv_graph.figure.add_subplot(111,
                                                              projection='3d')

        layout.addWidget(self.rtv_graph, 1, 1, 15, 1)

        self.hvt_graph = MatplotlibPyQT()
        self.hvt_graph.ax = self.hvt_graph.figure.add_subplot(111)
        layout.addWidget(self.hvt_graph, 16, 1, 15, 1)

        stn_name_list = []
        for stn in self.bam.stn_list:
            stn_name_list.append("{:}-{:}".format(stn.metadata.network,
                                                  stn.metadata.code))

        _, self.source_height = createLabelEditObj(
            'Source Height Along Trajectory [m]',
            layout,
            1,
            width=1,
            h_shift=1,
            tool_tip='',
            validate='float')
        _, self.station_combo = createComboBoxObj('Station',
                                                  layout,
                                                  2,
                                                  items=stn_name_list,
                                                  width=1,
                                                  h_shift=1,
                                                  tool_tip='')
        self.trajmode = createToggle("Plot Trajectory?",
                                     layout,
                                     3,
                                     width=1,
                                     h_shift=2,
                                     tool_tip='')
        self.netmode = createToggle("Run Ray Net?",
                                    layout,
                                    9,
                                    width=1,
                                    h_shift=2,
                                    tool_tip='')

        self.run_trace_button = createButton("Run", layout, 4, 3,
                                             self.runRayTrace)
        self.clear_trace_button = createButton("Clear", layout, 5, 3,
                                               self.clearRayTrace)
        # _, self.ray_frac = createLabelEditObj('Fraction of Rays to Show', layout, 5, width=1, h_shift=1, tool_tip='', validate='int', default_txt='50')

        _, self.horizontal_tol = createLabelEditObj('Horizontal Tolerance',
                                                    layout,
                                                    6,
                                                    width=1,
                                                    h_shift=1,
                                                    tool_tip='',
                                                    validate='float',
                                                    default_txt='330')
        _, self.vertical_tol = createLabelEditObj('Vertical Tolerance',
                                                  layout,
                                                  7,
                                                  width=1,
                                                  h_shift=1,
                                                  tool_tip='',
                                                  validate='float',
                                                  default_txt='3000')

        self.pertstog = createToggle("Use Pertubations",
                                     layout,
                                     8,
                                     width=1,
                                     h_shift=2,
                                     tool_tip='')
        _, self.source_lat = createLabelEditObj('Source Latitude',
                                                layout,
                                                10,
                                                width=1,
                                                h_shift=1,
                                                tool_tip='',
                                                validate='float')
        _, self.source_lon = createLabelEditObj('Source Longitude',
                                                layout,
                                                11,
                                                width=1,
                                                h_shift=1,
                                                tool_tip='',
                                                validate='float')

        self.save_ray = createButton("Export Ray", layout, 12, 3,
                                     self.exportRay)

        self.load_ray_label, self.load_ray_edits, self.load_ray_buton = createFileSearchObj(
            'Load Ray Trace: ', layout, 13, width=1, h_shift=1)
        self.load_ray_buton.clicked.connect(
            partial(fileSearch, ['DAT (*.dat)'], self.load_ray_edits))
        self.load_ray_buton.clicked.connect(self.plotLoadedRay)

        self.draw_stat = createButton("Draw Station", layout, 14, 3,
                                      self.drawStat)
        self.draw_src = createButton("Draw Source", layout, 15, 3,
                                     self.drawSrc)
        self.draw_traj = createButton("Draw Trajectory", layout, 16, 3,
                                      self.drawTraj)

        _, self.draw_beam = createLabelEditObj('Beam Azimuth',
                                               layout,
                                               17,
                                               width=1,
                                               h_shift=1,
                                               tool_tip='',
                                               validate='float')
        self.draw_beam_button = createButton("Draw", layout, 17, 4,
                                             self.drawBeam)
        _, self.draw_exp_time = createLabelEditObj('Expected Arrival Time [s]',
                                                   layout,
                                                   18,
                                                   width=1,
                                                   h_shift=1,
                                                   tool_tip='',
                                                   validate='float')
        self.trace_rev_button = createButton("Trace Reverse", layout, 18, 4,
                                             self.traceRev)

        self.hvt_graph.ax.set_xlabel("Time after Source [s]")
        self.hvt_graph.ax.set_ylabel("Height [km]")

        self.load_glm_label, self.load_glm_edits, self.load_glm_buton = createFileSearchObj(
            'Load GLM: ', layout, 19, width=1, h_shift=1)
        self.load_glm_buton.clicked.connect(
            partial(fileSearch, ['CSV (*.csv)'], self.load_glm_edits))
        self.load_glm_buton.clicked.connect(partial(self.procGLM, True))

        self.fireball_datetime_label, self.fireball_datetime_edits = createLabelDateEditObj(
            "GLM Initial Datetime", layout, 20, h_shift=1)
        self.glm2lc = createButton("GLM to Light Curve", layout, 21, 4,
                                   self.glm2LC)

        self.pol_graph = MatplotlibPyQT()
        self.pol_graph.ax1 = self.pol_graph.figure.add_subplot(211)
        self.pol_graph.ax2 = self.pol_graph.figure.add_subplot(212)
        layout.addWidget(self.pol_graph, 1, 5, 25, 1)

        self.load_baz_label, self.load_baz_edits, self.load_baz_buton = createFileSearchObj(
            'Load Backazimuth: ', layout, 22, width=1, h_shift=1)
        self.load_baz_buton.clicked.connect(
            partial(fileSearch, ['CSV (*.csv)'], self.load_baz_edits))
        self.load_baz_buton.clicked.connect(self.loadAngleCSV)
        self.height_unc_button = createButton("Height Uncertainty", layout, 23,
                                              4, self.heightUnc)
Ejemplo n.º 9
0
    def __init__(self, bam, prefs, current_station):

        #################
        # Initialize GUI
        #################
        QWidget.__init__(self)
        self.setWindowTitle('Yields')
        p = self.palette()
        p.setColor(self.backgroundRole(), Qt.black)
        self.setPalette(p)

        self.prefs = prefs
        self.bam = bam
        self.setup = bam.setup
        self.stn_list = bam.stn_list
        self.current_station = current_station
        self.iterator = 0

        theme(self)

        self.count = 0
        layout = QHBoxLayout()
        self.setLayout(layout)

        pane1 = QGridLayout()
        layout.addLayout(pane1)

        pane2 = QVBoxLayout()
        layout.addLayout(pane2)

        self.station_label = QLabel('Station: {:}'.format(
            self.stn_list[self.current_station].metadata.code))
        pane1.addWidget(self.station_label, 0, 1, 1, 1)

        self.station1_label = QLabel('Nominal')
        pane1.addWidget(self.station1_label, 0, 2, 1, 1)

        self.height_label, self.height_edits = createLabelEditObj(
            'Height', pane1, 1)
        self.range_label, self.range_edits = createLabelEditObj(
            'Range', pane1, 2)
        self.pressure_label, self.pressure_edits = createLabelEditObj(
            'Explosion Height Pressure', pane1, 3)
        self.overpressure_label, self.overpressure_edits = createLabelEditObj(
            'Overpressure', pane1, 4)
        self.afi_label, self.afi_edits = createLabelEditObj(
            'Attenuation Integration Factor', pane1, 5)
        self.geo_label, self.geo_edits = createLabelEditObj(
            'Geometric Factor', pane1, 6)
        self.p_a_label, self.p_a_edits = createLabelEditObj(
            'Ambient Pressure', pane1, 7)
        self.Jd_label, self.Jd_edits = createLabelEditObj(
            'Positive Phase Length [ms]', pane1, 8)
        self.fd_label, self.fd_edits = createLabelEditObj(
            'Transmission Factor', pane1, 9)
        _, self.freq_edits = createLabelEditObj("Dominant Period", pane1, 10)
        _, self.rfangle_edits = createLabelEditObj("Refraction Angle", pane1,
                                                   11)
        # _, self.I_A_edits = createLabelEditObj("Impulse per Area (Area under curve)", pane1, 12)

        # self.fyield_button = QPushButton('Calculate Yield (Frequency)')
        # pane1.addWidget(self.fyield_button, 15, 1, 1, 4)
        # self.fyield_button.clicked.connect(self.freqYield)

        self.yield_button = QPushButton('Calculate Yield')
        pane1.addWidget(self.yield_button, 14, 1, 1, 4)
        self.yield_button.clicked.connect(self.yieldCalc)

        self.integrate_button = QPushButton('Integrate')
        pane1.addWidget(self.integrate_button, 13, 1, 1, 4)
        self.integrate_button.clicked.connect(self.intCalc)

        # Constants - Reed 1972
        self.W_0 = 4.184e6  # Standard reference explosion yield (1 kg of Chemical TNT)
        self.P_0 = 101325  # Standard pressure
        self.b = 1 / consts.SCALE_HEIGHT
        self.k = consts.ABSORPTION_COEFF
        self.J_m = 0.375  # Avg positive period of reference explosion
        self.c_m = 347  # Sound speed of reference explosion

        # self.blastline_view = pg.GraphicsLayoutWidget()
        # self.blastline_canvas = self.blastline_view.addPlot()
        # pane2.addWidget(self.blastline_view)
        # self.blastline_view.sizeHint = lambda: pg.QtCore.QSize(100, 100)

        self.blastline_plot = MatplotlibPyQT()
        self.blastline_plot.ax = self.blastline_plot.figure.add_subplot(111)
        pane2.addWidget(self.blastline_plot)