[ncl-talk] [EXT]Re: Adding two arrays - with missing values in different rows and columns
JETAL SUTARIYA
jetal164 at email.arizona.edu
Sun Apr 3 13:12:11 MDT 2022
Hi Rashed,
Thank you very much for your helpful suggestion. It worked well to solve
total soil moisture correctly!
Best regards,
Jetal
On Sat, Apr 2, 2022 at 5:39 PM Rashed Mahmood <rashidcomsis at gmail.com>
wrote:
> *External Email*
> Hi Jetal,
> I do not think that the way you are trying to get the sum is the correct
> way to get your desired results.
>
> I think you need to use dimension sum function, e.g. something as:
>
> Assuming that you are using a loop/or some select time steps, as
> x=1,2,3,...
>
> combVar=var3(0:1,:,:) ; tric to define a variable with metadata
> combVar=var3 at _FillValue ;
> combVar(0,:,:)=var3(x,:,:)
> combVar(1,:,:)=var4(x,:,:)
>
> var5 = dim_sum_n_Wrap(combVar,0) ; This will sum if both var3 and var4
> are not missing, otherwise will use values from either var3 or var4
> (whichever is not missing). It will result in missing if both values are
> missing.
>
> delete(combVar) ; delete before next iteration.
>
> HTH
> Rashed
>
>
>
>
> On Sat, Apr 2, 2022 at 3:07 PM JETAL SUTARIYA via ncl-talk <
> ncl-talk at mailman.ucar.edu> wrote:
>
>> Hi NCL user community,
>>
>> I am trying to add two arrays: SMAP soil moisture L3 am and pm arrays, to
>> obtain total soil moisture.
>> Soil moisture total(var5) is var3+var4 but when there are missing values
>> in either of those arrays, then var5 is also having missing values.
>> Instead, I want to use sm_pm(var4) when sm_am(var3) is having missing values
>> and if sm_pm(var4) is having missing values then use sm_am(var3), and when
>> both are having nonmissing values then sum them. I guess NCL does not
>>
>> I use below code but var5 is solved for line 3 of the code rather than
>> both the line 3 and line 4, so where var4 is missing it does not use var3
>> value:
>> var3 = sm_am(x,:,:) ;sm_am = soil moisture am data x = time dimension
>> var4 = sm_pm(x,:,:) ;sm_pm = soil moisture pm data x = time dimension
>> var5 = where(ismissing(var3), var4, var3+var4)
>> var5 = where(ismissing(var4), var3, var3+var4)
>>
>> Please suggest a way to get the correct total soil moisture array such
>> that these conditions are satisfied.
>>
>> I appreciate your help in finding a solution.
>>
>> Thank you,
>> Jetal
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at mailman.ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> https://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20220403/472dc846/attachment.html>
More information about the ncl-talk
mailing list