[ncl-talk] write netcdf

Toni Klemm toni-klemm at tamu.edu
Fri Nov 30 11:19:02 MST 2018


Hi Debasish,

Try taking out the space between systemfunc and (“date”) here:

> fAtt at creation_date = systemfunc ("date")


which changes it to this:

> fAtt at creation_date = systemfunc("date")


If that doesn’t solve it, try taking the spaces out of:

>  fileattdef( fout, fAtt )


to this

>  fileattdef(fout,fAtt )



Good 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 12:09 PM, Debasish Hazra <debasish.hazra5 at gmail.com> wrote:
> 
> Thanks Toni. I switched the lines, but it still show error at
>  fileattdef( fout, fAtt )
> and odes not create netcdf file. I think the problem comes from this line :
> fAtt at creation_date = systemfunc ("date")
> Do I have to define date before ?
> Debasish
> 
> On Fri, Nov 30, 2018 at 12:55 PM Toni Klemm <toni-klemm at tamu.edu <mailto:toni-klemm at tamu.edu>> wrote:
> 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 <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.eccforum.org&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5bcGgnrpl7xPRfic&m=AhPAW_80wDzCMtnVlNa6lt6ob2Ry8twXpfcse-Zzyo0&s=dkIA-iN1GiZcr9S2dVSIsYTWqjsxn3SBNsX76k0PMPM&e=>
> www.toni-klemm.de <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.toni-2Dklemm.de&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5bcGgnrpl7xPRfic&m=AhPAW_80wDzCMtnVlNa6lt6ob2Ry8twXpfcse-Zzyo0&s=VhxrGEIcsx_bmsihHPNLUGS4bru6-0m_Prt036iyrzk&e=> | @toniklemm <https://urldefense.proofpoint.com/v2/url?u=http-3A__twitter.com_toniklemm&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5bcGgnrpl7xPRfic&m=AhPAW_80wDzCMtnVlNa6lt6ob2Ry8twXpfcse-Zzyo0&s=W2NJGiF2TmAEPo2hBAy4USeevwdcKTq_BjCPqYjQoMY&e=>
> 
> 
> 
> 
> 
> 
> 
> 
>> On Nov 30, 2018, at 11:47 AM, Debasish Hazra <debasish.hazra5 at gmail.com <mailto: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 <mailto:ncl-talk at ucar.edu>
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk <https://urldefense.proofpoint.com/v2/url?u=http-3A__mailman.ucar.edu_mailman_listinfo_ncl-2Dtalk&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5bcGgnrpl7xPRfic&m=AhPAW_80wDzCMtnVlNa6lt6ob2Ry8twXpfcse-Zzyo0&s=29ChGHh36O1jDtQZPh_lATDDQDZhDZiwN098O0cqZMw&e=>
> 

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


More information about the ncl-talk mailing list