Jianwei,
You may change time, soil to coordinate variables, or try this example:
 lon = 3
 lat = 2
 patch = 2
 soil = 2
 time = 2
 var = new((/time, soil, patch, lat, lon/), float)
 var = 12.3
 system("rm -f test.nc");
 f = addfile("test.nc", "c")
 dimNames = (/"time", "soil", "patch", "lat", "lon"/)  
 dimSizes = (/ -1   ,  soil,   patch,   lat,   lon /) 
 dimUnlim = (/ True , False,   False, False, False/)   
 filedimdef(f,dimNames,dimSizes,dimUnlim)
 filevardef(f, "var", typeof(var), dimNames)
 f->var = (/var/)
Wei
huangwei@ucar.edu
VETS/CISL
National Center for Atmospheric Research
P.O. Box 3000 (1850 Table Mesa Dr.)
Boulder, CO 80307-3000 USA
(303) 497-8924
On Mar 5, 2013, at 2:11 PM, Jianwei Li <jianweili.2@gmail.com> wrote:
> Hi Wei,
> I have tried modify that code to my case.
> Still, I found the issue is about the coordinate variable.
> In that case, lat, lon, lev and time are all coordinate variables and their dimension sizes can thus be modified.
> However, in my case, lat and lon are coordinate variables, but soil and time are not.  I need to change the dimension size of soil!
> Does this make sense to you?
> If soil and time can become coordinate variable as lon and lat, then I think I can follow what the code tells me.
> Any idea on the coordinate variable or relevant?
> Thanks.
> Jianwei
> 
> 
> 
> On Tue, Mar 5, 2013 at 2:52 PM, Wei Huang <huangwei@ucar.edu> wrote:
> Jianwei,
> 
> In that example, some variables have 4 dimensions,
> and lat, lon are two of those dimensions.
> That example certainly won't work for your case directly.
> You have to modify it to your case.
> 
> Wei
> 
> huangwei@ucar.edu
> VETS/CISL
> National Center for Atmospheric Research
> P.O. Box 3000 (1850 Table Mesa Dr.)
> Boulder, CO 80307-3000 USA
> (303) 497-8924
> 
> 
> 
> 
> 
> 
> On Mar 5, 2013, at 12:17 PM, Jianwei Li <jianweili.2@gmail.com> wrote:
> 
>> Wei,
>> I followed this method yesterday but it turns out that that code is for coordinate variable.
>> That is, only lon and lat work but other dimensions not working.
>> Do you know why or how to operate on variables other than lon and lat?
>> Thanks!
>> Jianwei
>> 
>> On Tue, Mar 5, 2013 at 1:14 PM, Wei Huang <huangwei@ucar.edu> wrote:
>> Jianwei,
>> 
>> Check out:
>> http://www.ncl.ucar.edu/Applications/method_2.shtml
>> 
>> You may follow this example to get what you want.
>> 
>> Wei
>> 
>> huangwei@ucar.edu
>> VETS/CISL
>> National Center for Atmospheric Research
>> P.O. Box 3000 (1850 Table Mesa Dr.)
>> Boulder, CO 80307-3000 USA
>> (303) 497-8924
>> 
>> 
>> 
>> 
>> 
>> 
>> On Mar 5, 2013, at 12: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 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 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 Tue Mar  5 14:46:41 2013
This archive was generated by hypermail 2.1.8 : Thu Mar 07 2013 - 08:55:58 MST