anjaroesel / netcdf4-python

Automatically exported from code.google.com/p/netcdf4-python
Other
0 stars 0 forks source link

Documentation issue: tutorial is missing a line #205

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Attempt to follow the section 'Dimensions in a netCDF file' in the Tutorial 
at http://netcdf4-python.googlecode.com/svn/trunk/docs/netCDF4-module.html

What is the expected output? What do you see instead?
After following the first line in the third block of example code (i.e. "print 
len(lon)"), the output should be as what appears in the tutorial, i.e. 144.  
The actual output is "NameError: name 'lon' is not defined".

What version of the product are you using? On what operating system?
Not relevant - this is a documentation bug.

Please provide any additional information below.
The tutorial appears to be missing a line of code: adding the line

>>> lon = f.dimensions['lon']

immediately before the line

>>> print len(lon)

should resolve this issue.

This may seem a trivial issue, but it has caused at least one person problems: 
see http://stackoverflow.com/q/19527463/.

Original issue reported on code.google.com by lackofl...@googlemail.com on 23 Oct 2013 at 6:54

GoogleCodeExporter commented 8 years ago
Just a few lines above the 'print len(lon)' there is this:

>>> lon = rootgrp.createDimension('lon', 144)

so I don't see what you mean.

Note also that the complete tutorial code is in examples/tutorial.py.  

Original comment by whitaker.jeffrey@gmail.com on 23 Oct 2013 at 7:35

GoogleCodeExporter commented 8 years ago
OK, thanks for getting back to me.

It seems the tutorial wasn't quite doing exactly what the person asking the 
StackOverflow question above was hoping for.  The code in the tutorial creates 
dimensions, whereas the person asking the question was looking to read existing 
dimensions.  It seems they tried unsuccessfully to adapt the tutorial code to 
their situation, quite probably because they are unfamiliar with Python.

It's unfortunate that someone spent an hour reading the documentation and 
struggling with netCDF4, but I imagine that all of us programmers have at least 
once in the past spent an hour or more struggling with a bit of code because we 
can't see the elementary mistake we've made.

I take back any comment that there is a defect in the documentation.  I 
apologise for missing the line of code you mentioned above, and for not 
identifying that the tutorial aims to do something slightly different to what 
the StackOverflow questioner was asking.  I've also updated my StackOverflow 
answer appropriately.  Please feel free to close this issue as 'not an issue' 
or suchlike - I'm not sure I can do this myself.

Original comment by lackofl...@googlemail.com on 24 Oct 2013 at 7:15

GoogleCodeExporter commented 8 years ago

Original comment by whitaker.jeffrey@gmail.com on 26 Feb 2014 at 2:04