save calculated 2D array as 3D array

From: kelly lombardo <kellyann7319_at_nyahnyahspammersnyahnyah>
Date: Mon Nov 21 2011 - 14:11:34 MST

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/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", "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/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", "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
Received on Mon Nov 21 14:43:52 2011

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