forked from Universite-Gustave-Eiffel/NoiseModelling
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Large commit including new tests in PathFinder.
Iso problem: TC21, TC28. Rays problem, update the Z of S' after diffraction: TC18. Gpath problem: TC19.
- Loading branch information
Showing
33 changed files
with
5,147 additions
and
372 deletions.
There are no files selected for viewing
87 changes: 87 additions & 0 deletions
87
...src/main/java/org/noise_planet/noisemodelling/emission/directivity/DirectivityRecord.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/** | ||
* NoiseModelling is a library capable of producing noise maps. It can be freely used either for research and education, as well as by experts in a professional use. | ||
* <p> | ||
* NoiseModelling is distributed under GPL 3 license. You can read a copy of this License in the file LICENCE provided with this software. | ||
* <p> | ||
* Official webpage : http://noise-planet.org/noisemodelling.html | ||
* Contact: [email protected] | ||
*/ | ||
|
||
|
||
package org.noise_planet.noisemodelling.emission.directivity; | ||
|
||
import java.util.Arrays; | ||
import java.util.Locale; | ||
import java.util.Objects; | ||
|
||
|
||
public class DirectivityRecord { | ||
double theta; | ||
double phi; | ||
double[] attenuation; | ||
|
||
/** | ||
* directivity record is the attenuation value for a specific angle (theta, phi) - a point of the directivity sphere | ||
* | ||
* @param theta (-π/2 π/2) 0 is horizontal; π is top | ||
* @param phi (0 2π) 0 is front | ||
* @param attenuation in dB | ||
*/ | ||
public DirectivityRecord(double theta, double phi, double[] attenuation) { | ||
this.theta = theta; | ||
this.phi = phi; | ||
this.attenuation = attenuation; | ||
} | ||
|
||
/** | ||
* | ||
* @return | ||
*/ | ||
public double getTheta() { | ||
return theta; | ||
} | ||
|
||
public double getPhi() { | ||
return phi; | ||
} | ||
|
||
/** | ||
* compare the values of theta et phi of the Object DirectivityRecord | ||
* @param o object | ||
* @return a boolean | ||
*/ | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
DirectivityRecord record = (DirectivityRecord) o; | ||
return Double.compare(record.theta, theta) == 0 && | ||
Double.compare(record.phi, phi) == 0; | ||
} | ||
|
||
|
||
/** | ||
* generate a hash code for an object with theta and phi argument | ||
* @return | ||
*/ | ||
@Override | ||
public int hashCode() { | ||
return Objects.hash(theta, phi); | ||
} | ||
|
||
/** | ||
* generate a string representation of the object DirectivityRecord | ||
* @return a string | ||
*/ | ||
@Override | ||
public String toString() { | ||
return String.format(Locale.ROOT, "DirectivityRecord{theta=%.2f (%.2g°)" + | ||
", phi=%.2f (%.2g°) , attenuation=%s}", theta, Math.toDegrees(theta), phi, Math.toDegrees(phi), | ||
Arrays.toString(attenuation)); | ||
} | ||
|
||
public double[] getAttenuation() { | ||
return attenuation; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...n/java/org/noise_planet/noisemodelling/emission/directivity/OmnidirectionalDirection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* NoiseModelling is a library capable of producing noise maps. It can be freely used either for research and education, as well as by experts in a professional use. | ||
* <p> | ||
* NoiseModelling is distributed under GPL 3 license. You can read a copy of this License in the file LICENCE provided with this software. | ||
* <p> | ||
* Official webpage : http://noise-planet.org/noisemodelling.html | ||
* Contact: [email protected] | ||
*/ | ||
|
||
package org.noise_planet.noisemodelling.emission.directivity; | ||
|
||
|
||
public class OmnidirectionalDirection implements DirectivitySphere { | ||
|
||
|
||
/** | ||
* Returns the attenuation in dB of the directivity pattern at a given angle (phi, theta). | ||
* @param frequency Frequency in Hertz | ||
* @param phi (0 2π) with 0 is front | ||
* @param theta (-π/2 π/2) with 0 is horizontal; π is top | ||
* @return | ||
*/ | ||
@Override | ||
public double getAttenuation(double frequency, double phi, double theta) { | ||
return 0; | ||
} | ||
|
||
/** | ||
* Returns the attenuation in dB of the directivity pattern at a given angle (phi, theta). | ||
* @param frequencies Frequency array in Hertz (same order will be returned) | ||
* @param phi (0 2π) 0 is front | ||
* @param theta (-π/2 π/2) 0 is horizontal π is top | ||
* @return Attenuation in dB for each frequency | ||
*/ | ||
@Override | ||
public double[] getAttenuationArray(double[] frequencies, double phi, double theta) { | ||
return new double[frequencies.length]; | ||
} | ||
|
||
/** | ||
* Check if this sphere is capable of producing an attenuation for this frequency | ||
* @param frequency Frequency in Hertz | ||
* @return True | ||
*/ | ||
@Override | ||
public boolean coverFrequency(double frequency) { | ||
return true; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...ion/src/main/java/org/noise_planet/noisemodelling/emission/directivity/PhiComparator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* NoiseModelling is a library capable of producing noise maps. It can be freely used either for research and education, as well as by experts in a professional use. | ||
* <p> | ||
* NoiseModelling is distributed under GPL 3 license. You can read a copy of this License in the file LICENCE provided with this software. | ||
* <p> | ||
* Official webpage : http://noise-planet.org/noisemodelling.html | ||
* Contact: [email protected] | ||
*/ | ||
|
||
package org.noise_planet.noisemodelling.emission.directivity; | ||
|
||
import java.io.Serializable; | ||
import java.util.Comparator; | ||
|
||
|
||
public class PhiComparator implements Comparator<DirectivityRecord>, Serializable { | ||
|
||
/** | ||
* Compare two directivity record | ||
* @param o1 the first object to be compared. | ||
* @param o2 the second object to be compared. | ||
* @return 1 or 0 or -1 | ||
*/ | ||
@Override | ||
public int compare(DirectivityRecord o1, DirectivityRecord o2) { | ||
final int phiCompare = Double.compare(o1.phi, o2.phi); | ||
if (phiCompare != 0) { | ||
return phiCompare; | ||
} | ||
return Double.compare(o1.theta, o2.theta); | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
...n/src/main/java/org/noise_planet/noisemodelling/emission/directivity/ThetaComparator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* NoiseModelling is a library capable of producing noise maps. It can be freely used either for research and education, as well as by experts in a professional use. | ||
* <p> | ||
* NoiseModelling is distributed under GPL 3 license. You can read a copy of this License in the file LICENCE provided with this software. | ||
* <p> | ||
* Official webpage : http://noise-planet.org/noisemodelling.html | ||
* Contact: [email protected] | ||
*/ | ||
package org.noise_planet.noisemodelling.emission.directivity; | ||
|
||
import java.io.Serializable; | ||
import java.util.Comparator; | ||
|
||
public class ThetaComparator implements Comparator<DirectivityRecord>, Serializable { | ||
|
||
/** | ||
* Compare two directivity record | ||
* @param o1 the first object to be compared. | ||
* @param o2 the second object to be compared. | ||
* @return 1 or 0 or -1 | ||
*/ | ||
@Override | ||
public int compare(DirectivityRecord o1, DirectivityRecord o2) { | ||
final int thetaCompare = Double.compare(o1.theta, o2.theta); | ||
if (thetaCompare != 0) { | ||
return thetaCompare; | ||
} | ||
return Double.compare(o1.phi, o2.phi); | ||
} | ||
|
||
} |
63 changes: 63 additions & 0 deletions
63
...e_planet/noisemodelling/emission/directivity/cnossos/RailwayCnossosDirectivitySphere.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/** | ||
* NoiseModelling is a library capable of producing noise maps. It can be freely used either for research and education, as well as by experts in a professional use. | ||
* <p> | ||
* NoiseModelling is distributed under GPL 3 license. You can read a copy of this License in the file LICENCE provided with this software. | ||
* <p> | ||
* Official webpage : http://noise-planet.org/noisemodelling.html | ||
* Contact: [email protected] | ||
*/ | ||
|
||
package org.noise_planet.noisemodelling.emission.directivity.cnossos; | ||
|
||
import org.noise_planet.noisemodelling.emission.LineSource; | ||
import org.noise_planet.noisemodelling.emission.directivity.DirectivitySphere; | ||
import org.noise_planet.noisemodelling.emission.railway.cnossos.RailWayCnossosParameters; | ||
|
||
|
||
public final class RailwayCnossosDirectivitySphere implements DirectivitySphere { | ||
LineSource lineSource; | ||
|
||
public RailwayCnossosDirectivitySphere(LineSource lineSource) { | ||
this.lineSource = lineSource; | ||
} | ||
|
||
/** | ||
* Returns the attenuation in dB due to a particular frequency of the directivity pattern at a given angle (phi, theta) | ||
* @param frequency Frequency in Hertz | ||
* @param phi (0 2π) with 0 is front | ||
* @param theta (-π/2 π/2) with 0 is horizontal; π is top | ||
* @return Attenuation in dB | ||
*/ | ||
@Override | ||
public double getAttenuation(double frequency, double phi, double theta) { | ||
return RailWayCnossosParameters.getDirectionAttenuation(lineSource, phi, theta, frequency); | ||
} | ||
|
||
|
||
/** | ||
* Returns the attenuation in dB of the directivity pattern at a given angle (phi, theta). | ||
* @param frequencies Frequency array in Hertz (same order will be returned) | ||
* @param phi (0 2π) 0 is front | ||
* @param theta (-π/2 π/2) 0 is horizontal π is top | ||
* @return Attenuation in dB for each frequency | ||
*/ | ||
@Override | ||
public double[] getAttenuationArray(double[] frequencies, double phi, double theta) { | ||
double[] ret = new double[frequencies.length]; | ||
for (int idFrequency = 0; idFrequency < frequencies.length; idFrequency++) { | ||
ret[idFrequency] = getAttenuation(frequencies[idFrequency], phi, theta); | ||
} | ||
return ret; | ||
} | ||
|
||
|
||
/** | ||
* Check if this sphere is capable of producing an attenuation for this frequency | ||
* @param frequency Frequency in Hertz | ||
* @return True | ||
*/ | ||
@Override | ||
public boolean coverFrequency(double frequency) { | ||
return true; | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
...src/main/java/org/noise_planet/noisemodelling/emission/railway/nmpb/TrainAttenuation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** | ||
* NoiseModelling is a library capable of producing noise maps. It can be freely used either for research and education, as well as by experts in a professional use. | ||
* <p> | ||
* NoiseModelling is distributed under GPL 3 license. You can read a copy of this License in the file LICENCE provided with this software. | ||
* <p> | ||
* Official webpage : http://noise-planet.org/noisemodelling.html | ||
* Contact: [email protected] | ||
*/ | ||
package org.noise_planet.noisemodelling.emission.railway.nmpb; | ||
|
||
import org.noise_planet.noisemodelling.emission.directivity.DirectivitySphere; | ||
|
||
public final class TrainAttenuation implements DirectivitySphere { | ||
RailWayNMPBParameters.TrainNoiseSource noiseSource; | ||
|
||
public TrainAttenuation(RailWayNMPBParameters.TrainNoiseSource noiseSource) { | ||
this.noiseSource = noiseSource; | ||
} | ||
|
||
/** | ||
* Returns the attenuation in dB due to a particular frequency of the directivity pattern at a given angle (phi, theta) | ||
* @param frequency Frequency in Hertz | ||
* @param phi (0 2π) with 0 is front | ||
* @param theta (-π/2 π/2) with 0 is horizontal; π is top | ||
* @return Attenuation in dB | ||
*/ | ||
@Override | ||
public double getAttenuation(double frequency, double phi, double theta) { | ||
return RailWayNMPBParameters.getDirectionAttenuation(noiseSource, phi, theta, frequency); | ||
} | ||
|
||
/** | ||
* Returns the attenuation in dB of the directivity pattern at a given angle (phi, theta). | ||
* @param frequencies Frequency array in Hertz (same order will be returned) | ||
* @param phi (0 2π) 0 is front | ||
* @param theta (-π/2 π/2) 0 is horizontal π is top | ||
* @return Attenuation in dB for each frequency | ||
*/ | ||
@Override | ||
public double[] getAttenuationArray(double[] frequencies, double phi, double theta) { | ||
double[] ret = new double[frequencies.length]; | ||
for (int idFrequency = 0; idFrequency < frequencies.length; idFrequency++) { | ||
ret[idFrequency] = getAttenuation(frequencies[idFrequency], phi, theta); | ||
} | ||
return ret; | ||
} | ||
|
||
/** | ||
* Check if this sphere is capable of producing an attenuation for this frequency | ||
* @param frequency Frequency in Hertz | ||
* @return True | ||
*/ | ||
@Override | ||
public boolean coverFrequency(double frequency) { | ||
return true; | ||
} | ||
} |
Oops, something went wrong.