Skip to content

Commit

Permalink
Add test for BUG # 1728: wrapping data creates long cells.
Browse files Browse the repository at this point in the history
  • Loading branch information
danlipsa committed Feb 16, 2016
1 parent 9a71d85 commit 1676bfc
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
5 changes: 5 additions & 0 deletions testing/vcs/CMakeLists.txt
Expand Up @@ -311,6 +311,11 @@ cdat_add_test(vcs_test_boxfill_decreasing_latitude
"${BASELINE_DIR}/test_vcs_boxfill_decreasing_latitude.png"
"${UVCDAT_GIT_TESTDATA_DIR}/data/decreasing_latitude.nc"
)
cdat_add_test(vcs_test_boxfill_robinson_wrap
"${PYTHON_EXECUTABLE}"
${cdat_SOURCE_DIR}/testing/vcs/vcs_test_boxfill_robinson_wrap.py
"${BASELINE_DIR}/vcs_test_boxfill_robinson_wrap.png"
)
cdat_add_test(vcs_test_boxfill_10x10_numpy
"${PYTHON_EXECUTABLE}"
${cdat_SOURCE_DIR}/testing/vcs/test_boxfill_10x10_numpy.py
Expand Down
70 changes: 70 additions & 0 deletions testing/vcs/vcs_test_boxfill_robinson_wrap.py
@@ -0,0 +1,70 @@
#!/usr/bin/env python
import cdms2, cdutil, genutil
import vcs,os
import sys

# This tests if extening the longitude to more than 360 decrees is handled correctly by
# proj4. See https://github.com/UV-CDAT/uvcdat/issues/1728 for more information.
pth = os.path.join(os.path.dirname(__file__), "..")
sys.path.append(pth)
import checkimage


cdmsfile = cdms2.open(os.path.join(vcs.sample_data, "clt.nc"))
clt2 = cdmsfile('clt')
clt3 = clt2(latitude=(-90.0, 90.0),squeeze=1,longitude=(-180, 200.0),time=('1979-01', '1988-12'),)
axesOperations = eval("{'latitude': 'def', 'longitude': 'def', 'time': 'def'}")
for axis in list(axesOperations):
if axesOperations[axis] == 'sum':
clt3 = cdutil.averager(clt3, axis='(%s)'%axis, weight='equal', action='sum')
elif axesOperations[axis] == 'avg':
clt3 = cdutil.averager(clt3, axis='(%s)'%axis, weight='equal')
elif axesOperations[axis] == 'wgt':
clt3 = cdutil.averager(clt3, axis='(%s)'%axis)
elif axesOperations[axis] == 'gtm':
clt3 = genutil.statistics.geometricmean(clt3, axis='(%s)'%axis)
elif axesOperations[axis] == 'std':
clt3 = genutil.statistics.std(clt3, axis='(%s)'%axis)
canvas = vcs.init()
gmBoxfill = vcs.getboxfill('a_robinson_boxfill')
args = []
args.append(clt3)
gmBoxfill.boxfill_type = 'linear'
gmBoxfill.color_1 = 16
gmBoxfill.color_2 = 239
gmBoxfill.datawc_calendar = 135441
gmBoxfill.datawc_timeunits = 'days since 2000'
gmBoxfill.datawc_x1 = 1e+20
gmBoxfill.datawc_x2 = 1e+20
gmBoxfill.datawc_y1 = 1e+20
gmBoxfill.datawc_y2 = 1e+20
gmBoxfill.levels = [1e+20, 1e+20]
gmBoxfill.ext_1 = False
gmBoxfill.ext_2 = False
gmBoxfill.fillareacolors = None
gmBoxfill.fillareaindices = [1]
gmBoxfill.fillareastyle = 'solid'
gmBoxfill.legend = None
gmBoxfill.level_1 = 1e+20
gmBoxfill.level_2 = 1e+20
gmBoxfill.missing = 1
gmBoxfill.projection = 'robinson'
gmBoxfill.xaxisconvert = 'linear'
gmBoxfill.xmtics1 = ''
gmBoxfill.xmtics2 = ''
gmBoxfill.xticlabels1 = '*'
gmBoxfill.xticlabels2 = '*'
gmBoxfill.yaxisconvert = 'linear'
gmBoxfill.ymtics1 = ''
gmBoxfill.ymtics2 = ''
gmBoxfill.yticlabels1 = '*'
gmBoxfill.yticlabels2 = '*'
kwargs = {}
kwargs[ 'cdmsfile' ] = cdmsfile.id
kwargs['bg'] = 1
args.append( gmBoxfill )
canvas.plot( *args, **kwargs)
fnm = "test_robinson_wrap.png"
canvas.png(fnm)
ret = checkimage.check_result_image(fnm, sys.argv[1], checkimage.defaultThreshold)
sys.exit(ret)

0 comments on commit 1676bfc

Please sign in to comment.