<div dir="ltr"><div class="gmail_default" style="font-size:small">There are a number of issues with your script. <br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">[1]</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">By default, when you pull a variable off a set of files opened with &quot;addfiles&quot;, they are &quot;concatenated&quot; (this is known as &quot;cat&quot; mode in NCL) across the leftmost dimension.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">If you ​use the &quot;join&quot; mode, then a new leftmost dimension will be created that will be the same size as the number of files (in your case, 20).</div><div class="gmail_default" style="font-size:small"><font color="#000000"><br></font></div><div class="gmail_default" style="font-size:small"><font color="#000000">To get &quot;join&quot; mode, uncomment your ListSetType option above and change it to:</font></div><div class="gmail_default" style="font-size:small"><font color="#000000"><br></font></div><div class="gmail_default" style="font-size:small"><font color="#000000" face="monospace, monospace"><span style="font-size:12.8px">  ListSetType (f, &quot;join&quot;) ;join files</span><br style="font-size:12.8px"></font></div><div class="gmail_default" style="font-size:small"><font color="#000000" face="monospace, monospace"><span style="font-size:12.8px"><br></span></font></div><div class="gmail_default" style="font-size:small">[2] </div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style=""><span style="font-size:12.8px"><font color="#000000">To get a 4 x 5 configuration rather than a 20 configuration, you can use reshape to change the dimensions:</font></span></div><div class="gmail_default" style=""><span style="font-size:12.8px"><font color="#000000" face="monospace, monospace"><br></font></span></div><div class="gmail_default" style=""><font color="#000000" face="monospace, monospace"><span style="font-size:12.8px">  npp_dims = filevardimsizes(f[0],&quot;</span><span style="font-size:12.8px">Npp_1km_</span><span style="font-size:12.8px">MOD_Grid_MOD17A3&quot;)<br></span></font></div><div class="gmail_default" style=""><span style="color:rgb(0,0,0);font-family:monospace,monospace;font-size:12.8px">  npp      = reshape(short2flt(f[:]-&gt;Npp_1km_</span><span style="color:rgb(0,0,0);font-family:monospace,monospace;font-size:12.8px">MOD_Grid_MOD17A3),(/4,5,npp_dims(0),npp_dims(1)/))</span></div><div class="gmail_default" style=""><br></div><div class="gmail_default" style=""><div class="gmail_default"><font color="#000000" face="arial, helvetica, sans-serif"><span style="font-size:12.8px"><br class="">Please see the documentation for &quot;addfiles&quot; for more information:</span></font></div><div class="gmail_default"><font color="#000000" face="arial, helvetica, sans-serif"><span style="font-size:12.8px"><br></span></font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif" color="#000000"><span style="font-size:12.8px"><a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/addfiles.shtml">http://www.ncl.ucar.edu/Document/Functions/Built-in/addfiles.shtml</a></span></font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif" color="#000000"><br></font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif" color="#000000">[3]</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif" color="#000000"><br></font></div></div><div class="gmail_default" style=""><span style="color:rgb(0,0,0);font-size:12.8px"><font face="arial, helvetica, sans-serif">An issue with using reshape is that you may lose attribute and coordinate information, if any. </font></span><span style="font-family:arial,helvetica,sans-serif;color:rgb(0,0,0);font-size:12.8px">You can use copy_VarAtts and copy_VarCoords to copy over any information you need.  </span></div><div class="gmail_default" style=""><span style="color:rgb(0,0,0);font-size:12.8px"><font face="arial, helvetica, sans-serif"><br></font></span></div><div class="gmail_default" style=""><span style="color:rgb(0,0,0);font-size:12.8px"><font face="arial, helvetica, sans-serif">See:</font></span></div><div class="gmail_default" style=""><span style="color:rgb(0,0,0);font-size:12.8px"><font face="arial, helvetica, sans-serif"><br></font></span></div><div class="gmail_default" style=""><font face="arial, helvetica, sans-serif"><font color="#000000"><span style="font-size:12.8px"><a href="http://www.ncl.ucar.edu/Document/Functions/Contributed/copy_VarAtts.shtml">http://www.ncl.ucar.edu/Document/Functions/Contributed/copy_VarAtts.shtml</a></span></font><br></font></div><div class="gmail_default" style=""><font color="#000000" face="arial, helvetica, sans-serif"><span style="font-size:12.8px"><a href="http://www.ncl.ucar.edu/Document/Functions/Contributed/copy_VarCoords.shtml">http://www.ncl.ucar.edu/Document/Functions/Contributed/copy_VarCoords.shtml</a></span><br></font></div><div class="gmail_default" style=""><font color="#000000" face="arial, helvetica, sans-serif"><span style="font-size:12.8px"><br>[4]</span></font></div><div class="gmail_default" style=""><font color="#000000" face="arial, helvetica, sans-serif"><span style="font-size:12.8px"><br></span></font></div><div class="gmail_default" style=""><font color="#000000" face="arial, helvetica, sans-serif"><span style="font-size:12.8px">You are reading two-dimensional latitude and longitude arrays off the file, and then trying to treat them as coordinate arrays with:</span></font></div><div class="gmail_default" style=""><font color="#000000" face="monospace, monospace"><span style="font-size:12.8px"><br></span></font></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default" style=""><font color="#000000"><font face="monospace, monospace"><span style="font-size:12.8px">npp!0=&quot;lat2d&quot;</span></font></font></div><div class="gmail_default" style=""><font color="#000000"><font face="monospace, monospace"><span style="font-size:12.8px">npp!1=&quot;lon2d&quot;</span></font></font></div><div class="gmail_default" style=""><font color="#000000"><font face="monospace, monospace"><span style="font-size:12.8px">npp&amp;lat2d=lat2d</span></font></font></div><div class="gmail_default" style=""><font color="#000000"><font face="monospace, monospace"><span style="font-size:12.8px">npp&amp;lon2d=lon2d</span></font></font></div></blockquote><div class="gmail_default" style=""><span style="font-size:12.8px"><font color="#000000"><br></font></span></div><div class="gmail_default" style=""><span style="font-size:12.8px"><font color="#000000">By strict definition, coordinate arrays can only be one-dimensional, and of the same size as whatever dimension they are associated with.  Since your lat/lon arrays are 2D, you cannot assign them as coordinate arrays.  </font></span></div><div class="gmail_default" style=""><span style="font-size:12.8px"><font color="#000000"><br></font></span></div><div class="gmail_default" style=""><span style="font-size:12.8px"><font color="#000000">You can, however, write them separately to the file just like your &quot;npp&quot; variable, and then create a &quot;coordinates&quot; attribute (that I see you have already) that indicates what the name of the lat/lon arrays are on the new file:</font></span></div><div class="gmail_default" style=""><span style="font-size:12.8px"><font color="#000000"><br></font></span></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default" style=""><font color="#000000" face="monospace, monospace"><span style="font-size:12.8px">npp@coordinates=&quot;lon2d lat2d&quot;</span></font></div></blockquote><div class="gmail_default" style=""><span style="font-size:12.8px"><font color="#000000"><br></font></span></div><div class="gmail_default" style=""><span style="font-size:12.8px"><font color="#000000">Note that the &quot;coordinates&quot; attribute generally doesn&#39;t have a comma in it. Also, if your &quot;npp&quot; variable is 4D, and the other two dimensions have variables associated with them, you&#39;ll want to include these in the &quot;coordinates&quot; setting.  For example, if you had a 3D array, and the leftmost dimension was represented by a variable on the file called &quot;time&quot;, then you would use:</font></span></div><div class="gmail_default" style=""><span style="font-size:12.8px"><font color="#000000"><br></font></span></div><div class="gmail_default" style=""><span style="font-size:12.8px"><font color="#000000">npp@coordinates = &quot;lon2d lat2d time&quot;</font></span></div><div class="gmail_default" style=""><span style="font-size:12.8px"><font color="#000000"><br></font></span></div><div class="gmail_default" style=""><span style="font-size:12.8px"><font color="#000000">For some reason, the coordinates are usually listed right-to-left, although I don&#39;t think this is required.</font></span></div><div class="gmail_default" style=""><span style="font-size:12.8px"><font color="#000000"><br></font></span></div><div class="gmail_default" style=""><span style="font-size:12.8px"><font color="#000000">[5]</font></span></div><div class="gmail_default" style=""><span style="font-size:12.8px"><font color="#000000"><br></font></span></div><div class="gmail_default" style=""><span style="font-size:12.8px"><font color="#000000">You should use the same dimension names for your &quot;npp&quot; variable that you have for the lat2d/lon2d variables:</font></span></div><div class="gmail_default" style=""><span style="font-size:12.8px"><font color="#000000"><br></font></span></div><div class="gmail_default" style=""><span style="font-size:12.8px"><font color="#000000">npp!2 = &quot;nlat&quot;</font></span></div><div class="gmail_default" style=""><span style="font-size:12.8px"><font color="#000000">npp!3 = &quot;nlon&quot;</font></span></div><div class="gmail_default" style=""><span style="font-size:12.8px"><font color="#000000"><br></font></span></div><div class="gmail_default" style=""><span style="font-size:12.8px"><font color="#000000">Note that I changed these to dimensions 2 and 3, because dimensions 0 and 1 are associated with the &quot;4 x 5&quot; part of your array. You will need to name these accordingly.</font></span></div><div class="gmail_default" style=""><br></div><div class="gmail_default" style=""><font color="#000000" face="arial, helvetica, sans-serif"><span style="font-size:12.8px"><br></span></font></div><div class="gmail_default" style=""><font color="#000000"><span style="font-size:12.8px">--Mary</span></font></div><div class="gmail_default" style=""><font color="#000000"><span style="font-size:12.8px"><br></span></font></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 9, 2015 at 5:13 AM, Abdulla Sakalli <span dir="ltr">&lt;<a href="mailto:as@abdulla-sakalli.com" target="_blank">as@abdulla-sakalli.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

    
  <div style="word-wrap:break-word" text="#000000" bgcolor="#FFFFFF">
    Dear List,
    <div><br>
    </div>
    <div>I downloaded 20 files from MODIS satellite for NPP (MOD17A3).
      I’d like to read the hdf files and merge it in 4x5 to get the NPP
      value for pan-European domain. I&#39;ve been written the fallowing
      script for my aim. Unfortunately, I get the files merged in 1x20
      (i.e. merged along latitude and not lonxlat direction).<br>
      Can please anyone help me to read the npp from the 20 files and
      enlarge it in LonxLat direction.<br>
      <br>
      Thank you very much in advance<br>
      Abu<br>
      <br>
      Script:<br>
      <br>
      <br>
    </div>
    <div><font color="#ff0000"><br>
      </font></div>
    <div><font color="#ff0000">load
        &quot;$NCARG_ROOT/share/ncarg/nclscripts/csm/gsn_code.ncl&quot;<br>
        load &quot;$NCARG_ROOT/share/ncarg/nclscripts/csm/gsn_csm.ncl&quot;<br>
        load &quot;$NCARG_ROOT/share/ncarg/nclscripts/csm/contributed.ncl&quot;<br>
        load &quot;$NCARG_ROOT/share/ncarg/nclscripts/csm/shea_util.ncl&quot;<br>
        <br>
        begin<br>
        <br>
        ; 1km annual npp MOD17A3 on 1200x1200 tiles<br>
        <br>
        files = systemfunc(&quot;ls *.hdfeos&quot;)<br>
        <br>
        f = addfiles(files,&quot;r&quot;)<br>
        ;print(f)<br>
        ;ListSetType (f, &quot;cat&quot;) ;concatenate files<br>
        <br>
        lat2d=f[:]-&gt;GridLat_MOD_Grid_MOD17A3<br>
        lon2d=f[:]-&gt;GridLon_MOD_Grid_MOD17A3<br>
        <br>
        npp=short2flt(f[:]-&gt;Npp_1km_MOD_Grid_MOD17A3)<br>
        <br>
        lat2d!0=&quot;nlat&quot;<br>
        lat2d!1=&quot;nlon&quot;<br>
        lon2d!0=&quot;nlat&quot;<br>
        lon2d!1=&quot;nlon&quot;<br>
        <br>
        ;printVarSummary(lon2d)<br>
        <br>
        npp!0=&quot;lat2d&quot;<br>
        npp!1=&quot;lon2d&quot;<br>
        npp&amp;lat2d=lat2d<br>
        npp&amp;lon2d=lon2d<br>
        npp@coordinates=&quot;lat2d,lon2d&quot;<br>
        npp@projection=&quot;sinusoidal&quot;<br>
        <br>
        printVarSummary(npp)<br>
        <br>
        system(&quot;rm <a href="http://test.nc" target="_blank">test.nc</a>&quot;)<br>
        out=addfile(&quot;<a href="http://test.nc" target="_blank">test.nc</a>&quot;,&quot;c&quot;)<br>
        out-&gt;npp=npp<br>
        out-&gt;lat2d=lat2d<br>
        out-&gt;lon2d=lon2d<br>
        <br>
        end<br>
      </font></div>
    <div><br>
    </div>
    <div><i><small>print summary is<br>
          <br>
          Variable: npp<br>
          Type: short<br>
          Total Size: 57600000 bytes<br>
                      28800000 values<br>
          Number of Dimensions: 2<br>
          Dimensions and sizes:    [YDim_MOD_Grid_MOD17A3 | 24000] x
          [XDim_MOD_Grid_MOD17A3 | 1200]<br>
          Coordinates: <br>
          Number Of Attributes: 6<br>
            lon2d :    &lt;ARRAY of 28800000 elements&gt;<br>
            lat2d :    &lt;ARRAY of 28800000 elements&gt;<br>
            coordinates :    lat2d,lon2d<br>
            hdfeos_name :    Npp_1km<br>
            projection :    sinusoidal<br>
            unsigned :    True<br>
        </small></i><br>
    </div>
    <div><br>
      <div>
<div style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div><div style="word-wrap:break-word"><div style="word-wrap:break-word"><div><font color="#aaaaaa">---------------------------------------------------------------------------<br>Asst. Prof. Abdulla Sakalli<br><br></font><font color="#aaaaaa">Iskenderun Technical University</font></div><div><font color="#aaaaaa">Faculty of Marine Sciences &amp; Technology<br>Dept. Water Resources Management and Organization<br>Meydan Mah. 512 Sk<br>Iskenderun-Hatay-Turkey<br></font></div><div><a href="http://www.abdulla-sakalli.com" target="_blank">as@abdulla-sakalli.com</a></div><div><a href="mailto:asakalli@mku.edu.tr" target="_blank">asakalli@istek.edu.tr</a><font color="#aaaaaa"><br><a href="tel:%2B90%20326%20614%201693" value="+903266141693" target="_blank">+90 326 614 1693</a> (330)<br><a href="tel:%2B90%20536%20506%209191" value="+905365069191" target="_blank">+90 536 506 9191</a></font></div><div><font color="#aaaaaa"><br></font></div></div></div></div></div><br></div><br></div><br></div><br><br>
</div>

      <br>
    </div>
  

</div><br>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>