Commit de351b08 authored by Eric Duminil's avatar Eric Duminil
Browse files

Writing etia too

parent 621d0f6f
This diff is collapsed.
...@@ -75,7 +75,7 @@ public class EvapotranspirationCalculator { ...@@ -75,7 +75,7 @@ public class EvapotranspirationCalculator {
List<Double> et0s = new ArrayList<>(); List<Double> et0s = new ArrayList<>();
List<Double> demands = new ArrayList<>(); List<Double> demands = 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");
...@@ -83,7 +83,8 @@ public class EvapotranspirationCalculator { ...@@ -83,7 +83,8 @@ public class EvapotranspirationCalculator {
try (BufferedWriter bw = Files.newBufferedWriter(Paths.get("all_values.csv"), StandardCharsets.UTF_8)) { try (BufferedWriter bw = Files.newBufferedWriter(Paths.get("all_values.csv"), StandardCharsets.UTF_8)) {
bw.write( bw.write(
"DateTime;Temperature;Humidity;GHI;DayOrNight;NetLongwaveRadiation;WindSpeed;SaturationVaporPressure;ActualVaporPressure;Psy;ExtraterrestrialRadiation;NetRadiation;ET0;ET0u\n"); "DateTime;Temperature;Humidity;GHI;DayOrNight;NetLongwaveRadiation;WindSpeed;SaturationVaporPressure;ActualVaporPressure;Psy;ExtraterrestrialRadiation;NetRadiation;ET0;ET0u\n");
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)];[l/h];[l/h]\n"); 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)];[l/h];[l/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))); bw.write(String.format("%s;", counter.format(f)));
String[] row = csvValues.get(i + 2); String[] row = csvValues.get(i + 2);
...@@ -105,12 +106,13 @@ public class EvapotranspirationCalculator { ...@@ -105,12 +106,13 @@ public class EvapotranspirationCalculator {
double hourOfDay = counter.getHour() + 0.5; double hourOfDay = counter.getHour() + 0.5;
double extraterrestrialRadiation = ra(dayOfYear, hourOfDay, lz, lm, latitude); double extraterrestrialRadiation = ra(dayOfYear, hourOfDay, lz, lm, latitude);
double netLongwaveRadiation = rnl(temp, actualVaporPressure, incomingRadiation, altitude, extraterrestrialRadiation); double netLongwaveRadiation = rnl(temp, actualVaporPressure, incomingRadiation, altitude,
extraterrestrialRadiation);
double netRadiation = rn(incomingRadiation, netLongwaveRadiation); double netRadiation = rn(incomingRadiation, netLongwaveRadiation);
double et0 = et0(temp, actualVaporPressure, incomingRadiation, altitude, windSpeed, humidity, netRadiation); double et0 = et0(temp, actualVaporPressure, incomingRadiation, altitude, windSpeed, humidity,
netRadiation);
double et0u = et0u(svf, advection, et0); double et0u = et0u(svf, advection, et0);
bw.write(String.format(";%.5f", netLongwaveRadiation)); bw.write(String.format(";%.5f", netLongwaveRadiation));
bw.write(String.format(";%.1f", windSpeed)); bw.write(String.format(";%.1f", windSpeed));
bw.write(String.format(";%.5f", saturationVaporPressure)); bw.write(String.format(";%.5f", saturationVaporPressure));
...@@ -131,22 +133,28 @@ public class EvapotranspirationCalculator { ...@@ -131,22 +133,28 @@ public class EvapotranspirationCalculator {
// System.out.println(rain.stream().collect(Collectors.summarizingDouble(Double::doubleValue))); // System.out.println(rain.stream().collect(Collectors.summarizingDouble(Double::doubleValue)));
Double et0Sum = et0s.stream().collect(Collectors.summingDouble(Double::doubleValue)); Double et0Sum = et0s.stream().collect(Collectors.summingDouble(Double::doubleValue));
System.out.println("Summe aller ET0: " + et0Sum); System.out.println(String.format("Summe aller ET0 : %4.0f mm / y", et0Sum));
Double et0uSum = et0us.stream().collect(Collectors.summingDouble(Double::doubleValue)); Double et0uSum = et0us.stream().collect(Collectors.summingDouble(Double::doubleValue));
System.out.println("Summe aller ET0u: " + 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);
for (double et0u : et0us) { try (BufferedWriter bw = Files.newBufferedWriter(Paths.get("etia.csv"), StandardCharsets.UTF_8)) {
double etia = 0; bw.write("ETIa\n");
if (et0u > 0) { bw.write("[l/h]\n");
etia = etia(tr, et0u, et0uFactor);
for (double et0u : et0us) {
double etia = 0;
if (et0u > 0) {
etia = etia(tr, et0u, et0uFactor);
}
demands.add(etia);
bw.write(String.format("%.3f%n", etia));
} }
demands.add(etia);
} }
System.out.println( System.out.println(String.format("Summe aller ETIa: %4.0f mm / y",
"Summe aller ETIa: " + demands.stream().collect(Collectors.summingDouble(Double::doubleValue))); demands.stream().collect(Collectors.summingDouble(Double::doubleValue))));
} }
...@@ -161,7 +169,8 @@ public class EvapotranspirationCalculator { ...@@ -161,7 +169,8 @@ public class EvapotranspirationCalculator {
return svf * advection * et0; return svf * advection * et0;
} }
private static double et0(double temperature, double actualVaporPressure, double shortWaveRadiation, double altitude, private static double et0(double temperature, double actualVaporPressure, double shortWaveRadiation,
double altitude,
double windSpeed, double humidity, double netRadiation) { double windSpeed, double humidity, double netRadiation) {
double gamma = gamma(altitude); double gamma = gamma(altitude);
double saturationVaporPressure = saturationVaporPressure(temperature); double saturationVaporPressure = saturationVaporPressure(temperature);
...@@ -203,7 +212,7 @@ public class EvapotranspirationCalculator { ...@@ -203,7 +212,7 @@ public class EvapotranspirationCalculator {
// NetLongwaveRadiation // NetLongwaveRadiation
// unit is apparently [MJ / (m².h)] // unit is apparently [MJ / (m².h)]
private static double rnl(double temperature, double actualVaporPressure, double rs, double altitude, private static double rnl(double temperature, double actualVaporPressure, double rs, double altitude,
double extraterrestrialRadiation){ double extraterrestrialRadiation) {
// divide by 24 for hourly // divide by 24 for hourly
double sigma = 4.903E-9 / 24; double sigma = 4.903E-9 / 24;
double rso = (0.75 + 2E-5 * altitude) * extraterrestrialRadiation; double rso = (0.75 + 2E-5 * altitude) * extraterrestrialRadiation;
......
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