convert 2d array into 3d array

From: Jin Young Kim <Jin-Young.Kim_at_nyahnyahspammersnyahnyah>
Date: Thu, 07 May 2009 18:56:51 -0600

Greetings,,

I would like to plot hovmeller (time vs lon).
However my data is 2d array without time dimension.

Would you guide me ?

Here is my scripts.

; Hovmueller
; Time vs. Longitude

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"

model = getenv ("MID")
domain = getenv ("DOMAIN")

begin

;************************************************
; read in grib file
;************************************************

 ifim = sprinti("./postprd/wrfprs_d01.%0.2i_mod",ispan(0,12,1))
 ofim = sprinti("./W500_d01_%0.2i",ispan(0,12,1))

 wks =gsn_open_wks("ps","hovw500")

do i= 0, dimsizes(ifim)-1
  grb_file = addfile(ifim(i)+".grb","r")

;************************************************
; read in 1d lat/lon arrays
;************************************************

  lat1d = grb_file->g0_lat_0
  lon1d = grb_file->g0_lon_1

  lat_dim = dimsizes(lat1d)
  lon_dim = dimsizes(lon1d)

  minlat = min(lat1d)
  maxlat = max(lat1d)
  minlon = min(lon1d)
  maxlon = max(lon1d)

; print (min(lat1d))
; print (max(lat1d))
; print (min(lon1d))
; print (max(lon1d))

;************************************************
; Make sure data is ordered from N->S and W->E
;************************************************

  lat_flag = 0
  lon_flag = 0

  if (lat1d(0).gt.lat1d(1)) then
    ; data ordered from S->N
    ; flip lat to go from N->S
    lat1d = lat1d(::-1)
    lat_flag = 1
  end if

  if (lon1d(0).gt.lat1d(1)) then
    ; data ordered from E->W
    ; flip lon to go from W->E
    lon1d = lon1d(::-1)
    lon_flag = 1
  end if
;************************************************
; Create workstation and assign the colormap
;************************************************

  gsn_define_colormap(wks,"uniform")

;************************************************
; Get Sfc Wind from grib file
;************************************************

  p = grb_file->MSLET_GDS0_MSL(:,:)
; u = grb_file->U_GRD_GDS0_HTGL(:,:)
; v = grb_file->V_GRD_GDS0_HTGL(:,:)
  u = grb_file->U_GRD_GDS0_ISBL(1,:,:)
  v = grb_file->V_GRD_GDS0_ISBL(1,:,:)
  w = grb_file->V_VEL_GDS0_ISBL(25,:,:)
  t = grb_file->TMP_GDS0_ISBL(33,:,:)
  level = grb_file->lv_ISBL3

  times = i

  whov = w({27.5:27.5},{-94:-81}) ; current 2d array ??

end do

;************************************************
; Set mslp contour resources.
;************************************************end do

;************************************************
; Set mslp contour resources.
;************************************************

  cnres3 = True
  cnres3_at_gsnDraw = False
  cnres3_at_gsnFrame = False
  cnres3_at_gsnMaximize = True

  cnres3_at_cnLevelSelectionMode = "ManualLevels"
  cnres3_at_cnLevelSpacingF = 1
  cnres3_at_cnSmoothingOn = True

; plot=gsn_csm_hov(wks,whov,cnres3)
;************************************************
; Draw everything for final image
;************************************************
; draw(plot)
; frame(wks)
end

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu May 07 2009 - 18:56:51 MDT

This archive was generated by hypermail 2.2.0 : Fri May 08 2009 - 10:05:07 MDT