Skip to content

Commit

Permalink
fix: allow for decimal places on more fields in habitat
Browse files Browse the repository at this point in the history
Ref #313
  • Loading branch information
stdavis committed May 15, 2023
1 parent 8166d59 commit 3319a36
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
43 changes: 43 additions & 0 deletions scripts/migrations/migration_313.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env python
# * coding: utf8 *
'''
migration_313.py
A module that converts a few fields in the Habitat table to floats
Ref: https://github.com/agrc/electrofishing/issues/313
'''

from os.path import dirname, join

import arcpy

arcpy.env.workspace = r'...'
table = 'Habitat'

def change_field(field, alias):
print('adding temp field')
arcpy.management.AddField(table, field_name='TEMP', field_type='SHORT')
print('copying values to temp field')
arcpy.management.CalculateField(table, 'TEMP', f'!{field}!', 'PYTHON3')
print(f'deleting {field}')
arcpy.management.DeleteField(table, field)
print('adding new field')
arcpy.management.AddField(table, field_name=field, field_type='FLOAT', field_alias=alias)
print('copying values to new field')
arcpy.management.CalculateField(table, field, '!TEMP!', 'PYTHON3')
print('deleting temp field')
arcpy.management.DeleteField(table, 'TEMP')


fields = [
('CON', 'Conductivity'),
('OXYGEN', 'Dissolved Oxygen (mg/l)'),
('SOLIDS', 'Total Dissolved Solids (ppm)'),
('TURBIDITY', 'Turbidity'),
('ALKALINITY', 'Alkalinity (ppm CaCO3)'),
]

for field, alias in fields:
change_field(field, alias)

5 changes: 5 additions & 0 deletions src/components/habitat/Habitat.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -351,34 +351,39 @@ function Habitat() {
label="Conductivity (μs/cm)"
min="0"
max="15000"
step="0.1"
field={fnHabitat.CON}
value={habitat[fnHabitat.CON]}
/>
<HabitatNumericInput
label="Dissolved Oxygen (mg/l)"
min="0"
max="1500"
step="0.1"
field={fnHabitat.OXYGEN}
value={habitat[fnHabitat.OXYGEN]}
/>
<HabitatNumericInput
label="Total Dissolved Solids (ppm)"
min="0"
max="5000"
step="0.1"
field={fnHabitat.SOLIDS}
value={habitat[fnHabitat.SOLIDS]}
/>
<HabitatNumericInput
label="Turbidity (NTU)"
min="0"
max="3000"
step="0.1"
field={fnHabitat.TURBIDITY}
value={habitat[fnHabitat.TURBIDITY]}
/>
<HabitatNumericInput
label="Alkalinity (ppm CaCO3)"
min="0"
max="1000"
step="0.1"
field={fnHabitat.ALKALINITY}
value={habitat[fnHabitat.ALKALINITY]}
/>
Expand Down

0 comments on commit 3319a36

Please sign in to comment.