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 {
List<Double> et0s = new ArrayList<>();
List<Double> demands = new ArrayList<>();
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 hours = (int) Duration.between(start, end).toHours();
DateTimeFormatter f = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm");
......@@ -83,7 +83,8 @@ public class EvapotranspirationCalculator {
try (BufferedWriter bw = Files.newBufferedWriter(Paths.get("all_values.csv"), StandardCharsets.UTF_8)) {
bw.write(
"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++) {
bw.write(String.format("%s;", counter.format(f)));
String[] row = csvValues.get(i + 2);
......@@ -105,12 +106,13 @@ public class EvapotranspirationCalculator {
double hourOfDay = counter.getHour() + 0.5;
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 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);
bw.write(String.format(";%.5f", netLongwaveRadiation));
bw.write(String.format(";%.1f", windSpeed));
bw.write(String.format(";%.5f", saturationVaporPressure));
......@@ -131,22 +133,28 @@ public class EvapotranspirationCalculator {
// System.out.println(rain.stream().collect(Collectors.summarizingDouble(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));
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);
for (double et0u : et0us) {
double etia = 0;
if (et0u > 0) {
etia = etia(tr, et0u, et0uFactor);
try (BufferedWriter bw = Files.newBufferedWriter(Paths.get("etia.csv"), StandardCharsets.UTF_8)) {
bw.write("ETIa\n");
bw.write("[l/h]\n");
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(
"Summe aller ETIa: " + demands.stream().collect(Collectors.summingDouble(Double::doubleValue)));
System.out.println(String.format("Summe aller ETIa: %4.0f mm / y",
demands.stream().collect(Collectors.summingDouble(Double::doubleValue))));
}
......@@ -161,7 +169,8 @@ public class EvapotranspirationCalculator {
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 gamma = gamma(altitude);
double saturationVaporPressure = saturationVaporPressure(temperature);
......@@ -203,7 +212,7 @@ public class EvapotranspirationCalculator {
// NetLongwaveRadiation
// unit is apparently [MJ / (m².h)]
private static double rnl(double temperature, double actualVaporPressure, double rs, double altitude,
double extraterrestrialRadiation){
double extraterrestrialRadiation) {
// divide by 24 for hourly
double sigma = 4.903E-9 / 24;
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