Compare commits
	
		
			2 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| c723c4c6f7 | |||
| 75618c9a0d | 
@@ -1,4 +1,4 @@
 | 
			
		||||
# SPDX-FileCopyrightText: 2022-present Hubert Siejkowski <h.siejkowski.cyfronet.pl>
 | 
			
		||||
#
 | 
			
		||||
# SPDX-License-Identifier: GPL
 | 
			
		||||
__version__ = "0.6.3"
 | 
			
		||||
__version__ = "0.6.4"
 | 
			
		||||
 
 | 
			
		||||
@@ -73,16 +73,25 @@ class ModelRunner:
 | 
			
		||||
        fpath = self.output_dir / f"{stream_path.stem}_annotations.mseed"
 | 
			
		||||
        ann.write(fpath, format="MSEED")
 | 
			
		||||
 | 
			
		||||
    @staticmethod
 | 
			
		||||
    def validate_stream(stream):
 | 
			
		||||
    def validate_stream(self, stream):
 | 
			
		||||
        model = self.model
 | 
			
		||||
        groups = defaultdict(list)
 | 
			
		||||
        samples = defaultdict(list)
 | 
			
		||||
        for trace in stream:
 | 
			
		||||
            groups[trace.stats.station].append(trace.stats.channel[-1])
 | 
			
		||||
            samples[trace.stats.station].append(
 | 
			
		||||
                    float(trace.stats.npts / trace.stats.sampling_rate)
 | 
			
		||||
                    )
 | 
			
		||||
 | 
			
		||||
        number_of_channels = list(map(len, groups.values()))
 | 
			
		||||
        lenght_of_traces = list(map(max , samples.values()))
 | 
			
		||||
 | 
			
		||||
        if max(number_of_channels) < 3:
 | 
			
		||||
            exit_error("Not enough traces in the stream")
 | 
			
		||||
        if max(number_of_channels) < model.in_channels:
 | 
			
		||||
            exit_error("Not enough channels in the stream.")
 | 
			
		||||
 | 
			
		||||
        minimal_trace_length = model.in_samples / model.sampling_rate
 | 
			
		||||
        if max(lenght_of_traces) < minimal_trace_length:
 | 
			
		||||
            exit_error(f"All traces are shorter than required {int(minimal_trace_length):d} seconds")
 | 
			
		||||
 | 
			
		||||
    def find_picks(self, stream_file_name, save_annotations=True):
 | 
			
		||||
        stream_path = pathlib.Path(stream_file_name)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user