Ejemplo n.º 1
0
    def get_record_type_1(self):
        """
        Write record type 1.

        Returns
        -------
        None.

        """
        tmp = sdt.seisan_1()
        tmp.year = self.year
        tmp.month = self.mondec
        tmp.day = self.day
        tmp.hour = self.hour
        tmp.minutes = self.minute
        tmp.seconds = self.sec
        tmp.distance_indicator = self.distanceindicator
        tmp.latitude = self.lat  # -999 means none
        tmp.longitude = self.lon  # -999 means none
        tmp.depth = self.depth  # -999 means none
        if self.depth != -999:
            tmp.depth_indicator = 'F'
        tmp.hypocenter_reporting_agency = 'PRE'
        tmp.number_of_stations_used = self.numstations
        tmp.rms_of_time_residuals = self.datarms
        tmp.magnitude_1 = self.magnitude
        tmp.type_of_magnitude_1 = 'L'
        tmp.magnitude_reporting_agency_1 = 'PRE'
        self.event['1'] = tmp
Ejemplo n.º 2
0
def read_record_type_1(i):
    """ Reads record type 1"""

    tmp = sdt.seisan_1()
    tmp.year = str2int(i[1:5])
    tmp.month = str2int(i[6:8])
    tmp.day = str2int(i[8:10])
    tmp.fixed_origin_time = i[10]
    tmp.hour = str2int(i[11:13])
    tmp.minutes = str2int(i[13:15])
    tmp.seconds = str2float(i[16:20])
    tmp.location_model_indicator = i[20]
    tmp.distance_indicator = i[21]
    tmp.event_id = i[22]
    tmp.latitude = str2float(i[23:30])
    tmp.longitude = str2float(i[30:38])
    tmp.depth = str2float(i[38:43])
    tmp.depth_indicator = i[43]
    tmp.locating_indicator = i[44]
    tmp.hypocenter_reporting_agency = i[45:48]
    tmp.number_of_stations_used = str2int(i[48:51])
    tmp.rms_of_time_residuals = str2float(i[51:55])
    tmp.magnitude_1 = str2float(i[55:59])
    tmp.type_of_magnitude_1 = i[59]
    tmp.magnitude_reporting_agency_1 = i[60:63]
    tmp.magnitude_2 = str2float(i[63:67])
    tmp.type_of_magnitude_2 = i[67]
    tmp.magnitude_reporting_agency_2 = i[68:71]
    tmp.magnitude_3 = str2float(i[71:75])
    tmp.type_of_magnitude_3 = i[75]
    tmp.magnitude_reporting_agency_3 = i[76:79]

    return tmp
Ejemplo n.º 3
0
def read_record_type_1(i):
    """ Reads record type 1"""

    tmp = sdt.seisan_1()
    tmp.year = str2int(i[1:5])
    tmp.month = str2int(i[6:8])
    tmp.day = str2int(i[8:10])
    tmp.fixed_origin_time = i[10]
    tmp.hour = str2int(i[11:13])
    tmp.minutes = str2int(i[13:15])
    tmp.seconds = str2float(i[16:20])
    tmp.location_model_indicator = i[20]
    tmp.distance_indicator = i[21]
    tmp.event_id = i[22]
    tmp.latitude = str2float(i[23:30])
    tmp.longitude = str2float(i[30:38])
    tmp.depth = str2float(i[38:43])
    tmp.depth_indicator = i[43]
    tmp.locating_indicator = i[44]
    tmp.hypocenter_reporting_agency = i[45:48]
    tmp.number_of_stations_used = str2int(i[48:51])
    tmp.rms_of_time_residuals = str2float(i[51:55])
    tmp.magnitude_1 = str2float(i[55:59])
    tmp.type_of_magnitude_1 = i[59]
    tmp.magnitude_reporting_agency_1 = i[60:63]
    tmp.magnitude_2 = str2float(i[63:67])
    tmp.type_of_magnitude_2 = i[67]
    tmp.magnitude_reporting_agency_2 = i[68:71]
    tmp.magnitude_3 = str2float(i[71:75])
    tmp.type_of_magnitude_3 = i[75]
    tmp.magnitude_reporting_agency_3 = i[76:79]

    return tmp
Ejemplo n.º 4
0
    def get_record_type_e(self):
        """ Get record type E"""
        if self.laterr != -999:
            tmp = sdt.seisan_1()
            tmp.gap = 0
            tmp.origin_time_error = self.secerr
            tmp.latitude_error = self.laterr
            tmp.longitude_error = self.lonerr
            tmp.depth_error = 0
            tmp.cov_xy = 0
            tmp.cov_xz = 0
            tmp.cov_yz = 0

            self.event['E'] = tmp
Ejemplo n.º 5
0
    def get_record_type_e(self):
        """Get record type E."""
        if self.laterr != -999:
            tmp = sdt.seisan_1()
            tmp.gap = 0
            tmp.origin_time_error = self.secerr
            tmp.latitude_error = self.laterr
            tmp.longitude_error = self.lonerr
            tmp.depth_error = 0
            tmp.cov_xy = 0
            tmp.cov_xz = 0
            tmp.cov_yz = 0

            self.event['E'] = tmp
Ejemplo n.º 6
0
 def get_record_type_1(self):
     """ Writes record type 1"""
     tmp = sdt.seisan_1()
     tmp.year = self.year
     tmp.month = self.mondec
     tmp.day = self.day
     tmp.hour = self.hour
     tmp.minutes = self.minute
     tmp.seconds = self.sec
     tmp.distance_indicator = self.distanceindicator
     tmp.latitude = self.lat  # -999 means none
     tmp.longitude = self.lon  # -999 means none
     tmp.depth = self.depth  # -999 means none
     if self.depth != -999:
         tmp.depth_indicator = 'F'
     tmp.hypocenter_reporting_agency = 'PRE'
     tmp.number_of_stations_used = self.numstations
     tmp.rms_of_time_residuals = self.datarms
     tmp.magnitude_1 = self.magnitude
     tmp.type_of_magnitude_1 = 'L'
     tmp.magnitude_reporting_agency_1 = 'PRE'
     self.event['1'] = tmp
Ejemplo n.º 7
0
    def settings(self):
        """ Settings """
        QtWidgets.QMessageBox.information(
            self.parent, 'File Format', 'The file should have the following '
            'columns: longitude, latitude, '
            'depth, strike, dip, rake, '
            'magnitude.')

        ext = \
            "Comma Delimeted Text (*.csv);;" +\
            "All Files (*.*)"

        filename, _ = QtWidgets.QFileDialog.getOpenFileName(
            self.parent, 'Open File', '.', ext)
        if filename == '':
            return False
        os.chdir(filename.rpartition('/')[0])

        self.ifile = str(filename)
        self.ext = filename[-3:]

        dlim = ','

        pntfile = open(filename)
        ltmp = pntfile.readline()
        pntfile.close()

        isheader = any(c.isalpha() for c in ltmp)

        srows = 0
        ltmp = ltmp.split(dlim)
        if isheader:
            srows = 1
        else:
            ltmp = [str(c) for c in range(len(ltmp))]

        try:
            datatmp = np.loadtxt(filename, delimiter=dlim, skiprows=srows)
        except ValueError:
            QtWidgets.QMessageBox.critical(
                self.parent, 'Import Error', 'There was a problem loading the '
                'file. You may have a text '
                'character in one of your columns.')
            return False

        dat = []
        if datatmp.ndim == 1:
            datatmp = np.expand_dims(datatmp, 0)

        for i in datatmp:
            event = {}
            tmp = sdt.seisan_1()
            tmp.longitude = i[0]
            tmp.latitude = i[1]
            tmp.depth = i[2]
            tmp.magnitude_1 = i[-1]
            event['1'] = tmp

            tmp2 = sdt.seisan_F()
            tmp2.program_used = 'Generic'
            tmp2.strike = i[3]
            tmp2.dip = i[4]
            tmp2.rake = i[5]
            event['F'] = {}
            event['F']['Generic'] = tmp2
            dat.append(event)

        self.outdata['Seis'] = dat

        return True
Ejemplo n.º 8
0
    def settings(self):
        """ Settings """
        QtWidgets.QMessageBox.information(self.parent, 'File Format',
                                          'The file should have the following '
                                          'columns: longitude, latitude, '
                                          'depth, strike, dip, rake, '
                                          'magnitude.')

        ext = \
            "Comma Delimeted Text (*.csv);;" +\
            "All Files (*.*)"

        filename, _ = QtWidgets.QFileDialog.getOpenFileName(
            self.parent, 'Open File', '.', ext)
        if filename == '':
            return False
        os.chdir(filename.rpartition('/')[0])

        self.ifile = str(filename)
        self.ext = filename[-3:]

        dlim = ','

        pntfile = open(filename)
        ltmp = pntfile.readline()
        pntfile.close()

        isheader = any(c.isalpha() for c in ltmp)

        srows = 0
        ltmp = ltmp.split(dlim)
        if isheader:
            srows = 1
        else:
            ltmp = [str(c) for c in range(len(ltmp))]

        try:
            datatmp = np.loadtxt(filename, delimiter=dlim, skiprows=srows)
        except ValueError:
            QtWidgets.QMessageBox.critical(self.parent, 'Import Error',
                                           'There was a problem loading the '
                                           'file. You may have a text '
                                           'character in one of your columns.')
            return False

        dat = []
        if datatmp.ndim == 1:
            datatmp = np.expand_dims(datatmp, 0)

        for i in datatmp:
            event = {}
            tmp = sdt.seisan_1()
            tmp.longitude = i[0]
            tmp.latitude = i[1]
            tmp.depth = i[2]
            tmp.magnitude_1 = i[-1]
            event['1'] = tmp

            tmp2 = sdt.seisan_F()
            tmp2.program_used = 'Generic'
            tmp2.strike = i[3]
            tmp2.dip = i[4]
            tmp2.rake = i[5]
            event['F'] = {}
            event['F']['Generic'] = tmp2
            dat.append(event)

        self.outdata['Seis'] = dat

        return True