Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nshmp-ws-static
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ghsc
National Seismic Hazard Model Project
nshmp-ws-static
Commits
6c40de2e
Commit
6c40de2e
authored
2 years ago
by
Clayton, Brandon Scott
Browse files
Options
Downloads
Patches
Plain Diff
Netcdf data files for hazard curves class
parent
aac6d4ee
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!128
Production Release | nshmp-ws-static
,
!127
Resolves - Handle Multiple NetCDF Files for AASHTO Service
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/hazard/src/main/java/gov/usgs/earthquake/nshmp/netcdf/NetcdfDataFilesHazardCurves.java
+75
-0
75 additions, 0 deletions
.../earthquake/nshmp/netcdf/NetcdfDataFilesHazardCurves.java
with
75 additions
and
0 deletions
src/hazard/src/main/java/gov/usgs/earthquake/nshmp/netcdf/NetcdfDataFilesHazardCurves.java
0 → 100644
+
75
−
0
View file @
6c40de2e
package
gov.usgs.earthquake.nshmp.netcdf
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
import
java.nio.file.Path
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
gov.usgs.earthquake.nshmp.gmm.Imt
;
/**
* Read in and parse all hazard NetCDF data files.
*
* @author U.S. Geological Survey
*/
public
class
NetcdfDataFilesHazardCurves
extends
NetcdfDataFiles
<
NetcdfHazardCurves
>
{
public
NetcdfDataFilesHazardCurves
(
Path
netcdfPath
)
{
super
(
netcdfPath
,
NetcdfDataType
.
HAZARD_CURVES
);
addAll
(
readFiles
(
netcdfPath
,
dataType
()));
}
/**
* Returns the set of NEHRP site classes for all data files.
*/
public
Set
<
Imt
>
imts
()
{
return
stream
()
.
flatMap
(
netcdf
->
netcdf
.
netcdfData
().
imts
().
stream
())
.
sorted
()
.
collect
(
Collectors
.
toSet
());
}
/**
* Returns the Netcdf object associated with a location.
*
* @param location The location to find the NetCDF object
* @throws IllegalArgumentException If no location is contained in a Netcdf
* object.
*/
public
NetcdfHazardCurves
netcdf
(
Nshm
nshm
)
{
return
stream
()
.
filter
(
netcdf
->
netcdf
.
nshm
()
==
nshm
)
.
findFirst
()
.
orElseThrow
(()
->
new
IllegalArgumentException
(
String
.
format
(
"NSHM %s not found in data sets."
,
nshm
)));
}
/**
* Returns the {@link Nshm NSHMs} associated with the data sets read in.
*/
public
Set
<
Nshm
>
nshms
()
{
return
stream
()
.
map
(
netcdf
->
netcdf
.
nshm
())
.
sorted
()
.
collect
(
Collectors
.
toSet
());
}
@Override
protected
List
<
NetcdfHazardCurves
>
readFiles
(
Path
netcdfPath
,
NetcdfDataType
dataType
)
{
try
{
List
<
NetcdfHazardCurves
>
data
=
walkFiles
(
netcdfPath
,
dataType
)
.
map
(
NetcdfHazardCurves:
:
new
)
.
collect
(
Collectors
.
toList
());
if
(
data
.
isEmpty
())
{
throw
new
FileNotFoundException
(
"Failed to find hazard NetCDF files"
);
}
return
List
.
copyOf
(
data
);
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
"Failed to read NetCDF directory "
+
netcdfPath
,
e
);
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment