Skip to content

Commit

Permalink
convert_pressure converts to Pa now
Browse files Browse the repository at this point in the history
  • Loading branch information
eadlg2 committed Mar 26, 2024
1 parent 2521880 commit a9dca12
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
def convert_time(data, key):
"""
Convert the time from the input data to hours.
Convert the time from the input data to seconds.
Args:
data (dict): The input data.
Expand All @@ -26,29 +26,29 @@ def convert_time(data, key):

def convert_pressure(data, key):
"""
Convert the pressure from the input data to atmospheres.
Convert the pressure from the input data to Pascals.
Args:
data (dict): The input data.
key (str): The key for the pressure in the input data.
Returns:
float: The pressure in atmospheres.
float: The pressure in Pascals.
"""
pressure = None
for unit in ['Pa', 'atm', 'bar', 'kPa', 'hPa', 'mbar']:
if f'{key} [{unit}]' in data:
pressure_value = float(data[f'{key} [{unit}]'])
if unit == 'Pa':
pressure = pressure_value / 101325
elif unit == 'atm':
pressure = pressure_value
elif unit == 'atm':
pressure = pressure_value * 101325
elif unit == 'bar':
pressure = pressure_value * 0.986923
pressure = pressure_value * 100000
elif unit == 'kPa':
pressure = pressure_value / 101.325
pressure = pressure_value * 1000
elif unit == 'hPa' or unit == 'mbar':
pressure = pressure_value / 1013.25
pressure = pressure_value * 100
break
return pressure

Expand Down Expand Up @@ -78,14 +78,14 @@ def convert_temperature(data, key):

def convert_concentration(data, key):
"""
Convert the concentration from the input data to molecules per cubic centimeter.
Convert the concentration from the input data to molecules per cubic meter.
Args:
data (dict): The input data.
key (str): The key for the concentration in the input data.
Returns:
float: The concentration in molecules per cubic centimeter.
float: The concentration in molecules per cubic meter.
"""
concentration = None
for unit in ['mol m-3', 'mol cm-3', 'molec m-3', 'molec cm-3']:
Expand Down

0 comments on commit a9dca12

Please sign in to comment.