Re: YOTC data with real_imaginary dimension

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Fri, 18 Sep 2009 14:41:22 -0600

Matthew figured it out on his own.

---
It will not be possible to have a variable of size
       124*15*800*1600 [*4 bytes]
all contained in memory. Currently, NCL can handle
variables of 2BG or less. Hopefully, the next release
will address this issue.
---
Although I did not have a YOTC file available,
I created a script that 'should' work. This if
for future FAC reference.
[1] read the complex coefficients
[2] synthesize using the shsgc procedure
[3] add meta data
Cheers!
Matthew Janiga wrote:
> Greetings,
> 
> I am having some trouble with YOTC model data
> (http://data-portal.ecmwf.int/data/d/yotc_od/levtype=pl/type=an/).
> When I use ncl_filedump on the pv .grib format YOTC data I get normal
> lat lon grids. However, the primary variables are packed using
> spherical harmonics (I may be phrasing this wrong). These variables
> have half the “lon” elements (it isn’t really lon correct?) and an
> extra dimension real_imaginary. I saw some old messages pertaining to
> this problem but I can’t seem to figure out how to get this into the
> same coordinates as the pv.
> 
> I’d like to read in these “packed” primary variables and covert them
> to the dimensions that pv is in. Any help with this would be greatly
> appreciated!
> 
> I’ve included the results of ncl_filedump on pv and temperature data below.
> 
> Thanks,
> Matt (janiga_at_atmos.albany.edu)
> 
> Copyright (C) 1995-2009 - All Rights Reserved
>  University Corporation for Atmospheric Research
>  NCAR Command Language Version 5.1.1
>  The use of this software is governed by a License Agreement.
>  See http://www.ncl.ucar.edu/ for more details.
> Variable: f (file variable)
> 
> filename:       pv.200807
> path:   pv.200807.grib
>    file global attributes:
>    dimensions:
>       initial_time0_hours = 124
>       lv_ISBL1 = 15
>       g4_lat_2 = 800
>       g4_lon_3 = 1600
>    variables:
>       float PV_GDS4_ISBL ( initial_time0_hours, lv_ISBL1, g4_lat_2, g4_lon_3 )
>          center :       European Center for Medium-Range Weather
> Forecasts (RSMC)
>          long_name :    Potential vorticity
>          units :        K m**2 kg**-1 s**-1
>          _FillValue :   1e+20
>          level_indicator :      100
>          gds_grid_type :        4
>          parameter_table_version :      128
>          parameter_number :     60
>          forecast_time :        0
>          forecast_time_units :  hours
> 
>       double initial_time0_hours ( initial_time0_hours )
>          long_name :    initial time
>          units :        hours since 1800-01-01 00:00
> 
>       double initial_time0_encoded ( initial_time0_hours )
>          long_name :    initial time encoded as double
>          units :        yyyymmddhh.hh_frac
> 
>       float g4_lat_2 ( g4_lat_2 )
>          long_name :    latitude
>          GridType :     Gaussian Latitude/Longitude Grid (Quasi-Regular)
>          units :        degrees_north
>          N :    400
>          Di :   0.225
>          Lo2 :  359.775
>          La2 :  -89.827
>          Lo1 :   0
>          La1 :  89.827
> 
>       float g4_lon_3 ( g4_lon_3 )
>          long_name :    longitude
>          GridType :     Gaussian Latitude/Longitude Grid (Quasi-Regular)
>          units :        degrees_east
>          N :    400
>          Di :   0.225
>          Lo2 :  359.775
>          La2 :  -89.827
>          Lo1 :   0
>          La1 :  89.827
> 
>       integer lv_ISBL1 ( lv_ISBL1 )
>          long_name :    isobaric level
>          units :        hPa
> 
>       string initial_time0 ( initial_time0_hours )
>          long_name :    Initial time of first record
>          units :        mm/dd/yyyy (hh:mm)
> 
> 
> Copyright (C) 1995-2009 - All Rights Reserved
>  University Corporation for Atmospheric Research
>  NCAR Command Language Version 5.1.1
>  The use of this software is governed by a License Agreement.
>  See http://www.ncl.ucar.edu/ for more details.
> Variable: f (file variable)
> 
> filename:       t.200807
> path:   t.200807.grib
>    file global attributes:
>    dimensions:
>       initial_time0_hours = 124
>       lv_ISBL1 = 15
>       real_imaginary = 2
>       g50_lat_3 = 800
>       g50_lon_4 = 800
>    variables:
>       float T_GDS50_ISBL ( initial_time0_hours, lv_ISBL1,
> real_imaginary, g50_lat_3, g50_lon_4 )
>          center :       European Center for Medium-Range Weather
> Forecasts (RSMC)
>          long_name :    Temperature
>          units :        K
>          _FillValue :   1e+20
>          level_indicator :      100
>          gds_grid_type :        50
>          parameter_table_version :      128
>          parameter_number :     130
>          forecast_time :        0
>          forecast_time_units :  hours
> 
>       double initial_time0_hours ( initial_time0_hours )
>          long_name :    initial time
>          units :        hours since 1800-01-01 00:00
> 
>       double initial_time0_encoded ( initial_time0_hours )
>          long_name :    initial time encoded as double
>          units :        yyyymmddhh.hh_frac
> 
>       integer lv_ISBL1 ( lv_ISBL1 )
>          long_name :    isobaric level
>          units :        hPa
> 
>       string initial_time0 ( initial_time0_hours )
>          long_name :    Initial time of first record
>          units :        mm/dd/yyyy (hh:mm)
> 
> 
> 
> 
> 

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/contributed.ncl"

function yotc_synthesize(f:file, varName[1]:string, PV:numeric, ntStrt, ntLast)
local ccr, cci, dimsPV, x
begin
  ccr = f->$varName$(ntStrt:ntLast,:,0,:,:) ; (time,lev, real, 800, 800)
  cci = f->$varName$(ntStrt:ntLast,:,1,:,:) ; (time,lev, imag, 800, 800)

  x = new( dimsizes(PV), "float", "No_FillValue")
  shsgc(ccr,cci,x) ; synthesize

  copy_VarCoords(PV, x) ; meta data
  x_at_long_name = ccr_at_long_name
  x_at_units = ccr_at_units
  return(x)
end

begin

 diri = "./" ; input directory
 fili = "YOTC.ecmwf.grib"

 ntStrt = 0
 ntLast = 0
 nlat = 800
 mlon = 1600
 netCDF = True ; ? create netCDF
 PLOT = True ; ? PLOT sample time

 f = addfile(diri+fili, "r") ; reference the file

 PV = f->PV_GDS4_ISBL(ntStrt:ntLast,:,:,:) ; (time,lev,800,1600)
 printVarSummary(PV)
 printMinMax(PV, True)

 T = yotc_synthesize(f, "T_GDS50_ISBL", PV, ntStrt, ntLast)
 printVarSummary(T)
 printMinMax(T, True)

 U = yotc_synthesize(f, "U_GDS50_ISBL", PV, ntStrt, ntLast)
 printVarSummary(U)
 printMinMax(U, True)

 if (netCDF) then
     diro = "./"
     filo = "YOTC.800x1600.nc"

     system("/bin/rm -f "+diro+filo) ; remove any pre-existing file
     ncdf = addfile(diro+filo ,"c") ; open output netCDF file

    ; make time and UNLIMITED dimension ; recommended for most applications
     filedimdef(ncdf,"time",-1,True)

    ; output variables directly ... slow but easy
      ncdf->PV = PV
      ncdf->T = T
      ncdf->U = U
 end if

 if (PLOT) then
     pltDir = "./" ; directory for plot output
     pltName = "SAMPLE" ; netCDF name output
     pltType = "ps"

     wks = gsn_open_wks(pltType, pltDir+pltName)
     gsn_define_colormap(wks, "amwg")
   
     res = True ; plot mods desired
     res_at_cnFillOn = True ; turn on color fill
     res_at_cnLinesOn = False ; turn of contour lines
     res_at_gsnSpreadColors = True ; span color map
     res_at_lbLabelAutoStride = True
     res_at_mpFillOn = False

     ymdh = ut_calendar(f->initial_time0_hours, -3)

     level = 500
   
     do nt=0,0
        res_at_gsnCenterString = ymdh(nt)+" p="+level
        plot = gsn_csm_contour_map_ce(wks,T(nt,{level},:,:), res)
        plot = gsn_csm_contour_map_ce(wks,U(nt,{level},:,:), res)
     end do
 end if

 end

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Sep 18 2009 - 14:41:22 MDT

This archive was generated by hypermail 2.2.0 : Mon Sep 21 2009 - 09:40:03 MDT