Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Mayer
CircularGreenSimCity
Commits
5b161862
Commit
5b161862
authored
Jun 01, 2023
by
Eric Duminil
Browse files
CSV table with many intermediate values, for debugging
parent
a2247488
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
tree-water-demand/all_values.csv
0 → 100644
View file @
5b161862
This diff is collapsed.
Click to expand it.
tree-water-demand/src/main/java/de/hft/stuttgart/water/TreeWaterDemand.java
View file @
5b161862
package
de.hft.stuttgart.water
;
package
de.hft.stuttgart.water
;
import
java.io.BufferedWriter
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.file.Files
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.nio.file.Paths
;
import
java.time.Duration
;
import
java.time.Duration
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.time.
Month
;
import
java.time.
format.DateTimeFormatter
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
com.opencsv.CSVReader
;
import
com.opencsv.CSVReader
;
import
com.opencsv.exceptions.CsvException
;
import
com.opencsv.exceptions.CsvException
;
public
class
TreeWaterDemand
{
public
class
TreeWaterDemand
{
/**
/**
* Rs/Rso für Nacht = 0.5
* Rs/Rso für Nacht = 0.5
*
* @param args
* @param args
* @throws IOException
* @throws IOException
* @throws CsvException
* @throws CsvException
...
@@ -62,8 +66,8 @@ public class TreeWaterDemand {
...
@@ -62,8 +66,8 @@ public class TreeWaterDemand {
LocalDateTime
start
=
LocalDateTime
.
of
(
2005
,
1
,
1
,
0
,
0
);
LocalDateTime
start
=
LocalDateTime
.
of
(
2005
,
1
,
1
,
0
,
0
);
LocalDateTime
end
=
LocalDateTime
.
of
(
2006
,
1
,
1
,
0
,
0
);
LocalDateTime
end
=
LocalDateTime
.
of
(
2006
,
1
,
1
,
0
,
0
);
// LocalDateTime start = LocalDateTime.of(2005, 4, 1, 0, 0);
// LocalDateTime start = LocalDateTime.of(2005, 4, 1, 0, 0);
// LocalDateTime end = LocalDateTime.of(2005, 10, 1, 0, 0);
// LocalDateTime end = LocalDateTime.of(2005, 10, 1, 0, 0);
List
<
Double
>
et0us
=
new
ArrayList
<>();
List
<
Double
>
et0us
=
new
ArrayList
<>();
List
<
Double
>
et0s
=
new
ArrayList
<>();
List
<
Double
>
et0s
=
new
ArrayList
<>();
...
@@ -73,11 +77,21 @@ public class TreeWaterDemand {
...
@@ -73,11 +77,21 @@ public class TreeWaterDemand {
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"
);
try
(
BufferedWriter
bw
=
Files
.
newBufferedWriter
(
Paths
.
get
(
"all_values.csv"
),
StandardCharsets
.
UTF_8
))
{
bw
.
write
(
"DateTime;Temperature;Humidity;GHI;WindSpeed;SaturationVaporPressure;ActualVaporPressure;ET0;ET0u\n"
);
bw
.
write
(
"dd/mm/yyyy HH:MM;[°C];[%];[W/m²];[m/s];[?];[?];[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
)));
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
));
bw
.
write
(
String
.
format
(
"%.0f;"
,
humidity
));
bw
.
write
(
String
.
format
(
"%.0f;"
,
incomingRadiation
));
// 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
;
double
windSpeed
=
Double
.
parseDouble
(
row
[
windSpeedIndex
]);
double
windSpeed
=
Double
.
parseDouble
(
row
[
windSpeedIndex
]);
...
@@ -89,14 +103,22 @@ public class TreeWaterDemand {
...
@@ -89,14 +103,22 @@ public class TreeWaterDemand {
hourOfDay
,
lz
,
lm
);
hourOfDay
,
lz
,
lm
);
double
et0u
=
et0u
(
svf
,
advection
,
et0
);
double
et0u
=
et0u
(
svf
,
advection
,
et0
);
bw
.
write
(
String
.
format
(
"%.1f;"
,
windSpeed
));
bw
.
write
(
String
.
format
(
"%.3f;"
,
saturationVaporPressure
));
bw
.
write
(
String
.
format
(
"%.3f;"
,
actualVaporPressure
));
bw
.
write
(
String
.
format
(
"%.3f;"
,
et0
));
bw
.
write
(
String
.
format
(
"%.3f;"
,
et0u
));
et0s
.
add
(
et0
);
et0s
.
add
(
et0
);
// System.out.println("et0: " + et0);
// System.out.println("et0: " + et0);
// System.out.println("etia: " + etia);
// System.out.println("etia: " + etia);
et0us
.
add
(
et0u
);
et0us
.
add
(
et0u
);
counter
=
counter
.
plusHours
(
1
);
counter
=
counter
.
plusHours
(
1
);
bw
.
write
(
"\n"
);
}
}
}
// 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
(
"Summe aller ET0: "
+
et0Sum
);
...
@@ -114,13 +136,14 @@ public class TreeWaterDemand {
...
@@ -114,13 +136,14 @@ public class TreeWaterDemand {
demands
.
add
(
etia
);
demands
.
add
(
etia
);
}
}
System
.
out
.
println
(
"Summe aller ETIa: "
+
demands
.
stream
().
collect
(
Collectors
.
summingDouble
(
Double:
:
doubleValue
)));
System
.
out
.
println
(
"Summe aller ETIa: "
+
demands
.
stream
().
collect
(
Collectors
.
summingDouble
(
Double:
:
doubleValue
)));
// printHourly(start, et0s, demands);
// printHourly(start, et0s, demands);
// printDaily(start, et0s, demands);
// printDaily(start, et0s, demands);
// test();
// test();
}
}
private
static
void
printHourly
(
LocalDateTime
start
,
List
<
Double
>
et0s
,
List
<
Double
>
demands
)
{
private
static
void
printHourly
(
LocalDateTime
start
,
List
<
Double
>
et0s
,
List
<
Double
>
demands
)
{
...
@@ -165,9 +188,9 @@ public class TreeWaterDemand {
...
@@ -165,9 +188,9 @@ public class TreeWaterDemand {
}
}
private
static
double
etia
(
double
tr
,
double
et0u
,
double
et0uFactor
)
{
private
static
double
etia
(
double
tr
,
double
et0u
,
double
et0uFactor
)
{
// return 1 * 1.6 * et0u;
// return 1 * 1.6 * et0u;
return
tr
*
1.25
*
et0u
*
et0uFactor
;
return
tr
*
1.25
*
et0u
*
et0uFactor
;
// return tr * (1.61 * Math.log10(800) - 3.39) * et0u * (0.865 * Math.log10(1 / et0u) + 3.36);
// return tr * (1.61 * Math.log10(800) - 3.39) * et0u * (0.865 * Math.log10(1 / et0u) + 3.36);
}
}
private
static
double
et0u
(
double
svf
,
double
advection
,
double
et0
)
{
private
static
double
et0u
(
double
svf
,
double
advection
,
double
et0
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment