# Re: Change of dimension size

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed Mar 06 2013 - 16:33:28 MST

The question is unclear.

NCL array indexing starts at 0.
When you have an array on the right hand side, it must
match ("conform") to the left hand side if the left hand
side array exists.

undef("make_big")
function make_big(x, d2big)
local dimx, rankx, xnew
begin
dimx = dimsizes(x)
rankx= dimsizes(dimx)
if (rankx.ne.8) then
print("make_big: rankx="+rankx+": expecting rank=8")
exit
end if

xnew = new ( (/dimx(0),dimx(1), d2big, dim(3) \
,dimx(4),dimx(5),dimx(6),dimx(7)/) \
,typeof(x), getFillValue(x))
xnew(:,:,0:dimx(2)-1,:,:,:,:,:) = (/ x /)
return(xnew)
end

If you want to add some values from some array

xbig = make_big(x, d2big)
x(:,:,11,:,:,:,:,:) = (/ z /) ; dimension sizes must match

you can replace values

x(:,:,3,:,:,:,:,:) = (/ q /) ; dimension sizes must match

On 3/6/13 3:46 PM, Jianwei Li wrote:
> Hi,
> Based on the make_big function replied a few days ago in this list, I
> have successfully changed the dimension sizes for my case.
>
> However, how can I replace the old values in that dimension I changed?
>
> Take my case below as an example, if I have changed "soil size: 10" to
> "soil size: 11", the output values for the original "size 10" are kept
> unchanged, with "size 11" being empty currently. I need to give 11 new
> values for all of them, how can I do it?
>
> Can this also be done in the make_big function?
>
> I appreciate any help!
> Jianwei
>
>
>
>
> On Tue, Mar 5, 2013 at 1:08 PM, Jianwei Li <jianweili.2@gmail.com> wrote:
>
>> Hi,
>>
>> I have a netcdf file with 5 dimensions and 8 variables as shown below.
>> I want to change the dimension "soil size: 10" to "soil size: 20", with the output file should keep all variables and data from the original file.
>>
>>
>>
>> Does anyone have the idea?
>>
>> Sincerely,
>> Jianwei
>>
>>
>>
>>
>> [1] "file E:/Jianwei/sample.nc <http://gridinfo.nc> has 5 dimensions:"
>> [1] "longitude Size: 360"
>> [1] "latitude Size: 150"
>> [1] "patch Size: 1"
>> [1] "soil Size: 10"
>> [1] "time Size: 12"
>> [1] "------------------------"
>> [1] "file E:/Jianwei/sample.nc <http://gridinfo.nc> has 8 variables:"
>> [1] "float area[longitude,latitude] Longname:area Missval:-99"
>> [1] "int iveg[longitude,latitude] Longname:classification of veg type Missval:-1"
>> [1] "float patchfrac[longitude,latitude,patch] Longname:Patch fraction; 1.0 for 1x1 grid Missval:-1"
>> [1] "int isoil[longitude,latitude] Longname:Zobler soil type Missval:-1"
>> [1] "float soilmoist[longitude,latitude,soil,time] Longname:Soil moisture profile from previous GSWP runs Missval:-1"
>> [1] "float soiltemp[longitude,latitude,soil,time] Longname:Soil temperature profile from previous GSWP runs Missval:-1"
>> [1] "float SnowDepth[longitude,latitude,time] Longname:SnowDepth Missval:-1"
>> [1] "float LAI[longitude,latitude,time] Longname:Leaf area index Missval:-1"
>>
>>
>
>
>
> _______________________________________________
> 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 Wed Mar 6 16:33:28 2013

This archive was generated by hypermail 2.1.8 : Thu Mar 07 2013 - 08:55:58 MST