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)
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
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)