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
fb69129f
Commit
fb69129f
authored
2 years ago
by
Clayton, Brandon Scott
Browse files
Options
Downloads
Patches
Plain Diff
add abstract class to read in all files
parent
6f1db0b6
No related branches found
No related tags found
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/lib/src/main/java/gov/usgs/earthquake/nshmp/netcdf/NetcdfDataFiles.java
+76
-0
76 additions, 0 deletions
...ava/gov/usgs/earthquake/nshmp/netcdf/NetcdfDataFiles.java
with
76 additions
and
0 deletions
src/lib/src/main/java/gov/usgs/earthquake/nshmp/netcdf/NetcdfDataFiles.java
0 → 100644
+
76
−
0
View file @
fb69129f
package
gov.usgs.earthquake.nshmp.netcdf
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
import
gov.usgs.earthquake.nshmp.gmm.NehrpSiteClass
;
/**
* Read in all NetCDF files associated with a {@link NetcdfDataType},
* holds {@link Netcdf} objects associated with each NetCDF file.
*
* @author U.S. Geological Survey
*/
public
abstract
class
NetcdfDataFiles
<
T
extends
Netcdf
<?>>
extends
ArrayList
<
T
>
{
private
final
Path
netcdfPath
;
private
final
NetcdfDataType
dataType
;
public
NetcdfDataFiles
(
Path
netcdfPath
,
NetcdfDataType
dataType
)
{
super
();
this
.
netcdfPath
=
netcdfPath
;
this
.
dataType
=
dataType
;
}
/**
* Returns the path to the directory where all NetCDF files are.
*/
public
Path
netcdfPath
()
{
return
netcdfPath
;
}
/**
* Returns the data type of the NetCDF files.
*/
public
NetcdfDataType
dataType
()
{
return
dataType
;
}
/**
* Returns the set of NEHRP site classes for all data files.
*/
public
Set
<
NehrpSiteClass
>
siteClasses
()
{
return
stream
()
.
flatMap
(
netcdf
->
netcdf
.
netcdfData
().
siteClasses
().
stream
())
.
sorted
()
.
collect
(
Collectors
.
toSet
());
}
/**
* Find NetCDF files (.nc) with specific {@link NetcdfDataType}.
*
* @param netcdfPath Path to NetCDF files
* @param dataType The data type to filter by
* @throws IOException
*/
protected
Stream
<
Path
>
walkFiles
(
Path
netcdfPath
,
NetcdfDataType
dataType
)
throws
IOException
{
return
Files
.
walk
(
netcdfPath
)
.
filter
(
file
->
file
.
getFileName
().
toString
().
endsWith
(
".nc"
))
.
filter
(
file
->
NetcdfDataType
.
getDataType
(
file
)
==
dataType
);
}
/**
* Returns the list of {@link Netcdf} objects associated with a NetCDF file
* and {@link NetcdfDataType}.
*
* @param netcdfPath The path to NetCDF files
* @param dataType The data type to read in
* @throws IOException
*/
protected
abstract
List
<
T
>
readFiles
(
Path
netcdfPath
,
NetcdfDataType
dataType
);
}
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