[ncl-talk] about where as mask in NCL

Dennis Shea shea at ucar.edu
Thu Feb 8 08:05:44 MST 2018


Based on the code segment you sent, I could see nothing wrong.

rPCT_NET = mPCT_NET
rPCT_NET = where(Mfc .eq. 1, PCT_NET, mPCT_NET)
-----

function where (
		condtnl_expr  ,
		true_value    ,
		false_value
	)

-----

I am sure that NCL's 'where' is working correctly. It is one of the most
commonly used functions within NCL.

printMinMax(Mfc,0)

Or, you can ftp the necessary files and we can look .

D


On Wed, Feb 7, 2018 at 3:38 PM, yogesh kumkar <yogeshkumkar at gmail.com>
wrote:

> Hello Dennis,
>
> Sorry for the misunderstanding.
>
> Here I explained in more details.
> In previous email, I gave an example of states which was misleading.
>
>
> ncl 113> printVarSummary(PCT_NET)
>
> *Variable: PCT_NET*
> Type: double
> Total Size: 2700000 bytes
>             337500 values
> Number of Dimensions: 2
> Dimensions and sizes:   [lsmlat | 450] x [lsmlon | 750]
> Coordinates:
> Number Of Attributes: 2
>   long_name :   percent plant functional type of gridcell
>   units :       unitless
>
> ncl 114> printVarSummary(mPCT_NET)
>
> *Variable: mPCT_NET*
> Type: double
> Total Size: 2700000 bytes
>             337500 values
> Number of Dimensions: 2
> Dimensions and sizes:   [lsmlat | 450] x [lsmlon | 750]
> Coordinates:
> ncl 115>
> ncl 116> printVarSummary(Mfc)
>
> *Variable: Mfc*
> Type: double
> Total Size: 2700000 bytes
>             337500 values
> Number of Dimensions: 2
> Dimensions and sizes:   [lat | 450] x [lon | 750]
> Coordinates:
> Number Of Attributes: 0
>
>
> I want to replace values from  *mPCT_NET *to  *PCT_NET *only where there
> is '1' in* Mfc.*
> Mfc has values 0 and 1 only.
>
> I am doing the following, but its not working as expected.
>
> FM = addfile(dir+"surfdata_c0Control.nc","w")
> ​rPCT_NET = mPCT_NET
> rPCT_NET = where(Mfc .eq. 1, PCT_NET, mPCT_NET)
> FM->PCT_PFT(2,:,:) = rPCT_NET
>
> In this figure, I want to replace/superimpose mPCT_NET to PCT_NET where
> there is 1 in Mfc only. In simple words, I want to crop fig1 (where Mfc==1)
> and paste/stick on fig 3.
>
> ncl 139> print(num(mPCT_NET.gt.0))
> (0)     113191
> ncl 140> print(num(Mfc.gt.0))
> (0)     136086
> ncl 141> print(num(PCT_NET.gt.0))
> (0)     172161
>
> I want to replace only 136086 values from mPCT_NET to PCT_NET, keeping the
> others unchanged.
>
> [image: Inline image 1]
> Thank you,
> Yogesh
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180208/a887bb91/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 86997 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180208/a887bb91/attachment.png>


More information about the ncl-talk mailing list