@@ -108,16 +108,35 @@ def is3D(self):
108
108
109
109
class LSC2 (Vgrid ):
110
110
111
- def __init__ (self , hsm , nv , h_c , theta_b , theta_f ):
111
+ def __init__ (self , hsm , nv , h_c , theta_b , theta_f , sigma ):
112
112
self .hsm = np .array (hsm )
113
113
self .nv = np .array (nv )
114
114
self .h_c = h_c
115
115
self .theta_b = theta_b
116
116
self .theta_f = theta_f
117
117
self .m_grid = None
118
118
self ._znd = None
119
- self ._snd = None
120
119
self ._nlayer = None
120
+ self .sigma = sigma # expose sigma for backward compatibility
121
+ self ._snd = self .sigma
122
+
123
+ @classmethod
124
+ def from_sigma (cls , sigma ):
125
+ '''
126
+ Initialize the LSC2 class using the sigma values for backward compatibility
127
+
128
+ sigma: np.ndarray of shape (n, m), where
129
+ n: number of horizontal nodes
130
+ m: number of vertical layers
131
+ '''
132
+ hsm = None # placeholder value
133
+ nv = sigma .shape [1 ] # number of vertical layers
134
+ h_c = None # placeholder value
135
+ theta_b = None # placeholder value
136
+ theta_f = None # placeholder value
137
+
138
+ # Return an instance of the class using the computed values
139
+ return cls (hsm = hsm , nv = nv , h_c = h_c , theta_b = theta_b , theta_f = theta_f , sigma = sigma )
121
140
122
141
def __str__ (self ):
123
142
f = [
@@ -298,7 +317,7 @@ def open(cls, path):
298
317
299
318
sline = np .array (lines [2 ].split ()).astype ('float' )
300
319
if sline .min () < 0 :
301
- #old version
320
+ # old version
302
321
kbp = np .array ([int (i .split ()[1 ])- 1 for i in lines [2 :]])
303
322
sigma = - np .ones ((len (kbp ), nvrt ))
304
323
@@ -307,15 +326,15 @@ def open(cls, path):
307
326
line .strip ().split ()[2 :]).astype ('float' )
308
327
309
328
else :
310
- #new version
329
+ # new version
311
330
sline = sline .astype ('int' )
312
331
kbp = sline - 1
313
332
sigma = np .array ([line .split ()[1 :] for line in lines [3 :]]).T .astype ('float' )
314
- #replace -9. with -1.
315
- fpm = sigma < - 1
333
+ # replace -9. with -1.
334
+ fpm = sigma < - 1
316
335
sigma [fpm ] = - 1
317
336
318
- return cls (sigma )
337
+ return cls . from_sigma (sigma )
319
338
320
339
@property
321
340
def nvrt (self ):
0 commit comments