[ncl-talk] need help to edit maps to exclude color on the ocean and contour values on land points

Mary Haley haley at ucar.edu
Thu Jan 26 10:17:55 MST 2017


Hi Ruksana,

I should have been more thorough in my previous email to you, because it's
always a concern when your data is being read off a file and it has the
incorrect _FillValue.

I see from the global attributes on the file that the data was processed
with CDO. Perhaps this command was used incorrectly and it didn't propagate
the correct missing value? Or else CDO did something incorrect.

​T
o quickly answer your question, I'm not actually sure how to get the full
precision of the actual minimum value of your data.  NCL prints it as
-1.073742e+09
​ and I can't seem to get more precision than that.  Ncdump (which is an
application that comes with NetCDF) also prints the value as
-1.073742e+-09.​

​Perhaps one of our other developers can weigh in here.​

​A better way to fix your missing values might be to simply redefine the
_FillValue attribute to be the actual minimum of your data:

;---One way to fix the missing value                                 rstn_fix
= rstn_orig
  rstn_fix at _FillValue = rstn_min
​

For debugging purposes, I've included a script that plots your data after
it's fixed, and then draws dots where there are missing value locations.
Note also that before I fixed the data values, I counted the number of
missing values using "num" and "ismissing", and it said there were 0
missing values:

====================================================================
Number of original values that are equal to the missing value as
  defined on the file: 0
Number of fixed values that are missing: 297
====================================================================

Hopefully this helps clear things up.

--Mary





On Thu, Jan 26, 2017 at 5:22 AM, Ruksana Abedin <ruksana.abedin at gmail.com>
wrote:

> Hi Mary,
>
> Thanks a lot. This does perfectly solves the problem. Here is the updated
> figure.
> Is there any kind of documentation where I can learn how to know the
> actual value of -1.07374e+09? I am asking this because I am confused about
> setting the correct range in the bias map. Please ignore this query if not
> apprpriate for this platform.
>
> Best regards,
> Ruksana
>
> On Thu, Jan 26, 2017 at 5:34 AM, Mary Haley <haley at ucar.edu> wrote:
>
>> Ruksana,
>>
>> If you look at the output from the "printMinMax" commands, you will see
>> that you have very large negative values for the minimum:
>>
>> daily mean temperature analysis [degC] (degC) : min=-1.07374e+09
>> max=1.78964
>> daily mean temperature analysis [degC] (degC) : min=-1.07374e+09
>> max=4.93295
>> daily mean temperature analysis [degC] (degC) : min=-1.07374e+09
>> max=2.17995
>> daily mean temperature analysis [degC] (degC) : min=-1.07374e+09
>> max=1.05083
>>
>> This indicates to me that your missing values are not correct on the
>> file. You can easily fix this by setting this minimum value to missing for
>> all four values:
>>
>> tmin = min(TmeanM0)
>> TmeanM0 = where(TmeanM0.eq.tmin,TmeanM0 at _FillValue,TmeanM0)
>> TmeanM1 = where(TmeanM1.eq.tmin,TmeanM1 at _FillValue,TmeanM1)
>> TmeanM2 = where(TmeanM2.eq.tmin,TmeanM2 at _FillValue,TmeanM2)
>> TmeanM3 = where(TmeanM3.eq.tmin,TmeanM3 at _FillValue,TmeanM3)
>>
>>
>> --Mary
>>
>>
>>
>> On Wed, Jan 25, 2017 at 3:45 AM, Ruksana Abedin <ruksana.abedin at gmail.com
>> > wrote:
>>
>>> Dear Mary and NCL users,
>>>
>>> I have got similar problem while making bias maps for temperature. The
>>> script, variable summary, min-max, the panel plot temp_mean_diff(3).jpg.
>>> and the input files are given. This time missing value has been set
>>> properly but still I am getting colour on the Ocean points.
>>>
>>> These biases are calculated by subtracting observation from the climate
>>> model. However, if I do the opposite, bias = observation-model; I get no
>>> problem with the same script and the panel plot is temp_mean_diff(4).jpg.
>>> Can you please help me to get rid of this problem. I need to have the
>>> bias maps using the first method.
>>> Thank you very much for your kind support, this really keeps me going on
>>> with using ncl.
>>>
>>> Best regards,
>>> Ruksana
>>>
>>> begin
>>>
>>> ; read in data for bias maps
>>>
>>> fM0=addfile("/.../WAH_APHRO_TMEAN_1988_2007_DJF_bias.nc", "r");
>>> fM1=addfile("/.../WAH_APHRO_TMEAN_1988_2007_MAM_bias.nc", "r");
>>> fM2=addfile("/.../WAH_APHRO_TMEAN_1988_2007_JJAS_bias.nc", "r");
>>> fM3=addfile("/.../WAH_APHRO_TMEAN_1988_2007_ON_bias.nc", "r");
>>> ;***********************************************************
>>> ********************************************************************
>>> ; read variable
>>>
>>> TmeanM0 = fM0 ->tave(:,:,:)
>>> timeM0 = fM0 ->time
>>> latM0 = fM0 ->lat
>>> lonM0 = fM0 ->lon
>>>
>>> TmeanM1 = fM1 ->tave(:,:,:)
>>> timeM1 = fM1 ->time
>>> latM1 = fM1 ->lat
>>> lonM1 = fM1 ->lon
>>>
>>> TmeanM2 = fM2 ->tave(:,:,:)
>>> timeM2 = fM2 ->time
>>> latM2 = fM2 ->lat
>>> lonM2 = fM2 ->lon
>>>
>>> TmeanM3 = fM3 ->tave(:,:,:)
>>> timeM3 = fM3 ->time
>>> latM3 = fM3 ->lat
>>> lonM3 = fM3 ->lon
>>>
>>> printVarSummary(TmeanM0)
>>> printVarSummary(TmeanM1)
>>> printVarSummary(TmeanM2)
>>> printVarSummary(TmeanM3)
>>>
>>> printMinMax(TmeanM0, 0)
>>> printMinMax(TmeanM1, 0)
>>> printMinMax(TmeanM2, 0)
>>> printMinMax(TmeanM3, 0)
>>>
>>> ;***********************************************************
>>> ; create plots
>>> ;***********************************************************
>>>
>>>   wks = gsn_open_wks("eps","temp_mean_diff")
>>>   plot = new(4,graphic)
>>>   gsn_define_colormap(wks,"temp_diff_18lev")      ; choose colormap
>>>
>>>   ;gsn_reverse_colormap(wks)
>>>   res                          = True
>>>   res at gsnDraw                  = False
>>>   res at gsnFrame                   = False
>>>   res at cnInfoLabelOn            = False
>>>   res at cnFillOn                 = True                 ; turn on color
>>>   res at cnLinesOn                = False             ; turn off contour
>>> lines
>>>   res at cnLevelSpacingF          = 0.10              ; contour interval
>>>   res at cnFillDrawOrder          = "PreDraw"         ; draw contours first
>>>   res at lbLabelStride            = 2                 ; stride on label bar
>>>   res at gsnSpreadColors          = True              ; use full colormap
>>>   res at gsnSpreadColorEnd        = -3                ; -3 don't use land
>>> color
>>>   res at gsnAddCyclic             = False             ; regional data
>>>   res at gsnStringFontHeightF     = 0.01
>>>   res at tiMainString             = ""
>>>   res at gsnRightString           = ""
>>>   ;res at mpProjection            = "LambertConformal"
>>>   ;res at gsnMaskLambertConformal = True
>>>   res at gsnLeftString            = ""
>>>   res at mpMaxLatF                = 30;max(lat)  ; zoom in on region
>>>   res at mpMinLatF                = 15;min(lat)
>>>   res at mpMinLonF                = 83;min(lon)
>>>   res at mpMaxLonF                = 97; max(lon)
>>>   res at mpCenterLonF             = 10                ; def is zero
>>>   res at mpLandFillColor          = "Transparent"
>>>   res at cnLevelSelectionMode= "ManualLevels"
>>>   res at cnLineLabelsOn = False
>>>    res at lbLabelAutoStride   = True
>>>   res at lbLabelBarOn = False
>>>   TmeanM1 at _FillValue    = 0.0
>>>   TmeanM1 at _FillValue    = -99.9
>>>   res at cnMinLevelValF      = -5.
>>>   res at cnMaxLevelValF      = 5.; 1
>>>   res at cnLevelSpacingF     = 1; 1
>>>   res at lbLabelAutoStride   = True
>>>
>>> plot(0) = gsn_csm_contour_map(wks,TmeanM0(0,:,:),res)
>>> plot(1) = gsn_csm_contour_map(wks,TmeanM1(0,:,:),res)
>>> plot(2) = gsn_csm_contour_map(wks,TmeanM2(0,:,:),res)
>>> plot(3) = gsn_csm_contour_map(wks,TmeanM3(0,:,:),res)
>>>
>>> ;***********************************************************
>>> ; create panel
>>> ;***********************************************************
>>> resP                          = True
>>> resP at gsnFrame                 = False
>>> resP at gsnMaximize              = True
>>> resP at gsnPanelLabelBar         = True   ; add common labelbar
>>> ;resP at lbLabelFontHeightF       = 0.005
>>> ;resP at gsnPanelMainString       =""
>>> ;resP at txString                 =""
>>> resP at gsnPanelFigureStrings    =(/"DJF","MAM","JJAS","ON"/)            ;
>>> add strings to panel
>>> gsn_panel(wks,plot,(/4,4/),resP)          ; now draw as one plot
>>>
>>> end
>>>
>>> ;***********************************************************
>>> ********************************************************************
>>>
>>> *Variable information*
>>> Variable: TmeanM0
>>> Type: float
>>> Total Size: 3480 bytes
>>>             870 values
>>> Number of Dimensions: 3
>>> Dimensions and sizes:   [time | 1] x [lat | 30] x [lon | 29]
>>> Coordinates:
>>>             time: [19980101..19980101]
>>>             lat: [15.25..29.75]
>>>             lon: [  83..  97]
>>> Number Of Attributes: 5
>>>   long_name :   daily mean temperature analysis [degC]
>>>   units :       degC
>>>   _FillValue :  -99.9
>>>   missing_value :       -99.9
>>>   level_description :   Earth surface
>>>
>>> Variable: TmeanM1
>>> Type: float
>>> Total Size: 3480 bytes
>>>             870 values
>>> Number of Dimensions: 3
>>> Dimensions and sizes:   [time | 1] x [lat | 30] x [lon | 29]
>>> Coordinates:
>>>             time: [19971016..19971016]
>>>             lat: [15.25..29.75]
>>>             lon: [  83..  97]
>>> Number Of Attributes: 5
>>>   long_name :   daily mean temperature analysis [degC]
>>>   units :       degC
>>>   _FillValue :  -99.9
>>>   missing_value :       -99.9
>>>   level_description :   Earth surface
>>>
>>> Variable: TmeanM2
>>> Type: float
>>> Total Size: 3480 bytes
>>>             870 values
>>> Number of Dimensions: 3
>>> Dimensions and sizes:   [time | 1] x [lat | 30] x [lon | 29]
>>> Coordinates:
>>>             time: [19980201..19980201]
>>>             lat: [15.25..29.75]
>>>             lon: [  83..  97]
>>> Number Of Attributes: 5
>>>   long_name :   daily mean temperature analysis [degC]
>>>   units :       degC
>>>   _FillValue :  -99.9
>>>   missing_value :       -99.9
>>>   level_description :   Earth surface
>>>
>>> Variable: TmeanM3
>>> Type: float
>>> Total Size: 3480 bytes
>>>             870 values
>>> Number of Dimensions: 3
>>> Dimensions and sizes:   [time | 1] x [lat | 30] x [lon | 29]
>>> Coordinates:
>>>             time: [19980501..19980501]
>>>             lat: [15.25..29.75]
>>>             lon: [  83..  97]
>>> Number Of Attributes: 5
>>>   long_name :   daily mean temperature analysis [degC]
>>>   units :       degC
>>>   _FillValue :  -99.9
>>>   missing_value :       -99.9
>>>   level_description :   Earth surface
>>> (0)     daily mean temperature analysis [degC]: min=-1.07374e+09
>>> max=1.78964
>>> (0)     daily mean temperature analysis [degC]: min=-1.07374e+09
>>> max=4.93295
>>> (0)     daily mean temperature analysis [degC]: min=-1.07374e+09
>>> max=2.17995
>>> (0)     daily mean temperature analysis [degC]: min=-1.07374e+09
>>> max=1.05083
>>>
>>>
>>>
>>> On Tue, Nov 29, 2016 at 5:37 PM, Mary Haley <haley at ucar.edu> wrote:
>>>
>>>> Sorry for the delay. I was out of the office last week.
>>>>
>>>> I assume you are talking about the contour line labels.  Try setting:
>>>>
>>>> res at cnLineLabelsOn = False
>>>>
>>>> I suggest that you visit our examples page at:
>>>>
>>>> http://test.www.ncl.ucar.edu/Applications/
>>>>
>>>> You will see lots of topics on this page, like "contour labels" and
>>>> "contour effects".  If you click on any one of the topics, you will see a
>>>> page with a list of examples, each with a sample NCL script and graphic.
>>>> This is one of the best ways to learn about the various graphical resources
>>>> in NCL and how to set them.
>>>>
>>>> Good luck,
>>>>
>>>> --Mary
>>>>
>>>>
>>>> On Mon, Nov 21, 2016 at 6:55 AM, Ruksana Abedin <
>>>> ruksana.abedin at gmail.com> wrote:
>>>>
>>>>> Dear Mary,
>>>>>
>>>>> Thank you very much for pointing at the issue and the fix for it. Now,
>>>>> the plot could be corrected with no color on the ocean points.
>>>>>
>>>>> But what about excluding the data values on the contours randomly on
>>>>> the land points? How can I disable this option? I have not set any resource
>>>>> for this, it is done somehow automatically. Please can you help me to avoid
>>>>> these values on the maps?
>>>>>
>>>>> Best regards,
>>>>> Ruksana
>>>>>
>>>>>
>>>>> On Mon, Nov 21, 2016 at 12:37 PM, Mary Haley <haley at ucar.edu> wrote:
>>>>>
>>>>>> Ruksana,
>>>>>>
>>>>>> It is very important that you look at your data before you assume
>>>>>> that NCL is plotting it incorrectly.
>>>>>>
>>>>>> If you look at "ppt3" with printVarSummary and printMinMax, you will
>>>>>> see that your missing values are not set correctly.
>>>>>>
>>>>>> Here's the printVarSummary, which claims the missing value is -99.9:
>>>>>>
>>>>>> Variable: ppt3
>>>>>> Type: float
>>>>>> Total Size: 3480 bytes
>>>>>>             870 values
>>>>>> Number of Dimensions: 3
>>>>>> Dimensions and sizes: [time | 1] x [lat | 30] x [lon | 29]
>>>>>> Coordinates:
>>>>>>             time: [14400..14400]
>>>>>>             lat: [15.25..29.75]
>>>>>>             lon: [  83..  97]
>>>>>> Number Of Attributes: 5
>>>>>>   long_name : daily precipitation analysis interpolated onto 0.5deg
>>>>>> grids [mm/day]
>>>>>>   units : mm/day
>>>>>>   _FillValue : -99.9
>>>>>>   missing_value : -99.9
>>>>>>   level_description : Earth surface
>>>>>>
>>>>>> However, if you do a printMinMax on pp3, you will see a maximum value
>>>>>> of 1e+20, which seems suspicious:
>>>>>>
>>>>>> daily precipitation analysis interpolated onto 0.5deg grids [mm/day]
>>>>>> (mm/day) : min=-2497.37   max=1e+20
>>>>>>
>>>>>> My guess is that you need to set the missing value of ppt3 to 1e20:
>>>>>>
>>>>>> ppt3 at _FillValue = 1e20
>>>>>>
>>>>>> --Mary
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Sat, Nov 19, 2016 at 2:35 PM, Ruksana Abedin <
>>>>>> ruksana.abedin at gmail.com> wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> I have plotted a panel of two bias maps. The plot, input files and
>>>>>>> the script is attached. Problem is although my data is only on land points,
>>>>>>> on the first bias map, the ocean is colored as orange, which should not be
>>>>>>> the case. And the maps show few values of the contours on the land points
>>>>>>> irregularly, but I do not want any values to be shown. Can you please help
>>>>>>> me to do these two corections?
>>>>>>>
>>>>>>> Thank you for your time and kind efforts.
>>>>>>>
>>>>>>> Best regards,
>>>>>>> Ruksana
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> begin
>>>>>>>
>>>>>>> ; read in data
>>>>>>>
>>>>>>> f3=addfile(".........../WAH_APHRO_1998_2007_ANN_sum_precip_bias.nc",
>>>>>>> "r");
>>>>>>> f4=addfile(".........../WAH_GPCC_1998_2007_ANN_sum_precip_bias.nc",
>>>>>>> "r");
>>>>>>>
>>>>>>> ppt3 = f3->precip
>>>>>>> time = f3->time
>>>>>>> lat = f3->lat
>>>>>>> lon = f3->lon
>>>>>>>
>>>>>>> ppt4 = f4->precip
>>>>>>> time = f4->time
>>>>>>> lat = f4->lat
>>>>>>> lon = f4->lon
>>>>>>>
>>>>>>> wks = gsn_open_wks("eps","ppt1")
>>>>>>> plot = new(2,graphic)
>>>>>>>
>>>>>>> printVarSummary(ppt3)
>>>>>>> printVarSummary(ppt4)
>>>>>>>
>>>>>>>  gsn_define_colormap(wks,"percent_11lev")      ; choose colormap
>>>>>>> for bias map
>>>>>>>   ;gsn_reverse_colormap(wks)
>>>>>>>   res                          = True
>>>>>>>   res at gsnDraw                  = False
>>>>>>>   res at gsnFrame                   = False
>>>>>>>   res at cnInfoLabelOn            = False
>>>>>>>   res at cnFillOn                 = True                 ; turn on
>>>>>>> color
>>>>>>>   res at cnLinesOn                = False             ; turn off
>>>>>>> contour lines
>>>>>>>   res at cnLevelSpacingF          = 0.10              ; contour
>>>>>>> interval
>>>>>>>   res at cnFillDrawOrder          = "PreDraw"         ; draw contours
>>>>>>> first
>>>>>>>   res at lbLabelStride            = 2                 ; stride on
>>>>>>> label bar
>>>>>>>   res at gsnSpreadColors          = True              ; use full
>>>>>>> colormap
>>>>>>>   res at gsnSpreadColorEnd        = -3                ; -3 don't use
>>>>>>> land color
>>>>>>>   res at gsnAddCyclic             = False             ; regional data
>>>>>>>   res at gsnStringFontHeightF     = 0.01
>>>>>>>   res at tiMainString             = ""
>>>>>>>   res at gsnRightString           = ""
>>>>>>>   ;res at mpProjection            = "LambertConformal"
>>>>>>>   ;res at gsnMaskLambertConformal = True
>>>>>>>   res at gsnLeftString            = ""
>>>>>>>   res at mpMaxLatF                = 30;max(lat)  ; zoom in on region
>>>>>>>   res at mpMinLatF                = 15;min(lat)
>>>>>>>   res at mpMinLonF                = 83;min(lon)
>>>>>>>   res at mpMaxLonF                = 97; max(lon)
>>>>>>>   res at mpCenterLonF             = 10                ; def is zero
>>>>>>>   res at mpLandFillColor          = "Transparent"
>>>>>>>   res at cnLevelSelectionMode= "ManualLevels"
>>>>>>>
>>>>>>>   res at cnMinLevelValF      =  -2150.00       ;for bias maps
>>>>>>>   res at cnMaxLevelValF      =  4450;100
>>>>>>>   res at cnLevelSpacingF     = 150 ; 150
>>>>>>>
>>>>>>>   res at lbLabelBarOn         = False
>>>>>>>   res at lbLabelAutoStride   = True
>>>>>>>   ppt3 at _FillValue    = 0.0
>>>>>>>   ppt3 at _FillValue    = -999
>>>>>>>
>>>>>>> plot(0) = gsn_csm_contour_map(wks,ppt3(0,:,:),res)
>>>>>>> plot(1) = gsn_csm_contour_map(wks,ppt4(0,:,:),res)
>>>>>>>
>>>>>>> ;***********************************************************
>>>>>>> ; create panel
>>>>>>> ;***********************************************************
>>>>>>>
>>>>>>> resP                          = True
>>>>>>> resP at gsnFrame                 = False
>>>>>>> resP at gsnMaximize              = True
>>>>>>> resP at gsnPanelLabelBar         = True
>>>>>>> resP at lbLabelFontHeightF       = 0.01
>>>>>>> gsn_panel(wks,plot,(/2,2/),resP)          ; now draw as one plot
>>>>>>>
>>>>>>> end
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> 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/20170126/faf2d9e6/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plot_wah.000001.png
Type: image/png
Size: 75599 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170126/faf2d9e6/attachment-0002.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plot_wah.000002.png
Type: image/png
Size: 191975 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170126/faf2d9e6/attachment-0003.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plot_wah.ncl
Type: application/octet-stream
Size: 3280 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170126/faf2d9e6/attachment-0001.obj 


More information about the ncl-talk mailing list