<div dir="ltr"><div><div><div><div><div>Hi Steven,<br><br></div>I&#39;m not expert here on this, but from what I can tell, you&#39;ve got curvilinear lat/lon variables that are two dimensional, and so in the statement:<br><br>  dim_sizes = (/nlat, nlon/)<br><br></div>nlat/nlon are themselves 2D, so dim_sizes is a 2x2 (I think).   Your lat2d/lon2d are defined in more fundamental dimensions in the HDF files -- it looks like perhaps nrows/ncol -- and its those values&amp;names you likely want to use for filedimdefs().<br><br></div>Make sense?<br><br></div>Hope that helps...<br></div>Rick<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 22, 2015 at 9:35 AM, BLIUJUS, STEVEN D CTR USAF AFMC AFLCMC/HBAW-OL <span dir="ltr">&lt;<a href="mailto:steven.bliujus.3.ctr@us.af.mil" target="_blank">steven.bliujus.3.ctr@us.af.mil</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I am taking several hdf files (200-400) and trying to generate one NetCDF file. I am able to plot it on a grid, but when I try to write to a NetCDF file, I get the following error:<br>
<br>
fatal:Number of dimensions in parameter (2) of (filedimdef) is (2), (1) dimensions were expected<br>
fatal:[&quot;Execute.c&quot;:8128]:Execute: Error occurred at or near line 82 in file File.ncl<br>
<br>
<br>
The data I am creating is AOD with two dimensions (lat/lon). I am uncertain as to why it is expecting one dimension. Below is my script. FYI, the original files had to be manipulated in order to make AOD have the lat/lon dimensions. Any help would be greatly appreciated.<br>
<br>
<br>
load &quot;/home/bliujuss/ncl/lib/ncarg/nclscripts/csm/gsn_code.ncl&quot;<br>
load &quot;/home/bliujuss/ncl/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl&quot;<br>
load &quot;/home/bliujuss/ncl/lib/ncarg/nclscripts/csm/gsn_csm.ncl&quot;<br>
load &quot;/home/bliujuss/ncl/lib/ncarg/nclscripts/csm/shea_util.ncl&quot;<br>
begin<br>
<br>
diri = &quot;/home/bliujuss/Verification_data/Test/&quot;<br>
fili = systemfunc(&quot;ls &quot;+diri+&quot;*.hdf&quot;)<br>
a = addfiles(fili,&quot;r&quot;)<br>
<br>
;ListSetType(a,&quot;cat&quot;)<br>
<br>
var1=a[:]-&gt;Optical_Depth_Land_And_Ocean(:,:)<br>
Optical_Depth_Land_And_Ocean = short2flt(var1)<br>
<br>
var2=a[:]-&gt;Longitude(:,:)<br>
Longitude=var2<br>
<br>
<br>
var3 = a[:]-&gt;Latitude(:,:)<br>
Latitude=var3<br>
<br>
dims = dimsizes(Optical_Depth_Land_And_Ocean)<br>
nrows = dims(0) ;203<br>
npixels = dims(1) ;135<br>
<br>
lat2d = new((/nrows,npixels/),float)<br>
lon2d = new((/nrows,npixels/),float)<br>
<br>
do i=0,npixels-1<br>
  lat2d(:,i) = Latitude(:,i)<br>
end do<br>
<br>
do i=0,nrows-1<br>
  lon2d(i,:) = Longitude(i,:)<br>
end do<br>
<br>
Optical_Depth_Land_And_Ocean@lat2d = lat2d(::5,::5)<br>
Optical_Depth_Land_And_Ocean@lon2d = lon2d(::5,::5)<br>
<br>
<br>
wks = gsn_open_wks(&quot;x11&quot;,&quot;plot_aod&quot;)<br>
gsn_define_colormap(wks,&quot;NCV_banded&quot;)<br>
setvalues NhlGetWorkspaceObjectId()<br>
  &quot;wsMaximumSize&quot;: 300000000<br>
end setvalues<br>
<br>
res                   = True               ; plot mods desired<br>
res@cnLinesOn         = False              ; turn off contour lines<br>
res@cnFillOn          = True               ; color plot desired<br>
res@cnLineLabelsOn    = False              ; turn off contour lines<br>
res@gsnAddCyclic      = False             ; non-global data<br>
res@gsnSpreadColors   = True               ; use full range of colormap<br>
;res@cnFillMode        = &quot;RasterFill&quot;       ; turn on raster mode<br>
res@lbLabelAutoStride = True               ; nice spacing of lables<br>
res@gsnMaximize       = True               ; blow up plot as much as poss<br>
;print(min(lat2d))<br>
;print(max(lat2d))<br>
;print(min(lon2d))<br>
;print(max(lon2d))<br>
<br>
plot = gsn_csm_contour_map_ce(wks,Optical_Depth_Land_And_Ocean(::5,::5),res)<br>
print(max(Optical_Depth_Land_And_Ocean(::5,::5)))<br>
<br>
nlat = dimsizes(lat2d(::5,::5))<br>
nlon = dimsizes(lon2d(::5,::5))<br>
<br>
diro = &quot;/home/bliujuss/Plots/&quot;<br>
filo = &quot;<a href="http://example.nc" target="_blank">example.nc</a>&quot;<br>
system(&quot;rm -f&quot; + diro + filo)<br>
fout = addfile (diro + filo, &quot;c&quot;)<br>
<br>
setfileoption(fout,&quot;DefineMode&quot;,True)<br>
<br>
dim_names = (/&quot;lat&quot;, &quot;lon&quot;/)<br>
dim_sizes = (/nlat, nlon/)<br>
dimUnlim = (/False, False/)<br>
filedimdef(fout,dim_names,dim_sizes,dimUnlim)<br>
<br>
filevardef(fout, &quot;lat&quot;, typeof(lat2d(::5,::5)),getvardims(lat2d(::5,::5)))<br>
filevardef(fout, &quot;lon&quot;, typeof(lon2d(::5,::5)),getvardims(lon2d(::5,::5)))<br>
filevardef(fout, &quot;AOT&quot;, typeof(Optical_Depth_Land_And_Ocean(::5,::5)),getvardims(Optical_Depth_Land_And_Ocean(::5,::5)))<br>
<br>
filevarattdef(fout,&quot;AOT&quot;, Optical_Depth_Land_And_Ocean(::5,::5))<br>
filevarattdef(fout,&quot;lat&quot;, lat2d(::5,::5))<br>
filevarattdef(fout,&quot;lon&quot;, lon2d(::5,::5))<br>
<br>
setfileoption(fout,&quot;DefineMode&quot;,False)<br>
<br>
fout-&gt;Optical_Depth_Land_And_Ocean(::5,::5) = (/Optical_Depth_Land_And_Ocean(::5,::5)/)<br>
fout-&gt;lat2d(::5,::5) = (/lat2d(::5,::5)/)<br>
fout-&gt;lon2d(::5,::5) = (/lon2d(::5,::5)/)<br>
<br>
end<br>
<br>
<br>
Steven Bliujus<br>
<br>
<br>
_______________________________________________<br>
ncl-talk mailing list<br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
</blockquote></div><br></div>