Skip to content

A seemingly OK variable will completely break DV3D #1155

@jypeter

Description

@jypeter

We have found a variable that will completely break DV3D: we get the following message and core dump

Warning, can't open data file 'None'
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
Abort (core dumped)

The variable can be downloaded with

wget http://dods.ipsl.jussieu.fr/brocksce/tmp/temp.nc

The variable seems OK and vcs will not complain when plotting 2D slices of the variable. DV3D will work again if we create the axes of the variable from scratch, to create a new variable, so there must be some metadata in the original variable that DV3D is not happy with

You can use the following script to reproduce the crash, or try to plot the corrected variable

#!/usr/bin/env python

import numpy as np
import cdms2, vcs, sys

# A variable that dv3d is happy with
f = cdms2.open( sys.prefix+"/sample_data/geos5-sample.nc" )
v_ok = f('uwnd')
f.close()

print '=== Some information about a variable that works in dv3d:'
v_ok.info()

# A variable that will break dv3d
# wget http://dods.ipsl.jussieu.fr/brocksce/tmp/temp.nc
f = cdms2.open("./temp.nc" )
v_pb = f('TEMP', longitude=(0, 360, 'co'))
f.close()

print '\n=== Some information about the variable that breaks dv3d:\n'
v_pb.info()

# Replacing the axes of the 'buggy' variable will make dv3d happy again
new_lon = cdms2.createUniformLongitudeAxis(0.5, 360, 1.)
new_lat = cdms2.createUniformLatitudeAxis(-89.5, 180, 1.)
new_lev = cdms2.createAxis(v_pb.getLevel()[:], id='level')
new_lev.designateLevel()
new_lev.units = 'meters'
v_corrected = cdms2.createVariable(v_pb, axes=(new_lev, new_lat, new_lon), id='TEMP')

print '\n=== Some information about the corrected variable:'
v_corrected.info()

dv3d = vcs.get3d_scalar()

x = vcs.init()

raw_input('\n\nPress return to try to plot the buggy variable, or CTRL-C')
x.plot(v_pb, dv3d)
x.interact()

# The end

Running the script will produce the following output (including the variables v.info() output):

>python -i pb_dv3d_crash.py
=== Some information about a variable that works in dv3d:
*** Description of Slab uwnd ***
id: uwnd
shape: (1, 14, 181, 360)
filename: 
missing_value: 1e+15
comments: 
grid_name: <None>
grid_type: generic
time_statistic: 
long_name: Zonal Wind
units: m/s
_FillValue: [  9.99999987e+14]
autoApiInfo: <AutoAPI.AutoAPI.Info instance at 0x7fb2fd263998>
vmin: [  9.99999987e+14]
tileIndex: None
vmax: [  9.99999987e+14]
fmissing_value: [  9.99999987e+14]
Grid has Python id 0x7fb2fde84e10.
Gridtype: generic
Grid shape: (181, 360)
Order: yx
** Dimension 1 **
   id: time
   Designated a time axis.
   units:  minutes since 2011-05-01 00:00:00
   Length: 1
   First:  0
   Last:   0
   Other axis attributes:
      begin_date: [20110501]
      begin_time: [0]
      long_name: time
      time_increment: [60000]
      calendar: gregorian
      axis: T
   Python id:  0x7fb2da908490
** Dimension 2 **
   id: lev
   Designated a level axis.
   units:  mb
   Length: 14
   First:  10.0
   Last:   1000.0
   Other axis attributes:
      positive: down
      axis: Z
      long_name: vertical level
   Python id:  0x7fb2da908e90
** Dimension 3 **
   id: lat
   Designated a latitude axis.
   units:  degrees_north
   Length: 181
   First:  -90.0
   Last:   90.0
   Other axis attributes:
      long_name: latitude
      axis: Y
   Python id:  0x7fb2da908f50
** Dimension 4 **
   id: lon
   Designated a longitude axis.
   units:  degrees_east
   Length: 360
   First:  0.0
   Last:   359.0
   Other axis attributes:
      long_name: longitude
      axis: X
      modulo: 360.0
      topology: circular
   Python id:  0x7fb2da908850
*** End of description for uwnd ***

=== Some information about the variable that breaks dv3d:

*** Description of Slab TEMP ***
id: TEMP
shape: (20, 180, 360)
filename: 
missing_value: [ -1.00000000e+10]
comments: 
grid_name: <None>
grid_type: generic
time_statistic: 
long_name: TEMPERATURE
units: DEG C
_FillValue: [ -1.00000000e+10]
autoApiInfo: <AutoAPI.AutoAPI.Info instance at 0x7fb2da979248>
tileIndex: None
history: From /usr/local/install/ferret-6.9/data/levitus_climatology.cdf
Grid has Python id 0x7fb2da916c90.
Gridtype: generic
Grid shape: (180, 360)
Order: yx
** Dimension 1 **
   id: ZAXLEVITR
   Designated a level axis.
   units:  meters
   Length: 20
   First:  0.0
   Last:   5000.0
   Other axis attributes:
      positive: down
      point_spacing: uneven
      standard_name: depth
      axis: Z
   Python id:  0x7fb2fde84dd0
** Dimension 2 **
   id: YAXLEVITR
   Designated a latitude axis.
   units:  degrees_north
   Length: 180
   First:  -89.5
   Last:   89.5
   Other axis attributes:
      standard_name: latitude
      point_spacing: even
      axis: Y
   Python id:  0x7fb2da908090
** Dimension 3 **
   id: XAXLEVITR
   Designated a longitude axis.
   units:  degrees_east
   Length: 360
   First:  0.5
   Last:   359.5
   Other axis attributes:
      modulo: 360.0
      point_spacing: even
      standard_name: longitude
      axis: X
      topology: circular
   Python id:  0x7fb2da908310
*** End of description for TEMP ***

=== Some information about the corrected variable:
*** Description of Slab TEMP ***
id: TEMP
shape: (20, 180, 360)
filename: 
missing_value: [ -1.00000000e+10]
comments: 
grid_name: <None>
grid_type: generic
time_statistic: 
long_name: TEMPERATURE
units: DEG C
autoApiInfo: <AutoAPI.AutoAPI.Info instance at 0x7fb2da979638>
tileIndex: None
history: From /usr/local/install/ferret-6.9/data/levitus_climatology.cdf
Grid has Python id 0x7fb2da916c90.
Gridtype: generic
Grid shape: (180, 360)
Order: yx
** Dimension 1 **
   id: level
   Designated a level axis.
   units:  meters
   Length: 20
   First:  0.0
   Last:   5000.0
   Other axis attributes:
      axis: Z
   Python id:  0x7fb2da916090
** Dimension 2 **
   id: latitude
   Designated a latitude axis.
   units:  degrees_north
   Length: 180
   First:  -89.5
   Last:   89.5
   Other axis attributes:
      axis: Y
   Python id:  0x7fb2da916210
** Dimension 3 **
   id: longitude
   Designated a longitude axis.
   units:  degrees_east
   Length: 360
   First:  0.5
   Last:   359.5
   Other axis attributes:
      axis: X
      modulo: 360.0
      topology: circular
   Python id:  0x7fb2fde84d90
*** End of description for TEMP ***

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions