[ncl-talk] NetCDF output file from NCL not opening in GrADS

S Br sbr.climate at gmail.com
Thu Jul 6 03:34:54 MDT 2017


Hi,
Thanks for your reply.
I made the time dimension unlimited but it didn't work. I just checked that
lat and lon dimension is missing in the output file. I don't know how to
add the lat and lon dimension using NCL. I was thinking that it is will
take from tasmax array.
Could you please modify my code to add lat and lon dimension.

*Output file:*

ncdump -h tas_aave_Asia_bandpass30-100.nc
netcdf tas_aave_Asia_bandpass30-100 {
dimensions:
time = UNLIMITED ; // (1000 currently)
variables:
double tasmax(time) ;
tasmax:_FillValue = -999000000. ;
tasmax:lon = 0. ;
tasmax:lat = 0. ;
tasmax:missing_value = -999000000. ;
double time(time) ;
time:standard_name = "time" ;
time:long_name = "Time" ;
time:units = "years since 850-1-1 00:00:00" ;
time:calendar = "standard" ;
time:axis = "T" ;
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
*Input file:*
ncdump -h tas_aave_Asia.nc
netcdf tas_aave_Asia {
dimensions:
lon = 1 ;
lat = 1 ;
time = UNLIMITED ; // (1000 currently)
variables:
double lon(lon) ;
lon:standard_name = "longitude" ;
lon:long_name = "longitude" ;
lon:units = "degrees_east" ;
lon:axis = "X" ;
double lat(lat) ;
lat:standard_name = "latitude" ;
lat:long_name = "latitude" ;
lat:units = "degrees_north" ;
lat:axis = "Y" ;
double time(time) ;
time:standard_name = "time" ;
time:long_name = "Time" ;
time:units = "years since 850-1-1 00:00:00" ;
time:calendar = "standard" ;
time:axis = "T" ;
double tasmask(time, lat, lon) ;
tasmask:_FillValue = -999000000. ;
tasmask:missing_value = -999000000. ;
*>>>>>>>>>>>>>>>>>>>>*
*NCL code:*
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
begin

   fn  = "tas_aave_Asia.nc" ; define filename
   in  = addfile(fn,"r")                                 ; open netcdf file
    x  = in->tasmask(:,0,0)                                       ; get data

; ***********************************************
; create the filter weights and apply
; ***********************************************

  ihp     = 2                             ; band pass
  sigma   = 1.0                           ; Lanczos sigma

  nWgt    = 201                           ; loose 100 each end
  fca     = 1./100.                       ; start freq
  fcb     = 1./30.                        ; last  freq
  wgt     = filwgts_lanczos (nWgt, ihp, fca, fcb, sigma )
  xBPF    = wgt_runave ( x, wgt, 0 )      ; 30-100 days

   copy_VarMeta(x,xBPF)
   dNames= getvardims(xBPF)
   dSIZES=dimsizes(xBPF)
   print (dNames)
   print (dSIZES)

; ***********************************************
; create new date array for use on the plot
; ***********************************************
  filo = "tas_aave_Asia_bandpass30-100.nc"
  system ("/bin/rm "+filo) ; remove any pre-existing file
  fo = addfile(filo , "c") ; open output file
  filedimdef(fo,"time",-1,True)       ; make 'time' unlimited
  tasmax=xBPF
  fo->tasmax = tasmax ; write ud to a file
end



On Thu, Jul 6, 2017 at 12:07 AM, Adam Phillips <asphilli at ucar.edu> wrote:

> Hi SB,
> Dennis is correct, in that this type of question would be better posed to
> the GrADS user forum. However, I have some limited experience with GrADS,
> and in my experience GrADS will not open a file unless there is a X
> (latitude) and Y (longitude) array present. The arrays do not have to have
> anything to do with your tasmax array. Thus, I would recommend writing some
> random latitude/longitude arrays to your file along with your tasmax array.
>
> If that advice does not help, I would suggest posing your query to the
> GrADS user forum.
> Adam
>
>
>
> On Wed, Jul 5, 2017 at 4:57 PM, Dennis Shea <shea at ucar.edu> wrote:
>
>> In my view, this question should be sent to the GrADS User forum not
>> ncl-talk.
>>
>> Did you look at the created nc file?
>>
>> %> ncdump  tas_aave_Asia_bandpass30-100.nc  |  less
>>
>> ===========================================
>> Maybe try making the 'time' dimension unlimited.
>>
>>
>>   filo = "tas_aave_Asia_bandpass30-100.nc"
>>   system ("/bin/rm "+filo) ; remove any pre-existing file
>>   fo  = addfile(filo , "c") ; open output file
>>   *filedimdef*
>> <http://www.ncl.ucar.edu/Document/Functions/Built-in/filedimdef.shtml>
>> (fo,"time",-1,True)       ; make 'time' unlimited
>>   tasmax = xBPF
>>
>>
>> On Wed, Jul 5, 2017 at 10:13 AM, S Br <sbr.climate at gmail.com> wrote:
>>
>>> Hi,
>>> I have applied bandpass filter to my one dimentional NetCDF file. I have
>>> written the output to a NetCDF file but this output file is not opening in
>>> GrADS. I get the following error.
>>>
>>> ga-> sdfopen tas_aave_Asia_bandpass30-100.nc
>>> Scanning self-describing file:  tas_aave_Asia_bandpass30-100.nc
>>> gadsdf: SDF file has no discernable X coordinate.
>>>   To open this file with GrADS, use a descriptor file with an XDEF entry.
>>>   Documentation is at http://cola.gmu.edu/grads/gado
>>> c/SDFdescriptorfile.html
>>>
>>> Could you please suggest if I am doing somewhere wrong in my NCL script
>>> . The input file is perfectly fine with GrADS.
>>>
>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>>> begin
>>>
>>>    fn  = "tas_aave_Asia.nc" ; define filename
>>>    in  = addfile(fn,"r")                                 ; open netcdf
>>> file
>>>     x  = in->tasmask(:,0,0)                                       ; get
>>> data
>>>
>>> ; ***********************************************
>>> ; create the filter weights and apply
>>> ; ***********************************************
>>>
>>>   ihp     = 2                             ; band pass
>>>   sigma   = 1.0                           ; Lanczos sigma
>>>
>>>   nWgt    = 201                           ; loose 100 each end
>>>   fca     = 1./100.                       ; start freq
>>>   fcb     = 1./30.                        ; last  freq
>>>   wgt     = filwgts_lanczos (nWgt, ihp, fca, fcb, sigma )
>>>   xBPF    = wgt_runave ( x, wgt, 0 )      ; 30-100 days
>>>
>>>    copy_VarMeta(x,xBPF)
>>>    dNames= getvardims(xBPF)
>>>    dSIZES=dimsizes(xBPF)
>>>    print (dNames)
>>>    print (dSIZES)
>>>
>>> ; ***********************************************
>>> ; create new date array for use on the plot
>>> ; ***********************************************
>>>   filo = "tas_aave_Asia_bandpass30-100.nc"
>>>   system ("/bin/rm "+filo) ; remove any pre-existing file
>>>   fo = addfile(filo , "c") ; open output file
>>>   tasmax=xBPF(:)
>>>   fo->tasmax = tasmax ; write ud to a file
>>> end
>>>
>>>
>>> Thanks.
>>> SB
>>>
>>>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
>
> --
> Adam Phillips
> Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
> www.cgd.ucar.edu/staff/asphilli/   303-497-1726 <(303)%20497-1726>
>
> <http://www.cgd.ucar.edu/staff/asphilli>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170706/27938d5a/attachment.html 


More information about the ncl-talk mailing list