Re: regrid script that is a bit buggy

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon Apr 22 2013 - 14:23:20 MDT

Hi Marston,

To see how to correctly write scalars to a file, run the attached script and then look at the resultant "test.nc" file with ncl_filedump:

  ncl write_scalars.ncl
  ncl_filedump test.nc

The dimensions will look like this:

   dimensions:
      ncl_scalar = 1
      time = 10
      lat = 64
      lon = 128

If you edit write_scalars.ncl and comment out these three lines:

; filevardef(fout, "fish", typeof(fish), "ncl_scalar")
; filevardef(fout, "PI_FLT",typeof(PI_FLT),"ncl_scalar")
; filevardef(fout, "PI_DBL",typeof(PI_DBL),"ncl_scalar")

and then run the script again, you will get these dimensions:

   dimensions:
      time = 10
      lat = 64
      lon = 128
      ncl3 = 1
      ncl4 = 1
      ncl5 = 1

--Mary

On Apr 17, 2013, at 2:06 AM, Marston Johnston wrote:

> Hi Mary,
>
> Thanks for the reply. I'm not new to writing variables in netcdf, just to new to NCL. I'm pretty sure I defined the necessary dimensions to cover all the variables I'm writing to the netcdf file. Things may have gotten a bit messy since I'm copying data from one netcdf file, regirdding it, and then writing the regridded data to an new netcdf file.
> It works but I think I'm missing a few things. I'll follow Dennis suggestion and read up more on NCL. I'll be using it quite bit more in the future.
>
> Much obliged,
> /Marston
>
>
> On Mon, Apr 15, 2013 at 11:41 PM, Mary Haley <haley@ucar.edu> wrote:
> Hi Marston,
>
> My guess is that you defined dimensions for your array variables, but not your scalar
> variables.
>
> Everytime you write a variable to a file that you haven't defined the dimensions for,
> NCL will assign a new dimension name, starting with "ncl1", and so on. It will give
> a different name every time.
>
> To get around this, you need to call filevardef for each of your scalar variables, and use the
> special "ncl_scalar" dimension name:
>
> filevardef(ncid, varname,vartype,"ncl_scalar")
> where "varname" and "vartype" need to be replaced by the appropriate variable names and types.
>
> This is covered in our FAQ:
>
> http://www.ncl.ucar.edu/FAQ/#file_io_007
>
> --Mary
>
>
> On Apr 15, 2013, at 1:45 AM, Marston Johnston wrote:
>
>> Hi,
>>
>> I'm new to NCL and jumpped right in at the deep end.
>> NCL seems to be very powerful but the learning curve seems a bit steep.
>> I have taken a regridding script found the NCL example website and modified it to handle very very large arrays
>> and write the data, time step by time step. But, the code is buggy. It works ok but my file keeps adding these strange ncl dimensions to the output file:
>>
>> dimensions:
>> time = UNLIMITED ; // (5848 currently)
>> lev = 9 ;
>> lat = 81 ;
>> lon = 360 ;
>> ncl4 = 1 ;
>> ncl5 = 1 ;
>> ncl6 = 1 ;
>> ncl7 = 1 ;
>> ncl8 = 1 ;
>> ncl9 = 1 ;
>> ncl10 = 1 ;
>> ncl11 = 1 ;
>> ncl12 = 1 ;
>> ncl13 = 1 ;
>> ncl14 = 1 ;
>> ncl15 = 1 ;
>> ncl16 = 1 ;
>>
>> I've attached the ncl script. Would appreciate some help with understanding how ncl writes netcdf files and how to write the data and data attributes to the output file. Also how to do this per time step or even per pressure level.
>>
>> /Marston
>> --
>> Only the fruitful thing is true!
>> <regrid_new.ncl>_______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
>
> --
> Only the fruitful thing is true!

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

Received on Mon Apr 22 14:23:30 2013

This archive was generated by hypermail 2.1.8 : Tue Apr 23 2013 - 12:54:13 MDT