NCAS-CMS / NCAS-CMS/cf-python

Unexpected arithmetic when multiplying field

Open
#96 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
150
Forks
23
Avg merge
1d 11h
Merged PRs (30d)
2

Description

Hi folks - first attempt to report features this way!

Have encountered an unexpected behaviour when combining fields - should this happen?
Is it something to do with units? T is degC here, maybe we are expecting K?
(see attached file)
amv.nc.gz

>>> import cf
>>> cf.__version__
'3.5.1'
>>> data=cf.read('amv.nc')[0]
>>> data.array[0]
array([[20.51099598]])
>>> (data-data).array[0]
array([[0.]])
>>> (data-1*data).array[0]
array([[273.15]])
>>> (1*data-1*data).array[0]
array([[0.]])
>>> 

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the arithmetic shown in the issue with the attached amv.nc.gz file and compare the units on data before and after each expression. Trace the field and unit handling used by subtraction and multiplication; confirm the intended Celsius behavior with the project maintainers. Done means the inconsistent results are explained and corrected, with coverage for the demonstrated expressions.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.