File: test_decadal.py

package info (click to toggle)
drslib 0.3.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,596 kB
  • sloc: python: 6,119; xml: 988; makefile: 128; sh: 121
file content (33 lines) | stat: -rw-r--r-- 709 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""
Test drslib is configured to accept decadal experiments with explicit years rather than "decadalXXXX"

"""

from drslib import cmip5
from drslib.translate import TranslationError

cmip5_trans = None

def setup():
    global cmip5_trans

    cmip5_trans = cmip5.make_translator('/cmip5', with_version=False)

years = range(1960, 2010)
        

def test():
    filepat = "zg_Amon_HadCM3_decadal%s_r4i2p1_196011-199012.nc"

    for year in years:
        filename = filepat % year

        print (year, )

        try:
            drs_obj = cmip5_trans.filename_to_drs(filename)
        except TranslationError:
            raise AssertionError

        assert drs_obj.experiment == 'decadal%s' % year