From 4eaf9b8675c5b7c2808a992f8c102e8e75b65642 Mon Sep 17 00:00:00 2001 From: Peter Powers <pmpowers@usgs.gov> Date: Tue, 8 Feb 2022 06:57:27 -0700 Subject: [PATCH] cleaned up TODOs --- .../gov/usgs/earthquake/nshmp/DisaggCalc.java | 8 ----- .../gov/usgs/earthquake/nshmp/RateCalc.java | 3 -- .../usgs/earthquake/nshmp/site/NshmpSite.java | 4 --- .../earthquake/nshmp/site/NshmpSiteFiles.java | 31 ++++++++-------- .../earthquake/nshmp/www/ServletUtil.java | 2 -- .../nshmp/www/hazard/HazardService.java | 7 ++-- .../nshmp/www/services/RateService.java | 5 ++- .../nshmp/www/services/SourceServices.java | 35 +------------------ 8 files changed, 23 insertions(+), 72 deletions(-) diff --git a/src/main/java/gov/usgs/earthquake/nshmp/DisaggCalc.java b/src/main/java/gov/usgs/earthquake/nshmp/DisaggCalc.java index de59f18b2..1250ee5b8 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/DisaggCalc.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/DisaggCalc.java @@ -260,10 +260,6 @@ public class DisaggCalc { /* * Compute hazard curves using the supplied model, config, and sites. Method * returns the path to the directory where results were written. - * - * TODO consider refactoring to supply an Optional<Double> return period to - * HazardCalc.calc() that will trigger disaggregations if the value is - * present. */ private static Path calcRp( HazardModel model, @@ -353,10 +349,6 @@ public class DisaggCalc { /* * Compute hazard curves using the supplied model, config, and sites. Method * returns the path to the directory where results were written. - * - * TODO consider refactoring to supply an Optional<Double> return period to - * HazardCalc.calc() that will trigger disaggregations if the value is - * present. */ private static Path calcIml( HazardModel model, diff --git a/src/main/java/gov/usgs/earthquake/nshmp/RateCalc.java b/src/main/java/gov/usgs/earthquake/nshmp/RateCalc.java index 8c59131d9..d2a3fd5c0 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/RateCalc.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/RateCalc.java @@ -186,9 +186,6 @@ public class RateCalc { * there are one or more longer-running calcs in the batch, processing * batches of locations to a List preserves submission order; as opposed to * using FutureCallbacks, which will reorder sites on export. - * - * TODO this is a terrible implementation with batch size 10. resulted from - * refactor to exports not queueing results */ for (Site site : sites) { Callable<EqRate> task = EqRate.callable(model, config, site); diff --git a/src/main/java/gov/usgs/earthquake/nshmp/site/NshmpSite.java b/src/main/java/gov/usgs/earthquake/nshmp/site/NshmpSite.java index f8754e839..21ef1cd42 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/site/NshmpSite.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/site/NshmpSite.java @@ -20,10 +20,6 @@ import gov.usgs.earthquake.nshmp.internal.UsRegion; */ public enum NshmpSite implements NamedLocation { - // TODO move this and other nshmp specific classes to nshmp-haz - // TODO update output files which should also be part of nshmp-haz - // TODO do we need ATC sites? - /* Northern CA (16) */ BIG_SUR_CA(-121.75, 36.25), COALINGA_CA(-120.40, 36.15), diff --git a/src/main/java/gov/usgs/earthquake/nshmp/site/NshmpSiteFiles.java b/src/main/java/gov/usgs/earthquake/nshmp/site/NshmpSiteFiles.java index 5d1022116..cb633b94f 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/site/NshmpSiteFiles.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/site/NshmpSiteFiles.java @@ -56,7 +56,7 @@ import gov.usgs.earthquake.nshmp.geo.json.Properties.Style; */ final class NshmpSiteFiles { - // TODO consider removing this to nshm-model-dev + // Consider removing this to nshm-model-dev // keeping the outputs in nshmp-haz /* @@ -185,19 +185,24 @@ final class NshmpSiteFiles { static void writeNshmpSummaryPoly() throws IOException { Set<NshmpPolygon> polys = EnumSet.range(LA_BASIN, UCERF3_NSHM14); + + List<String> nameList = polys.stream() + .map(Functions.toStringFunction()) + .collect(Collectors.toList()); + + List<LocationList> coordList = polys.stream() + .map(new Function<NshmpPolygon, LocationList>() { + @Override + public LocationList apply(NshmpPolygon poly) { + return poly.coordinates(); + } + }::apply) + .collect(Collectors.toList()); + writePolysJson( EXPORT_DIR.resolve("map-nshmp-all.geojson"), - polys.stream() - .map(Functions.toStringFunction()) - .collect(Collectors.toList()), - polys.stream() - .map(new Function<NshmpPolygon, LocationList>() { - @Override - public LocationList apply(NshmpPolygon poly) { - return poly.coordinates(); - } - }::apply) - .collect(Collectors.toList())); + nameList, + coordList); } static void writePolysJson( @@ -210,7 +215,6 @@ final class NshmpSiteFiles { .put("spacing", 0.1); int i = 0; - // TODO this incrementer is messed up // can't name and coords come as a map? for (LocationList border : coordList) { props.put(Style.TITLE, nameList.get(i++)); @@ -395,7 +399,6 @@ final class NshmpSiteFiles { .put(Style.MARKER_SIZE, "small"); for (NamedLocation loc : sites) { - // TODO test loc vs loc.toString() b.add(Feature.point(loc.location()) .properties(props .put(Style.TITLE, loc.toString()) diff --git a/src/main/java/gov/usgs/earthquake/nshmp/www/ServletUtil.java b/src/main/java/gov/usgs/earthquake/nshmp/www/ServletUtil.java index 3e3b7425d..ec22fe0c2 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/www/ServletUtil.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/www/ServletUtil.java @@ -32,7 +32,6 @@ import gov.usgs.earthquake.nshmp.calc.ValueFormat; import gov.usgs.earthquake.nshmp.gmm.Imt; import gov.usgs.earthquake.nshmp.model.HazardModel; import gov.usgs.earthquake.nshmp.www.meta.MetaUtil; - import io.micronaut.context.annotation.Value; import io.micronaut.context.event.ShutdownEvent; import io.micronaut.context.event.StartupEvent; @@ -64,7 +63,6 @@ public class ServletUtil { private static HazardModel HAZARD_MODEL; static { - /* TODO modified for disagg-epsilon branch; should be context var */ THREAD_COUNT = getRuntime().availableProcessors(); CALC_EXECUTOR = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(THREAD_COUNT)); TASK_EXECUTOR = Executors.newSingleThreadExecutor(); diff --git a/src/main/java/gov/usgs/earthquake/nshmp/www/hazard/HazardService.java b/src/main/java/gov/usgs/earthquake/nshmp/www/hazard/HazardService.java index c5c278ee2..41641e3be 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/www/hazard/HazardService.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/www/hazard/HazardService.java @@ -39,7 +39,6 @@ import gov.usgs.earthquake.nshmp.www.ServletUtil; import gov.usgs.earthquake.nshmp.www.meta.DoubleParameter; import gov.usgs.earthquake.nshmp.www.meta.Parameter; import gov.usgs.earthquake.nshmp.www.services.SourceServices.SourceModel; - import io.micronaut.http.HttpRequest; import io.micronaut.http.HttpResponse; import jakarta.inject.Singleton; @@ -162,7 +161,7 @@ public final class HazardService { Metadata(HazardModel model) { this.model = new SourceModel(model); - // TODO need min max from model + // should get min max from model longitude = new DoubleParameter( "Longitude", "°", @@ -252,7 +251,7 @@ public final class HazardService { } Builder hazard(Hazard hazard) { - // TODO necessary?? + // necessary?? checkState(totalMap == null, "Hazard has already been added to this builder"); componentMaps = new EnumMap<>(Imt.class); @@ -347,7 +346,7 @@ public final class HazardService { * If entire curve is <1e-4, this method will return a curve consisting of * just the first point in the supplied curve. * - * TODO We probably want to move the TRUNCATION_LIMIT out to a config. + * Consider moving to config. */ double[] yValues = curve.yValues().toArray(); diff --git a/src/main/java/gov/usgs/earthquake/nshmp/www/services/RateService.java b/src/main/java/gov/usgs/earthquake/nshmp/www/services/RateService.java index d4b81df81..500167ba5 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/www/services/RateService.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/www/services/RateService.java @@ -27,7 +27,6 @@ import gov.usgs.earthquake.nshmp.www.ServletUtil; import gov.usgs.earthquake.nshmp.www.WsUtils; import gov.usgs.earthquake.nshmp.www.meta.DoubleParameter; import gov.usgs.earthquake.nshmp.www.meta.Metadata.DefaultParameters; - import io.micronaut.http.HttpRequest; import io.micronaut.http.HttpResponse; import jakarta.inject.Singleton; @@ -311,8 +310,8 @@ public final class RateService { } /* - * TODO would rather use this a general container for mfds and hazard curves. - * See HazardService.Curve + * Would rather use this a general container for mfds and hazard curves. See + * HazardService.Curve */ private static class Sequence { final String component; diff --git a/src/main/java/gov/usgs/earthquake/nshmp/www/services/SourceServices.java b/src/main/java/gov/usgs/earthquake/nshmp/www/services/SourceServices.java index b473fd92f..bb6cbd904 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/www/services/SourceServices.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/www/services/SourceServices.java @@ -21,7 +21,6 @@ import gov.usgs.earthquake.nshmp.www.ResponseBody; import gov.usgs.earthquake.nshmp.www.ServletUtil; import gov.usgs.earthquake.nshmp.www.WsUtils; import gov.usgs.earthquake.nshmp.www.meta.Parameter; - import io.micronaut.http.HttpRequest; import io.micronaut.http.HttpResponse; import jakarta.inject.Singleton; @@ -70,47 +69,21 @@ public class SourceServices { } /* - * TODO service metadata should be in same package as services (why + * task... service metadata should be in same package as services (why * ResponseData is currently public); rename meta package to */ public static class ResponseData { final String description; final Object server; - // final Parameters parameters; public ResponseData() { this.description = "Installed source model listing"; this.server = ServletUtil.serverData( ServletUtil.THREAD_COUNT, Stopwatch.createStarted()); - // this.parameters = new Parameters(); } } - // static class Parameters { - // List<SourceModel> models; - // DoubleParameter returnPeriod; - // DoubleParameter vs30; - // - // Parameters() { - // models = ServletUtil.hazardModels().stream() - // .map(SourceModel::new) - // .collect(Collectors.toList()); - // - // returnPeriod = new DoubleParameter( - // "Return period", - // "years", - // 100.0, - // 1e6); - // - // vs30 = new DoubleParameter( - // "Vs30", - // "m/s", - // 150, - // 1500); - // } - // } - public static class SourceModel { String name; Set<Gmm> gmms; @@ -129,12 +102,6 @@ public class SourceServices { .map(imt -> new Parameter(ServletUtil.imtShortLabel(imt), imt.name())) .collect(toList()); } - - // public static List<SourceModel> getList() { - // return ServletUtil.hazardModels().stream() - // .map(SourceModel::new) - // .collect(Collectors.toList()); - // } } enum Attributes { -- GitLab