8
8
from ngi_calculations .cpt_correlations .definitions .geo import GEO
9
9
from ngi_calculations .cpt_correlations .definitions .physics import PhysicParameters as PHY
10
10
from ngi_calculations .cpt_correlations .methods .cpt_process .options import CptProcessOptions
11
+ from ngi_calculations .cpt_correlations .models .cpt_cone import CptCone
11
12
from ngi_calculations .cpt_correlations .models .cpt_raw import RawCPT
12
13
from ngi_calculations .cpt_correlations .models .lab_data import LabData
13
14
from ngi_calculations .cpt_correlations .utils .interpolation import interpolate_missing_values
@@ -30,7 +31,6 @@ def __init__(self, raw_cpt: RawCPT, lab_data: LabData, options: CptProcessOption
30
31
self .raw_cpt = raw_cpt
31
32
self .lab_data = lab_data
32
33
self .options = options
33
- # self.calculate()
34
34
35
35
@measure ("ProcessCPT_Calculation" , log_time = False , log_child = False )
36
36
@track_execution
@@ -50,6 +50,7 @@ def calculate(self):
50
50
self ._differential_pressure ()
51
51
self ._normalized_differential_pressure ()
52
52
self ._elevation ()
53
+ self ._set_cone_info ()
53
54
self ._total_cone_resistance ()
54
55
self ._net_cone_resistance ()
55
56
self ._normalized_cone_resistance ()
@@ -63,7 +64,7 @@ def calculate(self):
63
64
self ._filter_data ()
64
65
65
66
def _set_initial_data (self ):
66
- self .data = self .raw_cpt .data [ self . raw_cpt . columns . all ] .copy ()
67
+ self .data = self .raw_cpt .data .copy ()
67
68
self .data [GEO .u2_raw .key ] = self .data [GEO .u2 .key ]
68
69
self .data [GEO .depth_raw .key ] = self .data [GEO .depth .key ]
69
70
self .depth_raw = self .data [GEO .depth .key ].values
@@ -164,7 +165,14 @@ def _integrate_lab_profile(self):
164
165
_df = _df .drop ([x for x in lab_cols if x in _df .columns ], axis = 1 )
165
166
166
167
# Merge the two Dataframes
167
- _df .astype (np .float64 , copy = False )
168
+ # Create a type dictionary for all columns
169
+ types_dict = {col : np .float64 for col in _df .columns if col != self .options .cpt_identifier and col != depth }
170
+ # Add depth type if needed
171
+ types_dict [depth ] = np .float64
172
+ # Apply types
173
+ _df = _df .astype (types_dict )
174
+
175
+ # _df.astype(np.float64, copy=False)
168
176
_df = pd .merge (_df , lab_df , on = depth , how = "outer" )
169
177
_df .sort_values (by = depth , inplace = True )
170
178
_df .set_index (depth , drop = False , inplace = True )
@@ -231,16 +239,36 @@ def _elevation(self):
231
239
# TODO: Where to make available the self.options.elevation?
232
240
self .data [GEO .elevation .key ] = self .options .elevation - self .data [GEO .depth .key ]
233
241
242
+ def _set_cone_info (self ):
243
+ if self .options .cpt_identifier in self .data .columns :
244
+ # Create a function to map each identifier to the corresponding cone area ratio value
245
+ def get_cone_area_ratio (identifier ):
246
+ cone = self .raw_cpt .cone .get (identifier )
247
+ # Return the numeric cone_area_ratio attribute, not the entire CptCone object
248
+ return cone .cone_area_ratio if cone else CptCone ().cone_area_ratio
249
+
250
+ # Apply the function to each row's identifier
251
+ self .data [GEO .cone_area_ratio .key ] = self .data [self .options .cpt_identifier ].apply (get_cone_area_ratio )
252
+ else :
253
+ # If the identifier column doesn't exist, use the default value
254
+ self .data [GEO .cone_area_ratio .key ] = CptCone ().cone_area_ratio
255
+
256
+ # Do the same for sleeve_area_ratio
257
+ if self .options .cpt_identifier in self .data .columns :
258
+
259
+ def get_sleeve_area_ratio (identifier ):
260
+ cone = self .raw_cpt .cone .get (identifier )
261
+ # Return the numeric sleeve_area_ratio attribute, not the entire CptCone object
262
+ return cone .sleeve_area_ratio if cone else CptCone ().sleeve_area_ratio
263
+
264
+ self .data [GEO .sleeve_area_ratio .key ] = self .data [self .options .cpt_identifier ].apply (get_sleeve_area_ratio )
265
+ else :
266
+ self .data [GEO .sleeve_area_ratio .key ] = CptCone ().sleeve_area_ratio
267
+
234
268
def _total_cone_resistance (self ):
235
- self .data [GEO .cone_area_ratio .key ] = self .raw_cpt .cone .cone_area_ratio
236
- self .data [GEO .sleeve_area_ratio .key ] = self .raw_cpt .cone .sleeve_area_ratio
237
269
self .data [GEO .qt .key ] = (
238
270
1000 * self .data [GEO .qc .key ] + self .data [GEO .u2 .key ] * (1 - self .data [GEO .cone_area_ratio .key ])
239
271
) / 1000
240
- # self.df[GEO.qt.key] = (
241
- # 1000 * self.df[GEO.qc.key]
242
- # + self.df[GEO.u2.key] * (1 - self.df[GEO.cone_area_ratio.key]) * self.df[GEO.sleeve_area_ratio.key]
243
- # ) / 1000
244
272
245
273
def _net_cone_resistance (self ):
246
274
self .data [GEO .qn .key ] = self .data [GEO .qt .key ] - self .data [GEO .sigVtTotal .key ] / 1000
0 commit comments