Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced noise modelling report #515

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
bf0dd02
In RAYS Table export ray attenuation and time period
nicolas-f Sep 21, 2022
b919fe5
check for diff in day evening night output
nicolas-f Sep 21, 2022
cc4797a
update wps scripts
nicolas-f Sep 21, 2022
e9d0fd8
Merge branch '4.X' of github.com:Ifsttar/NoiseModelling into advanced…
nicolas-f Sep 22, 2022
af8d517
clean code, was moved or commented by spalominos
nicolas-f Sep 22, 2022
90d6a80
fix call to diffraction parameters
nicolas-f Sep 22, 2022
cf0ca52
clean code
nicolas-f Sep 22, 2022
d07060e
javadoc, fix building rendering kml, add color to propagation rays in…
nicolas-f Sep 22, 2022
d11b9f6
Fix buildings definnition
nicolas-f Sep 22, 2022
1111d04
clean imports
nicolas-f Sep 23, 2022
2dfb5ae
fix test
nicolas-f Sep 23, 2022
f30b9b2
Check if dem is used before exporting KML Document
nicolas-f Sep 26, 2022
9824529
do not use synchronized list, add parameter to limit the number of ra…
nicolas-f Sep 26, 2022
ea49677
set limitation in tutorial, fix unit test with new class of propagati…
nicolas-f Sep 26, 2022
6eb1616
About #516 check for Z ordinate when reading receiver table
nicolas-f Sep 26, 2022
bfefdb6
add an option to output cell computation to kml files in wps script
nicolas-f Sep 26, 2022
ad148db
add demo python core
nicolas-f Sep 29, 2022
d1b6d6f
reenable unit test
nicolas-f Sep 30, 2022
168ee42
Add python script example with jnius
nicolas-f Sep 30, 2022
a318aa6
ignore venv python dir
nicolas-f Sep 30, 2022
6eb033b
Change to minimum z terrain under building instead of average z
nicolas-f Oct 11, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ nbactions.xml
Docs/build
Docs/venv
profile_*.csv

venv/
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ public JdbcNoiseMap(String buildingsTableName, String sourcesTableName) {

public PropagationProcessPathData getPropagationProcessPathData(LDENConfig.TIME_PERIOD time_period) {
switch (time_period) {
case TIME_PERIOD_DAY:
case DAY:
return propagationProcessPathDataDay;
case TIME_PERIOD_EVENING:
case EVENING:
return propagationProcessPathDataEvening;
default:
return propagationProcessPathDataNight;
Expand All @@ -98,9 +98,9 @@ public PropagationProcessPathData getPropagationProcessPathData(LDENConfig.TIME_

public void setPropagationProcessPathData(LDENConfig.TIME_PERIOD time_period, PropagationProcessPathData propagationProcessPathData) {
switch (time_period) {
case TIME_PERIOD_DAY:
case DAY:
propagationProcessPathDataDay = propagationProcessPathData;
case TIME_PERIOD_EVENING:
case EVENING:
propagationProcessPathDataEvening = propagationProcessPathData;
default:
propagationProcessPathDataNight = propagationProcessPathData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -53,19 +54,19 @@ public static class DENAttenuation {

public double[] getTimePeriodLevel(LDENConfig.TIME_PERIOD timePeriod) {
switch (timePeriod) {
case TIME_PERIOD_DAY:
case DAY:
return dayLevels;
case TIME_PERIOD_EVENING:
case EVENING:
return eveningLevels;
default:
return nightLevels;
}
}
public void setTimePeriodLevel(LDENConfig.TIME_PERIOD timePeriod, double [] levels) {
switch (timePeriod) {
case TIME_PERIOD_DAY:
case DAY:
dayLevels = levels;
case TIME_PERIOD_EVENING:
case EVENING:
eveningLevels = levels;
default:
nightLevels = levels;
Expand Down Expand Up @@ -116,26 +117,48 @@ public ThreadComputeRaysOut(LDENComputeRaysOut multiThreadParent) {


@Override
public double[] addPropagationPaths(long sourceId, double sourceLi, long receiverId, List<PropagationPath> propagationPath) {
ldenComputeRaysOut.rayCount.addAndGet(propagationPath.size());
if(ldenComputeRaysOut.inputData != null && sourceId < ldenComputeRaysOut.inputData.sourcesPk.size() &&
receiverId < ldenComputeRaysOut.inputData.receiversPk.size()) {
for(PropagationPath path : propagationPath) {
// Copy path content in order to keep original ids for other method calls
PropagationPath pathPk = new PropagationPath(path);
pathPk.setIdReceiver(ldenComputeRaysOut.inputData.receiversPk.get((int)receiverId).intValue());
pathPk.setIdSource(ldenComputeRaysOut.inputData.sourcesPk.get((int)sourceId).intValue());
propagationPaths.add(pathPk);
public double[] addPropagationPaths(long sourceId, double sourceLi, long receiverId, List<PropagationPath> propagationPathsParameter) {
ldenComputeRaysOut.rayCount.addAndGet(propagationPathsParameter.size());
if(ldenComputeRaysOut.keepRays && !ldenComputeRaysOut.keepAbsorption) {
for(PropagationPath propagationPath : propagationPathsParameter) {
// Use only one ray as the ray is the same if we not keep absorption values
if (ldenComputeRaysOut.inputData != null && sourceId < ldenComputeRaysOut.inputData.sourcesPk.size() && receiverId < ldenComputeRaysOut.inputData.receiversPk.size()) {
// Copy path content in order to keep original ids for other method calls
PropagationPath pathPk = new PropagationPath(propagationPath);
pathPk.setIdReceiver(ldenComputeRaysOut.inputData.receiversPk.get((int) receiverId).intValue());
pathPk.setIdSource(ldenComputeRaysOut.inputData.sourcesPk.get((int) sourceId).intValue());
this.propagationPaths.add(pathPk);
} else {
this.propagationPaths.add(propagationPath);
}
}
} else {
propagationPaths.addAll(propagationPath);
}
double[] ldenLevels = lDENThreadRaysOut[0].addPropagationPaths(sourceId, sourceLi, receiverId, propagationPath);
ldenLevels = PowerUtils.sumDbArray(ldenLevels, lDENThreadRaysOut[1].addPropagationPaths(sourceId, sourceLi,
receiverId, propagationPath));
ldenLevels = PowerUtils.sumDbArray(ldenLevels, lDENThreadRaysOut[2].addPropagationPaths(sourceId, sourceLi,
receiverId, propagationPath));
return ldenLevels;
double[] globalLevel = null;
for(LDENConfig.TIME_PERIOD timePeriod : LDENConfig.TIME_PERIOD.values()) {
for(PropagationPath propagationPath : propagationPathsParameter) {
if (globalLevel == null) {
globalLevel = lDENThreadRaysOut[timePeriod.ordinal()].addPropagationPaths(sourceId, sourceLi,
receiverId, Collections.singletonList(propagationPath));
} else {
globalLevel = PowerUtils.sumDbArray(globalLevel, lDENThreadRaysOut[timePeriod.ordinal()].addPropagationPaths(sourceId, sourceLi,
receiverId, Collections.singletonList(propagationPath)));
}
propagationPath.setTimePeriod(timePeriod.name());
if(ldenComputeRaysOut.keepRays && ldenComputeRaysOut.keepAbsorption) {
// copy ray for each time period because absorption is different for each period
if (ldenComputeRaysOut.inputData != null && sourceId < ldenComputeRaysOut.inputData.sourcesPk.size() && receiverId < ldenComputeRaysOut.inputData.receiversPk.size()) {
// Copy path content in order to keep original ids for other method calls
PropagationPath pathPk = new PropagationPath(propagationPath);
pathPk.setIdReceiver(ldenComputeRaysOut.inputData.receiversPk.get((int) receiverId).intValue());
pathPk.setIdSource(ldenComputeRaysOut.inputData.sourcesPk.get((int) sourceId).intValue());
this.propagationPaths.add(pathPk);
} else {
this.propagationPaths.add(propagationPath);
}
}
}
}
return globalLevel;
}

/**
Expand Down Expand Up @@ -187,8 +210,23 @@ public void pushInStack(ConcurrentLinkedDeque<PropagationPath> stack, Collection
return;
}
}
stack.addAll(data);
ldenComputeRaysOut.ldenData.queueSize.addAndGet(data.size());
if(ldenConfig.getMaximumRaysOutputCount() == 0 || ldenComputeRaysOut.ldenData.totalRaysInserted.get() < ldenConfig.getMaximumRaysOutputCount()) {
long newTotalRays = ldenComputeRaysOut.ldenData.totalRaysInserted.addAndGet(data.size());
if(ldenConfig.getMaximumRaysOutputCount() > 0 && newTotalRays > ldenConfig.getMaximumRaysOutputCount()) {
// too many rays, remove unwanted rays
int newListSize = data.size() - (int)(newTotalRays - ldenConfig.getMaximumRaysOutputCount());
List<PropagationPath> subList = new ArrayList<PropagationPath>(newListSize);
for(PropagationPath propagationPath : data) {
subList.add(propagationPath);
if(subList.size() >= newListSize) {
break;
}
}
data = subList;
}
stack.addAll(data);
ldenComputeRaysOut.ldenData.queueSize.addAndGet(data.size());
}
}

@Override
Expand All @@ -197,7 +235,16 @@ public void finalizeReceiver(final long receiverId) {
if(ldenConfig.getExportRaysMethod() == LDENConfig.ExportRaysMethods.TO_RAYS_TABLE) {
// Push propagation rays
pushInStack(ldenComputeRaysOut.ldenData.rays, propagationPaths);
} else if(ldenConfig.getExportRaysMethod() == LDENConfig.ExportRaysMethods.TO_MEMORY){
} else if(ldenConfig.getExportRaysMethod() == LDENConfig.ExportRaysMethods.TO_MEMORY
&& (ldenConfig.getMaximumRaysOutputCount() == 0 ||
ldenComputeRaysOut.propagationPathsSize.get() < ldenConfig.getMaximumRaysOutputCount())){
int newRaysSize = ldenComputeRaysOut.propagationPathsSize.addAndGet(propagationPaths.size());
if(ldenConfig.getMaximumRaysOutputCount() > 0 && newRaysSize > ldenConfig.getMaximumRaysOutputCount()) {
// remove exceeded elements of the array
propagationPaths = propagationPaths.subList(0,
propagationPaths.size() - Math.min( propagationPaths.size(),
newRaysSize - ldenConfig.getMaximumRaysOutputCount()));
}
ldenComputeRaysOut.propagationPaths.addAll(propagationPaths);
}
propagationPaths.clear();
Expand Down Expand Up @@ -307,6 +354,7 @@ public void finalizeReceiver(final long receiverId) {

public static class LdenData {
public final AtomicLong queueSize = new AtomicLong(0);
public final AtomicLong totalRaysInserted = new AtomicLong(0);
public final ConcurrentLinkedDeque<VerticeSL> lDayLevels = new ConcurrentLinkedDeque<>();
public final ConcurrentLinkedDeque<VerticeSL> lEveningLevels = new ConcurrentLinkedDeque<>();
public final ConcurrentLinkedDeque<VerticeSL> lNightLevels = new ConcurrentLinkedDeque<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@
import org.noise_planet.noisemodelling.propagation.PropagationProcessPathData;

import java.io.File;
import java.util.concurrent.atomic.AtomicInteger;

/**
* Configuration of NoiseModelling computation based on database data using standard Lden outputs
*/
public class LDENConfig {
public enum TIME_PERIOD {TIME_PERIOD_DAY, TIME_PERIOD_EVENING, TIME_PERIOD_NIGHT}
public enum TIME_PERIOD {DAY, EVENING, NIGHT}
public enum INPUT_MODE { INPUT_MODE_TRAFFIC_FLOW, INPUT_MODE_LW_DEN, INPUT_MODE_PROBA}
final INPUT_MODE input_mode;

Expand Down Expand Up @@ -68,6 +69,7 @@ public enum ExportRaysMethods {TO_RAYS_TABLE, TO_MEMORY, NONE}

boolean exportProfileInRays = false;
boolean keepAbsorption = false; // in rays, keep store detailed absorption data
int maximumRaysOutputCount = 0; // if export rays, do not keep more than this number of rays (0 infinite)
pierromond marked this conversation as resolved.
Show resolved Hide resolved
// Maximum result stack to be inserted in database
// if the stack is full, the computation core is waiting
int outputMaximumQueue = 50000;
Expand All @@ -93,20 +95,34 @@ public LDENConfig(INPUT_MODE input_mode) {

public PropagationProcessPathData getPropagationProcessPathData(TIME_PERIOD time_period) {
switch (time_period) {
case TIME_PERIOD_DAY:
case DAY:
return propagationProcessPathDataDay;
case TIME_PERIOD_EVENING:
case EVENING:
return propagationProcessPathDataEvening;
default:
return propagationProcessPathDataNight;
}
}

/**
* @return if export rays, do not keep more than this number of rays (0 infinite)
*/
public int getMaximumRaysOutputCount() {
return maximumRaysOutputCount;
}

/**
* @param maximumRaysOutputCount if export rays, do not keep more than this number of rays per computation area (0 infinite)
*/
public void setMaximumRaysOutputCount(int maximumRaysOutputCount) {
this.maximumRaysOutputCount = maximumRaysOutputCount;
}

public void setPropagationProcessPathData(TIME_PERIOD time_period, PropagationProcessPathData propagationProcessPathData) {
switch (time_period) {
case TIME_PERIOD_DAY:
case DAY:
propagationProcessPathDataDay = propagationProcessPathData;
case TIME_PERIOD_EVENING:
case EVENING:
propagationProcessPathDataEvening = propagationProcessPathData;
default:
propagationProcessPathDataNight = propagationProcessPathData;
Expand Down
Loading