# Sum of temperature values with Unitful.jl

**URL:** https://discourse.julialang.org/t/sum-of-temperature-values-with-unitful-jl/104714
**Category:** General Usage
**Tags:** question, unitful
**Created:** [October 7, 2023, 8:46pm UTC](https://discourse.julialang.org/t/sum-of-temperature-values-with-unitful-jl/104714 "2023-10-07T20:46:20Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![fnoessler](https://avatars.discourse-cdn.com/v4/letter/f/eb9ed0/32.png) [@fnoessler](https://discourse.julialang.org/u/fnoessler)
#### Post date: [October 7, 2023, 8:46pm UTC](https://discourse.julialang.org/t/sum-of-temperature-values-with-unitful-jl/104714/1 "2023-10-07T20:46:20Z")

</div>

Hello,

is there a way to calculate the (cumulative) sum of temperature values in °C with Unitful.jl?

I know this does not have a direct physical meaning. Nonetheless, it would be nice to keep the °C unit attached to my calculated values. I want to use the yearly cumulative temperature values in an ecological system model to account for changes in growth rates of plants over the year. I think the concept is similar to growing degree days:

> **[Growing degree-day](https://en.m.wikipedia.org/wiki/Growing_degree-day)**
>
> Growing degree days (GDD), also called growing degree units (GDUs), are a heuristic tool in phenology. GDD are a measure of heat accumulation used by horticulturists, gardeners, and farmers to predict plant and animal development rates such as the date that a flower will bloom, an insect will emerge from dormancy, or a crop will reach maturity. GDD is credited to be first defined by Reaumur in 1735.
> In the absence of extreme conditions such as unseasonal drought or disease, plants grow in a cumu...

When I want to calculate the sum of °C values, I get an AffineError as expected, see:  
[https://docs.sciml.ai/Unitful/stable/temperature/](https://docs.sciml.ai/Unitful/stable/temperature/)

Is there a way to overrride this behaviour and just use the temperature unit °C similiar to a length or weight unit?

Best  
Felix

---

<div class="post-metadata">

### Author: ![Dan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dan/32/42581_2.png) [@Dan](https://discourse.julialang.org/u/Dan)
#### Post date: [October 7, 2023, 9:51pm UTC](https://discourse.julialang.org/t/sum-of-temperature-values-with-unitful-jl/104714/2 "2023-10-07T21:51:18Z")

</div>

You can use K (Kelvin) instead of C. They are the same “degrees” and K addition works.

---

<div class="post-metadata">

### Author: ![fnoessler](https://avatars.discourse-cdn.com/v4/letter/f/eb9ed0/32.png) [@fnoessler](https://discourse.julialang.org/u/fnoessler)
#### Post date: [October 8, 2023, 10:14am UTC](https://discourse.julialang.org/t/sum-of-temperature-values-with-unitful-jl/104714/3 "2023-10-08T10:14:11Z")

</div>

thanks, maybe this is the easiest solution!

---

<div class="post-metadata">

### Author: ![cstjean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cstjean/32/1444_2.png) [@cstjean](https://discourse.julialang.org/u/cstjean)
#### Post date: [October 8, 2023, 6:37pm UTC](https://discourse.julialang.org/t/sum-of-temperature-values-with-unitful-jl/104714/4 "2023-10-08T18:37:13Z")

</div>

We follow the rule that measured (“absolute”) temperature can be in °C (or K) while temperature differences have to be in K, and it works well enough. So indeed growing degree days should be in K.
