Source:
<code>public static List<Event> getLightEvents(final List<Sample> lightData) { final LinkedList<AmplitudeData> lightAmplitudeData = new LinkedList<>(); for (final Sample sample : lightData) { lightAmplitudeData.add(new AmplitudeData(sample.dateTime, (double) sample.value, sample.offsetMillis)); } final double darknessThreshold = 0.0001; final int approxSunsetHour = 17; final int approxSunriseHour = 6; final int smoothingDegree = 30; final LightEventsDetector detector = new LightEventsDetector(approxSunriseHour, approxSunsetHour, darknessThreshold, smoothingDegree); final LinkedList<Segment> lightSegments = detector.process(lightAmplitudeData); final List<Event> events = new ArrayList<>(); for (final Segment segment : lightSegments) { <START> final String label = segment.getLabel(); <END> if (label.equals(LightLabel.Type.NONE.toString())) continue; final long startTimestamp = segment.getStartTimestamp() + smoothingDegree * 60000; if (label.equals(LightLabel.Type.LIGHTS_OUT.toString()) ) { final LightEvent event = new LightEvent(startTimestamp, startTimestamp + 60000, segment.getOffsetMillis(), label); event.setDescription("Lights on"); events.add(event); final long endTimestamp = segment.getEndTimestamp() - smoothingDegree * 60000; events.add(new LightsOutEvent(endTimestamp, endTimestamp + 60000, segment.getOffsetMillis())); } else if (label.equals(LightLabel.Type.LIGHT_SPIKE.toString())) { events.add(new LightEvent(startTimestamp, startTimestamp + 60000, segment.getOffsetMillis(), label)); } } return events; }</code><technical_language>Label in Event</technical_language>

Target:
public static List<Event> getLightEvents(final List<Sample> lightData) { final LinkedList<AmplitudeData> lightAmplitudeData = new LinkedList<>(); for (final Sample sample : lightData) { lightAmplitudeData.add(new AmplitudeData(sample.dateTime, (double) sample.value, sample.offsetMillis)); } final double darknessThreshold = 0.0001; final int approxSunsetHour = 17; final int approxSunriseHour = 6; final int smoothingDegree = 20; final LightEventsDetector detector = new LightEventsDetector(approxSunriseHour, approxSunsetHour, darknessThreshold, smoothingDegree); final LinkedList<LightSegment> lightSegments = detector.process(lightAmplitudeData); final List<Event> events = new ArrayList<>(); for (final LightSegment segment : lightSegments) { final LightSegment.Type segmentType = segment.segmentType; if (segmentType == LightSegment.Type.NONE) { continue; } final long startTimestamp = segment.startTimestamp + smoothingDegree * MINUTE_IN_MILLIS; final int offsetMillis = segment.offsetMillis; if (segmentType == LightSegment.Type.LIGHTS_OUT) { final LightEvent event = new LightEvent(startTimestamp, startTimestamp + MINUTE_IN_MILLIS, offsetMillis, segmentType.toString()); event.setDescription("Lights on"); events.add(event); final long endTimestamp = segment.endTimestamp - smoothingDegree * MINUTE_IN_MILLIS; events.add(new LightsOutEvent(endTimestamp, endTimestamp + MINUTE_IN_MILLIS, offsetMillis)); } else if (segmentType == LightSegment.Type.LIGHT_SPIKE) { events.add(new LightEvent(startTimestamp, startTimestamp + MINUTE_IN_MILLIS, offsetMillis, segmentType.toString())); } } return events; }