<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Jayant,<div class=""><br class=""></div><div class="">Could you please try running “ncl_filedump example.nc”?</div><div class=""><br class=""></div><div class="">This is the output that I see on my machine:</div><div class=""><font face="Menlo" class="">$ ncl_filedump example.nc<br class=""> Copyright (C) 1995-2017 - All Rights Reserved<br class=""> University Corporation for Atmospheric Research<br class=""> NCAR Command Language Version 6.5.0<br class=""> The use of this software is governed by a License Agreement.<br class=""> See <a href="http://www.ncl.ucar.edu/" class="">http://www.ncl.ucar.edu/</a> for more details.<br class=""><br class="">Variable: f<br class="">Type: file<br class="">filename:<span class="Apple-tab-span" style="white-space:pre">        </span>example<br class="">path:<span class="Apple-tab-span" style="white-space:pre">   </span>example.nc<br class="">   file global attributes:<br class="">      creation_date : Fri Nov  3 13:50:10 MDT 2017<br class="">      Conventions : None<br class="">      source_file : ham_oxi_aps_T63L31.nc<br class="">      title : NCL Efficient Approach to netCDF Creation<br class="">   dimensions:<br class="">      time = 12  // unlimited<br class="">      lat = 96<br class="">      lon = 192<br class="">      lev = 28<br class="">   variables:<br class="">      double time ( time )<br class="">         units :<span class="Apple-tab-span" style="white-space:pre"> </span>months since 2000-01-01 00:00<br class=""><br class="">      float lev ( lev )<br class="">         long_name :<span class="Apple-tab-span" style="white-space:pre">        </span>hybrid level at midpoints (1000*(A+B))<br class="">         units :<span class="Apple-tab-span" style="white-space:pre">        </span>hPa<br class="">         formula_terms :<span class="Apple-tab-span" style="white-space:pre">   </span>a: hyam b: hybm p0: P0 ps: PS<br class="">         standard_name :<span class="Apple-tab-span" style="white-space:pre"> </span>atmosphere_hybrid_sigma_pressure_coordinate<br class="">         positive :<span class="Apple-tab-span" style="white-space:pre">        </span>down<br class="">         _FillValue :<span class="Apple-tab-span" style="white-space:pre">     </span>9.96921e+36<br class=""><br class="">      double lat ( lat )<br class="">         long_name :<span class="Apple-tab-span" style="white-space:pre"> </span>latitude<br class="">         units :<span class="Apple-tab-span" style="white-space:pre">      </span>degrees_north<br class="">         standard_name :<span class="Apple-tab-span" style="white-space:pre"> </span>latitude<br class=""><br class="">      double lon ( lon )<br class="">         long_name :<span class="Apple-tab-span" style="white-space:pre">    </span>longitude<br class="">         units :<span class="Apple-tab-span" style="white-space:pre">     </span>degrees_east<br class="">         standard_name :<span class="Apple-tab-span" style="white-space:pre">  </span>longitude<br class=""><br class="">      float OX_VMR_avrg ( time, lev, lat, lon )<br class="">         _FillValue :<span class="Apple-tab-span" style="white-space:pre">   </span>9.96921e+36<br class="">         rmvmean_op_NCL :<span class="Apple-tab-span" style="white-space:pre">  </span>dim_rmvmean over dimension(s): lon<br class="">         long_name :<span class="Apple-tab-span" style="white-space:pre">        </span>Deviation from mean<br class="">         units :<span class="Apple-tab-span" style="white-space:pre">   </span>VMR<br class="">         grid_type :<span class="Apple-tab-span" style="white-space:pre">       </span>gaussian<br class="">         info :<span class="Apple-tab-span" style="white-space:pre">       </span>NCL function hyi2hyo used to interpolate</font></div><div class=""><br class=""></div><div class="">Kevin</div><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 2, 2017, at 12:11 PM, Jayant <<a href="mailto:jayantkp2979@gmail.com" class="">jayantkp2979@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class=""><div class="">Dear Kevin,<br class=""></div>Thank you! I incorporated your suggestion. But when I open the output file in ncview or grads it shows nothing.<br class=""></div><div class="">Is there still something missing?<br class=""></div><div class="">Best,<br class=""></div><div class="">JP<br class=""></div>My grads screen shows:<br class=""><span style="font-family:monospace,monospace" class="">ga-> sdfopen <a href="http://example.nc/" class="">example.nc</a> <br class="">Scanning self-describing file:  <a href="http://example.nc/" class="">example.nc</a><br class="">SDF file <a href="http://example.nc/" class="">example.nc</a> is open as file 1<br class="">LON set to 0 360 <br class="">LAT set to -88.5722 88.5722 <br class="">LEV set to 10.1325 10.1325 <br class="">Time values set: 2000:1:1:0 2000:1:1:0 <br class="">E set to 1 1 <br class="">Notice: Z coordinate pressure values have been converted from Pa to mb<br class="">ga-> q file<br class="">File 1 : NCL Efficient Approach to netCDF Creation<br class="">  Descriptor: <a href="http://example.nc/" class="">example.nc</a><br class="">  Binary: <a href="http://example.nc/" class="">example.nc</a><br class="">  Type = Gridded<br class="">  Xsize = 192  Ysize = 96  Zsize = 28  Tsize = 12  Esize = 1<br class="">  Number of Variables = 1<br class="">     ox_vmr_avrg  28  t,z,y,x  Deviation from mean<br class="">ga-> set gxout shaded<br class="">ga-> d ox_vmr_avrg<br class="">Cannot contour grid - all undefined values </span><br class=""></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Nov 1, 2017 at 9:28 PM, Kevin Hallock <span dir="ltr" class=""><<a href="mailto:hallock@ucar.edu" target="_blank" class="">hallock@ucar.edu</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">Hi Jayant,<div class=""><br class=""></div><div class=""><div class="">I found several lines of code that I think might be contributing to this issue.</div><div class=""><br class=""></div><div class="">First of all, the values that have been assigned in this snippet of code might not be what you expect them to be:</div><span class=""><div class=""><font face="Menlo" class="">  dNames = getvardims(xo)<br class="">  time  = dNames(0)<br class="">  lev   = dNames(1)<br class="">  lat   = dNames(2)<br class="">  lon   = dNames(3)<br class=""></font><br class=""></div></span><div class="">If you print() any of the variables “time”, “lev”, “lat”, or “lon”, the result will just be the scalar <b class="">string</b> “time”, “lev”, “lat”, or “lon”, respectively. Based on the rest of the code, I suspect we really want those variables to contain the coordinate arrays from the variable “xo”.</div><div class=""><br class=""></div><div class="">When NCL reaches the line:</div><div class=""><font face="Menlo" class="">filevardef(fout, "time" ,<wbr class="">typeof(time),getvardims(time))</font></div><div class=""><br class=""></div><div class="">“typeof(time)” will be “string” as mentioned above, and “getvardims(time)” will actually be a missing value. Really what we want is the coordinate array for “time”, which should show “typeof(time)” as “double” and “getvardims(time)” as “time”.</div><div class=""><br class=""></div><div class="">Since “time”, “lev”, “lat”, and “lon” are all coordinate arrays associated with the dimensions of the variable “xo”, we can instead access them using NCL’s coordinate array operator ‘&’:</div><div class=""><span style="font-family:Menlo" class="">  time  = xo&time</span><br style="font-family:Menlo" class=""><span style="font-family:Menlo" class="">  lev   = xo&lev</span><br style="font-family:Menlo" class=""><span style="font-family:Menlo" class="">  lat   = xo&lat</span><br style="font-family:Menlo" class=""><span style="font-family:Menlo" class="">  lon   = xo&lon</span><br style="font-family:Menlo" class=""></div><div class=""><br class=""></div><div class="">After making this change, the script should run without showing any error messages. <i class="">However</i>, there is one other issue I found near the end of your script when assigning variables in the output data file:</div><span class=""><div class=""><font face="Menlo" class="">  fout->time   = (/time/)<br class="">  fout->lev    = (/lev/)<br class="">  fout->lat    = (/lat/)<br class="">  fout->lon    = (/lon/)<br class="">  fout->xo     = (/xo/)<br class=""></font><br class=""></div></span><div class="">In this case, “fout->xo” will be assigned only the <b class="">data array</b> of the “xo” script variable. Previously in the script, the <b class="">metadata</b> from the script variable “xo” was assigned to the output file variable named “OX_VMR_avrg”:</div><div class=""><font face="Menlo" class="">  filevarattdef(fout,"OX_VMR_<wbr class="">avrg",xo)<br class=""></font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class="">Essentially what this means is that the output file will have a variable named “xo” containing the <b class="">data</b> and a variable named “OX_VMR_avrg” containing only the <b class="">metadata</b>.</div><div class=""><br class=""></div><div class="">Changing the line:</div><div class=""><span style="font-family:Menlo" class="">  </span><span style="font-family:Menlo" class="">fout->xo</span><span style="font-family:Menlo" class="">     </span><span style="font-family:Menlo" class="">= </span><span style="font-family:Menlo" class="">(/</span><span style="font-family:Menlo" class="">xo</span><span style="font-family:Menlo" class="">/)</span></div><div class="">to instead be:</div><div class=""><span style="font-family:Menlo" class="">  </span><span style="font-family:Menlo" class="">fout->OX_VMR_avrg</span><span style="font-family:Menlo" class="">     </span><span style="font-family:Menlo" class="">= </span><span style="font-family:Menlo" class="">(/</span><span style="font-family:Menlo" class="">xo</span><span style="font-family:Menlo" class="">/)</span></div><div class=""><br class=""></div><div class="">should eliminate the unnecessary “xo” variable in the output file.</div><div class=""><br class=""></div><div class="">I hope this helps!</div><div class="">Kevin</div><div class=""><br class=""><blockquote type="cite" class=""><div class="">Begin forwarded message:</div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px" class="">From: <b class="gmail_sendername">Jayant</b> <span dir="ltr" class=""><<a href="mailto:jayantkp2979@gmail.com" target="_blank" class="">jayantkp2979@<wbr class="">gmail.com</a>></span></div><div class=""><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><div class=""><div class=""><div class=""><div class="gmail_quote">Date: Tue, Oct 31, 2017 at 9:06 PM<br class="">Subject: Re: [ncl-talk] hyi2hyo: rightmost dimension of ps and xi must be the same<br class="">To: Dennis Shea <<a href="mailto:shea@ucar.edu" target="_blank" class="">shea@ucar.edu</a>><br class="">Cc: "<a href="mailto:ncl-talk@ucar.edu" target="_blank" class="">ncl-talk@ucar.edu</a>" <<a href="mailto:ncl-talk@ucar.edu" target="_blank" class="">ncl-talk@ucar.edu</a>><div class=""><div class="h5"><br class=""><br class=""><br class=""><div dir="ltr" class=""><div class=""><div class=""><div class="">Hi Denis,<br class=""></div>Thank you for the corrections. I am expanding the script to write the output in a netcdf file.<br class=""></div>I am getting error with 'filevardef' function. Can you help me fix teh error? Below I paste the complete code.</div><div class="">Thanks in advance,</div><div class="">Jayant</div><div class="">----------------------------</div><div class="">the error code</div><div class=""><span style="font-family:monospace,monospace" class="">fatal:["Execute.c":8575]:Execu<wbr class="">te: Error occurred at or near line 103 in file scr_vregrid_ham.ncl</span><br class=""></div><div class="">----------------------------</div><div class=""><span style="font-family:monospace,monospace" class="">load "$NCARG_ROOT/lib/ncarg/nclscri<wbr class="">pts/csm/gsn_code.ncl"<br class="">load "$NCARG_ROOT/lib/ncarg/nclscri<wbr class="">pts/csm/gsn_csm.ncl"         <span class="m_-4243942448191902916Apple-converted-space"> </span><br class="">load "$NCARG_ROOT/lib/ncarg/nclscri<wbr class="">pts/csm/contributed.ncl"<br class="">load "$NCARG_ROOT/lib/ncarg/nclscri<wbr class="">pts/esmf/ESMF_regridding.ncl"<br class="">;<br class="">begin<br class="">;<div class=""><div class="m_-4243942448191902916h5"><br class="">  f    = addfile("ham_oxi_aps_T63L31.nc<wbr class="">","r")<br class="">  hyai = f->hyam          ; input A(k)<br class="">  hybi = f->hybm          ; input B(k)<br class="">  xi   = f->OX_VMR_avrg   ; variable to be interpolated<br class="">  printVarSummary(xi)     ; (time,lev,lon,lat);  (0,1,2,3)<br class="">  print("---")<br class=""><br class="">  xi  := xi(time|:,lev|:,lat|:,lon|:)  ; (time,lev,lat,lon); REORDER<br class="">  printVarSummary(xi)     ; (time,lev,lat,lon);  (0,1,2,3)<br class="">  print("---")<br class=""><br class="">  xi   = dim_rmvmean_Wrap(xi)        ; remove zonal means<br class=""> ;xi   = dim_rmvmean_n_Wrap(xi, 0)   ; remove time mean<br class="">  printVarSummary(xi)          ; rmvmean_op_NCL:  dim_rmvmean over dimension(s): lon<br class="">  print("---")<br class=""><br class="">  fP   = addfile("<a href="http://surf_pres_new_exp_echam_exp.nc/" target="_blank" class="">surf_pres_new_exp_ech<wbr class="">am_exp.nc</a>","r")<br class="">  psfc = fP->aps          ; surface pressure (Pa)<br class="">  printVarSummary(psfc)   ; (time,lat,lon)<br class="">  print("---")<br class=""><br class="">  PSFC = conform( xi(:,0,:,:), psfc(0,:,:), (/1,2/) )<br class="">  copy_VarMeta(psfc(0,:,:), PSFC(0,:,:))<br class="">  printVarSummary(PSFC)<br class=""><br class="">  sigma = (/0.00657, 0.01386, 0.02309, 0.03469, 0.04920, 0.06723, 0.08945, 0.11654, 0.14916, \<br class="">         0.18783, 0.23286, 0.28421, 0.34137, 0.40334, 0.46860, 0.53529, 0.60135, 0.66482,    \<br class="">         0.72401, 0.77773, 0.82527, 0.86642, 0.90135, 0.93054, 0.95459, 0.97418, 0.99000,    \<br class="">         1.00000/)<br class=""><br class="">  hybo = sigma            ; *your* B(k) [ sigma levels ]<br class="">  nsig = dimsizes(hybo)<br class="">  hyao = new(nsig,typeof(hybo))<br class="">  hyao = 0.0             ; set output A(k) to 0.0<br class=""><br class="">  p0   = 101325           ; reference pressure (Pa)<br class="">  p0@units = "Pa"<br class=""><br class="">  xo   = hyi2hyo_Wrap(p0,hyai,hybi,PSFC<wbr class="">,xi,hyao,hybo,0) ; contributed.ncl<br class="">  printVarSummary(xo)<br class=""></div></div>  ;<br class="">  ; writing output in netdf<br class="">  ;<br class="">  dNames = getvardims(xo)<br class="">  time  = dNames(0)<br class="">  lev   = dNames(1)<br class="">  lat   = dNames(2)<br class="">  lon   = dNames(3)<br class=""><br class="">  ntim  = dimsizes(time)                 ; get dimension sizes <span class="m_-4243942448191902916Apple-converted-space"> </span><br class="">  klev  = dimsizes(lev)                 <wbr class="">                             <span class="m_-4243942448191902916Apple-converted-space"> </span><br class="">  nlat  = dimsizes(lat) <span class="m_-4243942448191902916Apple-converted-space"> </span><br class="">  nlon  = dimsizes(lon)     <span class="m_-4243942448191902916Apple-converted-space"> </span><br class=""><br class="">  diro = "./"                     ; Output directory<br class="">  filo = "<a href="http://example.nc/" target="_blank" class="">example.nc</a>"             ; Output file<br class="">  system("/bin/rm -f " + diro + filo)    ; remove if exists<br class="">  fout  = addfile (diro + filo, "c")  ; open output file<br class=""><br class="">  ; explicitly declare file definition mode. Improve efficiency.<br class="">  setfileoption(fout,"DefineMode<wbr class="">",True)<br class=""><br class="">  ; create global attributes of the file<br class="">  fAtt               = True            ; assign file attributes<br class="">  fAtt@title         = "NCL Efficient Approach to netCDF Creation" <span class="m_-4243942448191902916Apple-converted-space"> </span><br class="">  fAtt@source_file   = "ham_oxi_aps_T63L31.nc"<br class="">  fAtt@Conventions   = "None"  <span class="m_-4243942448191902916Apple-converted-space"> </span><br class="">  fAtt@creation_date = systemfunc ("date")       <span class="m_-4243942448191902916Apple-converted-space"> </span><br class="">  fileattdef( fout, fAtt )            ; copy file attributes<br class=""><br class="">  ;=============================<wbr class="">==============================<wbr class="">========<br class="">  ; predefine the coordinate variables and their dimensionality<br class="">  ; Note: to get an UNLIMITED record dimension, we set the dimensionality<br class="">  ; to -1 (or the actual size) and set the dimension name to True.<br class="">  ;=============================<wbr class="">==============================<wbr class="">========<br class="">  dimNames = (/"time", "lat", "lon", "lev"/) <span class="m_-4243942448191902916Apple-converted-space"> </span><br class="">  dimSizes = (/ ntim ,  nlat,  nlon, klev /)<span class="m_-4243942448191902916Apple-converted-space"> </span><br class="">  dimUnlim = (/ True , False, False, False/)  <span class="m_-4243942448191902916Apple-converted-space"> </span><br class="">  filedimdef(fout,dimNames,dimSi<wbr class="">zes,dimUnlim)<br class=""><br class="">  ;=============================<wbr class="">==============================<wbr class="">========<br class="">  ; predefine the the dimensionality of the variables to be written out<br class="">  ;=============================<wbr class="">==============================<wbr class="">========<br class="">  ; Here we are using NCL functions to facilitate defining<span class="m_-4243942448191902916Apple-converted-space"> </span><br class="">  ; each variable's dimension name(s) and type.<span class="m_-4243942448191902916Apple-converted-space"> </span><br class="">  ; The following could be replaced with explicit, user defined dimension<span class="m_-4243942448191902916Apple-converted-space"> </span><br class="">  ; names different from those associated with the variable in memory.<span class="m_-4243942448191902916Apple-converted-space"> </span><br class="">  ; Say, PS(time,lat,lon) in the NCL script. They could be redefined for the file via:<span class="m_-4243942448191902916Apple-converted-space"> </span><br class="">  ; filevardef(fout, "PS"   ,typeof(PS) ,(/"TIME","latitude","longitud<wbr class="">e"/))<span class="m_-4243942448191902916Apple-converted-space"> </span><br class="">  ;=============================<wbr class="">==============================<wbr class="">========<br class="">  filevardef(fout, "time" ,typeof(time),getvardims(time)<wbr class="">)<span class="m_-4243942448191902916Apple-converted-space"> </span><br class="">  filevardef(fout, "lev"  ,typeof(lev),getvardims(lev) )                          <span class="m_-4243942448191902916Apple-converted-space"> </span><br class="">  filevardef(fout, "lat"  ,typeof(lat),getvardims(lat)) <wbr class="">                        <span class="m_-4243942448191902916Apple-converted-space"> </span><br class="">  filevardef(fout, "lon"  ,typeof(lon),getvardims(lon)) <wbr class="">                        <span class="m_-4243942448191902916Apple-converted-space"> </span><br class="">  filevardef(fout, "OX_VMR_avrg"    ,typeof(xo)  ,getvardims(xo))<br class=""><br class="">  ;=============================<wbr class="">==============================<wbr class="">========<br class="">  ; Copy attributes associated with each variable to the file<br class="">  ; All attributes associated with each variable will be copied.<br class="">  ;=============================<wbr class="">==============================<wbr class="">=========<br class="">  filevarattdef(fout,"OX_VMR_avr<wbr class="">g",xo)                ; copy T attributes<br class="">  filevarattdef(fout,"time" ,time)                    ; copy time attributes<br class="">  filevarattdef(fout,"lev"  ,lev)                     ; copy lev attributes<br class="">  filevarattdef(fout,"lat"  ,lat)                     ; copy lat attributes<br class="">  filevarattdef(fout,"lon"  ,lon)                     ; copy lon attributes   <span class="m_-4243942448191902916Apple-converted-space"> </span><br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span><br class="">  ;=============================<wbr class="">==============================<wbr class="">========<br class="">  ; explicitly exit file definition mode. **NOT REQUIRED**<br class="">  ;=============================<wbr class="">==============================<wbr class="">========<br class="">  setfileoption(fout,"DefineMode<wbr class="">",False)<br class=""><br class="">  ;=============================<wbr class="">==============================<wbr class="">========<br class="">  ; output only the data values since the dimensionality and such have<br class="">  ; been predefined. The "(/", "/)" syntax tells NCL to only output the<br class="">  ; data values to the predefined locations on the file.<br class="">  ;=============================<wbr class="">==============================<wbr class="">=========<br class="">  fout->time   = (/time/)    <span class="m_-4243942448191902916Apple-converted-space"> </span><br class="">  fout->lev    = (/lev/)<br class="">  fout->lat    = (/lat/)<br class="">  fout->lon    = (/lon/)<span class="m_-4243942448191902916Apple-converted-space"> </span><br class="">  fout->xo      = (/xo/)<br class=""><br class="">end</span><br class=""><br class=""></div></div><div class="m_-4243942448191902916HOEnZb"><div class="m_-4243942448191902916h5"><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Oct 31, 2017 at 6:17 PM, Dennis Shea<span class="m_-4243942448191902916Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:shea@ucar.edu" target="_blank" class="">shea@ucar.edu</a>></span><span class="m_-4243942448191902916Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr" class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><span style="font-family:monospace,monospace" class="">I think the refrain 'look at your data' applies here.<br class=""><br class="">===<br class="">There are several<b class=""><span class="m_-4243942448191902916Apple-converted-space"> </span>dimension related<span class="m_-4243942448191902916Apple-converted-space"> </span></b>issues with your data.<br class=""><br class=""></span></div><div class=""><span style="font-family:monospace,monospace" class="">[A]</span><span class="m_-4243942448191902916Apple-converted-space"> </span>Variable<span class="m_-4243942448191902916Apple-converted-space"> </span><b class="">xi<br class=""><br class=""></b></div><div class=""><b class="">xi: <span class="m_-4243942448191902916Apple-converted-space"> </span></b><span style="font-family:monospace,monospace" class=""><span style="color:rgb(0,0,255)" class="">[time |<span class="m_-4243942448191902916Apple-converted-space"> </span><b class="">12</b>]</span><span class="m_-4243942448191902916Apple-converted-space"> </span>x [lev | 31] x<span class="m_-4243942448191902916Apple-converted-space"> </span><span style="color:rgb(255,0,0)" class=""><b class="">[lon | 192] x [lat | 96]</b></span><br class=""></span><b class=""><span style="font-family:monospace,monospace" class=""></span></b></div><div class=""><span style="font-family:monospace,monospace" class=""><br class=""></span><span style="font-family:monospace,monospace" class=""><span style="font-family:monospace,monospace" class=""></span></span></div><div class=""><span style="font-family:monospace,monospace" class="">Note the two rightmost 'spatial' dimensions: names and sizes<br class=""><br class=""></span></div><div class=""><span style="font-family:monospace,monospace" class="">[B] Variable psfc<br class=""></span><br class=""><span style="font-family:monospace,monospace" class=""><span style="font-family:monospace,monospace" class=""><b class="">psfc</b>:<span class="m_-4243942448191902916Apple-converted-space"> </span><span style="color:rgb(0,0,255)" class="">[time |<span class="m_-4243942448191902916Apple-converted-space"> </span><b class="">1</b>]</span><span class="m_-4243942448191902916Apple-converted-space"> </span>x<span class="m_-4243942448191902916Apple-converted-space"> </span><span style="color:rgb(255,0,0)" class=""><b class="">[lat | 96] x [lon | 192]</b></span></span></span></div><div class=""><span style="font-family:monospace,monospace" class=""><br class=""></span></div><span style="font-family:monospace,monospace" class="">----------------------<br class=""><br class=""></span></div><div class=""><span style="font-family:monospace,monospace" class="">spatial dimensions:<br class=""></span></div><span style="font-family:monospace,monospace" class="">xi has order (...,lon,lat)     ==> (...,192,96)<br class=""></span></div><span style="font-family:monospace,monospace" class="">psfc gas order (...,lat,lon)   ==> (...,96,192)<br class=""><br class=""></span></div><span style="font-family:monospace,monospace" class="">temporal dimension size<br class=""></span></div><span style="font-family:monospace,monospace" class="">xi has time=12, psfc=1<br class=""><br class="">-----------------------<br class=""><br class=""></span></div><span style="font-family:monospace,monospace" class="">You could expand psfc 12 size 12 but I am not sure that is wht you want to do.<br class=""><br class=""></span></div><span style="font-family:monospace,monospace" class="">[C]<br class=""><br class=""></span></div><span style="font-family:monospace,monospace" class="">P0 must have a units attribute<br class=""><br class=""></span></div><span style="font-family:monospace,monospace" class="">[D]<br class=""><br class=""></span></div><span style="font-family:monospace,monospace" class="">Did you want to remove the zonal means or the time mena???<br class=""></span><div class=""><div class=""><span style="font-family:monospace,monospace" class=""><br class="">++++++++++++++++++++++++++++++<wbr class="">++++++++++++++<br class=""><br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>f    = addfile("ham_oxi_aps_T63L31.nc<wbr class="">","r")<span class=""><br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>hyai = f->hyam          ; input A(k)<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>hybi = f->hybm          ; input B(k)<br class=""></span> <span class="m_-4243942448191902916Apple-converted-space"> </span>xi   = f->OX_VMR_avrg   ; variable to be interpolated<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>printVarSummary(xi)     ; (time,lev,lon,lat);  (0,1,2,3)<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>print("---")<br class=""><br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>xi  := xi(time|:,lev|:,lat|:,lon|:)  ; (time,lev,lat,lon); REORDER<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>printVarSummary(xi)     ; (time,lev,lat,lon);  (0,1,2,3)<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>print("---")<br class=""><br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>xi   = dim_rmvmean_Wrap(xi)        ;<span class="m_-4243942448191902916Apple-converted-space"> </span><b class="">remove zonal means</b><br class=""></span></div><div class=""><span style="font-family:monospace,monospace" class=""> ;xi   = dim_rmvmean_n_Wrap(xi, 0)  <span class="m_-4243942448191902916Apple-converted-space"> </span><b class="">; remove time mean</b><br class=""></span></div><div class=""><span style="font-family:monospace,monospace" class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>printVarSummary(xi)          ; rmvmean_op_NCL:  dim_rmvmean over dimension(s): lon<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>print("---")<span class=""><br class=""><br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>fP   = addfile("<a href="http://surf_pres_new_exp_echam_exp.nc/" target="_blank" class="">surf_pres_new_exp_ech<wbr class="">am_exp.nc</a>","r")<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>psfc = fP->aps          ; surface pressure (Pa)<br class=""></span> <span class="m_-4243942448191902916Apple-converted-space"> </span>printVarSummary(psfc)   ; (time,lat,lon)<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>print("---")<br class=""><br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>PSFC = conform( xi(:,0,:,:), psfc(0,:,:), (/1,2/) )<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>copy_VarMeta(psfc(0,:,:), PSFC(0,:,:))<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>printVarSummary(PSFC)<span class=""><br class=""><br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>sigma = (/0.00657, 0.01386, 0.02309, 0.03469, 0.04920, 0.06723, 0.08945, 0.11654, 0.14916, \<br class="">        <span class="m_-4243942448191902916Apple-converted-space"> </span>0.18783, 0.23286, 0.28421, 0.34137, 0.40334, 0.46860, 0.53529, 0.60135, 0.66482,    \<br class="">        <span class="m_-4243942448191902916Apple-converted-space"> </span>0.72401, 0.77773, 0.82527, 0.86642, 0.90135, 0.93054, 0.95459, 0.97418, 0.99000,    \<br class="">        <span class="m_-4243942448191902916Apple-converted-space"> </span>1.00000/)<br class=""><br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>hybo = sigma            ; *your* B(k) [ sigma levels ]<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>nsig = dimsizes(hybo)<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>hyao = new(nsig,typeof(hybo))<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>hyao = 0.0             ; set output A(k) to 0.0<br class=""><br class=""></span><span class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>p0   = 101325           ; reference pressure (Pa)<br class=""></span> <span class="m_-4243942448191902916Apple-converted-space"> </span>p0@units = "Pa"<br class=""><br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>xo   = hyi2hyo_Wrap(p0,hyai,hybi,PSFC<wbr class="">,xi,hyao,hybo,0) ; contributed.ncl<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>printVarSummary(xo)<br class=""></span><div class=""><div class=""><span style="font-family:monospace,monospace" class=""><br class=""><br class=""></span></div></div></div></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote"><span class="">On Tue, Oct 31, 2017 at 11:01 AM, Jayant<span class="m_-4243942448191902916Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:jayantkp2979@gmail.com" target="_blank" class="">jayantkp2979@gmail.com</a><wbr class="">></span><span class="m_-4243942448191902916Apple-converted-space"> </span>wrote:<br class=""></span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div class=""><div class="m_-4243942448191902916m_-5819008324443537227h5"><div dir="ltr" class=""><div class=""><div class="">Dear,<br class=""><br class=""></div>I am following the steps given in thread (<a href="https://www.ncl.ucar.edu/Support/talk_archives/2006/0001.html" target="_blank" class="">https://www.ncl.ucar.edu/Supp<wbr class="">ort/talk_archives/2006/0001.ht<wbr class="">ml</a>) to convert a file from hybrid level to sigma levels. I paste below my script and the outputs. I am not able to understand where I am going wrong. Please advice. Also, let me know if I need to send my netcdf files as well.</div><div class="">Thanks in advance,</div><div class="">Jayant<br class=""></div><div class=""><br class=""><span style="font-family:monospace,monospace" class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>f=addfile("ham_oxi_aps_<wbr class="">T63L31.nc","r")<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>hyai = f->hyam         ; input A(k)<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>hybi = f->hybm         ; input B(k)<span class="m_-4243942448191902916Apple-converted-space"> </span><br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>xi   = f->OX_VMR_avrg        ; (0,:,:,:)     ; variable to be interpolated<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>dims = getvardims(xi)<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>xin  = dim_rmvmean_Wrap(xi($dims(0)$|<wbr class="">:,$dims(1)$|:,$dims(3)$|:,$dim<wbr class="">s(2)$|:))<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>printVarSummary(xin)<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>p0   = 101325            ; reference pressure (Pa)<br class=""><br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>fP   = addfile("<a href="http://surf_pres_new_exp_echam_exp.nc/" target="_blank" class="">surf_pres_new_exp_ech<wbr class="">am_exp.nc</a>","r")<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>psfc = fP->aps            ; surface pressure (Pa)<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>printVarSummary(psfc)<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>; dims = getvardims(psfc)<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>; psfcr = dim_rmvmean_Wrap(psfc($dims(0)<wbr class="">$|:,$dims(2)$|:,$dims(1)$|:))<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>; psfc2d = psfcr(0,:,:)<br class=""><br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>sigma = (/0.00657, 0.01386, 0.02309, 0.03469, 0.04920, 0.06723, 0.08945, 0.11654, 0.14916, \<br class="">        <span class="m_-4243942448191902916Apple-converted-space"> </span>0.18783, 0.23286, 0.28421, 0.34137, 0.40334, 0.46860, 0.53529, 0.60135, 0.66482,    \<br class="">        <span class="m_-4243942448191902916Apple-converted-space"> </span>0.72401, 0.77773, 0.82527, 0.86642, 0.90135, 0.93054, 0.95459, 0.97418, 0.99000,    \<br class="">        <span class="m_-4243942448191902916Apple-converted-space"> </span>1.00000/)<br class=""><br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>hybo = sigma            ; *your* B(k) [ sigma levels ]<span class="m_-4243942448191902916Apple-converted-space"> </span><br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>nsig = dimsizes(hybo)<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>hyao = new(nsig,typeof(hybo))<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>hyao = 0.0             ; set output A(k) to 0.0<span class="m_-4243942448191902916Apple-converted-space"> </span><br class=""><br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>; xo = hyi2hyo_Wrap(p0,hyai,hybi,psfc<wbr class="">r,xi,hyao,hybo,0) ; contributed.ncl<span class="m_-4243942448191902916Apple-converted-space"> </span><br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>xo = hyi2hyo_Wrap(p0,hyai,hybi,psfc<wbr class="">,xin,hyao,hybo,0) ; contributed.ncl<span class="m_-4243942448191902916Apple-converted-space"> </span><br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>printVarSummary(xo)</span><br class=""><br class=""></div>On running, I am getting the following error:<br class=""><br class=""><span style="font-family:monospace,monospace" class="">Variable: xin<br class="">Type: float<br class="">Total Size: 27426816 bytes<br class="">           <span class="m_-4243942448191902916Apple-converted-space"> </span>6856704 values<br class="">Number of Dimensions: 4<br class="">Dimensions and sizes:    [time | 12] x [lev | 31] x [lat | 96] x [lon | 192]<br class="">Coordinates:<span class="m_-4243942448191902916Apple-converted-space"> </span><br class="">           <span class="m_-4243942448191902916Apple-converted-space"> </span>time: [   0..  11]<br class="">           <span class="m_-4243942448191902916Apple-converted-space"> </span>lev: [ 1..31]<br class="">           <span class="m_-4243942448191902916Apple-converted-space"> </span>lat: [88.5721685140073..-88.5721685<wbr class="">140073]<br class="">           <span class="m_-4243942448191902916Apple-converted-space"> </span>lon: [   0..358.125]<br class="">Number Of Attributes: 5<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>rmvmean_op_NCL :    dim_rmvmean over dimension(s): lon<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>long_name :    Deviation from mean<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>grid_type :    gaussian<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>units :    VMR<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>_FillValue :    9.96921e+36<br class=""><br class="">Variable: psfc<br class="">Type: float<br class="">Total Size: 73728 bytes<br class="">           <span class="m_-4243942448191902916Apple-converted-space"> </span>18432 values<br class="">Number of Dimensions: 3<br class="">Dimensions and sizes:    [time | 1] x [lat | 96] x [lon | 192]<br class="">Coordinates:<span class="m_-4243942448191902916Apple-converted-space"> </span><br class="">           <span class="m_-4243942448191902916Apple-converted-space"> </span>time: [30.99166666666667..30.9916666<wbr class="">6666667]<br class="">           <span class="m_-4243942448191902916Apple-converted-space"> </span>lat: [88.57216851400727..-88.572168<wbr class="">51400727]<br class="">           <span class="m_-4243942448191902916Apple-converted-space"> </span>lon: [   0..358.125]<br class="">Number Of Attributes: 5<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>grid_type :    gaussian<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>table :    128<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>code :    134<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>units :    Pa<br class=""> <span class="m_-4243942448191902916Apple-converted-space"> </span>long_name :    surface pressure<br class="">fatal:hyi2hyo: The rightmost dimensions of 'ps' and 'xi' must be the same<br class="">fatal:["Execute.c":8575]:Execu<wbr class="">te: Error occurred at or near line 9139 in file $NCARG_ROOT/lib/ncarg/nclscrip<wbr class="">ts/csm/contributed.ncl<br class=""></span></div><br class=""></div></div><span class="">______________________________<wbr class="">_________________<br class="">ncl-talk mailing list<br class=""><a href="mailto:ncl-talk@ucar.edu" target="_blank" class="">ncl-talk@ucar.edu</a><br class="">List instructions, subscriber options, unsubscribe:<br class=""><a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank" class="">http://mailman.ucar.edu/mailma<wbr class="">n/listinfo/ncl-talk</a><br class=""><br class=""></span></blockquote></div><br class=""></div></blockquote></div></div></div></div></div></div></div></div></div></div></div><br class=""></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></body></html>