Skip to content

Version 0.4.0#25

Merged
jirhiker merged 18 commits into
pre-productionfrom
dev/jab
Feb 12, 2025
Merged

Version 0.4.0#25
jirhiker merged 18 commits into
pre-productionfrom
dev/jab

Conversation

@jacob-a-brown

Copy link
Copy Markdown
Contributor

With these changes the following occurs:

  • source parameter name and units included in time series tables
  • conversion rates included in time series tables
  • conversion rates are documented in UNIT_CONVERSIONS.md
  • pH units are set to None

Comment thread backend/config.py
if not os.path.exists(self.output_path):
os.mkdir(self.output_path)

def _update_output_units(self):

@jirhiker jirhiker Feb 11, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parameter = self.parameter.lower()
if parameter == 'ph': 
   ... 
if parameter == 'waterlevels'
   ...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm only keeping if self.parameter.lower() == "ph" here because all analytes use mg/L and water levels uses ft (both of which are already defined).

Many of the functionalities and processes for obtaining water levels and analytes are the same. To consolidate code and make it more streamlined I'll combine them (in refactoring). When that happens I'll have more if statements here, but for the time being I'll just check for ph and update config.analyte_output_units accordingly.

Comment thread backend/transformer.py Outdated
https://aqua-chem.com/water-chemistry-caco3-equivalents/
https://industrialh2osolutions.com/conversions-and-guides-water-chemistry-caco3-equivalents/
"""
if (

@jirhiker jirhiker Feb 11, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should consolidate your conditionals. You should also use if/else and elif statements. they way its written all the top level conditionals are tested even tho if one of the conditionals is true its logically impossible for any of the other conditionals to be true (i.e. why execute another if statement when you know already know the conversion_factor is set)

if (input_units.lower() in ('mg/l caco3', 'mg/l caco3**') and output_units == mgl:
    if die_parameter_name == 'bicarbonate':
         conversion_factor = 1.22
   elif die_parameter_name =='calcium':
        conversion_factor = 0.4
...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conditionals have been consolidated based firstly based off of output_units, then input_units, die_parameter_name, and source_parameter_name where applicable (with the exception of ph since it has no units. For the sake of clarity I'm checking die_parameter_name but can check if output_units == "").

Unit conversions are now blocked by output_units where possible (unless
the analyte is pH, in which case the die_parameter_name is used). All
conversions for output units are now assessed in if/elif statements for
clarity and ease. Furthermore, no else statements are used so that if
the conversion is not accounted for it will be reported to the user
@jirhiker jirhiker merged commit ff92c19 into pre-production Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants