[ncl-talk] Issues adding variables to chart

David Brown dbrown at ucar.edu
Thu May 7 11:26:03 MDT 2015


Hi Steven,
Rick's answer will work, but the reason your solution had problems has
to do with the way the _FillValue attribute works in NCL.
If you have a variable that has a _FillValue attributes you can change
all instances of the _FillValue in the variable by assigning to the
_FillValue. Supposing the _FillValue initially is set to -9999:
you can change all instances of -9999 in the variable (say 'v')  to 0
with this statement:
v at _FillValue = 0.0
However this means that 0.0 is now the _FillValue and all locations
with 0.0 will propagate as a _FillValue to the result of any operation
such as addition. The addition will not be performed for any element
of v that is 0.0. Instead the result will be set to 0.0 since it is
the _FillValue. The way to get the addition to proceed is to delete
the _FillValue attribute after you have set it to 0.0:

v at _FillValue = 0.0
delete(v at _FillValue)

 -dave





On Thu, May 7, 2015 at 9:19 AM, Rick Brownrigg <brownrig at ucar.edu> wrote:
> ...last one got away from me too quick...as I was saying...
>
> Steven,
>
> Yes it looks like the missing values is the culprit in your case; for more
> check out:
>
>
> http://ncl.ucar.edu/Document/Manuals/Ref_Manual/NclExpressions.shtml#MissingValues
>
> In any case, assuming var2 is the variable with missing values, then perhaps
> try something like:
>
>    var = where(ismissing(var2), var1, var1 + var2)
>
> Hope that helps...
> Rick
>
> On Thu, May 7, 2015 at 9:16 AM, Rick Brownrigg <brownrig at ucar.edu> wrote:
>>
>> Hi Steven,
>>
>> Yes a quick test indicates that the missing_values is the culprit (for
>> more, check out:
>>
>>
>> On Thu, May 7, 2015 at 8:13 AM, BLIUJUS, STEVEN D CTR USAF AFMC
>> AFLCMC/HBAW-OL <steven.bliujus.3.ctr at us.af.mil> wrote:
>>>
>>> I am trying to take two files and add the variables together. One
>>> variable
>>> has data over water while the other has missing values, when I try adding
>>> the values, nothing prints out for the areas over the ocean. I tried
>>> setting
>>> the variables to 0 instead of missing values but that did not work
>>> either. I
>>> have attached three images: var1, var2, and var. The variable var is the
>>> addition, and the addition gets done over land but not over water. Not
>>> sure
>>> why this is occurring, my only guess is the struggle with missing data.
>>> However, when I look at var, it doesn't look as though it is adding the
>>> variables properly either since the max for var is 2.49807, but the max
>>> for
>>> var2 is 2.544, so there is an obvious discrepancy. Here is my info:
>>>
>>> 1. I am using Version 6.1.2
>>> 2. My Script:
>>>
>>> load "/home/bliujuss/ncl/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>>> load "/home/bliujuss/ncl/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
>>> load "/home/bliujuss/ncl/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>>> begin
>>>
>>> a=addfile("/home/bliujuss/Plots/MYD08_D3.051.timeAverage.1.nc","r")
>>> b=addfile("/home/bliujuss/Plots/MOD08_D3.051.timeAverage.0.nc","r")
>>> wks = gsn_open_wks("x11","plt_aod")
>>> gsn_define_colormap(wks,"3gauss")
>>>
>>> var1 = a->Deep_Blue_Aerosol_Optical_Depth_550_Land_QA_Mean(:,:)
>>> var2 = b->Optical_Depth_Land_And_Ocean_Mean(:,:)
>>>
>>> printVarSummary(var1)
>>> printMinMax(var1, True)
>>> printVarSummary(var2)
>>> printMinMax(var2, True)
>>>
>>>
>>> var = var1
>>> var = 0.0
>>> var = var2+var1
>>>
>>> printVarSummary(var)
>>> printMinMax(var, True)
>>>
>>> pltres = True
>>> pltres at tiMainString = "AOD550"
>>> pltres at cnFillOn = True
>>> pltres at gsnSpreadColors = False
>>> pltres at gsnAddCyclic = False
>>>
>>> pltres at cnLineLabelsOn = False
>>> pltres at cnLineLabelBackgroundColor = "white"
>>> ;plot = gsn_csm_contour_map_ce(wks,var({-46.2:46.5},{-4.5:184.5}),pltres)
>>> ;plot =
>>> gsn_csm_contour_map_ce(wks,var1({-46.2:46.5},{-4.5:184.5}),pltres)
>>> ;plot =
>>> gsn_csm_contour_map_ce(wks,var2({-46.2:46.5},{-4.5:184.5}),pltres)
>>> End
>>>
>>> 3. Files are attached
>>>
>>> 4. Images attached
>>>
>>> 5. No error message
>>>
>>> 6. gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-44)
>>>
>>>
>>>
>>> Steven Bliujus, Contractor
>>> SEMS/16WS WXE
>>> 557th Weather Wing
>>> DNS: 232-7151
>>>
>>>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>


More information about the ncl-talk mailing list