import django

django.setup()

from panelhistory.models import PanelHistory
from django.db.transaction import atomic
from math import log10

ph = PanelHistory.objects.all()

with atomic():
    for hobj in ph:
        # correct ppm value itself
        hobj.ppm /= 1000
        if hobj.y_ite is not None:
            t = (10 ** hobj.y_ite) / 1000  # transform to ppm
            hobj.y_ite = log10(t)  # undo the 10**
        hobj.save()
