CDAT / dv3d

1 stars 0 forks source link

vector3d and other dv3d fail on Py3 and Py2 (differently) #16

Open doutriaux1 opened 6 years ago

doutriaux1 commented 6 years ago

The following code

import vcs, cdms2
x = vcs.init()
f = cdms2.open(vcs.sample_data+"/clt.nc")
s = f("u")
s2 = f("v")
dv3 = x.get3d_vector()
x.plot(dv3, s, s2)

leads to this in Python2:

Error pickling object {'lev_ordering': 'up', 'latLonGrid': True, 'lev': array([ 200.,  850.], dtype=float32), 'title': 'u:u', 'datatype': 'Float', 'timeUnits': 'months since 1978-12', 'timeValue': 0.0, 'lon': array([-180.  , -176.25, -172.5 , -168.75, -165.  , -161.25, -157.5 ,
       -153.75, -150.  , -146.25, -142.5 , -138.75, -135.  , -131.25,
       -127.5 , -123.75, -120.  , -116.25, -112.5 , -108.75, -105.  ,
       -101.25,  -97.5 ,  -93.75,  -90.  ,  -86.25,  -82.5 ,  -78.75,
        -75.  ,  -71.25,  -67.5 ,  -63.75,  -60.  ,  -56.25,  -52.5 ,
        -48.75,  -45.  ,  -41.25,  -37.5 ,  -33.75,  -30.  ,  -26.25,
        -22.5 ,  -18.75,  -15.  ,  -11.25,   -7.5 ,   -3.75,    0.  ,
          3.75,    7.5 ,   11.25,   15.  ,   18.75,   22.5 ,   26.25,
         30.  ,   33.75,   37.5 ,   41.25,   45.  ,   48.75,   52.5 ,
         56.25,   60.  ,   63.75,   67.5 ,   71.25,   75.  ,   78.75,
         82.5 ,   86.25,   90.  ,   93.75,   97.5 ,  101.25,  105.  ,
        108.75,  112.5 ,  116.25,  120.  ,  123.75,  127.5 ,  131.25,
        135.  ,  138.75,  142.5 ,  146.25,  150.  ,  153.75,  157.5 ,
        161.25,  165.  ,  168.75,  172.5 ,  176.25,  180.  ], dtype=float32), 'bounds': [-180.0, 183.75, -88.288399, 90.523548077933413, 200.0, 850.0], 'valueRange': (-17.199909, 68.351509), 'scalars': 'u', 'plotType': 'xyz', 'base_time': ['1978-12-1 0:0:0.0', '1978-12-1 0:0:0.0'], 'time': ['1979-1-1 0:0:0.0'], 'lat': array([-88.28839874, -86.07109833, -83.84079742, -81.60739899,
       -79.37299347, -77.13799286, -74.9026947 , -72.66729736,
       -70.43169403, -68.19599915, -65.96029663, -63.72449875,
       -61.48859787, -59.25279999, -57.01689911, -54.78099823,
       -52.54509735, -50.30919647, -48.07329941, -45.83739853,
       -43.60139847, -41.36549759, -39.12949753, -36.89359665,
       -34.65759659, -32.42169952, -30.18569946, -27.9496994 ,
       -25.71379852, -23.47779846, -21.2417984 , -19.00579834,
       -16.76989937, -14.53389931, -12.29789925, -10.06189919,
        -7.8258996 ,  -5.58999968,  -3.35399985,  -1.11799991,
         1.11799991,   3.35399985,   5.58999968,   7.8258996 ,
        10.06189919,  12.29789925,  14.53389931,  16.76989937,
        19.00579834,  21.2417984 ,  23.47779846,  25.71379852,
        27.9496994 ,  30.18569946,  32.42169952,  34.65759659,
        36.89359665,  39.12949753,  41.36549759,  43.60139847,
        45.83739853,  48.07329941,  50.30919647,  52.54509735,
        54.78099823,  57.01689911,  59.25279999,  61.48859787,
        63.72449875,  65.96029663,  68.19599915,  70.43169403,
        72.66729736,  74.9026947 ,  77.13799286,  79.37299347,
        81.60739899,  83.84079742,  86.07109833,  88.28839874], dtype=float32), 'attributes': {'scale': (0.0, 1.0), 'date': '2/26/93', 'name': 'u', 'title': 'Monthly Mean Eastward Wind Speed', 'tileIndex': None, 'source': 'BMRC BMRC2.3 R31L19 VIlp AMIP 10 Year Simulation ( 1979-1988 )', 'range': (-17.199909, 68.351509), 'time': '14:10:00', 'units': 'm/s', 'type': 'R*4'}, 'datasetId': 'u'}: unicode argument expected, got 'str'
Error pickling object {'lev_ordering': 'up', 'latLonGrid': True, 'lev': array([ 200.,  850.], dtype=float32), 'title': 'u:v', 'datatype': 'Float', 'timeUnits': 'months since 1978-12', 'timeValue': 0.0, 'lon': array([-180.  , -176.25, -172.5 , -168.75, -165.  , -161.25, -157.5 ,
       -153.75, -150.  , -146.25, -142.5 , -138.75, -135.  , -131.25,
       -127.5 , -123.75, -120.  , -116.25, -112.5 , -108.75, -105.  ,
       -101.25,  -97.5 ,  -93.75,  -90.  ,  -86.25,  -82.5 ,  -78.75,
        -75.  ,  -71.25,  -67.5 ,  -63.75,  -60.  ,  -56.25,  -52.5 ,
        -48.75,  -45.  ,  -41.25,  -37.5 ,  -33.75,  -30.  ,  -26.25,
        -22.5 ,  -18.75,  -15.  ,  -11.25,   -7.5 ,   -3.75,    0.  ,
          3.75,    7.5 ,   11.25,   15.  ,   18.75,   22.5 ,   26.25,
         30.  ,   33.75,   37.5 ,   41.25,   45.  ,   48.75,   52.5 ,
         56.25,   60.  ,   63.75,   67.5 ,   71.25,   75.  ,   78.75,
         82.5 ,   86.25,   90.  ,   93.75,   97.5 ,  101.25,  105.  ,
        108.75,  112.5 ,  116.25,  120.  ,  123.75,  127.5 ,  131.25,
        135.  ,  138.75,  142.5 ,  146.25,  150.  ,  153.75,  157.5 ,
        161.25,  165.  ,  168.75,  172.5 ,  176.25,  180.  ], dtype=float32), 'bounds': [-180.0, 183.75, -88.288399, 90.523548077933413, 200.0, 850.0], 'valueRange': (-15.022506, 16.282299), 'plotType': 'xyz', 'base_time': ['1978-12-1 0:0:0.0', '1978-12-1 0:0:0.0'], 'time': ['1979-1-1 0:0:0.0'], 'lat': array([-88.28839874, -86.07109833, -83.84079742, -81.60739899,
       -79.37299347, -77.13799286, -74.9026947 , -72.66729736,
       -70.43169403, -68.19599915, -65.96029663, -63.72449875,
       -61.48859787, -59.25279999, -57.01689911, -54.78099823,
       -52.54509735, -50.30919647, -48.07329941, -45.83739853,
       -43.60139847, -41.36549759, -39.12949753, -36.89359665,
       -34.65759659, -32.42169952, -30.18569946, -27.9496994 ,
       -25.71379852, -23.47779846, -21.2417984 , -19.00579834,
       -16.76989937, -14.53389931, -12.29789925, -10.06189919,
        -7.8258996 ,  -5.58999968,  -3.35399985,  -1.11799991,
         1.11799991,   3.35399985,   5.58999968,   7.8258996 ,
        10.06189919,  12.29789925,  14.53389931,  16.76989937,
        19.00579834,  21.2417984 ,  23.47779846,  25.71379852,
        27.9496994 ,  30.18569946,  32.42169952,  34.65759659,
        36.89359665,  39.12949753,  41.36549759,  43.60139847,
        45.83739853,  48.07329941,  50.30919647,  52.54509735,
        54.78099823,  57.01689911,  59.25279999,  61.48859787,
        63.72449875,  65.96029663,  68.19599915,  70.43169403,
        72.66729736,  74.9026947 ,  77.13799286,  79.37299347,
        81.60739899,  83.84079742,  86.07109833,  88.28839874], dtype=float32), 'attributes': {'scale': (0.0, 1.0), 'date': '2/26/93', 'name': 'v', 'title': 'Monthly Mean Northward Wind Speed', 'tileIndex': None, 'source': 'BMRC BMRC2.3 R31L19 VIlp AMIP 10 Year Simulation ( 1979-1988 )', 'range': (-15.022506, 16.282299), 'time': '14:10:00', 'units': 'm/s', 'type': 'R*4'}, 'datasetId': 'u'}: unicode argument expected, got 'str'
 Can't get Metadata!
[InputSpecs]: Error, Metadata for input 0 not found in ispec[1257b3b00]  
Traceback (most recent call last):
  File "test_it.py", line 12, in <module>
    x.plot(dv3, s, s2)
  File "/git/vcs/vcs/Canvas.py", line 2772, in plot
    a = self.__plot(arglist, keyargs)
  File "/git/vcs/vcs/Canvas.py", line 4116, in __plot
    returned_kargs = self.backend.plot(*arglist, **keyargs)
  File "/git/vcs/vcs/VTKPlots.py", line 705, in plot
    returned.update(self.plot3D(data1, data2, tpl, gm, ren, **kargs))
  File "/git/vcs/vcs/VTKPlots.py", line 809, in plot3D
    **kargs)  # , plot_type = PlotType.List  )
  File "/Users/doutriaux1/anaconda2/envs/nightly2/lib/python2.7/site-packages/DV3D/Application.py", line 65, in gminit
    self.plot.gminit( var1, var2, **args )
  File "/Users/doutriaux1/anaconda2/envs/nightly2/lib/python2.7/site-packages/DV3D/StructuredGridPlot.py", line 646, in gminit
    self.execute( )
  File "/Users/doutriaux1/anaconda2/envs/nightly2/lib/python2.7/site-packages/DV3D/StructuredGridPlot.py", line 239, in execute
    self.buildPipeline()
  File "/Users/doutriaux1/anaconda2/envs/nightly2/lib/python2.7/site-packages/DV3D/RectilinearGridPlot.py", line 980, in buildPipeline
    self.setMaxScalarValue( self.input().GetScalarType() )
  File "/Users/doutriaux1/anaconda2/envs/nightly2/lib/python2.7/site-packages/DV3D/StructuredGridPlot.py", line 144, in setMaxScalarValue
    else:                                   self._max_scalar_value = self.getRangeBounds()[1]
TypeError: 'NoneType' object has no attribute '__getitem__'

and this in Python3

Traceback (most recent call last):
  File "test_it.py", line 12, in <module>
    x.plot(dv3, s, s2)
  File "/git/vcs/vcs/Canvas.py", line 2772, in plot
    a = self.__plot(arglist, keyargs)
  File "/git/vcs/vcs/Canvas.py", line 4116, in __plot
    returned_kargs = self.backend.plot(*arglist, **keyargs)
  File "/git/vcs/vcs/VTKPlots.py", line 705, in plot
    returned.update(self.plot3D(data1, data2, tpl, gm, ren, **kargs))
  File "/git/vcs/vcs/VTKPlots.py", line 809, in plot3D
    **kargs)  # , plot_type = PlotType.List  )
  File "/Users/doutriaux1/anaconda2/envs/py3/lib/python3.6/site-packages/DV3D/Application.py", line 65, in gminit
    self.plot.gminit( var1, var2, **args )
  File "/Users/doutriaux1/anaconda2/envs/py3/lib/python3.6/site-packages/DV3D/StructuredGridPlot.py", line 641, in gminit
    self.variable_reader = StructuredDataReader( vars=var_list, otype=self.type, **args )
  File "/Users/doutriaux1/anaconda2/envs/py3/lib/python3.6/site-packages/DV3D/StructuredVariableReader.py", line 106, in __init__
    self.subSpace = get_scalar_value( args.get( 'axes', 'xyz' ) )
  File "/Users/doutriaux1/anaconda2/envs/py3/lib/python3.6/site-packages/DV3D/ConfigurationFunctions.py", line 31, in get_scalar_value
    return get_scalar_value( tvals[0] )
  File "/Users/doutriaux1/anaconda2/envs/py3/lib/python3.6/site-packages/DV3D/ConfigurationFunctions.py", line 31, in get_scalar_value
    return get_scalar_value( tvals[0] )
  File "/Users/doutriaux1/anaconda2/envs/py3/lib/python3.6/site-packages/DV3D/ConfigurationFunctions.py", line 31, in get_scalar_value
    return get_scalar_value( tvals[0] )
  [Previous line repeated 977 more times]
RecursionError: maximum recursion depth exceeded
doutriaux1 commented 6 years ago

@danlipsa could you and scott take a quick look, it might be a simple vtk fix.