forked from sxs-collaboration/spectre
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added CLI for CombineH5 along with a test
Made required modifications, added check_src flag Made newer changes Made newer changes Removed unnecessary includes Changes
- Loading branch information
Aastha Bagree
committed
Aug 22, 2023
1 parent
1ea6c6a
commit 3a3a7cd
Showing
7 changed files
with
227 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,13 @@ | ||
// Distributed under the MIT License. | ||
// See LICENSE.txt for details. | ||
|
||
#pragma once | ||
|
||
#include <boost/program_options.hpp> | ||
#include <cstddef> | ||
#include <cstdlib> | ||
#include <iterator> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include "DataStructures/DataVector.hpp" | ||
#include "IO/H5/AccessType.hpp" | ||
#include "IO/H5/CheckH5PropertiesMatch.hpp" | ||
#include "IO/H5/File.hpp" | ||
#include "IO/H5/SourceArchive.hpp" | ||
#include "IO/H5/VolumeData.hpp" | ||
#include "Parallel/Printf.hpp" | ||
#include "Utilities/FileSystem.hpp" | ||
#include "Utilities/MakeString.hpp" | ||
#include "Utilities/StdHelpers.hpp" | ||
|
||
namespace h5 { | ||
|
||
void combine_h5(const std::string& file_prefix, const std::string& subfile_name, | ||
const std::string& output); | ||
const std::string& output, const bool check_src = true); | ||
|
||
} // namespace h5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Distributed under the MIT License. | ||
# See LICENSE.txt for details. | ||
|
||
import logging | ||
import os | ||
|
||
import click | ||
import rich | ||
|
||
import spectre.IO.H5 as spectre_h5 | ||
|
||
|
||
@click.command(name="combine-h5") | ||
@click.option( | ||
"--file-prefix", | ||
required=True, | ||
type=str, | ||
help="prefix of the files to be combined (omit number and file extension)", | ||
) | ||
@click.option( | ||
"--subfile-name", | ||
"-d", | ||
type=str, | ||
help="subfile name of the volume file in the H5 file (omit file extension)", | ||
) | ||
@click.option( | ||
"--output", | ||
"-o", | ||
required=True, | ||
type=click.Path( | ||
exists=False, | ||
file_okay=True, | ||
dir_okay=False, | ||
writable=True, | ||
readable=True, | ||
), | ||
help="combined output filename (omit file extension)", | ||
) | ||
@click.option( | ||
"--check-src/--no-check-src", | ||
default=True, | ||
show_default=True, | ||
help=( | ||
"flag to check src files, True implies src files exist and can be" | ||
" checked, False implies no src files to check." | ||
), | ||
) | ||
def combine_h5_command(file_prefix, subfile_name, output, check_src): | ||
"""Combines multiple HDF5 volume files | ||
This executable is used for combining a series of HDF5 volume files into one | ||
continuous dataset to be stored in a single HDF5 volume file.""" | ||
|
||
# Print available subfile names and exit | ||
filename = file_prefix + "0.h5" | ||
if not subfile_name: | ||
if os.path.exists(filename): | ||
spectre_file = spectre_h5.H5File(filename, "r") | ||
import rich.columns | ||
|
||
rich.print(rich.columns.Columns(spectre_file.all_vol_files())) | ||
return | ||
|
||
if subfile_name[0] == "/": | ||
subfile_name = subfile_name[1:] | ||
|
||
spectre_h5.combine_h5(file_prefix, subfile_name, output, check_src) | ||
|
||
|
||
if __name__ == "__main__": | ||
combine_h5_command(help_option_names=["-h", "--help"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters