diff --git a/src/hazard/src/main/java/gov/usgs/earthquake/nshmp/netcdf/reader/BoundingReaderHazardCurves.java b/src/hazard/src/main/java/gov/usgs/earthquake/nshmp/netcdf/reader/BoundingReaderHazardCurves.java index 4257bc91f11fb088e370664d67bfd1350e8c6310..f03a2367efb3e64289551e3827629bcb32a21016 100644 --- a/src/hazard/src/main/java/gov/usgs/earthquake/nshmp/netcdf/reader/BoundingReaderHazardCurves.java +++ b/src/hazard/src/main/java/gov/usgs/earthquake/nshmp/netcdf/reader/BoundingReaderHazardCurves.java @@ -124,21 +124,24 @@ public class BoundingReaderHazardCurves extends BoundingReader<StaticDataHazardC for (int iImt = 0; iImt < netcdfData.imts().size(); iImt++) { var imt = netcdfData.imts().get(iImt); - // Build origin array, e.g [0, imt, siteClass] - var origin = netcdf.netcdfShape().buildShape() + // origin array builder, e.g [0, imt, siteClass] + var origin_builder = netcdf.netcdfShape().buildShape() .add(IndexKey.IML, 0) - .add(IndexKey.IMT, iImt) - .add(IndexKey.SITE_CLASS, iSiteClass) - .reduce() - .build(); + .add(IndexKey.IMT, iImt); - // Build shape array, e.g. [nIML, 1, 1] - var shape = netcdf.netcdfShape().buildShape() + // shape array builder, e.g. [nIML, 1, 1] + var shape_builder = netcdf.netcdfShape().buildShape() .add(IndexKey.IML, netcdfData.nIml()) - .add(IndexKey.IMT, 1) - .add(IndexKey.SITE_CLASS, 1) - .reduce() - .build(); + .add(IndexKey.IMT, 1); + + // Only add index for siteClass if this is not a singleton dimension + if (netcdfData.siteClasses().size() > 1) { + origin_builder.add(IndexKey.SITE_CLASS, iSiteClass); + shape_builder.add(IndexKey.SITE_CLASS, 1); + } + + var origin = origin_builder.reduce().build(); + var shape = shape_builder.reduce().build(); try { var xySequence = XySequence.create(