Re: Change of dimension size

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed Mar 06 2013 - 16:51:44 MST

x(:,:,11,:,:,:,:,:) = x(:,:,10,:,:,:,:,:)

On 3/6/13 4:48 PM, Jianwei Li wrote:
> Hi, Dennis,
> Sorry for confusing you.
> I have changed soil size from 10 to 11, but there is no variable values for
> soil size 11.
> If I want to copy all variable values of soil size 10 to soil size 11, how
> can I do it?
> Thank you again!
> Jianwei
>
>
> On Wed, Mar 6, 2013 at 5:33 PM, Dennis Shea <shea@ucar.edu> wrote:
>
>> 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)
>> ; add new values
>> 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?
>>>> I appreciate your help.
>>>>
>>>> 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<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:51:43 2013

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