Skip to content

Commit

Permalink
eps renamed to xi
Browse files Browse the repository at this point in the history
  • Loading branch information
yoctoyotta1024 committed Dec 22, 2023
1 parent f55c8cb commit 6269f42
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 34 deletions.
26 changes: 13 additions & 13 deletions pySD/initsuperdropsbinary_src/create_initsuperdrops.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Author: Clara Bayley (CB)
Additional Contributors:
-----
Last Modified: Friday 3rd November 2023
Last Modified: Friday 22nd December 2023
Modified By: CB
-----
License: BSD 3-Clause "New" or "Revised" License
Expand All @@ -27,7 +27,7 @@ class ManyInitAttrs:
'''store for lists of each attribute for all superdroplets '''
def __init__(self):
self.sdgbxindex = []
self.eps = []
self.xi = []
self.radius = []
self.msol = []
self.coord3 = []
Expand All @@ -37,7 +37,7 @@ def __init__(self):
def set_attrlists(self, a, b, c,
d, e, f, g):
self.sdgbxindex = a
self.eps = b
self.xi = b
self.radius = c
self.msol = d
self.coord3 = e
Expand All @@ -47,7 +47,7 @@ def set_attrlists(self, a, b, c,
def extend_attrlists_fromlists(self, a, b, c,
d, e, f, g):
self.sdgbxindex.extend(a)
self.eps.extend(b)
self.xi.extend(b)
self.radius.extend(c)
self.msol.extend(d)
self.coord3.extend(e)
Expand All @@ -58,7 +58,7 @@ def extend_attrlists(self, mia):
''' use an instance of ManyInitAttrs (mia) to
extend lists in this instance '''
self.sdgbxindex.extend(mia.sdgbxindex)
self.eps.extend(mia.eps)
self.xi.extend(mia.xi)
self.radius.extend(mia.radius)
self.msol.extend(mia.msol)
self.coord3.extend(mia.coord3)
Expand Down Expand Up @@ -117,7 +117,7 @@ def dimless_superdropsattrs(nsupers, initattrsgen, inputs, gbxindex,

# generate attributes
sdgbxindex = [gbxindex]*nsupers
eps, radius, msol = initattrsgen.generate_attributes(nsupers,
xi, radius, msol = initattrsgen.generate_attributes(nsupers,
inputs["RHO_SOL"],
NUMCONC,
gridboxbounds)
Expand All @@ -135,7 +135,7 @@ def dimless_superdropsattrs(nsupers, initattrsgen, inputs, gbxindex,
coord2 = coord2 / inputs["COORD0"]

attrs4gbx = ManyInitAttrs()
attrs4gbx.set_attrlists(sdgbxindex, eps, radius, msol,
attrs4gbx.set_attrlists(sdgbxindex, xi, radius, msol,
coord3, coord1, coord2)

return attrs4gbx
Expand Down Expand Up @@ -169,19 +169,19 @@ def set_arraydtype(arr, dtype):
return arr

def ctype_compatible_attrs(attrs):
''' make list from arrays of SD attributes that are compatible
with c type expected by SDM e.g. unsigned long ints for eps,
doubles for radius and msol'''
''' make list from arrays of SD attributes that are
compatible with c type expected by SDM e.g. unsigned
long ints for xi, doubles for radius and msol'''

datatypes = [np.uintc, np.uint, np.double, np.double]
datatypes += [np.double]*3 # coords datatype

attrs.sdgbxindex = list(set_arraydtype(attrs.sdgbxindex, datatypes[0]))
attrs.eps = list(set_arraydtype(attrs.eps, datatypes[1]))
attrs.xi = list(set_arraydtype(attrs.xi, datatypes[1]))
attrs.radius = list(set_arraydtype(attrs.radius, datatypes[2]))
attrs.msol = list(set_arraydtype(attrs.msol, datatypes[3]))

datalist = attrs.sdgbxindex + attrs.eps + attrs.radius + attrs.msol
datalist = attrs.sdgbxindex + attrs.xi + attrs.radius + attrs.msol

if any(attrs.coord3):
# make coord3 compatible if there is data for it (>= 1-D model)
Expand Down Expand Up @@ -260,7 +260,7 @@ def write_initsuperdrops_binary(initsupersfile, initattrsgen, configfile,
attrs = create_allsuperdropattrs(nsupersdict, initattrsgen,
gbxbounds, inputs, NUMCONC)

ndata = [len(dt) for dt in [attrs.sdgbxindex, attrs.eps,
ndata = [len(dt) for dt in [attrs.sdgbxindex, attrs.xi,
attrs.radius, attrs.msol, attrs.coord3,
attrs.coord1, attrs.coord2]]

Expand Down
10 changes: 5 additions & 5 deletions pySD/initsuperdropsbinary_src/initattributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,16 @@ def multiplicities(self, radii, NUMCONC, samplevol):
mulitiplicities are zero '''

prob = self.xiprobdist(radii) # normalised prob distrib
eps = np.rint(prob * NUMCONC * samplevol)
xi = np.rint(prob * NUMCONC * samplevol)

if any(eps == 0):
num = len(eps[eps==0])
errmsg = "ERROR, "+str(num)+" out of "+str(len(eps))+" SDs"+\
if any(xi == 0):
num = len(xi[xi==0])
errmsg = "ERROR, "+str(num)+" out of "+str(len(xi))+" SDs"+\
" created with multiplicity = 0. Consider increasing numconc"+\
" or changing range of radii sampled."
raise ValueError(errmsg)

return np.array(eps, dtype=np.uint)
return np.array(xi, dtype=np.uint)

def check_coordsgen_matches_modeldimension(self, nspacedims):

Expand Down
30 changes: 15 additions & 15 deletions pySD/initsuperdropsbinary_src/read_initsuperdrops.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Author: Clara Bayley (CB)
Additional Contributors:
-----
Last Modified: Friday 17th November 2023
Last Modified: Friday 22nd December 2023
Modified By: CB
-----
License: BSD 3-Clause "New" or "Revised" License
Expand Down Expand Up @@ -55,14 +55,14 @@ def read_dimless_superdrops_binary(filename, isprint=True):

attrs = ManyInitAttrs()
attrs.sdgbxindex = np.asarray(data[:ll[0]], dtype=datatypes[0])
attrs.eps = np.asarray(data[ll[0]:ll[1]], dtype=datatypes[1])
attrs.xi = np.asarray(data[ll[0]:ll[1]], dtype=datatypes[1])
attrs.radius = np.asarray(data[ll[1]:ll[2]], dtype=datatypes[2])
attrs.msol = np.asarray(data[ll[2]:ll[3]], dtype=datatypes[3])
attrs.coord3 = np.asarray(data[ll[3]:ll[4]], dtype=datatypes[4])
attrs.coord1 = np.asarray(data[ll[4]:ll[5]], dtype=datatypes[5])
attrs.coord2 = np.asarray(data[ll[5]:], dtype=datatypes[6])

print("attribute shapes: ", attrs.sdgbxindex.shape, attrs.eps.shape,
print("attribute shapes: ", attrs.sdgbxindex.shape, attrs.xi.shape,
attrs.radius.shape, attrs.msol.shape, attrs.coord3.shape,
attrs.coord1.shape, attrs.coord2.shape)

Expand All @@ -77,11 +77,11 @@ def print_initSDs_infos(initSDsfile, configfile, constsfile, gridfile):
constsfile,
initSDsfile)

eps = attrs.eps.flatten()
xi = attrs.xi.flatten()
vol = np.sum(gbxvols)
numconc = np.sum(eps)/vol / 1e6 #[/cm^3]
massconc = np.sum(attrs.msol.flatten() * eps) / vol * 1000 #[g m^-3]
dropvol = 4/3 * np.pi * np.sum((attrs.radius.flatten()**3) * eps)
numconc = np.sum(xi)/vol / 1e6 #[/cm^3]
massconc = np.sum(attrs.msol.flatten() * xi) / vol * 1000 #[g m^-3]
dropvol = 4/3 * np.pi * np.sum((attrs.radius.flatten()**3) * xi)
m_w_conc = dropvol * 1000 / vol * 1000 # mass as if drops had density of water=1000Kg/m^3 [g m^3]

inforstr = "\n------ DOMAIN SUPERDROPLETS INFO ------\n"+\
Expand All @@ -106,10 +106,10 @@ def plot_initdistribs(attrs, gbxvols, gbxidxs):
vol = gbxvols[idx]
sl = np.s_[attrs.sdgbxindex==idx]
l0 = plot_radiusdistrib(axs[0], hedgs,
attrs.radius[sl], attrs.eps[sl])
l1 = plot_numconcdistrib(axs[1], hedgs, attrs.eps[sl],
attrs.radius[sl], attrs.xi[sl])
l1 = plot_numconcdistrib(axs[1], hedgs, attrs.xi[sl],
attrs.radius[sl], vol)
l2 = plot_masssolutedistrib(axs[2], hedgs, attrs.eps[sl],
l2 = plot_masssolutedistrib(axs[2], hedgs, attrs.xi[sl],
attrs.radius[sl], attrs.msol[sl],
vol)
ls = plot_coorddistribs(axs, sl, hedgs, attrs)
Expand Down Expand Up @@ -191,11 +191,11 @@ def log10r_frequency_distribution(radius, hedgs, wghts):
return hist, hedgs, hwdths, hcens


def plot_radiusdistrib(ax, hedgs, radius, eps):
def plot_radiusdistrib(ax, hedgs, radius, xi):
''' get and plotthe superdroplet radius in each log10(r)
bin and as a scatter on a twinx axis with their multiplicities'''

l1 = ax.scatter(radius*1e6, eps, zorder=1,
l1 = ax.scatter(radius*1e6, xi, zorder=1,
label="multiplicities")

ax2 = ax.twinx()
Expand All @@ -217,10 +217,10 @@ def plot_radiusdistrib(ax, hedgs, radius, eps):
return [l1, l2]


def plot_numconcdistrib(ax, hedgs, eps, radius, vol):
def plot_numconcdistrib(ax, hedgs, xi, radius, vol):
''' get and plot frequency of real droplets in each log10(r) bin '''

wghts = eps / vol / 1e6 # [cm^-3]
wghts = xi / vol / 1e6 # [cm^-3]
hist, hedgs, hwdths, hcens = log10r_frequency_distribution(
radius, hedgs, wghts)

Expand All @@ -235,7 +235,7 @@ def plot_numconcdistrib(ax, hedgs, eps, radius, vol):
return line


def plot_masssolutedistrib(ax, hedgs, eps, radius, msol, vol):
def plot_masssolutedistrib(ax, hedgs, xi, radius, msol, vol):
''' get and plot frequency of real droplets in each log10(r) bin '''

wghts = msol*eps/vol * 1000 / 1e6 # [g cm^-3]
Expand Down
2 changes: 1 addition & 1 deletion scripts/create_initsuperdropsbinary_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
Path(binariespath).mkdir(exist_ok=True)

### write initial superdrops binary
initattrsgen = iattrs.InitManyAttrsGen(radiigen, radiiprobdist,
initattrsgen = iattrs.InitManyAttrsGen(radiigen, dryradiigen, xiprobdist,
coord3gen, coord1gen, coord2gen)
csupers.write_initsuperdrops_binary(initsupersfile, initattrsgen,
configfile, constsfile,
Expand Down

0 comments on commit 6269f42

Please sign in to comment.