Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Axis unit labels #97

Merged
merged 3 commits into from
Oct 3, 2012
Merged

Axis unit labels #97

merged 3 commits into from
Oct 3, 2012

Conversation

esc24
Copy link
Member

@esc24 esc24 commented Sep 18, 2012

Whilst tidying up the derived phenomena example I noticed what appeared to be an unnecessary assignment to the derived cube's units. It was already in kelvin (as calculated by the product of two cubes), but there was an explicit assignment of units i.e.

air_temperature = exner_pressure * air_potential_temperature
# set phenomenon definition and unit
air_temperature.standard_name = 'air_temperature'
air_temperature.units = 'K'

Removing this leaves the unit as iris.unit.Unit('kelvin') since:

>>> iris.unit.Unit('K') * iris.unit.Unit('1')
Unit('kelvin')

so the assignment appears to be there to change the label not the physical unit. I believe this should not be used in an example:

  1. it implies Iris does not propagate the unit
  2. it shows assignment to units without caution regarding the existing unit and the values of the data

This PR modifies quickplot axis labelling to remove '1' e.g. when plotting model level number one now gets 'Model level number' rather than 'Model level number / 1', and makes use of iris.unit.Unit.symbol when shorter than the full unit string e.g. to avoid 'kelvin' replacing 'K'. One downside is the abbreviation of units such as 'days' to 'd'.

@pelson
Copy link
Member

pelson commented Oct 3, 2012

I think this is fine. IMHO pending the blocker #119.

@rhattersley
Copy link
Member

Very nice. :-)

Since you need to rebase anyway ... would you consider putting the cherry on top of the icing on top of the cake and have some code to handle "d" => "days", "h" => "hours"?

@esc24
Copy link
Member Author

esc24 commented Oct 3, 2012

Looking into it now.

esc24 added 3 commits October 3, 2012 16:51
…emoved undesirable assignment to cube.units.

Modified axis labelling to remove '1' and use symbol where possible to avoid 'kelvin' replacing 'K' in some cases.
…00-01-01 00:00:00 -6:00' -> 'h @ 18000101T060000.0000000 UTC'.
@esc24
Copy link
Member Author

esc24 commented Oct 3, 2012

All done. Squash or not?

@rhattersley
Copy link
Member

Extra-super loveliness. Thanks @esc24 :-)

As for the squash - I think it's fine as it is.

rhattersley added a commit that referenced this pull request Oct 3, 2012
@rhattersley rhattersley merged commit eed7687 into SciTools:master Oct 3, 2012
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.

3 participants