Re: converting 2D array to 3D array

From: juki juki <juky_emc2_at_nyahnyahspammersnyahnyah>
Date: Mon Apr 09 2012 - 15:01:37 MDT

Mary, thanks for reply. The enclosed data are (101 x 3) x 406 that mean: first hour has 101 x 406 array, the second hours (row 102th..202) has 101 x 406 array and soon.. Is it possible to save re-ordered 3D data to ASCII file or must be in netcdf? Another question, is it possible by ncl to produce a volumetric plot ? I want to make a 3D map plot from this data. Thus, I can see the distribution of the data in 3D map/plot (lat-long-time). From the enclosed data, time (year, month, day, hour) is located at 1st to 4th column, 5th column to end = data. Thanks again for such helps. JukY ________________________________ From: Mary Haley <haley_at_ucar.edu> To: juki juki <juky_emc2_at_yahoo.com> Cc: "ncl-talk_at_ucar.edu" <ncl-talk_at_ucar.edu> Sent: Monday, April 9, 2012 8:54 PM Subject: Re: converting 2D array to 3D array Juky, You enclosed a data file, but you didn't indicate how the data are written to this file, so I'm not sure how to read it in. You can go from a 2D array to a 3D array by using a combination of ndtooned, onedtond, and possibly reordering commands. I'm not sure how your 303 x 406 array is ordered with regard to the "3" and the "101" values. It depends on how it is laid out. That is, is it laid out as (3x101) x 406, or as (101x3) x 406? If it is (3x101) x 406, then you could do something like: ;---Convert from 303 x 406 to 3 x 101 x 406   data3d = onedtond(ndtooned(data2d),(/3,101,406/)) ;---Reorder to 101 x 406 x 3 data3d!0 = "dim0" data3d!1 = "dim1" data3d!2 = "dim2" data3d_reorder = data3d( dim1 | :, dim2 | :, dim0 | :) ;---Check the results   printVarSummary(data3d_reorder) If it's (101x3) x 406: ;---Convert from 303 x 406 to 101 x 3 x 406   data3d = onedtond(ndtooned(data2d),(/101,3,406/)) ;---Reorder to 101 x 406 x 3 data3d!0 = "dim0" data3d!1 = "dim1" data3d!2 = "dim2" data3d_reorder = data3d( dim0 | :, dim2 | :, dim1 | :) ;---Check the results   printVarSummary(data3d_reorder) I used "dim0", "dim1" as examples here, but you should use whatever names are appropriate for your data's dimensions, like "lat", "lon", "time", etc. --Mary On Apr 6, 2012, at 3:19 AM, juki juki wrote: > Hi all, > > I would like to convert 2D to 3D array and save it as ascii file (txt file).  Enclosed file is an example. This file is from 3 hours observation(hourly) for latitude -10:10 and longitude 70:160E. I want to convert this 2D (303 x 406) to become 3D (101 x 406x 3) and save it to ascii file or if it is not possible to binary file. I think, almost all of NCAR data like OLR is 3D array format, but in nc file, how to produce it for text file or binary file using ncl language ? Thanks for sharing.... > > JuKy > > > > > <200111.txt>_______________________________________________ > 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 Mon Apr 9 15:01:47 2012

This archive was generated by hypermail 2.1.8 : Fri Apr 13 2012 - 13:37:52 MDT