source: nappy/trunk/nappy/cdms_utils/axis_utils.py @ 3331

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/nappy/trunk/nappy/cdms_utils/axis_utils.py@3349
Revision 3331, 1.1 KB checked in by astephen, 12 years ago (diff)
Line 
1#!/usr/bin/env python
2#   Copyright (C) 2004 CCLRC & NERC( Natural Environment Research Council ).
3#   This software may be distributed under the terms of the
4#   Q Public License, version 1.0 or later. http://ndg.nerc.ac.uk/public_docs/QPublic_license.txt
5
6"""
7axis_utils.py
8=============
9
10Holds utilities involving CDMS axis objects.
11
12"""
13
14
15print "MERGE axis_utils.py with other parts of cdms_utils in DDP libraries and Theo code"
16
17# Imports from python standard library
18
19# Import external packages
20import cdms
21
22def compareAxes(ax1, ax2):
23    """
24    Takes 2 cmds axis objects returning 1 if they are essentially
25    the same and 0 if not.
26    """
27    for axtype in ("time", "level", "latitude", "longitude"):
28        if cdms.axisMatches(ax1, axtype) and not cdms.axisMatches(ax2, axtype):
29            return 0
30
31    # Check ids
32    if ax1.id != ax2.id: return 0
33    # Check lengths
34    if len(ax1) != len(ax2): return 0
35    # Check values
36    if ax1._data_ != ax2._data_: return 0
37    # Check units
38    if ax1.units != ax2.units: return 0
39    # OK, I think they are the same axis!
40    return 1
41
Note: See TracBrowser for help on using the repository browser.