[ncl-talk] convert grd to nc
Dennis Shea
shea at ucar.edu
Wed May 23 16:11:10 MDT 2018
Forgot to mention. NCL has an 'NDVI' page:
https://www.ncl.ucar.edu/Applications/
Under '*Datasets*', Click
*NDVIhttps://www.ncl.ucar.edu/Applications/ndvi.shtml
<https://www.ncl.ucar.edu/Applications/ndvi.shtml>*===
Further, there will be some
*NDVI related colormaps in the next NCL release: 6.5.0*See:
https://www.ncl.ucar.edu*/future_release*.shtm
*l*
Click "*New Color Tables*"
For example:
The nasa_ndvi color map
<https://www.ncl.ucar.edu/Document/Graphics/ColorTables/nasa_ndvi.shtml>
comes from NASA's Ocean Color <https://oceancolor.gsfc.nasa.gov/> website.
The vegetation_ClarkU color map
<https://www.ncl.ucar.edu/Document/Graphics/ColorTables/vegetation_ClarkU.shtml>
was contributed by Clark Labs <https://clarklabs.org> / Clark University
<http://www.clarku.edu>.
On Wed, May 23, 2018 at 3:22 PM, Dennis Shea <shea at ucar.edu> wrote:
> Hi Amy,
>
> The Climate Data Operators (CDO) can be used to convert a binary file to
> netCDF. The command is described at:
>
> https://www.ncl.ucar.edu/Applications/grads.shtml
>
> %> cdo -f nc import_binary ndvip.ctl NDVI.polar_82-17.nc
>
> cdo import_binary: Processed 1 variable ( 1.27s )
> ----------------------------------------------------------------------
> This has a 'minor' problem.
>
> The file contains the following which looks good!
>
> float ndvi(time, lat, lon) ;
> ndvi:long_name = "normalized difference vegetation index" ;
> ndvi:*_FillValue = -999.f *;
> ndvi:*missing_value = -999.f *;
>
> However, if we observe *the golden rule of data processing: Look at your
> data*
>
> %> ncdump -v ndvi NDVI.polar_82-17.nc | less
>
> You will see the the actual _FillValue and missing_value should be
>
> *-0.0999**ndvi *=
> *-0.0999*, -0.0999, -0.0999, -0.0999, -0.0999, -0.0999, -0.0999,
> -0.0999,
> [SNIP]
>
> From and NCL perspective, this is readily addressed:
>
> f = addfile("NDVI.polar_82-17.nc", "r")
> ndvi = f->ndvi
> ndvi at _FillValue = -0.0999 ; change to correct _FillValue
> printVarSummary(ndvi)
>
> You could also use the netCDF Operator's attribute editor:
> ncatted <https://linux.die.net/man/1/ncatted>
> to change the values on the file.
> -----------------------------------------------------------------------
> The files [~ 291 MB] created by the CDO [ NDVI.polar_82-17.nc ] and NCL
> [ polar_82-17_MaxNDVI3g.grd.NCL.nc ] are at:
>
> ftp ftp.cgd.ucar.edu
> anonymous
> your_email
> cd pub/shea
> get NDVI.polar_82-17.nc
> get polar_82-17_MaxNDVI3g.grd.NCL.nc
> quit
> ===========================================
>
> They are functionally equivalent
> &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
> ============================================
> The NCL script you sent had an error or two. The .ctl file had:
>
> [1] the .ctl pointed to
>
> DSET ^polar82-*16*_maxndvi_dat.grd
>
> The file you sent was named: polar_82-17_MaxNDVI3g.grd
> The .ctl should point to:
>
> DSET ^polar_82-*17*_MaxNDVI3g.grd
>
> ====
> The file you sent has size:
>
> 299220480 May 22 22:25 polar_82-17_MaxNDVI3g.grd
>
> nlat(=481)*mlon(=4320)*ntim(=36)*nbyte(=4) = 299220480
>
> This means the the file has no 'extra' embedded bytes.
> Fortran's sequential binary files have record boundaries. They add to the
> size of the file.
>
> This means that you should be using NCL's 'fbindirread' function.
>
> https://www.ncl.ucar.edu/Document/Functions/Built-in/fbindirread.shtml
>
> and not 'fbinrecread' function.
>
> See attached.
>
> Good Luck
>
>
>
>
> On Tue, May 22, 2018 at 7:05 PM, Amy Hendricks <ashendricks at alaska.edu>
> wrote:
>
>> Hell NCL heroes,
>>
>> I am trying to read in ndvi data in .grd format and convert to netcdf.
>> The problem occurs when I go to read in the ndvi data. This script is
>> modified from grads_2.ncl (https://www.ncl.ucar.edu/Appl
>> ications/Scripts/grads_2.ncl). Please find attached the script, data,
>> and ctl file. The ctl file is an example from my advisor, only the DSET and
>> # of years are different.
>>
>> Thanks!
>>
>> Amy
>> ndvip.ctl
>> <https://drive.google.com/a/alaska.edu/file/d/1gfTy4cedHoVucV-YEan0Ph7NES9FfsMM/view?usp=drive_web>
>>
>> polar_82-17_MaxNDVI3g.grd
>> <https://drive.google.com/a/alaska.edu/file/d/1DNzWno-3WmFqINZBY-ENH7nnMn0lsGvf/view?usp=drive_web>
>>
>>
>> --
>> Amy Hendricks
>> Graduate Research Assistant
>> Department of Atmospheric Sciences
>> University of Alaska Fairbanks
>> IARC 343-R
>> 907-388-9893
>> ashendricks at alaska.edu
>>
>> _______________________________________________
>> 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/20180523/c171a5dd/attachment.html>
More information about the ncl-talk
mailing list