@Test public void testEventDepthPopulated() throws Exception { Waveform waveform = createValidWaveform(); SACHeader header = exporter.sacHeaderFromWaveform(waveform); Assertions.assertTrue(header.evdp != 0 && !SACHeader.isDefault(header.evdp), "Expect that the waveform should have a populated event depth if the original file had it."); }
public SACHeader sacHeaderFromWaveform(Waveform w) throws IOException { try (SACHeader header = new SACHeader()) { header.setTime(new TimeT(w.getEvent().getOriginTime())); header.setBeginTime(new TimeT(w.getBeginTime())); header.setOriginTime(new TimeT(w.getEvent().getOriginTime())); header.nevid = Integer.parseInt(w.getEvent().getEventId()); if (w.getAssociatedPicks() != null) { for (int i = 0; i < w.getAssociatedPicks().size() && i <= 10; i++) { try { WaveformPick pick = w.getAssociatedPicks().get(i); if (pick.getPickType().equalsIgnoreCase(PICK_TYPES.F.getPhase())) { header.f = pick.getPickTimeSecFromOrigin(); } else if (pick.getPickType().equalsIgnoreCase(PICK_TYPES.A.getPhase())) { header.a = pick.getPickTimeSecFromOrigin(); } else if (pick.getPickType().equalsIgnoreCase(PICK_TYPES.B.getPhase())) { header.b = pick.getPickTimeSecFromOrigin(); } else if (pick.getPickType().equalsIgnoreCase(PICK_TYPES.O.getPhase())) { header.o = pick.getPickTimeSecFromOrigin(); } else { header.setTimePick(i, pick.getPickTimeSecFromOrigin(), pick.getPickName()); } } catch (RuntimeException e) { log.error(e.getMessage(), e); } } } header.delta = (float) (1.0 / w.getSampleRate()); header.kstnm = w.getStream().getStation().getStationName(); header.kcmpnm = w.getStream().getChannelName(); header.stla = (float) w.getStream().getStation().getLatitude(); header.stlo = (float) w.getStream().getStation().getLongitude(); header.knetwk = w.getStream().getStation().getNetworkName(); header.kevnm = w.getEvent().getEventId(); header.evla = (float) w.getEvent().getLatitude(); header.evlo = (float) w.getEvent().getLongitude(); header.evdp = (float) w.getEvent().getDepth(); String depType = w.getSegmentType(); if (depType != null && !depType.trim().isEmpty()) { if (depType.toLowerCase(Locale.ENGLISH).startsWith("dis")) { header.idep = 6; } else if (depType.toLowerCase(Locale.ENGLISH).startsWith("vel")) { header.idep = 7; } else if (depType.toLowerCase(Locale.ENGLISH).startsWith("acc")) { header.idep = 8; } } return header; } }
SacExporter { public SACHeader sacHeaderFromWaveform(Waveform w) throws IOException { try (SACHeader header = new SACHeader()) { header.setTime(new TimeT(w.getEvent().getOriginTime())); header.setBeginTime(new TimeT(w.getBeginTime())); header.setOriginTime(new TimeT(w.getEvent().getOriginTime())); header.nevid = Integer.parseInt(w.getEvent().getEventId()); if (w.getAssociatedPicks() != null) { for (int i = 0; i < w.getAssociatedPicks().size() && i <= 10; i++) { try { WaveformPick pick = w.getAssociatedPicks().get(i); if (pick.getPickType().equalsIgnoreCase(PICK_TYPES.F.getPhase())) { header.f = pick.getPickTimeSecFromOrigin(); } else if (pick.getPickType().equalsIgnoreCase(PICK_TYPES.A.getPhase())) { header.a = pick.getPickTimeSecFromOrigin(); } else if (pick.getPickType().equalsIgnoreCase(PICK_TYPES.B.getPhase())) { header.b = pick.getPickTimeSecFromOrigin(); } else if (pick.getPickType().equalsIgnoreCase(PICK_TYPES.O.getPhase())) { header.o = pick.getPickTimeSecFromOrigin(); } else { header.setTimePick(i, pick.getPickTimeSecFromOrigin(), pick.getPickName()); } } catch (RuntimeException e) { log.error(e.getMessage(), e); } } } header.delta = (float) (1.0 / w.getSampleRate()); header.kstnm = w.getStream().getStation().getStationName(); header.kcmpnm = w.getStream().getChannelName(); header.stla = (float) w.getStream().getStation().getLatitude(); header.stlo = (float) w.getStream().getStation().getLongitude(); header.knetwk = w.getStream().getStation().getNetworkName(); header.kevnm = w.getEvent().getEventId(); header.evla = (float) w.getEvent().getLatitude(); header.evlo = (float) w.getEvent().getLongitude(); header.evdp = (float) w.getEvent().getDepth(); String depType = w.getSegmentType(); if (depType != null && !depType.trim().isEmpty()) { if (depType.toLowerCase(Locale.ENGLISH).startsWith("dis")) { header.idep = 6; } else if (depType.toLowerCase(Locale.ENGLISH).startsWith("vel")) { header.idep = 7; } else if (depType.toLowerCase(Locale.ENGLISH).startsWith("acc")) { header.idep = 8; } } return header; } } }
SacExporter { public SACHeader sacHeaderFromWaveform(Waveform w) throws IOException { try (SACHeader header = new SACHeader()) { header.setTime(new TimeT(w.getEvent().getOriginTime())); header.setBeginTime(new TimeT(w.getBeginTime())); header.setOriginTime(new TimeT(w.getEvent().getOriginTime())); header.nevid = Integer.parseInt(w.getEvent().getEventId()); if (w.getAssociatedPicks() != null) { for (int i = 0; i < w.getAssociatedPicks().size() && i <= 10; i++) { try { WaveformPick pick = w.getAssociatedPicks().get(i); if (pick.getPickType().equalsIgnoreCase(PICK_TYPES.F.getPhase())) { header.f = pick.getPickTimeSecFromOrigin(); } else if (pick.getPickType().equalsIgnoreCase(PICK_TYPES.A.getPhase())) { header.a = pick.getPickTimeSecFromOrigin(); } else if (pick.getPickType().equalsIgnoreCase(PICK_TYPES.B.getPhase())) { header.b = pick.getPickTimeSecFromOrigin(); } else if (pick.getPickType().equalsIgnoreCase(PICK_TYPES.O.getPhase())) { header.o = pick.getPickTimeSecFromOrigin(); } else { header.setTimePick(i, pick.getPickTimeSecFromOrigin(), pick.getPickName()); } } catch (RuntimeException e) { log.error(e.getMessage(), e); } } } header.delta = (float) (1.0 / w.getSampleRate()); header.kstnm = w.getStream().getStation().getStationName(); header.kcmpnm = w.getStream().getChannelName(); header.stla = (float) w.getStream().getStation().getLatitude(); header.stlo = (float) w.getStream().getStation().getLongitude(); header.knetwk = w.getStream().getStation().getNetworkName(); header.kevnm = w.getEvent().getEventId(); header.evla = (float) w.getEvent().getLatitude(); header.evlo = (float) w.getEvent().getLongitude(); header.evdp = (float) w.getEvent().getDepth(); String depType = w.getSegmentType(); if (depType != null && !depType.trim().isEmpty()) { if (depType.toLowerCase(Locale.ENGLISH).startsWith("dis")) { header.idep = 6; } else if (depType.toLowerCase(Locale.ENGLISH).startsWith("vel")) { header.idep = 7; } else if (depType.toLowerCase(Locale.ENGLISH).startsWith("acc")) { header.idep = 8; } } return header; } }  }
SacExporter { public SACHeader sacHeaderFromWaveform(Waveform w) throws IOException { try (SACHeader header = new SACHeader()) { header.setTime(new TimeT(w.getEvent().getOriginTime())); header.setBeginTime(new TimeT(w.getBeginTime())); header.setOriginTime(new TimeT(w.getEvent().getOriginTime())); header.nevid = Integer.parseInt(w.getEvent().getEventId()); if (w.getAssociatedPicks() != null) { for (int i = 0; i < w.getAssociatedPicks().size() && i <= 10; i++) { try { WaveformPick pick = w.getAssociatedPicks().get(i); if (pick.getPickType().equalsIgnoreCase(PICK_TYPES.F.getPhase())) { header.f = pick.getPickTimeSecFromOrigin(); } else if (pick.getPickType().equalsIgnoreCase(PICK_TYPES.A.getPhase())) { header.a = pick.getPickTimeSecFromOrigin(); } else if (pick.getPickType().equalsIgnoreCase(PICK_TYPES.B.getPhase())) { header.b = pick.getPickTimeSecFromOrigin(); } else if (pick.getPickType().equalsIgnoreCase(PICK_TYPES.O.getPhase())) { header.o = pick.getPickTimeSecFromOrigin(); } else { header.setTimePick(i, pick.getPickTimeSecFromOrigin(), pick.getPickName()); } } catch (RuntimeException e) { log.error(e.getMessage(), e); } } } header.delta = (float) (1.0 / w.getSampleRate()); header.kstnm = w.getStream().getStation().getStationName(); header.kcmpnm = w.getStream().getChannelName(); header.stla = (float) w.getStream().getStation().getLatitude(); header.stlo = (float) w.getStream().getStation().getLongitude(); header.knetwk = w.getStream().getStation().getNetworkName(); header.kevnm = w.getEvent().getEventId(); header.evla = (float) w.getEvent().getLatitude(); header.evlo = (float) w.getEvent().getLongitude(); header.evdp = (float) w.getEvent().getDepth(); String depType = w.getSegmentType(); if (depType != null && !depType.trim().isEmpty()) { if (depType.toLowerCase(Locale.ENGLISH).startsWith("dis")) { header.idep = 6; } else if (depType.toLowerCase(Locale.ENGLISH).startsWith("vel")) { header.idep = 7; } else if (depType.toLowerCase(Locale.ENGLISH).startsWith("acc")) { header.idep = 8; } } return header; } }  Result<String> writeWaveformToDirectory(File exportDirectory, Waveform w); SACHeader sacHeaderFromWaveform(Waveform w); String getFileName(Waveform w); }
SacExporter { public SACHeader sacHeaderFromWaveform(Waveform w) throws IOException { try (SACHeader header = new SACHeader()) { header.setTime(new TimeT(w.getEvent().getOriginTime())); header.setBeginTime(new TimeT(w.getBeginTime())); header.setOriginTime(new TimeT(w.getEvent().getOriginTime())); header.nevid = Integer.parseInt(w.getEvent().getEventId()); if (w.getAssociatedPicks() != null) { for (int i = 0; i < w.getAssociatedPicks().size() && i <= 10; i++) { try { WaveformPick pick = w.getAssociatedPicks().get(i); if (pick.getPickType().equalsIgnoreCase(PICK_TYPES.F.getPhase())) { header.f = pick.getPickTimeSecFromOrigin(); } else if (pick.getPickType().equalsIgnoreCase(PICK_TYPES.A.getPhase())) { header.a = pick.getPickTimeSecFromOrigin(); } else if (pick.getPickType().equalsIgnoreCase(PICK_TYPES.B.getPhase())) { header.b = pick.getPickTimeSecFromOrigin(); } else if (pick.getPickType().equalsIgnoreCase(PICK_TYPES.O.getPhase())) { header.o = pick.getPickTimeSecFromOrigin(); } else { header.setTimePick(i, pick.getPickTimeSecFromOrigin(), pick.getPickName()); } } catch (RuntimeException e) { log.error(e.getMessage(), e); } } } header.delta = (float) (1.0 / w.getSampleRate()); header.kstnm = w.getStream().getStation().getStationName(); header.kcmpnm = w.getStream().getChannelName(); header.stla = (float) w.getStream().getStation().getLatitude(); header.stlo = (float) w.getStream().getStation().getLongitude(); header.knetwk = w.getStream().getStation().getNetworkName(); header.kevnm = w.getEvent().getEventId(); header.evla = (float) w.getEvent().getLatitude(); header.evlo = (float) w.getEvent().getLongitude(); header.evdp = (float) w.getEvent().getDepth(); String depType = w.getSegmentType(); if (depType != null && !depType.trim().isEmpty()) { if (depType.toLowerCase(Locale.ENGLISH).startsWith("dis")) { header.idep = 6; } else if (depType.toLowerCase(Locale.ENGLISH).startsWith("vel")) { header.idep = 7; } else if (depType.toLowerCase(Locale.ENGLISH).startsWith("acc")) { header.idep = 8; } } return header; } }  Result<String> writeWaveformToDirectory(File exportDirectory, Waveform w); SACHeader sacHeaderFromWaveform(Waveform w); String getFileName(Waveform w);  }