[ncl-talk] Define and populate plev_bnds in NetCDF

Dennis Shea shea at ucar.edu
Wed Oct 21 13:55:46 MDT 2015


Also .... another recommendation ...

It is not required but I recommend the type of the 'plev_bnds' should
be the same type as 'plev'

=====================
typeof(plev) => Integer

   plev_bnds = (/ (/ 100000, 98750/) \
                , (/  98750, 96250/) \
                , (/  91250, 88750/) \
                , (/   1000,   500/) /)          ; last line
=================
 typeof(plev) => float

   plev_bnds = (/ (/ 100000.0, 98750.0/) \
                         , (/  98750.0, 96250.0/) \
                         , (/  91250.0, 88750.0/) \
                         , (/   1000.0,   500.0/) /)          ; last line

or, easier

typeof(plev) => float

   plev_bnds = (/ (/ 100000, 98750/) \
                , (/  98750, 96250/) \
                , (/  91250, 88750/) \
                , (/   1000,   500/) /)  *1.0           ; last line

=================

 typeof(plev) => double

   plev_bnds = (/ (/ 100000d0, 98750d0/) \
                         , (/  98750d0, 96250d0/) \
                         , (/  91250d0, 88750d0/) \
                         , (/    1000d0,    500d0/) /)          ; last line

or, easier

typeof(plev) => double

   plev_bnds = (/ (/ 100000, 98750/) \
                , (/  98750, 96250/) \
                , (/  91250, 88750/) \
                , (/   1000,   500/) /)  *1d0          ; last line


On Tue, Oct 20, 2015 at 4:30 PM, Dennis Shea <shea at ucar.edu> wrote:
> NCL .... A general place to go to get file IO information.
>
> Click 'Examples' .... then 'File I/O' .... Click 'Change netCDF file'
>
> For 'fun' look at other examples also.
>
> ===
>
>
> ===
>
> Two approaches:
>
> [1]
> If you are familiar withe the netCDF Operators (not associated with
> NCL). Use netCDF Operator: ncks   [Use WWW to search for
> documentation]
>
> (a) Create a netCDF with the plev_bnds variable:   plev_bnd.nc
>       See attached script. Of, course the 'plev' should be changed
>       to the appropriate variable name.
>
> (b)  If 'foo.nc' is your base file:
>                 ncks -O plev.nc  foo.nc
>       will append the bounds variable to the file.
>
>
> [2] NCL direct
>
>    plev_bnds = (/ (/100000, 98750/) \
>                          , (/  98750, 96250/) \
>                          , (/  91250, 88750/) \
>
>                          , (/ ...  ,    ...   /)  /)          ; last line
>
>               ; name dimensions using NCL syntax
>    plev_bnds!0 = "plev"   ; ... whatever is appropriate
>    plev_bnds!1 = "pbnd"
>    plev_bnds at units = plev at units
>    printVarSummary(plev_bnds)
>
>
>    f = addfile("foo.nc", "w")   ; NOTE the 'w'
>    f->plev_bnds = plev_bnds
>
> ===
> Either way, I would create test files in case there is a problem.
>
> On Tue, Oct 20, 2015 at 12:44 PM, Hertz, Judith A.
> (GSFC-606.0)[INTERNATIONAL TECHNOLOGY COALITION, INC]
> <judith.a.hertz at nasa.gov> wrote:
>> Greetings, NCL’ers
>>
>> I’m new to NCL. I want to add a variable, plev_bnds, to NetCDF files so that:
>>
>> double plev_bnds(plev, bnds) ;
>>
>> data:
>>
>>  plev_bnds =
>>   100000, 98750,
>>   98750, 96250,
>>   96250, 93750,
>>   93750, 91250,
>>   91250, 88750,…..
>>
>> I’ve found addfile, which looks to be a good way to populate the data but the docs say the variable must already exist. Do you know what is the NCL way to create/define a new variable?
>>
>> thanks,
>>
>> judy
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk


More information about the ncl-talk mailing list