예제 #1
0
    def __get_stations_stats(self):
        self.__dataless_files = MseedUtil.get_dataless_files(self.__root_path)
        stations_stats = []
        for file in self.dataless_files:
            stations_stats.append(StationsStats.from_dataless(file))

        return stations_stats
예제 #2
0
    def get_metadata(self, file_path):
        self.__metadata_files = MseedUtil.get_dataless_files(self.__root_path)
        #self.__metadata_files = MseedUtil.get_xml_files(self.__root_path)
        mseed_stats = ObspyUtil.get_stats(file_path)
        metadata = self.check_metadata(self.__metadata_files, mseed_stats)

        return metadata
예제 #3
0
 def validate_file(self):
     if not MseedUtil.is_valid_mseed(self.file_selector.file_path):
         msg = "The file {} is not a valid mseed. Please, choose a valid format".\
             format(self.file_selector.file_name)
         md = MessageDialog(self)
         md.set_info_message(msg)
         raise InvalidFile(msg)
예제 #4
0
파일: wavelet.py 프로젝트: ProjectISP/ISP
    def __init__(self, data, **kwargs):
        """
        Class to apply wavelet convolution to a mseed file.
        The bank of atoms is computed at the class initialisation.
        :param data: Either the mseed file path or an obspy Tracer.
        :keyword kwargs:
        :keyword wmin: Minimum number of cycles. Default = 6.
        :keyword wmax: Maximum number of cycles. Default = 6.
        :keyword tt: Period of the Morlet Wavelet. Default = 2.
        :keyword fmin: Minimum Central frequency (in Hz). Default = 2.
        :keyword fmax: Maximum Central frequency (in Hz). Default = 12.
        :keyword m: Parameter for Paul Wavelet. Default = 30.
        :keyword nf: Number of logarithmically spaced frequencies between fmin and fmax. Default = 20.
        :keyword use_wavelet: Default = Complex Morlet
        :keyword use_rfft: True if it should use rfft instead of fft. Default = True.
        :keyword decimate: True if it should try to decimate the trace. Default = False. The decimation
            factor is equal to q = 0.4*SR/fmax. For SR=200Hz and fmax=40Hz, q=2. This will downsize the
            sample rate to 100 Hz.
        :raise InvalidFile: If file is not a valid mseed.
        :example:
        >>> cw = ConvolveWavelet(data)
        >>> cw.setup_wavelet()
        >>> sc = cw.scalogram_in_dbs
        >>> cf = cw.cf_lowpass()
        """

        if isinstance(data, Trace):
            self.stats = TracerStats.from_dict(data.stats)
            self.trace: Trace = data
        else:
            if not MseedUtil.is_valid_mseed(data):
                raise InvalidFile("The file: {} is not a valid mseed.".format(data))
            self.trace: Trace = read(data)[0]
            self.stats = ObspyUtil.get_stats(data)

        self._wmin = float(kwargs.get("wmin", 6.))
        self._wmax = float(kwargs.get("wmax", 6.))
        self._tt = float(kwargs.get("tt", 2.))
        self._fmin = float(kwargs.get("fmin", 2.))
        self._fmax = float(kwargs.get("fmax", 12.))
        self._nf = int(kwargs.get("nf", 20))
        self._use_wavelet = kwargs.get("use_wavelet", "Complex Morlet")
        self._m = int(kwargs.get("m", 30))
        self._use_rfft = kwargs.get("use_rfft", False)
        self._decimate = kwargs.get("decimate", False)

        self._validate_kwargs()
        # print(self.stats)

        self._data = None
        self._npts = 0
        self._tf = None
        self._start_time = self.stats.StartTime
        self._end_time = self.stats.EndTime
        self._sample_rate = self.stats.Sampling_rate

        self._frex = None
        self._n_cycles = None
        self._wtime = None
        self._half_wave = None
예제 #5
0
 def stationsInfo(self, FK=True):
     if FK:
         obsfiles = MseedUtil.get_mseed_files(self.root_pathFK_bind.value)
     else:
         obsfiles = MseedUtil.get_mseed_files(self.root_pathBP_bind.value)
     obsfiles.sort()
     sd = []
     for file in obsfiles:
         st = SeismogramDataAdvanced(file)
         station = [
             st.stats.Network, st.stats.Station, st.stats.Location,
             st.stats.Channel, st.stats.StartTime, st.stats.EndTime,
             st.stats.Sampling_rate, st.stats.Npts
         ]
         sd.append(station)
     self._stations_info = StationsInfo(sd, check=True)
     self._stations_info.show()
예제 #6
0
파일: efg_frame.py 프로젝트: ProjectISP/ISP
    def get_files(self, dir_path):
        files_path = MseedUtil.get_tree_hd5_files(self, dir_path, robust=False)
        self.set_pagination_files(files_path)
        # print(files_path)
        pyc.QMetaObject.invokeMethod(self.progressbar, 'accept',
                                     qt.AutoConnection)

        return files_path
예제 #7
0
    def plot_map_stations(self):
        md = MessageDialog(self)
        md.hide()
        try:
            stations = []
            obsfiles = MseedUtil.get_mseed_files(self.root_path_bind.value)
            obsfiles.sort()
            try:
                if len(self.stream) > 0:
                    stations = ObspyUtil.get_stations_from_stream(self.stream)
            except:
                pass

            map_dict = {}
            sd = []

            for file in obsfiles:
                if len(stations) == 0:
                    st = SeismogramDataAdvanced(file)

                    name = st.stats.Network + "." + st.stats.Station

                    sd.append(name)

                    st_coordinates = self.__metadata_manager.extract_coordinates(
                        self.inventory, file)

                    map_dict[name] = [
                        st_coordinates.Latitude, st_coordinates.Longitude
                    ]
                else:
                    st = SeismogramDataAdvanced(file)
                    if st.stats.Station in stations:
                        name = st.stats.Network + "." + st.stats.Station

                        sd.append(name)

                        st_coordinates = self.__metadata_manager.extract_coordinates(
                            self.inventory, file)

                        map_dict[name] = [
                            st_coordinates.Latitude, st_coordinates.Longitude
                        ]
                    else:
                        pass

            self.map_stations = StationsMap(map_dict)
            self.map_stations.plot_stations_map(latitude=self.latDB.value(),
                                                longitude=self.lonDB.value())

            md.set_info_message("Station Map OK !!! ")
        except:
            md.set_error_message(
                " Please check you have process and plot seismograms and opened stations info,"
                "Please additionally check that your metada fits with your mseed files"
            )

        md.show()
예제 #8
0
파일: efg_frame.py 프로젝트: ProjectISP/ISP
    def sort_by_baz_advance(self, file):

        geodetic = MseedUtil.get_geodetic(file)

        if geodetic[1] is not None:

            return geodetic[0]
        else:
            return 0.
예제 #9
0
    def plot_seismograms(self):
        parameters = self.get_inversion_parameters()
        lat = float(parameters['latitude'])
        lon = float(parameters['longitude'])
        starttime = convert_qdatetime_utcdatetime(self.starttime_date)
        endtime = convert_qdatetime_utcdatetime(self.endtime_date)
        diff = endtime - starttime

        parameters = self.parameters.getParameters()
        all_traces = []
        obsfiles = MseedUtil.get_mseed_files(self.root_path_bind.value)
        obsfiles.sort()

        for file in obsfiles:
            sd = SeismogramDataAdvanced(file)
            if self.trimCB.isChecked() and diff >= 0:
                tr = sd.get_waveform_advanced(
                    parameters,
                    self.inventory,
                    filter_error_callback=self.filter_error_message,
                    start_time=starttime,
                    end_time=endtime)
            else:
                tr = sd.get_waveform_advanced(
                    parameters,
                    self.inventory,
                    filter_error_callback=self.filter_error_message)

            all_traces.append(tr)

        self.st = Stream(traces=all_traces)
        self.stream_frame = MatplotlibFrame(self.st, type='normal')
        self.stream_frame.show()

        if self.st:
            min_dist = self.min_distCB.value()
            max_dist = self.max_distCB.value()
            mt = MTIManager(self.st, self.inventory, lat, lon, min_dist,
                            max_dist)
            [self.stream, self.deltas,
             self.stations_isola_path] = mt.get_stations_index()
예제 #10
0
 def __init__(self, root_path):
     self.__root_path = root_path
     self.__dataless_files = []
     self.__stations_stats = None
     #self.__dataless_file = MseedUtil.get_dataless_files(self.__root_path)
     self.__metadata_file = MseedUtil.get_metadata_files(self.__root_path)
예제 #11
0
 def validate_file(self):
     if not MseedUtil.is_valid_mseed(self.file_selector.file_path):
         msg = "The file {} is not a valid mseed. Please, choose a valid format". \
             format(self.file_selector.file_name)
         raise InvalidFile(msg)