Re: Is there any method similar as ndtooned but can move the missing values?

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Sun Jun 01 2014 - 22:36:08 MDT

Hi Dachao,

You can use the “ind” function to get all the missing locations from the 1D array, and then the “ind_resolve” function to resolve the original values back to their original locations.
But, have you looked at the “where” function, which allows you to operate on the original array without having to convert it to 1D first?

   http://www.ncl.ucar.edu/Document/Functions/Built-in/where.shtml

If you really need to work with a 1D array, then this is how you can use “ind” and “ind_resolve” (UNTESTED):

  a1D = ndtooned(a)
  ind_nomsg = ind(.not.ismissing(a1D))
  a1D_nomsg = a1D(ind_nomsg) ; Strip off all missing values
  npts = dimsizes(ind_nomsg)

;---Store indexes into original "a" array.
  dsizes_a = dimsizes(a)
  ind_res = ind_resolve(ind_nomsg,dsizes_a)

...Do something with a1D_nomsg...

;---Put modified values back into original positions.
  do n=0,npts-1
     a(ind_res(n,0),ind_res(n,1),ind_res(n,2)) = a1D_nomsg(n)
  end do

http://www.ncl.ucar.edu/Document/Functions/Built-in/ind_resolve.shtml
http://www.ncl.ucar.edu/Document/Functions/Built-in/ind.shtml

—Mary

On May 31, 2014, at 12:38 AM, 小螃蟹直着走 <54215407@qq.com> wrote:

> Dear all,
>
> I want to convert a multi-dimensional array to one-dimensional array, but there exist some missing values in the multi-dimensional, so I want move these missing values in the oen-dimensional array. Then do some progress, is there still any way I can re-convert the one-dimensional to multi-dimensional array?
>
> Thanks for your time. Have a nice afternoon.
>
> Best regards,
> Dachao
> --------------------------------------------------
> Dachao Jin, Post-Doctor
> ARC-ENV, Center for Advanced Information Science and Technology,
> University of Aizu, Tsuruga, Ikki-machi,
> Aizuwakamatsu-shi, Fukushima 965-8580,
> Japan
>
> Tel: +81242 37-2562
> E-mail: jindc@u-aizu.ac.jp
> ResearchGate: https://www.researchgate.net/profile/Dachao_Jin
> _______________________________________________
> 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
Received on Sun Jun 1 22:36:18 2014

This archive was generated by hypermail 2.1.8 : Tue Jun 03 2014 - 11:40:09 MDT