forked from Auto-Mech/mechanalyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxarray_wrappers.py
85 lines (54 loc) · 1.54 KB
/
xarray_wrappers.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import xarray
import numpy
# Constructors
def from_data(temps, press, ktp_vals):
# WORK IN PROGRESS - SHOULD NOT WORK YET JUST TESTING THINGS OUT
# Construct a KTP DataArray from data
ktp = xarray.DataArray(ktp_vals, [("pres", press), ("temp", temps)])
return ktp
# Getters
def get_temperatures(ktp):
# WORK IN PROGRESS
# Gets the temperature values
temps = ktp.get("temps")
return(temps)
def get_pressures(ktp):
# WORK IN PROGRESS
# Gets the pressure values
press = ktp["press"]
return(press)
def get_values(ktp):
# WORK IN PROGRESS
# Gets the KTP values
vals = ktp(ktp_vals)
return(vals)
def get_pslice(ktp):
# WORK IN PROGRESS
# Get a slice at a selected pressure value
pslice = ktp.sel(pres = numpy.inf)
return pslice
def get_tslice(ktp, t):
# WORK IN PROGRESS
# Get a slice at a selected temperature value
tslice = ktp.sel(temp = t)
return tslice
def get_spec_vals(ktp, t, p):
# WORK IN PROGRESS
# Get a specific value at a selected temperature and pressure value
spec_vals = ktp.sel(temp = t, pres = p)
return spec_vals
def get_ipslice(ktp, i):
# WORK IN PROGRESS
# Get a slice at a selected pressure index
ipslice = ktp.isel(pres = i)
return ipslice
def get_itslice(ktp, i):
# WORK IN PROGRESS
# Get a slice at a selected temperature index
itslice = ktp.isel(temp = i)
return itslice
# Setters
def set_values(ktp_obj, ktp_vals):
# WORK IN PROGRESSS
# Sets the KTP values
return(ktp_vals)