Changing the name of a dimension in a variable

From: Tabish Ansari <tabishumaransari_at_nyahnyahspammersnyahnyah>
Date: Sun Apr 20 2014 - 06:26:00 MDT

Dear Mary

Thank you very much for your mail.

The above script works for me but there is a small issue.
I wish to merge files having variables like (time|1, lev|1, lat|109,
lon|99) to get new variables still with 4 dimensions wherein the time
dimension increases to the no. of files. However, the above script outputs
variables with 5 dimensions (ncl_join, time, lev, lat, lon).

Now that I used a subset operation over that variable like:

newvar= outputvar(:,0,:,:,:)

newvar is now like (ncl_join, lev, lat, lon)

Now my only aim is to rename the leftmost dimension "ncl_join" as "Time"
and my purpose will be soved.

Please suggest me a method to do that.

Thanks

On 19 April 2014 05:02, Mary Haley <haley@ucar.edu> wrote:

> Tabish,
>
> I believe you can simply use "addfiles" to open file1 through file10, read
> the the variables of interest, and then write them back out.
>
> Here's how it might look for one variable called "T".
> UNTESTED:
>
> ;---Get list of files and open them with one call
>
> filenames =systemfunc("ls -1 file*.nc" )
> f = addfiles(filenames,"r")
> ListSetType (f, "join") ; concatenate (=default)
>
>
> T = f[:]->T ; Read T off all files
> printVarSummary(T)
>
> ;---Open output file and write new variable
> system("rm -rf output.nc")
> fout = addfile("output.nc","c")
> fout->T = T
>
> This is just a rough script, and it writes the variable using the
> "inefficient" method. If you are going to be doing lots of variables, or
> really large variables, then you may want to write the file using the
> "efficient" method. See:
>
> http://www.ncl.ucar.edu/Applications/o-netcdf.shtml
>
> --Mary
>
> On Apr 17, 2014, at 1:56 PM, Tabish Ansari <tabishumaransari@gmail.com>
> wrote:
>
> Hello
>
> I have a netcdf files (say file1 to file10) with some 3d array variables
> of the form varname(z,x,y).
>
> Now I want to create a new netcdf file (say newfile) with 4d arrays that
> will contain all the variables corresponding to file1 to file10. This will
> be of the form:
>
> varname(time,z,x,y)
>
> where varname(0,z,x,y) comes from file 1 varname(z,x,y)
> varname(1,z,x,y) comes from file 2 varname(z,x,y)
> varname(2,z,x,y) comes from file 3 varname(z,x,y)
>
> and so on...
>
>
> ​For this I want to first declare a 4d array of the form:
>
> varname = new((/10,5,100,100/),float)
>
> but how do I assign this array to the newfile?​
>
> --
> Thanks & Regards
> Tabish Umar Ansari
> MS Research Scholar
> Environmental & Water Resources Engineering Division
> Department of Civil Engineering
> IIT Madras
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>

-- 
Thanks & Regards
Tabish Umar Ansari
MS Research Scholar
Environmental & Water Resources Engineering Division
Department of Civil Engineering
IIT Madras

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Sun Apr 20 06:26:17 2014

This archive was generated by hypermail 2.1.8 : Tue Apr 29 2014 - 09:04:20 MDT