[ncl-talk] Masked data

Dennis Shea shea at ucar.edu
Mon Nov 29 13:12:59 MST 2021


Maybe ....  code is not tested

+++always use PrintVarSummary when debugging+++

    a   = addfile("geo_em.nc","w")
    lu  = wrf_user_getvar(a,"LU_INDEX",-1)

    f   = addfile("wrf_mask.nc","r")
    marray  = f->WRF_mask
    printVarSummary(marray)
    printMinMax(marray, False)
    print("-----------------")


    lu_mask = mask(lu,marray,1)
    printVarSummary(lu_mask)
    printMinMax(lu_mask, False)
    print("-----------------")

    n11 = num(lu_mask.eq.11)
    n17 = num(lu_mask.eq.17)
    print("n11="+n11+ ;  n17="+n17)
    print("-----------------")

    lu_index = where(lu_mask.eq.17, 11, lu)                  ; replace value
    printVarSummary(lu_index)
    printMinMax(lu_indek, False)
    print("-----------------")

    a->LU_INDEX = *(/* lu_index* /)*                                    ;
overwrite values on netCDF file
or

    copy_VarMeta(lu, lu_index)
    lu_index at NCL_task "Index 17 replaced with 11"  ; add informative
attribute
    printVarSummary(lu_index)
    printMinMax(lu_index, False)
    print("-----------------")

    a->LU_INDEX =  lu_index                        ; replace values and add
new meta data

On Mon, Nov 29, 2021 at 1:11 AM ali mughal via ncl-talk <
ncl-talk at mailman.ucar.edu> wrote:

> Dear NCL users
> I use the following simple code to create map (C) in the attached image.
> As you can see, I am trying to change the land use index inside the mask
> from 17 to 11, which I succeeded in achieving. However, due to masking I
> lose the rest of the data.
>
>     a = addfile("geo_em.nc","w")
>     lu=wrf_user_getvar(a,"LU_INDEX",-1)
>     f   = addfile("wrf_mask.nc","r")
>      marray   = f->WRF_mask
>      lu_mask = mask(lu,marray,1)
>       a->LU_INDEX=where(lu_mask .eq. 17,11,a->LU_INDEX)
>
> To correct this problem I do step D and E in the attached image but I
> still am unable to achieve the required result. Can someone tell me how to
> correct this issue ?
>
>
> _______________________________________________
> 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/20211129/b1d0e9e0/attachment.html>


More information about the ncl-talk mailing list