Skip to content

Commit

Permalink
Also added MetSiteLatitude and WindInSectors as these are also releva…
Browse files Browse the repository at this point in the history
…nt ADMS options.
  • Loading branch information
Hilbrand committed Oct 1, 2024
1 parent 8b08ef4 commit 3cc4e77
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonIgnore;

/**
* Contains ADMS specific options for a calculation.
*/
Expand All @@ -37,6 +39,7 @@ public class ADMSOptions implements Serializable {
private List<String> metYears = new ArrayList<>();
// Map<meteo year, MetSiteSurfaceCharacteristics>
private Map<String, MetSurfaceCharacteristics> metSiteSurfaceCharacteristics = new HashMap<>();
private double metSiteLatitude;

private boolean plumeDepletionNH3;
private boolean plumeDepletionNOX;
Expand Down Expand Up @@ -91,6 +94,10 @@ public void setMetYears(final List<String> metYears) {
this.metYears = metYears;
}

public Map<String, MetSurfaceCharacteristics> getMetSiteSurfaceCharacteristics() {
return metSiteSurfaceCharacteristics;
}

public MetSurfaceCharacteristics getMetSiteCharacteristics(final String meteoYear) {
return metSiteSurfaceCharacteristics == null || !metSiteSurfaceCharacteristics.containsKey(meteoYear)
? getLegacyMetSiteCharacteristics()
Expand All @@ -105,41 +112,58 @@ public void putMetSiteCharacteristics(final String metYear, final MetSurfaceChar
this.metSiteSurfaceCharacteristics.put(metYear, msc);
}

public double getMetSiteLatitude() {
return metSiteLatitude;
}

public void setMetSiteLatitude(final double metSiteLatitude) {
this.metSiteLatitude = metSiteLatitude;
}

@Deprecated
@JsonIgnore
public double getMsRoughness() {
return getLegacyMetSiteCharacteristics().getRoughness();
}

@Deprecated
@JsonIgnore
public void setMsRoughness(final double msRoughness) {
getLegacyMetSiteCharacteristics().setRoughness(msRoughness);
}

@Deprecated
@JsonIgnore
public double getMsMinMoninObukhovLength() {
return getLegacyMetSiteCharacteristics().getMinMoninObukhovLength();
}

@Deprecated
@JsonIgnore
public void setMsMinMoninObukhovLength(final double msMinMoninObukhovLength) {
getLegacyMetSiteCharacteristics().setMinMoninObukhovLength(msMinMoninObukhovLength);
}

@Deprecated
@JsonIgnore
public double getMsSurfaceAlbedo() {
return getLegacyMetSiteCharacteristics().getSurfaceAlbedo();
}

@Deprecated
@JsonIgnore
public void setMsSurfaceAlbedo(final double msSurfaceAlbedo) {
getLegacyMetSiteCharacteristics().setSurfaceAlbedo(msSurfaceAlbedo);
}

@Deprecated
@JsonIgnore
public double getMsPriestleyTaylorParameter() {
return getLegacyMetSiteCharacteristics().getPriestleyTaylorParameter();
}

@Deprecated
@JsonIgnore
public void setMsPriestleyTaylorParameter(final double msPriestleyTaylorParameter) {
getLegacyMetSiteCharacteristics().setPriestleyTaylorParameter(msPriestleyTaylorParameter);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,18 @@ public class MetSurfaceCharacteristics implements Serializable {
private double minMoninObukhovLength;
private double surfaceAlbedo;
private double priestleyTaylorParameter;
private boolean windInSectors;

MetSurfaceCharacteristics() {
}

private MetSurfaceCharacteristics(final double roughness, final double minMoninObukhovLength, final double surfaceAlbedo,
final double priestleyTaylorParameter) {
final double priestleyTaylorParameter, final boolean windInSectors) {
this.roughness = roughness;
this.minMoninObukhovLength = minMoninObukhovLength;
this.surfaceAlbedo = surfaceAlbedo;
this.priestleyTaylorParameter = priestleyTaylorParameter;
this.windInSectors = windInSectors;
}

public double getRoughness() {
Expand All @@ -54,6 +56,9 @@ public double getPriestleyTaylorParameter() {
return priestleyTaylorParameter;
}

public boolean isWindInSectors() {
return windInSectors;
}

void setRoughness(final double roughness) {
this.roughness = roughness;
Expand All @@ -71,6 +76,10 @@ void setPriestleyTaylorParameter(final double priestleyTaylorParameter) {
this.priestleyTaylorParameter = priestleyTaylorParameter;
}

void setWindInSectors(final boolean windInSectors) {
this.windInSectors = windInSectors;
}

public static Builder builder() {
return new Builder();
}
Expand All @@ -80,6 +89,7 @@ public static class Builder {
private double minMoninObukhovLength;
private double surfaceAlbedo;
private double priestleyTaylorParameter;
private boolean windInSectors;

public Builder roughness(final double roughness) {
this.roughness = roughness;
Expand All @@ -101,8 +111,13 @@ public Builder priestleyTaylorParameter(final double priestleyTaylorParameter) {
return this;
}

public Builder windInSectors(final boolean windInSectors) {
this.windInSectors = windInSectors;
return this;
}

public MetSurfaceCharacteristics build() {
return new MetSurfaceCharacteristics(roughness, minMoninObukhovLength, surfaceAlbedo, priestleyTaylorParameter);
return new MetSurfaceCharacteristics(roughness, minMoninObukhovLength, surfaceAlbedo, priestleyTaylorParameter, windInSectors);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,14 @@ public enum Option {
ADMS_SPATIALLY_VARYING_ROUGHNESS,
ADMS_COMPLEX_TERRAIN,
ADMS_MET_SITE_ID,
ADMS_MET_SITE_LATITUDE,
ADMS_MET_DATASET_TYPE,
ADMS_MET_YEARS,
ADMS_MET_SITE_ROUGHNESS,
ADMS_MET_SITE_MIN_MONIN_OBUKHOV_LENGTH,
ADMS_MET_SITE_SURFACE_ALBEDO,
ADMS_MET_SITE_PRIESTLEY_TAYLOR_PARAMETER,
ADMS_MET_SITE_WIND_IN_SECTORS,

/* Road NOX - NO2 calculation related */
ROAD_LOCAL_FRACTION_NO2_RECEPTORS_OPTION,
Expand Down Expand Up @@ -244,14 +246,15 @@ private static void ncaOptionsFromMap(final NCACalculationOptions options, final

if (map.get(Option.ADMS_MET_SITE_ID) != null) {
admsOptions.setMetSiteId(Integer.parseInt(map.get(Option.ADMS_MET_SITE_ID)));
admsOptions.setMetSiteLatitude(Optional.ofNullable(map.get(Option.ADMS_MET_SITE_LATITUDE)).map(Double::parseDouble).orElse(0.0));
admsOptions.setMetDatasetType(MetDatasetType.safeValueOf(map.get(Option.ADMS_MET_DATASET_TYPE)));
ncaParseMetYears(admsOptions, map);
ncaMetSiteOptions(prefixedOptionsMap, admsOptions, map);
}
admsOptions.setPlumeDepletionNH3(isOrDefault(map, Option.ADMS_PLUME_DEPLETION_NH3, ADMSLimits.ADMS_PLUME_DEPLETION_NH3_DEFAULT));
admsOptions.setPlumeDepletionNOX(isOrDefault(map, Option.ADMS_PLUME_DEPLETION_NOX, ADMSLimits.ADMS_PLUME_DEPLETION_NOX_DEFAULT));
admsOptions
.setSpatiallyVaryingRoughness(isOrDefault(map, Option.ADMS_SPATIALLY_VARYING_ROUGHNESS, ADMSLimits.SPATIALLY_VARYING_ROUGHNESS_DEFAULT));
admsOptions.setSpatiallyVaryingRoughness(isOrDefault(map, Option.ADMS_SPATIALLY_VARYING_ROUGHNESS,
ADMSLimits.SPATIALLY_VARYING_ROUGHNESS_DEFAULT));
admsOptions.setComplexTerrain(isOrDefault(map, Option.ADMS_COMPLEX_TERRAIN, ADMSLimits.ADMS_COMPLEX_TERRAIN_DEFAULT));
}

Expand Down Expand Up @@ -279,6 +282,7 @@ private static void ncaPutMetSiteOptions(final ADMSOptions admsOptions, final St
.surfaceAlbedo(getOrDefault(prefixedMap, Option.ADMS_MET_SITE_SURFACE_ALBEDO, ADMSLimits.SURFACE_ALBEDO_DEFAULT))
.priestleyTaylorParameter(
getOrDefault(prefixedMap, Option.ADMS_MET_SITE_PRIESTLEY_TAYLOR_PARAMETER, ADMSLimits.PRIESTLEY_TAYLOR_PARAMETER_DEFAULT))
.windInSectors(isOrDefault(prefixedMap, Option.ADMS_MET_SITE_WIND_IN_SECTORS, false))
.build();
admsOptions.putMetSiteCharacteristics(metYear, msc);
}
Expand Down Expand Up @@ -318,6 +322,9 @@ private static void ncaOptionsToMap(final Map<String, String> mapToAddTo, final
addValue(mapToAddTo, Option.ADMS_SURFACE_ALBEDO, adms.getSurfaceAlbedo(), addDefaults);
addValue(mapToAddTo, Option.ADMS_PRIESTLEY_TAYLOR_PARAMETER, adms.getPriestleyTaylorParameter(), addDefaults);
addIntValue(mapToAddTo, Option.ADMS_MET_SITE_ID, adms.getMetSiteId(), addDefaults);
if (adms.getMetSiteLatitude() != 0.0) {
addValue(mapToAddTo, Option.ADMS_MET_SITE_LATITUDE, adms.getMetSiteLatitude(), addDefaults);
}
addValue(mapToAddTo, Option.ADMS_MET_DATASET_TYPE, adms.getMetDatasetType(), addDefaults);
ncaAddMetSite(mapToAddTo, addDefaults, adms);
// Always add the following fields to the GML as it also gives an indication if run in demo mode.
Expand Down Expand Up @@ -356,6 +363,9 @@ private static void addADMSMetSiteOptions(final Map<String, String> mapToAddTo,
addValue(mapToAddTo, prefix + Option.ADMS_MET_SITE_MIN_MONIN_OBUKHOV_LENGTH.toKey(), msc.getMinMoninObukhovLength(), addDefaults);
addValue(mapToAddTo, prefix + Option.ADMS_MET_SITE_SURFACE_ALBEDO.toKey(), msc.getSurfaceAlbedo(), addDefaults);
addValue(mapToAddTo, prefix + Option.ADMS_MET_SITE_PRIESTLEY_TAYLOR_PARAMETER.toKey(), msc.getPriestleyTaylorParameter(), addDefaults);
if (msc.isWindInSectors()) {
addValue(mapToAddTo, prefix + Option.ADMS_MET_SITE_WIND_IN_SECTORS.toKey(), String.valueOf(msc.isWindInSectors()), addDefaults);
}
}

private static void addValue(final Map<String, String> mapToAddTo, final Option key, final Object value, final boolean addDefaults) {
Expand Down

0 comments on commit 3cc4e77

Please sign in to comment.