Bug #636

gmtconvert is not outputing nans from netcdf vectors

Added by Duncan almost 7 years ago. Updated almost 7 years ago.

Status:ClosedStart date:2014-10-28
Priority:NormalDue date:
Assignee:Paul% Done:


Target version:Candidate for next bugfix release
Affected version:5.x-svn Platform:Linux


Hi there,
I have been outputting vectors from a "nf (# 18)" classic style netCDF file using gmtconvert version 5.1.2_r13381 with the following syntax:

gmtconvert IR2HI1B_2011314_ICP4_JKB2e_BIS01a_000.nc\?lon | wc -l
produces 309 entries

In GMT4:
nc2xy IR2HI1B_2011314_ICP4_JKB2e_BIS01a_000.nc -Flon | wc -l
produces 319 entries with the last 10 being NaNs.

I have tried setting the flags -N and -s flags on gmtconvert with no success. netcdf library version is "3.6.2" of Jul 13 2007 10:33:51.


IR2HI1B_2011314_ICP4_JKB2e_BIS01a_000.nc.zip - netCDF file zip archive (5.22 MB) Duncan, 2014-10-28 08:30


#1 Updated by Paul almost 7 years ago

  • Status changed from New to Feedback

GMT always skips data records where x or y are NaN. You are only asking for a single column here - how do you make a vector from that? Presumably you cannot plot a vector if one of its components is NaN. Please explain a bit more what you are trying to accomplish with those NaNs and I could suggest how it might be done.

#2 Updated by Paul almost 7 years ago

If I cannot get feedback on this then I cannot help. Please provide some context.

#3 Updated by Duncan almost 7 years ago

Paul wrote:

If I cannot get feedback on this then I cannot help. Please provide some context.

Hi Paul,
Apologies for the delay. The ultimate goal is to obtain a time, lon, lat vector from the sample data as follows:
gmtconvert IR2HI1B_2011314_ICP4_JKB2e_BIS01a_000.nc\?{time,lon,lat} -A
However, as the columns are of different length, the operation fails with the warning:
gmtconvert: Parsing requires files with same number of records.
and no data is output. Ideally, I would like a time,lon,lat vector with fans eliminated.

#4 Updated by Remko almost 7 years ago

Duncan wants, from what I understand, the following:

time1 time2 time3 ... time319
lon1 lon2 lon3 ... lon319
lat1 lat2 lat3 ... lat319

He used a bit of a confusing shorthand, but meant to write:
gmtconvert IR2HI1B_2011314_ICP4_JKB2e_BIS01a_000.nc\?time -A
gmtconvert IR2HI1B_2011314_ICP4_JKB2e_BIS01a_000.nc\?lon -A
gmtconvert IR2HI1B_2011314_ICP4_JKB2e_BIS01a_000.nc\?lat -A

That doesn't work because gmtconvert seems to always swallow the last 10 lons and lats, which are NaN, even when playing with -N and -s.
In fact, I don't understand in that context the *-N( option, since all-NaN records always seem to be eaten. Though it may only apply to lon and lat.

However, the following command:

gmtconvert IR2HI1B_2011314_ICP4_JKB2e_BIS01a_000.nc\?time/lon/lat
works. I checked it. It even produces the lons and lats that are NaN (the last ten). But as three columns.

The output of that command can be run through cut to select each column at the time, e.g.:

lon=(`gmtconvert IR2HI1B_2011314_ICP4_JKB2e_BIS01a_000.nc\?time/lon/lat | cut -f2`)
echo ${lon[@]}

#5 Updated by Paul almost 7 years ago

  • Status changed from Feedback to Resolved
  • Assignee set to Paul
  • Target version set to Candidate for next bugfix release

I have fixed this in trunk in r13694 so the NaNs are now output.

#6 Updated by Remko almost 7 years ago

  • Status changed from Resolved to Closed

Closed as implemented

Also available in: Atom PDF