[ncl-talk] NDVI_mask problem

Md. Jalal Uddin dmjalal90 at gmail.com
Fri May 11 07:02:56 MDT 2018


I am still getting following warnings though I put
  setfileoption("nc","MissingToFillValue", False)
  NDVI at _FillValue = toshort(NDVI at missing_value)     ; match typeof 'ndvi'
(netCDF rule).


warning:NetOpenFile: MissingToFillValue option set True, but missing_value
attribute and data variable (ndvi) types differ: not adding virtual
_FillValue attribute
warning:Attempt to reference attribute (missing_value) which is undefined
warning:toshort: there are 1 int less than SHRT_MIN, which has been flagged
missing.

Please find the script herewith. Please help me to fix these problems.



On Thu, May 10, 2018 at 10:02 PM, Dennis Shea <shea at ucar.edu> wrote:

> ncl 1> ndvi = f->ndvi
> ncl 2> print("typeof(ndvi)="+typeof(ndvi))   ; *"short"*
> ncl 3> print("typeof(ndvi at missing_value)="+typeof(ndvi at missing_value))
> ;  *"double"*
>
> The variable (ndvi) does not have an *_FillValue* attribute associated
> with it. By default, NCL tries to be 'smart' and set the variable's (ndvi)
> *missing_value* to* _FillValue*.  However, by netCDF (hence, NCL) rule
> the type of the variable (ndvi) and the type of _FillValue attribute should
> match. They do not. Again, one variable is  type "short" the other is type
> "double".
>
> The issue is explicitly mentioned in the error message.
>
> MissingToFillValue option set True, but missing_value attribute and data
> variable (ndvi) types differ: not adding virtual _FillValue attribute
>
> Please read the text associated with:
> https://www.ncl.ucar.edu/Document/Functions/Built-in/setfileoption.shtml
>
>
> *           MissingToFillValue*
> You can explicitly set this option to False"
>
> *      setfileoption*("nc","*MissingToFillValue*", False)
>
> This will eliminate the warning message.
>
> Still, you are left with no way to identify _FillValue. This is the
> attribute NCL recognizes.
> The following script on the NDVI page explicitly converts the type double
> missing_value (=5000.0d)
> to type short.
>
> ndvi_2.ncl
>
>   NDVI  = f->ndvi                      ; original unpacked values
>   NDVI at _FillValue = toshort(NDVI at missing_value)     ; match typeof 'ndvi' (netCDF rule)
>
> You need to do this for masking.
>
> Good Luck
>
>
> On Thu, May 10, 2018 at 6:00 AM, Md. Jalal Uddin <dmjalal90 at gmail.com>
> wrote:
>
>> Thank you for your help. Mary's suggestions are working now. However, I
>> am getting following errors.
>>
>> MissingToFillValue option set True, but missing_value attribute and data
>> variable (ndvi) types differ: not adding virtual _FillValue attribute
>>
>> I also went to the NCL NDVI examples page (https://www.ncl.ucar.edu/Appl
>> ications/ndvi.shtml) and tried to follow Example 2 that suggested by  Dennis
>> Shea. I got output but received the same problem.
>>
>> How could I solve the problem?
>>
>>
>> On Wed, May 9, 2018 at 11:54 PM, Dennis Shea <shea at ucar.edu> wrote:
>>
>>> If you go to NCL's Examples page:
>>>
>>>    https://www.ncl.ucar.edu/Applications/
>>>
>>> Under 'Datasets', click 'NDVI'
>>>
>>> There are three examples of differently sourced NDVI data sets.
>>>
>>> The 'GIMMS' version is Example 2.
>>>
>>> Please read the associated text description and the actual script.
>>> As noted, the netCDF file is poorly written.
>>>
>>>
>>>
>>> On Wed, May 9, 2018 at 8:14 AM, Mary Haley <haley at ucar.edu> wrote:
>>>
>>>> Hi Jalal,
>>>>
>>>> I took a look at one of these NDVI data files, and noticed that the
>>>> lat/lon coordinate arrays on the file have no attributes, which is not good.
>>>>
>>>> These arrays should at least have "units" and "long_name" attributes
>>>> and units should be something like "degrees_north" and "degrees_east".  For
>>>> rectilinear data (data with lat/lon coordinate arrays), NCL needs these
>>>> units to be something that indicates they are in degrees, or otherwise it
>>>> can't be sure it is plotting the data correctly.
>>>>
>>>> It's always important to look at your data when you get errors like
>>>> this.  You do have:
>>>>
>>>> printVarSummary(ndvi)
>>>>
>>>> but I also added:
>>>>
>>>> printVarSummary(ndvi&lat)
>>>> printVarSummary(ndvi&lon)
>>>>
>>>> in order to look at the lat/lon arrays to see what the units were and
>>>> you can see there are none:
>>>>
>>>> Variable: lat (coordinate)
>>>> Type: double
>>>> Total Size: 17280 bytes
>>>>             2160 values
>>>> Number of Dimensions: 1
>>>> Dimensions and sizes: [lat | 2160]
>>>> Coordinates:
>>>> Number Of Attributes: 0
>>>>
>>>>
>>>> To fix this, I did this after reading in ndvi:
>>>>
>>>>   ndvi           = f->ndvi(0,:,:)
>>>>   ndvi&lat at units = "degrees_north"    ; Fix the units
>>>>   ndvi&lon at units = "degrees_east"
>>>>   printVarSummary(ndvi)
>>>>
>>>> I also had to remove the reference to "ndvi at long_name" in a later
>>>> title string, because ndvi doesn't have a long_name attribute.
>>>>
>>>> --Mary
>>>>
>>>> On Wed, May 9, 2018 at 3:44 AM, Md. Jalal Uddin <dmjalal90 at gmail.com>
>>>> wrote:
>>>>
>>>>> Hi all,
>>>>>
>>>>> I tried to plot gimms ndvi (https://ecocast.ar
>>>>> c.nasa.gov/data/pub/gimms/3g.v1/) data by masking. I am getting
>>>>> following errors. I used  copy_VarCoords(ndvi,ndvi_mask) command to
>>>>> fix it but failed. Please help to solve this problem. Please find my script
>>>>> in the attachment.
>>>>>
>>>>> (0) check_for_y_lat_coord: Warning: Data either does not contain a
>>>>> valid latitude coordinate array or doesn't contain one at all.
>>>>> (0) A valid latitude coordinate array should have a 'units' attribute
>>>>> equal to one of the following values:
>>>>> (0)     'degrees_north' 'degrees-north' 'degree_north' 'degrees
>>>>> north' 'degrees_N' 'Degrees_north' 'degree_N' 'degreeN' 'degreesN' 'deg
>>>>> north'
>>>>> (0) check_for_lon_coord: Warning: Data either does not contain a
>>>>> valid longitude coordinate array or doesn't contain one at all.
>>>>> (0) A valid longitude coordinate array should have a 'units'
>>>>> attribute equal to one of the following values:
>>>>> (0)     'degrees_east' 'degrees-east' 'degree_east' 'degrees east'
>>>>> 'degrees_E' 'Degrees_east' 'degree_E' 'degreeE' 'degreesE' 'deg east'
>>>>> (0) check_for_y_lat_coord: Warning: Data either does not contain a
>>>>> valid latitude coordinate array or doesn't contain one at all.
>>>>> (0) A valid latitude coordinate array should have a 'units' attribute
>>>>> equal to one of the following values:
>>>>> (0)     'degrees_north' 'degrees-north' 'degree_north' 'degrees
>>>>> north' 'degrees_N' 'Degrees_north' 'degree_N' 'degreeN' 'degreesN' 'deg
>>>>> north'
>>>>> (0) check_for_lon_coord: Warning: Data either does not contain a
>>>>> valid longitude coordinate array or doesn't contain one at all.
>>>>> (0) A valid longitude coordinate array should have a 'units'
>>>>> attribute equal to one of the following values:
>>>>> (0)     'degrees_east' 'degrees-east' 'degree_east' 'degrees east'
>>>>> 'degrees_E' 'Degrees_east' 'degree_E' 'degreeE' 'degreesE' 'deg east'
>>>>> warning:Attempt to reference attribute (long_name) which is undefined
>>>>>
>>>>> Cheers,
>>>>> Jalal
>>>>> --
>>>>> *Md. Jalal Uddin*
>>>>> MSc in Applied Meteorology (English Language)
>>>>> Nanjing University of Information, Science and Technology, China
>>>>> Jasmine Jiangsu Government Scholar
>>>>> Cell: +8613260859092
>>>>> Office: Beichen Building, School of Geography and Remote Sensing, Room
>>>>> No. 406
>>>>>
>>>>> *AND *
>>>>> B.Sc. in Disaster Management (Hons.)
>>>>> Patuakhali Science and Technology University, Bangladesh.
>>>>> Cell: +8801792052662, +8801838613203
>>>>> Email: dmjalal90 at gmail.com
>>>>> Web: www.dmjalal90.weebly.com
>>>>> Facebook: jalal.hossen.39
>>>>> LinkedIn: https://bd.linkedin.com/in/md-jalal-uddin-80a026b0
>>>>> Twitter: dmjalal90
>>>>> Skype: dmjalal90
>>>>>
>>>>> _______________________________________________
>>>>> ncl-talk mailing list
>>>>> ncl-talk at ucar.edu
>>>>> List instructions, subscriber options, unsubscribe:
>>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> ncl-talk mailing list
>>>> ncl-talk at ucar.edu
>>>> List instructions, subscriber options, unsubscribe:
>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>
>>>>
>>>
>>
>>
>> --
>> *Md. Jalal Uddin*
>> MSc in Applied Meteorology (English Language)
>> Nanjing University of Information, Science and Technology, China
>> Jasmine Jiangsu Government Scholar
>> Cell: +8613260859092
>> Office: Beichen Building, School of Geography and Remote Sensing, Room
>> No. 406
>>
>> *AND *
>> B.Sc. in Disaster Management (Hons.)
>> Patuakhali Science and Technology University, Bangladesh.
>> Cell: +8801792052662, +8801838613203
>> Email: dmjalal90 at gmail.com
>> Web: www.dmjalal90.weebly.com
>> Facebook: jalal.hossen.39
>> LinkedIn: https://bd.linkedin.com/in/md-jalal-uddin-80a026b0
>> Twitter: dmjalal90
>> Skype: dmjalal90
>>
>
>


-- 
*Md. Jalal Uddin*
MSc in Applied Meteorology (English Language)
Nanjing University of Information, Science and Technology, China
Jasmine Jiangsu Government Scholar
Cell: +8613260859092
Office: Beichen Building, School of Geography and Remote Sensing, Room No.
406

*AND *
B.Sc. in Disaster Management (Hons.)
Patuakhali Science and Technology University, Bangladesh.
Cell: +8801792052662, +8801838613203
Email: dmjalal90 at gmail.com
Web: www.dmjalal90.weebly.com
Facebook: jalal.hossen.39
LinkedIn: https://bd.linkedin.com/in/md-jalal-uddin-80a026b0
Twitter: dmjalal90
Skype: dmjalal90
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180511/92ee4fb4/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gimms.ncl
Type: application/octet-stream
Size: 7884 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180511/92ee4fb4/attachment.obj>


More information about the ncl-talk mailing list