Re: merge levels from different nc files

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Tue Apr 15 2014 - 20:26:16 MDT

Hi Ahmad,

You can use array_append_record:

http://www.ncl.ucar.edu/Document/Functions/Contributed/array_append_record.shtml

but you will need to transpose the two arrays because this function wants the “fixed” dimensions to be the rightmost dimensions.

Here’s an example.

;---Create two dummy arrays, time by level
ntim = 10
nlev1 = 5
nlev2 = 7
U1 = random_uniform(-100,100,(/ntim,nlev1/))
U2 = random_uniform(-100,100,(/ntim,nlev2/))

;---Create dummy coordinate values
time = ispan(1,ntim,1)
lev1 = (/1000,900,850,100,10/)
lev2 = (/7,6,5,4,3,2,1/)
time!0 = "time"
time!0 = "time"
lev1!0 = "lev"
lev2!0 = "lev"
time@units = "dummy"
lev1@units = "hPa"
lev2@units = "hPa"

;---Attach metadata to U1 and U2
U1!0 = "time"
U2!0 = "time"
U1!1 = "lev"
U2!1 = "lev"
U1&time = time
U2&time = time
U1&lev = lev1
U2&lev = lev2

printVarSummary(U1)
printVarSummary(U2)

;
; To use array_append_record, you must have level
; be the leftmost dimension. All other dimensions
; have to be the same size.
;
U1_t = transpose(U1) ; lev x time
U2_t = transpose(U2) ; lev x time

;---Combine the two arrays and transpose back to original ordering
U = transpose(array_append_record (U1_t,U2_t,0))
printVarSummary(U)

On Apr 9, 2014, at 9:39 AM, Ahmad Farsyud <a.farsyud@gmail.com> wrote:

> Hallo Folks,
>
> I am wondering how to combine levels from two different ncl files with same grid resolution. Let' say
>
> U1= [time, level] ; level==>1000,...,10 hPa
> U2= [time, level] ; level==>7,...,1 hPa
>
> I need to merge the level so that I will have U with levels 1000----1 hPa.
> Thanks
> _______________________________________________
> 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 Tue Apr 15 20:26:28 2014

This archive was generated by hypermail 2.1.8 : Wed Apr 16 2014 - 09:14:14 MDT