DiadFit 0.0.78__py3-none-any.whl → 0.0.80__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.
DiadFit/CO2_EOS.py CHANGED
@@ -17,7 +17,7 @@ DiadFit_dir=Path(__file__).parent
17
17
 
18
18
  ## Calculating density for a given homogenization temp - Only available with Span and Wanger, but have equations
19
19
 
20
- def calculate_CO2_density_homog_T(T_h_C, EOS='SW96', Sample_ID=None, homog_to=None):
20
+ def calculate_CO2_density_homog_T(T_h_C, EOS='SW96', Sample_ID=None, homog_to=None, set_to_critical=False):
21
21
  """ Calculates CO2 density for a specified homogenization temperature in Celcius
22
22
  using the Span and Wanger (1996) equation of state.
23
23
 
@@ -37,6 +37,9 @@ def calculate_CO2_density_homog_T(T_h_C, EOS='SW96', Sample_ID=None, homog_to=No
37
37
  homog_to: str ('L', 'V'), pd.series with strings. Optional
38
38
  If specified, returns an additional column 'Bulk Density' to choose between the liquid and gas.
39
39
 
40
+ set_to_critical: bool
41
+ Default False. If true, if you enter T_h_C which exceeds 30.9782 (the critical point of CO2) it replaces your entered Temp with that temp.
42
+
40
43
  Returns
41
44
  -------------
42
45
  pd.DataFrame:
@@ -54,8 +57,14 @@ def calculate_CO2_density_homog_T(T_h_C, EOS='SW96', Sample_ID=None, homog_to=No
54
57
  #print('Sorry, algorithm cant converge for Ts above 29.878')
55
58
  raise TypeError('Sorry, algorithm cant converge for Ts above 30.9782')
56
59
  if isinstance(T_h_C, pd.Series) or isinstance(T_h_C, np.ndarray):
57
- if any(T_h_C)>=30.9782:
58
- raise TypeError('Sorry, algorithm cant converge for Ts above 30.9782')
60
+ if any(T_h_C)>=30.9782 and set_to_critical is False:
61
+ raise TypeError('Sorry, algorithm cant converge for Ts above 30.9782. You can put set_to_critical=True and this T_ will be replacd with 30.9782')
62
+ elif any(T_h_C)>=30.9782 and set_to_critical is True:
63
+ if isinstance(T_h_C, pd.Series):
64
+ T_h_C = np.where(T_h_C > 30.9782, 30.9782, T_h_C)
65
+ elif isinstance(T_h_C, np.ndarray):
66
+ T_h_C[T_h_C > 30.9782] = 30.9782
67
+
59
68
 
60
69
  if EOS!='SW96':
61
70
  raise TypeError('At the moment, only Span and Wanger (SW96) EOS can be used to convert T_h_C into density')
@@ -144,6 +153,8 @@ def calculate_CO2_density_homog_T(T_h_C, EOS='SW96', Sample_ID=None, homog_to=No
144
153
  df['Sample_ID']=Sample_ID
145
154
 
146
155
 
156
+
157
+
147
158
  return df
148
159
 
149
160