Re: save calculated 2D array as 3D array

From: James Correia, Jr <jimmyc42_at_nyahnyahspammersnyahnyah>
Date: Mon Nov 21 2011 - 15:19:28 MST

Hi Kelly-
You can just force it to be a 3d variable by defining it after out :

SLP = new((/10,dy,dx/),float)
SLP(0,:,:) = wrf_user_getvar(data,"slp",0)

The "0" in the function means you are only grabbing 1 time so it makes it a
2d array.

jimmyc

On Mon, Nov 21, 2011 at 3:11 PM, kelly lombardo <kellyann7319@yahoo.com>wrote:

> I am trying to calculate SLP using NCL and save it in a separate NCL file
> with similar attributes to the 2D variables in the original file. I am
> having some problems having the dimensions and sizes match up. For the
> original 2D data, there are 3 coordinates for time, latitude and longitude
> but for the calculated 2D SLP data, I can only seem to get 2 coordinates
> latitude and longitude. I have tried 2 ways to solve this:
>
> The first way I tried to calculate SLP and define the variable as having 3
> dimensions, time, latitude, and longitude, but that didn't work:
> ------------------------------**--------------------
> begin
>
> system("/bin/rm -f /R0/kelly/WRF/1985/slp.nc")
> out = addfile("/R0/kelly/WRF/1985/sl**p.nc <http://slp.nc/>","c")
>
> fileAtt = True
> fileAtt@creation_date = systemfunc("date")
> fileattdef(out,fileAtt)
>
> data = addfile("/R0/kelly/WRF/1985/**wrfout_d01_1985-10-16_00:00:00**.nc<http://00.nc/>",
> "r")
>
> T2 = wrf_user_getvar(data,"T2",0)
> SLP = wrf_user_getvar(data,"slp",0)
> U10 = wrf_user_getvar(data,"U10",0)
>
> dims = dimsizes(data->T2)
> print (dims)
>
> SLP = new((/dims(0),dims(1),dims(2)/**),"float")
>
> dimNames = (/"time", "south_north", "west_east"/) ; coordinate variables
> dimSizes = (/ -1, dims(1), dims(2) /) ; coordinate dimensions
> dimUnlim = (/ True , False, False/) ; define unlimited t
> filedimdef(out, dimNames , dimSizes, dimUnlim )
>
> out->SLP=SLP
>
> end
> ------------------------------**------------------------------**----------
> For the second, I tried to conform the already calculated 2D SLP data to
> the coordinates of U10 of the original file, but that didn't work either
> and I still get only 2 coordinates:
>
> begin
>
> system("/bin/rm -f /R0/kelly/WRF/1985/slp.nc")
> out = addfile("/R0/kelly/WRF/1985/sl**p.nc <http://slp.nc/>","c")
>
> fileAtt = True
> fileAtt@creation_date = systemfunc("date")
> fileattdef(out,fileAtt)
>
> data = addfile("/R0/kelly/WRF/1985/**wrfout_d01_1985-10-16_00:00:00**.nc<http://00.nc/>",
> "r")
>
> T2 = wrf_user_getvar(data,"T2",0)
> SLP = wrf_user_getvar(data,"slp",0)
> U10 = wrf_user_getvar(data,"U10",0)
>
> dims = dimsizes(data->T2)
> print (dims)
>
> filedimdef(out, "time", -1, True)
>
> out->SLP=SLP
> SLP2=conform(U10,SLP,(/0,1/))
> out->SLP2=SLP2
>
> end
> ------------------------------**----------
>
> Does anyone know how to fix this?
> Thanks so much
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>

-- 
James Correia Jr.
OU CIMMS Research Associate
SPC HWT Liaison
"The highest function of the teacher consists not so much in imparting
knowledge as in stimulating the pupil in its love and pursuit. To know how
to suggest is the art of teaching."
------------------------------------------------------------------------------------------
The views expressed in this email do not necessarily reflect those of NOAA,
the National Weather Service, or the University of Oklahoma.
------------------------------------------------------------------------------------------

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Nov 21 15:19:40 2011

This archive was generated by hypermail 2.1.8 : Tue Nov 22 2011 - 14:17:52 MST