[ncl-talk] write netcdf

Toni Klemm toni-klemm at tamu.edu
Fri Nov 30 10:55:43 MST 2018


Hi Debasish,

That’s because you create the variable fAtt *after* you assign it the creation date. You need to create it *before* you assign any attributes to it. Just switch these two lines:

> fAtt at creation_date = systemfunc ("date")

> fAtt               = True

to this

> fAtt               = True
> fAtt at creation_date = systemfunc ("date")


and it should work.


Best of luck,
Toni


Toni Klemm, Ph.D.
Postdoctoral Research Associate
Department of Ecosystem Science and Management
College of Agriculture and Life Sciences
Texas A&M University, College Station, TX
Contributor to the Early Career Climate Forum <http://www.eccforum.org/>
www.toni-klemm.de <http://www.toni-klemm.de/> | @toniklemm <http://twitter.com/toniklemm>








> On Nov 30, 2018, at 11:47 AM, Debasish Hazra <debasish.hazra5 at gmail.com> wrote:
> 
> Hi,
> I am regridding data and trying to write that in netcdf file but getting error :
> 
>      data_regrid = ESMF_regrid(data2,opt)
>       printVarSummary(data_regrid)
>       printMinMax(data_regrid,0)
>       ; write netCDF the 'simple' way
>       start_write_time = get_cpu_time()
>       fout  = addfile ("./2016/Regrid/GPM_3IMERGDL_05_precipitationCal.20160601.nc <https://urldefense.proofpoint.com/v2/url?u=http-3A__GPM-5F3IMERGDL-5F05-5FprecipitationCal.20160601.nc&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5bcGgnrpl7xPRfic&m=m6TpKEa7O0Cj3dUZmxrnPvld1cZSrJU2iAFWlhkU_3c&s=s9u-rRMRy_zB-nNalwPJbIwsn969qj_oSze9O9jJcWE&e=>", "c")
>       fAtt at creation_date = systemfunc ("date")
>       fAtt               = True
>       fAtt at Conventions   = "None"
>       fAtt at title         = "Regrid: 0.1 to 0.25 grid via ESMF interpolation"
>       fAtt at source_file   =  "g4.subsetted.GPM_3IMERGDL_05_precipitationCal.20160601.180W_90S_180E_90N.nc <https://urldefense.proofpoint.com/v2/url?u=http-3A__g4.subsetted.GPM-5F3IMERGDL-5F05-5FprecipitationCal.20160601.180W-5F90S-5F180E-5F90N.nc&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5bcGgnrpl7xPRfic&m=m6TpKEa7O0Cj3dUZmxrnPvld1cZSrJU2iAFWlhkU_3c&s=_wD-kFpaARvGRdB7kAc3f76mIpQWtI5rrl7v1_kGXzI&e=>"
>       fileattdef( fout, fAtt )
>       fout->data_regrid = precip
>       end_write_time = get_cpu_time()
> 
> But geting the following error : fatal:Variable (fAtt) is undefined, can not assign attribute (creation_date).Any help on how to fix fAtt error ?
> 
> Thanks
> Debasish
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20181130/13c0c589/attachment.html>


More information about the ncl-talk mailing list