forked from cdfortenbach/JET
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppend_util.py
37 lines (26 loc) · 1.2 KB
/
Append_util.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# -*- coding: utf-8 -*-
"""
Created on Thu Aug 29 17:47:50 2019
@author: Charles Fortenbach
"""
import numpy as np
###############################################################################
# Merge hi number Pdxo_Output file with low number Pdxo_Output file
###############################################################################
# Must run this within the Linux file structure
# From terminal within low number JET directory,
# enter cmd: python Append_util.py
dataset_low = np.loadtxt('Pdxo_Output.txt', ndmin=2, skiprows=0)
targets_dataset_low = np.max(dataset_low, axis=0)
last_target_low = targets_dataset_low[2]
PATH = input(' Enter the directory path to the hi number target Pdxo_Output file: ')
# for example: '/media/Win7share/JET_wkg_2/'
dataset_hi = np.loadtxt(PATH + 'Pdxo_Output.txt', ndmin=2, skiprows=0)
targets_dataset_hi = np.min(dataset_hi, axis=0)
first_target_hi = targets_dataset_hi[2]
# check compatibility then append data
if first_target_hi == last_target_low +1:
with open('Pdxo_Output.txt', 'ba') as f:
np.savetxt(f, dataset_hi)
print('Pdxo_Output file updated')
else: print('mismatch in Pdxo_Output files')