cleopy 0.57.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. cleopy/__init__.py +22 -0
  2. cleopy/cxx2py.py +136 -0
  3. cleopy/editconfigfile.py +61 -0
  4. cleopy/gbxboundariesbinary_src/__init__.py +16 -0
  5. cleopy/gbxboundariesbinary_src/create_gbxboundaries.py +197 -0
  6. cleopy/gbxboundariesbinary_src/read_gbxboundaries.py +350 -0
  7. cleopy/geninitconds.py +144 -0
  8. cleopy/initsuperdropsbinary_src/__init__.py +15 -0
  9. cleopy/initsuperdropsbinary_src/attrsgen.py +206 -0
  10. cleopy/initsuperdropsbinary_src/crdgens.py +101 -0
  11. cleopy/initsuperdropsbinary_src/create_initsuperdrops.py +360 -0
  12. cleopy/initsuperdropsbinary_src/dryrgens.py +31 -0
  13. cleopy/initsuperdropsbinary_src/probdists.py +239 -0
  14. cleopy/initsuperdropsbinary_src/read_initsuperdrops.py +465 -0
  15. cleopy/initsuperdropsbinary_src/rgens.py +81 -0
  16. cleopy/readbinary.py +120 -0
  17. cleopy/readconfigfile.py +61 -0
  18. cleopy/sdmout_src/__init__.py +16 -0
  19. cleopy/sdmout_src/massmoms.py +83 -0
  20. cleopy/sdmout_src/pygbxsdat.py +59 -0
  21. cleopy/sdmout_src/pysetuptxt.py +90 -0
  22. cleopy/sdmout_src/pyzarr.py +158 -0
  23. cleopy/sdmout_src/sdtracing.py +141 -0
  24. cleopy/sdmout_src/superdrops.py +428 -0
  25. cleopy/sdmout_src/supersdata.py +228 -0
  26. cleopy/sdmout_src/thermodata.py +146 -0
  27. cleopy/sdmout_src/thermoeqns.py +129 -0
  28. cleopy/sdmout_src/timedata.py +54 -0
  29. cleopy/thermobinary_src/__init__.py +16 -0
  30. cleopy/thermobinary_src/create_thermodynamics.py +256 -0
  31. cleopy/thermobinary_src/read_thermodynamics.py +498 -0
  32. cleopy/thermobinary_src/thermodyngen.py +56 -0
  33. cleopy/thermobinary_src/thermogen.py +466 -0
  34. cleopy/thermobinary_src/windsgen.py +228 -0
  35. cleopy/writebinary.py +218 -0
  36. cleopy-0.57.4.dist-info/METADATA +47 -0
  37. cleopy-0.57.4.dist-info/RECORD +39 -0
  38. cleopy-0.57.4.dist-info/WHEEL +4 -0
  39. cleopy-0.57.4.dist-info/licenses/LICENSE.md +43 -0
@@ -0,0 +1,228 @@
1
+ """
2
+ Copyright (c) 2025 MPI-M, Clara Bayley
3
+
4
+
5
+ ----- CLEO -----
6
+ File: supersdata.py
7
+ Project: sdmout_src
8
+ Created Date: Tuesday 24th October 2023
9
+ Author: Clara Bayley (CB)
10
+ Additional Contributors:
11
+ -----
12
+ License: BSD 3-Clause "New" or "Revised" License
13
+ https://opensource.org/licenses/BSD-3-Clause
14
+ -----
15
+ File Description:
16
+ !!!NOTE!!! DEPRECIATED SINCE V0.40.0, REPLACED BY SUPERDROPS MODULE !!!!!!
17
+ python class to handle superdroplet attributes data from SDM zarr store in ragged array format
18
+ """
19
+
20
+
21
+ import numpy as np
22
+ import xarray as xr
23
+ import awkward as ak
24
+ import warnings
25
+ from pathlib import Path
26
+ from typing import Optional
27
+
28
+ warnings.warn(
29
+ "supersdata module is depreciated since CLEO v0.40.0,\nreplaced by superdrops"
30
+ )
31
+
32
+
33
+ class SuperdropProperties:
34
+ """Contains attributes common to all superdroplets and functions
35
+ for calculating derived ones"""
36
+
37
+ def __init__(self, consts):
38
+ """Common attributes shared by superdroplets"""
39
+
40
+ # density of liquid in droplets (=density of water at 300K) [Kg/m^3]
41
+ self.RHO_L = consts["RHO_L"]
42
+
43
+ # density of (dry) solute [Kg/m^3]
44
+ self.RHO_SOL = consts["RHO_SOL"]
45
+
46
+ # Mr of solute [g/mol]
47
+ self.MR_SOL = consts["MR_SOL"]
48
+
49
+ # degree ionic dissociation (van't Hoff factor)
50
+ self.IONIC = consts["IONIC"]
51
+
52
+ self.print_properties()
53
+
54
+ def print_properties(self):
55
+ print("---- Superdrop Properties -----")
56
+ print("RHO_L =", self.RHO_L, "Kg/m^3")
57
+ print("RHO_SOL =", self.RHO_SOL, "Kg/m^3")
58
+ print("MR_SOL =", self.MR_SOL, "Kg/mol")
59
+ print("IONIC =", self.IONIC)
60
+ print("-------------------------------")
61
+
62
+ def rhoeff(self, r, msol):
63
+ """calculates effective density [g m^-3] of
64
+ droplet such that mass_droplet, m = 4/3*pi*r^3 * rhoeff
65
+ taking into account mass of liquid and mass of
66
+ solute assuming solute occupies volume it
67
+ would given its (dry) density, RHO_SOL."""
68
+
69
+ msol = msol / 1000 # convert from grams to Kg
70
+ r = r / 1e6 # convert microns to m
71
+
72
+ solfactor = 3 * msol / (4.0 * np.pi * (r**3))
73
+ rhoeff = self.RHO_L + solfactor * (1 - self.RHO_L / self.RHO_SOL)
74
+
75
+ return rhoeff * 1000 # [g/m^3]
76
+
77
+ def vol(self, r):
78
+ """volume of droplet [m^3]"""
79
+
80
+ r = r / 1e6 # convert microns to m
81
+
82
+ return 4.0 / 3.0 * np.pi * r**3
83
+
84
+ def mass(self, r, msol):
85
+ """
86
+ total mass of droplet (water + (dry) areosol) [g],
87
+ m = 4/3*pi*rho_l**3 + msol(1-rho_l/rho_sol)
88
+ ie. m = 4/3*pi*rhoeff*R**3
89
+ """
90
+
91
+ msol = msol / 1000 # convert from grams to Kg
92
+ r = r / 1e6 # convert microns to m
93
+
94
+ msoleff = msol * (1 - self.RHO_L / self.RHO_SOL) # effect of solute on mass
95
+ m = msoleff + 4 / 3.0 * np.pi * (r**3) * self.RHO_L
96
+
97
+ return m * 1000 # [g]
98
+
99
+ def m_water(self, r, msol):
100
+ """mass of only water in droplet [g]"""
101
+
102
+ msol = msol / 1000 # convert msol from grams to Kg
103
+ r = r / 1e6 # convert microns to m
104
+
105
+ v_sol = msol / self.RHO_SOL
106
+ v_w = 4 / 3.0 * np.pi * (r**3) - v_sol
107
+
108
+ return self.RHO_L * v_w * 1000 # [g]
109
+
110
+
111
+ class SupersData(SuperdropProperties):
112
+ def __init__(self, dataset: Path, consts: Optional[dict] = None):
113
+ if consts is not None:
114
+ SuperdropProperties.__init__(self, consts)
115
+ else:
116
+ warnings.warn("No superdroplet properties attached to superdroplet dataset")
117
+
118
+ ds = self.tryopen_dataset(dataset)
119
+ raggedcount = ds["raggedcount"] # ragged count variable
120
+
121
+ self.sdId = self.tryvar(ds, raggedcount, "sdId")
122
+ self.sdgbxindex = self.tryvar(ds, raggedcount, "sdgbxindex")
123
+ self.xi = self.tryvar(ds, raggedcount, "xi")
124
+ self.radius = self.tryvar(ds, raggedcount, "radius")
125
+ self.msol = self.tryvar(ds, raggedcount, "msol")
126
+
127
+ self.coord3 = self.tryvar(ds, raggedcount, "coord3")
128
+ self.coord1 = self.tryvar(ds, raggedcount, "coord1")
129
+ self.coord2 = self.tryvar(ds, raggedcount, "coord2")
130
+
131
+ self.radius_units = self.tryunits(ds, "radius") # probably microns
132
+ self.msol_units = self.tryunits(ds, "msol") # probably gramms
133
+ self.coord3_units = self.tryunits(ds, "coord3") # probably meters
134
+ self.coord1_units = self.tryunits(ds, "coord1") # probably meters
135
+ self.coord2_units = self.tryunits(ds, "coord2") # probably meters
136
+
137
+ def tryopen_dataset(self, dataset: Path):
138
+ if isinstance(dataset, str) or isinstance(dataset, Path):
139
+ print("supers dataset: ", dataset)
140
+ return xr.open_dataset(dataset, engine="zarr", consolidated=False)
141
+ else:
142
+ return dataset
143
+
144
+ def tryvar(self, ds: xr.Dataset, raggedcount: xr.DataArray, var: str):
145
+ """attempts to return variable in form of ragged array (ak.Array) with dims
146
+ [time, raggedcount] for a variable "var" in xarray dataset 'ds'.
147
+ If attempt fails, returns empty array instead"""
148
+ try:
149
+ return ak.unflatten(ds[var].values, raggedcount.values)
150
+ except KeyError:
151
+ return ak.Array([])
152
+
153
+ def tryunits(self, ds: xr.Dataset, var: str):
154
+ """attempts to return the units of a variable
155
+ in xarray dataset 'ds'. If attempt fails, returns null"""
156
+ try:
157
+ return ds[var].units
158
+ except KeyError:
159
+ return ""
160
+
161
+ def __getitem__(self, key):
162
+ if key == "sdId":
163
+ return self.sdId
164
+ elif key == "sdgbxindex":
165
+ return self.sdgbxindex
166
+ elif key == "xi":
167
+ return self.xi
168
+ elif key == "radius":
169
+ return self.radius
170
+ elif key == "msol":
171
+ return self.msol
172
+ elif key == "coord3":
173
+ return self.coord3
174
+ elif key == "coord1":
175
+ return self.coord1
176
+ elif key == "coord2":
177
+ return self.coord2
178
+ else:
179
+ err = "no known return provided for " + key + " key"
180
+ raise ValueError(err)
181
+
182
+
183
+ class RainSupers(SuperdropProperties):
184
+ def __init__(self, sddata, consts, rlim=40):
185
+ """return data for (rain)drops with radii > rlim.
186
+ Default minimum raindrops size is rlim=40microns"""
187
+
188
+ if not isinstance(sddata, SupersData):
189
+ sddata = SupersData(dataset=sddata, consts=consts)
190
+
191
+ israin = sddata.radius >= rlim # ak array True for raindrops
192
+
193
+ self.totnsupers_rain = ak.num(israin[israin is True])
194
+ self.sdId = sddata.sdId[israin]
195
+ self.sdgbxindex = sddata.sdgbxindex[israin]
196
+ self.xi = sddata.xi[israin]
197
+ self.radius = sddata.radius[israin]
198
+ self.msol = sddata.msol[israin]
199
+
200
+ if np.any(sddata.coord3):
201
+ self.coord3 = sddata.coord3[israin]
202
+ if np.any(sddata.coord1):
203
+ self.coord1 = sddata.coord1[israin]
204
+ if np.any(sddata.coord2):
205
+ self.coord2 = sddata.coord2[israin]
206
+
207
+ def __getitem__(self, key):
208
+ if key == "totnsupers_rain":
209
+ return self.totnsupers_rain
210
+ elif key == "sdId":
211
+ return self.sdId
212
+ elif key == "sdgbxindex":
213
+ return self.sdgbxindex
214
+ elif key == "xi":
215
+ return self.xi
216
+ elif key == "radius":
217
+ return self.radius
218
+ elif key == "msol":
219
+ return self.msol
220
+ elif key == "coord3":
221
+ return self.coord3
222
+ elif key == "coord1":
223
+ return self.coord1
224
+ elif key == "coord2":
225
+ return self.coord2
226
+ else:
227
+ err = "no known return provided for " + key + " key"
228
+ raise ValueError(err)
@@ -0,0 +1,146 @@
1
+ """
2
+ Copyright (c) 2024 MPI-M, Clara Bayley
3
+
4
+
5
+ ----- CLEO -----
6
+ File: thermodata.py
7
+ Project: sdmout_src
8
+ Created Date: Tuesday 24th October 2023
9
+ Author: Clara Bayley (CB)
10
+ Additional Contributors:
11
+ -----
12
+ License: BSD 3-Clause "New" or "Revised" License
13
+ https://opensource.org/licenses/BSD-3-Clause
14
+ -----
15
+ File Description:
16
+ python class to handle thermodynamics and wind fields data from SDM zarr store in cartesian domain
17
+ """
18
+
19
+ import numpy as np
20
+ import xarray as xr
21
+ from pathlib import Path
22
+
23
+ from . import thermoeqns
24
+
25
+
26
+ def thermotryopen_dataset(dataset):
27
+ if isinstance(dataset, str) or isinstance(dataset, Path):
28
+ print("thermodynamic fields dataset: ", dataset)
29
+ return xr.open_dataset(dataset, engine="zarr", consolidated=False)
30
+ else:
31
+ return dataset
32
+
33
+
34
+ def thermovar4d_fromzarr(ds, reshape, key):
35
+ """' returns 4D variable with dims
36
+ [time, y, x, z] from zarr dataset "ds" """
37
+
38
+ return np.reshape(ds[key].values, reshape)
39
+
40
+
41
+ class Thermodata:
42
+ def __init__(self, dataset, ntime, ndims, consts):
43
+ ds = thermotryopen_dataset(dataset)
44
+
45
+ self.consts = consts
46
+
47
+ reshape = [ntime] + list(ndims)
48
+ self.press = thermovar4d_fromzarr(ds, reshape, "press")
49
+ self.temp = thermovar4d_fromzarr(ds, reshape, "temp")
50
+ self.qvap = thermovar4d_fromzarr(ds, reshape, "qvap")
51
+ self.qcond = thermovar4d_fromzarr(ds, reshape, "qcond")
52
+ self.theta = self.potential_temp()
53
+
54
+ self.press_units = ds["press"].units # assumed probably hecto-pascals
55
+ self.temp_units = ds["temp"].units # assumed probably kelvin
56
+ self.qvap_units = ds["qvap"].units # assumed probably g/Kg
57
+ self.qcond_units = ds["qcond"].units # assumed probably g/Kg
58
+ self.theta_units = ds["temp"].units # assumed probably kelvin
59
+
60
+ def potential_temp(self):
61
+ """potential temperature, theta"""
62
+
63
+ press = self.press * 100 # convert from hPa to Pa
64
+ qvap = self.qvap / 1000 # convert g/Kg to Kg/Kg
65
+
66
+ return thermoeqns.dry_pot_temp(self.temp, press, qvap, self.consts)
67
+
68
+ def saturationpressure(self):
69
+ """saturation pressure in hectoPascals"""
70
+
71
+ psat = thermoeqns.saturation_pressure(self.temp) # [Pa]
72
+
73
+ return psat / 100 # [hPa]
74
+
75
+ def vapourpressure(self):
76
+ """returns vapour pressure in hectoPascals"""
77
+
78
+ p_pascals = self.press * 100 # convert from hPa to Pa
79
+ qvap = self.qvap / 1000 # convert g/Kg to Kg/Kg
80
+ Mr_ratio = self.consts["Mr_ratio"]
81
+ pvap = thermoeqns.vapour_pressure(p_pascals, qvap, Mr_ratio) # [Pa]
82
+
83
+ return pvap / 100 # [hPa]
84
+
85
+ def relative_humidity(self):
86
+ """returns relative humidty and supersaturation"""
87
+
88
+ p_pascals = self.press * 100 # convert from hPa to Pa
89
+ qvap = self.qvap / 1000 # convert g/Kg to Kg/Kg
90
+ Mr_ratio = self.consts["Mr_ratio"]
91
+
92
+ return thermoeqns.relative_humidity(p_pascals, self.temp, qvap, Mr_ratio)
93
+
94
+ def supersaturation(self):
95
+ """returns relative humidty and supersaturation"""
96
+
97
+ p_pascals = self.press * 100 # convert from hPa to Pa
98
+ qvap = self.qvap / 1000 # convert g/Kg to Kg/Kg
99
+ Mr_ratio = self.consts["Mr_ratio"]
100
+ return thermoeqns.supersaturation(p_pascals, self.temp, qvap, Mr_ratio)
101
+
102
+ def __getitem__(self, key):
103
+ if key == "press":
104
+ return self.press
105
+ elif key == "temp":
106
+ return self.temp
107
+ elif key == "qvap":
108
+ return self.qvap
109
+ elif key == "qcond":
110
+ return self.qcond
111
+ elif key == "theta":
112
+ return self.theta
113
+ elif key == "relh":
114
+ return self.relative_humidity()
115
+ elif key == "supersat":
116
+ return self.supersaturation()
117
+ else:
118
+ err = "no known return provided for " + key + " key"
119
+ raise ValueError(err)
120
+
121
+
122
+ class Winddata:
123
+ def __init__(self, dataset, ntime, ndims, consts):
124
+ ds = thermotryopen_dataset(dataset)
125
+
126
+ self.consts = consts
127
+
128
+ reshape = [ntime] + list(ndims)
129
+ self.wvel = thermovar4d_fromzarr(ds, reshape, "wvel")
130
+ self.uvel = thermovar4d_fromzarr(ds, reshape, "uvel")
131
+ self.vvel = thermovar4d_fromzarr(ds, reshape, "vvel")
132
+
133
+ self.wvel_units = ds["wvel"].units # probably hecto pascals
134
+ self.uvel_units = ds["uvel"].units # probably hecto pascals
135
+ self.vvel_units = ds["vvel"].units # probably hecto pascals
136
+
137
+ def __getitem__(self, key):
138
+ if key == "wvel":
139
+ return self.wvel
140
+ elif key == "uvel":
141
+ return self.uvel
142
+ elif key == "vvel":
143
+ return self.vvel
144
+ else:
145
+ err = "no known return provided for " + key + " key"
146
+ raise ValueError(err)
@@ -0,0 +1,129 @@
1
+ """
2
+ ----- CLEO -----
3
+ File: thermoeqns.py
4
+ Project: sdmout_src
5
+ Created Date: Tuesday 24th October 2023
6
+ Author: Clara Bayley (CB)
7
+ Additional Contributors:
8
+ -----
9
+ License: BSD 3-Clause "New" or "Revised" License
10
+ https://opensource.org/licenses/BSD-3-Clause
11
+ -----
12
+ Copyright (c) 2023 MPI-M, Clara Bayley
13
+ -----
14
+ File Description:
15
+ equations in python for calculating thermodynamic
16
+ variables e.g. potential temperature
17
+ """
18
+
19
+ import numpy as np
20
+
21
+
22
+ def vapour_pressure(press, qv, Mr_ratio):
23
+ pv = qv * press / (Mr_ratio + qv)
24
+
25
+ return pv
26
+
27
+
28
+ def relative_humidity(p, temp, qv, Mr_ratio):
29
+ pv = vapour_pressure(p, qv, Mr_ratio)
30
+ psat = saturation_pressure(temp)
31
+ relh = pv / psat
32
+
33
+ return relh
34
+
35
+
36
+ def supersaturation(p, temp, qv, Mr_ratio):
37
+ pv = vapour_pressure(p, qv, Mr_ratio)
38
+ psat = saturation_pressure(temp)
39
+
40
+ qsat = Mr_ratio * psat / (p - pv)
41
+ supersat = qv / qsat - 1
42
+
43
+ return supersat
44
+
45
+
46
+ def saturation_pressure(TEMP):
47
+ """Calculate the equilibrium vapor pressure
48
+ of water over liquid water ie. the
49
+ saturation pressure (psat) given TEMP /K.
50
+ Equation taken from Bjorn Steven's
51
+ "make_tetens" python function from his module
52
+ "moist_thermodynamics.saturation_vapour_pressures"
53
+ available on gitlab. Original paper
54
+ "Murray, F. W. On the Computation of Saturation
55
+ Vapor Pressure. Journal of Applied Meteorology
56
+ and Climatology 6, 203–204 (1967)." """
57
+
58
+ A = 17.4146 # constants from Bjorn Gitlab originally from paper
59
+ B = 33.639 # ditto
60
+ TREF = 273.16 # Triple point temperature [K] of water
61
+ PREF = 611.655 # Triple point pressure [Pa] of water
62
+
63
+ if np.any(TEMP <= 0):
64
+ err = "Temperature must be larger than 0K."
65
+ raise ValueError(err)
66
+
67
+ expothis = A * (TEMP - TREF) / (TEMP - B)
68
+
69
+ return PREF * np.exp(expothis) # dimensionless psat /Pa
70
+
71
+
72
+ def saturation_pressure_murphy_koop(TEMP):
73
+ """Calculate the equilibrium vapor pressure
74
+ of water over liquid water ie. the
75
+ saturation pressure (psat [Pa]). Equation taken from
76
+ typhon.physics.thermodynamics.e_eq_water_mk."""
77
+
78
+ if np.any(TEMP <= 0):
79
+ err = "Temperature must be larger than 0K."
80
+ raise ValueError(err)
81
+
82
+ lnpsat = (
83
+ 54.842763 # ln(psat) [Pa]
84
+ - 6763.22 / TEMP
85
+ - 4.21 * np.log(TEMP)
86
+ + 0.000367 * TEMP
87
+ + np.tanh(0.0415 * (TEMP - 218.8))
88
+ * (53.878 - 1331.22 / TEMP - 9.44523 * np.log(TEMP) + 0.014025 * TEMP)
89
+ )
90
+
91
+ return np.exp(lnpsat) # psat [Pa]
92
+
93
+
94
+ def dry_pot_temp(Temp, P, qv, consts):
95
+ """calculate potential Temperature [K]
96
+ assuming moist (unsaturated) air with
97
+ vapour content qv"""
98
+
99
+ Cpdry = consts["CP_DRY"]
100
+ Cpv = consts["CP_V"]
101
+ Rgasdry = consts["RGAS_DRY"]
102
+ Rgasv = consts["RGAS_V"]
103
+
104
+ Cp = Cpdry * (1 + qv * Cpv / Cpdry) / (1 + qv)
105
+ Rgas = Rgasdry * (1 + qv * Rgasv / Rgasdry) / (1 + qv)
106
+
107
+ Theta = Temp * (P[0] / P) ** (Rgas / Cp)
108
+
109
+ return Theta
110
+
111
+
112
+ def dry_adiabat(p, temp, consts):
113
+ gamma = consts["RGAS_DRY"] / consts["CP_DRY"]
114
+ dry_adia = temp[0] * (p / p[0]) ** gamma # dry adiabatic temp
115
+
116
+ dry_adia_theta = dry_adia * (p[0] / p) ** gamma # dry adiabatic theta (=const)
117
+
118
+ return dry_adia, dry_adia_theta
119
+
120
+
121
+ def specific_moist_static_energy(Z, Temp, qv, consts):
122
+ """calculate the specific mass moist static
123
+ energy, mse, J/Kg. (ie. mse per unit mass)."""
124
+
125
+ GRAVG = consts["G"] # [m/s^2]
126
+ Latent_v = consts["LATENT_V"] # [J/Kg]
127
+ Cp_dry = consts["CP_DRY"] # [J/Kg/K]
128
+
129
+ return GRAVG * Z + Latent_v * qv + Cp_dry * Temp
@@ -0,0 +1,54 @@
1
+ """
2
+ Copyright (c) 2024 MPI-M, Clara Bayley
3
+
4
+
5
+ ----- CLEO -----
6
+ File: timedata.py
7
+ Project: sdmout_src
8
+ Created Date: Tuesday 7th May 2024
9
+ Author: Clara Bayley (CB)
10
+ Additional Contributors:
11
+ -----
12
+ License: BSD 3-Clause "New" or "Revised" License
13
+ https://opensource.org/licenses/BSD-3-Clause
14
+ -----
15
+ File Description:
16
+ python class to get time data from SDM zarr store and return in various formats
17
+ """
18
+
19
+ import xarray as xr
20
+ from pathlib import Path
21
+
22
+
23
+ class Time:
24
+ def __init__(self, dataset):
25
+ timeds = self.tryopen_time(dataset) # time from dataset
26
+
27
+ if timeds.units != "s":
28
+ raise ValueError("units of time in dataset must be seconds")
29
+
30
+ self.secs = timeds.values
31
+ self.mins = self.secs / 60
32
+ self.hrs = self.secs / 60 / 60
33
+
34
+ def tryopen_time(self, dataset):
35
+ """returns time variable (with metadata) from xarray dataset"""
36
+
37
+ if isinstance(dataset, str) or isinstance(dataset, Path):
38
+ print("time from dataset: ", dataset)
39
+ timeds = xr.open_dataset(dataset, engine="zarr", consolidated=False)["time"]
40
+ else:
41
+ timeds = dataset["time"]
42
+
43
+ return timeds
44
+
45
+ def __getitem__(self, key):
46
+ if key == "secs":
47
+ return self.secs
48
+ elif key == "mins":
49
+ return self.mins
50
+ elif key == "hrs":
51
+ return self.hrs
52
+ else:
53
+ err = "no known return provided for " + key + " key"
54
+ raise ValueError(err)
@@ -0,0 +1,16 @@
1
+ """
2
+ Copyright (c) 2025 MPI-M, Clara Bayley
3
+
4
+
5
+ ----- CLEO -----
6
+ File: __init__.py
7
+ Project: thermobinary_src
8
+ Created Date: Tuesday 26th August 2025
9
+ Author: Clara Bayley (CB)
10
+ Additional Contributors:
11
+ -----
12
+ License: BSD 3-Clause "New" or "Revised" License
13
+ https://opensource.org/licenses/BSD-3-Clause
14
+ -----
15
+ File Description:
16
+ """