-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from gjmoore/ian
small changes to enable creation of llc snapshots
- Loading branch information
Showing
10 changed files
with
195 additions
and
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ job_logs*.json | |
*.DS_Store | ||
# emacs temporary files: | ||
*~ | ||
*._* | ||
\#*\# |
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
24 changes: 24 additions & 0 deletions
24
processing/src/ecco_dataset_production/utils/edp_generate_dataproducts_single.sh
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,24 @@ | ||
#!/usr/bin/env bash | ||
|
||
|
||
# Run in a directory with one or more json task files (extension .json) | ||
# Loops through each one; sends them all off to run in parallel | ||
# takes one argument, the root name of the task file json file(s) | ||
|
||
|
||
EDP_root_dir=/home/jpluser/edp | ||
CFGFILE="${EDP_root_dir}/ECCO-Dataset-Production/processing/configs/product_generation_config_updated.yaml" | ||
|
||
# loop through all task files | ||
TASKFILE=${1} | ||
|
||
echo $TASKFILE | ||
|
||
#KEYGEN='/usr/local/bin/aws-login.darwin.amd64' | ||
#PROFILE='saml-pub' | ||
|
||
edp_generate_dataproducts --tasklist ${TASKFILE} --cfgfile ${CFGFILE} --log DEBUG | ||
#> LOG_$TASKFILE.log 2> LOG_$TASKFILE.log | ||
# #--keygen ${KEYGEN} \ | ||
# #--profile ${PROFILE} \ | ||
|
70 changes: 70 additions & 0 deletions
70
processing/src/ecco_dataset_production/utils/split_task_json.py
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,70 @@ | ||
import json | ||
import math | ||
import argparse | ||
|
||
def split_json(input_file, num_files, output_base): | ||
""" | ||
Splits a JSON file into multiple smaller JSON files. | ||
Arguments: | ||
- input_file (str): Path to the input JSON file to split. | ||
- num_files (int): Number of output JSON files to create. | ||
- output_base (str): Base name for the output files. Each file will be named | ||
as `output_base_001.json`, `output_base_002.json`, etc. | ||
The script reads a JSON file, divides it into `num_files` parts, and writes | ||
each part into a new JSON file. Each new file will contain a roughly equal | ||
number of entries from the original JSON file. | ||
""" | ||
|
||
# Load the original JSON file | ||
with open(input_file, 'r') as infile: | ||
data = json.load(infile) | ||
|
||
# Total number of entries in the input JSON | ||
n = len(data) | ||
|
||
# Calculate the number of entries per file (ceiling division to ensure all data is covered) | ||
entries_per_file = math.ceil(n / num_files) | ||
|
||
# Split the data and write to new JSON files | ||
for i in range(num_files): | ||
start_index = i * entries_per_file | ||
end_index = start_index + entries_per_file | ||
|
||
# Create a subset of the data for the current split | ||
subset = data[start_index:end_index] | ||
|
||
# Output filename with zero-padded numbers (e.g., output_base_001.json) | ||
output_filename = f'{output_base}_{i+1:03}.json' | ||
|
||
# Write the subset to the output file | ||
with open(output_filename, 'w') as outfile: | ||
json.dump(subset, outfile, indent=4) | ||
|
||
print(f"Split into {num_files} files.") | ||
|
||
# Set up argument parsing | ||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser( | ||
description='Split a JSON file into multiple smaller files.' | ||
) | ||
|
||
# Positional argument for input file | ||
parser.add_argument('input_file', type=str, | ||
help='Path to the input JSON file to be split.') | ||
|
||
# Positional argument for number of files to split into | ||
parser.add_argument('num_files', type=int, | ||
help='Number of output JSON files to create.') | ||
|
||
# Positional argument for output base name | ||
parser.add_argument('output_base', type=str, | ||
help='Base name for the output files (e.g., "output" will result in "output_001.json", "output_002.json", etc.)') | ||
|
||
# Parse the command-line arguments | ||
args = parser.parse_args() | ||
|
||
# Call the function to split the JSON | ||
split_json(args.input_file, args.num_files, args.output_base) | ||
|
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,7 @@ | ||
# two steps | ||
|
||
# 1. create task list | ||
./edp_create_job_task_list_SSH_native_latlon_mon_mean.sh SSH_native_latlon_mon_mean_jobs.txt SSH_native_latlon_mon_mean_tasks.json.sav | ||
|
||
# 2. generate data products from task list | ||
./edp_generate_dataproducts_SSH_native_latlon_mon_mean.sh SSH_native_latlon_mon_mean_tasks.json.sav |
Oops, something went wrong.