Commit 5b7f6188 authored by Eric Duminil's avatar Eric Duminil
Browse files

All values in all_values.csv

parent fd00b00f
This diff is collapsed.
This diff is collapsed.
...@@ -74,28 +74,28 @@ public class EvapotranspirationCalculator { ...@@ -74,28 +74,28 @@ public class EvapotranspirationCalculator {
List<Double> et0us = new ArrayList<>(); List<Double> et0us = new ArrayList<>();
List<Double> et0s = new ArrayList<>(); List<Double> et0s = new ArrayList<>();
List<Double> demands = new ArrayList<>(); List<Double> demands = new ArrayList<>();
List<String> csvLines = new ArrayList<>();
LocalDateTime counter = start; LocalDateTime counter = start;
// System.out.println("Date,ETIa (L/m²/d),ET0 (L/m²/d)"); // System.out.println("Date,ETIa (L/m²/d),ET0 (L/m²/d)");
int startHours = (int) Duration.between(startOfYear, start).toHours(); int startHours = (int) Duration.between(startOfYear, start).toHours();
int hours = (int) Duration.between(start, end).toHours(); int hours = (int) Duration.between(start, end).toHours();
DateTimeFormatter f = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"); DateTimeFormatter f = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm");
Locale.setDefault(new Locale("en", "US")); Locale.setDefault(new Locale("en", "US"));
try (BufferedWriter bw = Files.newBufferedWriter(Paths.get("all_values.csv"), StandardCharsets.UTF_8)) { csvLines.add("DateTime;Temperature;Humidity;GHI;DayOrNight;NetLongwaveRadiation;WindSpeed;SaturationVaporPressure;ActualVaporPressure;Psy;ExtraterrestrialRadiation;NetRadiation;ET0;ET0u");
bw.write( csvLines.add(
"DateTime;Temperature;Humidity;GHI;DayOrNight;NetLongwaveRadiation;WindSpeed;SaturationVaporPressure;ActualVaporPressure;Psy;ExtraterrestrialRadiation;NetRadiation;ET0;ET0u\n"); "dd/mm/yyyy HH:MM;[°C];[%];[W/m²];[0/1];[MJ/(m².h)];[m/s];[kPa];[kPa];[kPa/°C];[MJ/(m².h)];[MJ/(m².h)];[mm/h];[mm/h]");
bw.write(
"dd/mm/yyyy HH:MM;[°C];[%];[W/m²];[0/1];[MJ/(m².h)];[m/s];[kPa];[kPa];[kPa/°C];[MJ/(m².h)];[MJ/(m².h)];[mm/h];[mm/h]\n");
for (int i = startHours; i <= startHours + hours; i++) { for (int i = startHours; i <= startHours + hours; i++) {
bw.write(String.format("%s;", counter.format(f))); StringBuffer csvLine = new StringBuffer();
csvLine.append(String.format("%s;", counter.format(f)));
String[] row = csvValues.get(i + 2); String[] row = csvValues.get(i + 2);
double temp = Double.parseDouble(row[tempIndex]); double temp = Double.parseDouble(row[tempIndex]);
double humidity = Double.parseDouble(row[humidityIndex]); double humidity = Double.parseDouble(row[humidityIndex]);
double incomingRadiation = Double.parseDouble(row[irrIndex]); double incomingRadiation = Double.parseDouble(row[irrIndex]);
bw.write(String.format("%.1f", temp)); csvLine.append(String.format("%.1f", temp));
bw.write(String.format(";%.0f", humidity)); csvLine.append(String.format(";%.0f", humidity));
bw.write(String.format(";%.0f", incomingRadiation)); csvLine.append(String.format(";%.0f", incomingRadiation));
bw.write(String.format(";%d", incomingRadiation > 0 ? 1 : 0)); csvLine.append(String.format(";%d", incomingRadiation > 0 ? 1 : 0));
// convert to MJ/h - 1 W = 0.0036 MJ/h // convert to MJ/h - 1 W = 0.0036 MJ/h
incomingRadiation *= 0.0036; incomingRadiation *= 0.0036;
...@@ -113,21 +113,20 @@ public class EvapotranspirationCalculator { ...@@ -113,21 +113,20 @@ public class EvapotranspirationCalculator {
netRadiation); netRadiation);
double et0u = et0u(svf, advection, et0); double et0u = et0u(svf, advection, et0);
bw.write(String.format(";%.5f", netLongwaveRadiation)); csvLine.append(String.format(";%.5f", netLongwaveRadiation));
bw.write(String.format(";%.1f", windSpeed)); csvLine.append(String.format(";%.1f", windSpeed));
bw.write(String.format(";%.5f", saturationVaporPressure)); csvLine.append(String.format(";%.5f", saturationVaporPressure));
bw.write(String.format(";%.5f", actualVaporPressure)); csvLine.append(String.format(";%.5f", actualVaporPressure));
bw.write(String.format(";%.5f", gamma(altitude))); csvLine.append(String.format(";%.5f", gamma(altitude)));
bw.write(String.format(";%.5f", extraterrestrialRadiation)); csvLine.append(String.format(";%.5f", extraterrestrialRadiation));
bw.write(String.format(";%.5f", netRadiation)); csvLine.append(String.format(";%.5f", netRadiation));
bw.write(String.format(";%.3f", et0)); csvLine.append(String.format(";%.3f", et0));
bw.write(String.format(";%.3f", et0u)); csvLine.append(String.format(";%.3f", et0u));
et0s.add(et0); et0s.add(et0);
et0us.add(et0u); et0us.add(et0u);
counter = counter.plusHours(1); counter = counter.plusHours(1);
bw.write("\n"); csvLines.add(csvLine.toString());
}
} }
// System.out.println(rain.stream().collect(Collectors.summarizingDouble(Double::doubleValue))); // System.out.println(rain.stream().collect(Collectors.summarizingDouble(Double::doubleValue)));
...@@ -139,17 +138,18 @@ public class EvapotranspirationCalculator { ...@@ -139,17 +138,18 @@ public class EvapotranspirationCalculator {
System.out.println(String.format("Summe aller ET0u: %4.0f mm / y", et0uSum)); System.out.println(String.format("Summe aller ET0u: %4.0f mm / y", et0uSum));
double et0uFactor = (0.865 * Math.log10(1 / et0uSum) + 3.36); double et0uFactor = (0.865 * Math.log10(1 / et0uSum) + 3.36);
try (BufferedWriter bw = Files.newBufferedWriter(Paths.get("etia.csv"), StandardCharsets.UTF_8)) { try (BufferedWriter bw = Files.newBufferedWriter(Paths.get("all_values.csv"), StandardCharsets.UTF_8)) {
bw.write("ETIa\n"); bw.write(csvLines.get(0) + ";ET0u;ETIa\n");
bw.write("[l/h]\n"); bw.write(csvLines.get(1) + ";[mm/h];[mm/h]\n");
for (double et0u : et0us) { for (int h = 0; h < et0us.size(); h++) {
double et0u = et0us.get(h);
double etia = 0; double etia = 0;
if (et0u > 0) { if (et0u > 0) {
etia = etia(tr, et0u, et0uFactor); etia = etia(tr, et0u, et0uFactor);
} }
demands.add(etia); demands.add(etia);
bw.write(String.format("%.3f%n", etia)); bw.write(String.format("%s;%.3f;%.3f%n", csvLines.get(h + 2), et0u, etia));
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment