<div dir="ltr"><div class="gmail_quote"><br>Subject: appending columns of a 2d array to a list<br><div dir="ltr"><span style="font-size:12.8px">Folks,</span><div style="font-size:12.8px">I am really new to NCL and am using NCL because that is what the original processing script uses.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">I am building a table that has columns that have the same type of data within the column. Each row of the table represents a different US county. The columns have information such as the state, the county name, latitude, longitude. So, within the column the data is the same type, and along a row the data type changes.I have no troubles manually constructing this table for a few. </div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Where things are not working for me is that I want to add a few hundred more columns of data. I have this data inside a 2d array. I know this 2d data is OK, because I can print it and manipulate it. I am not able to column-wise append the data to the existing part of my list.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">The start of my list works fine (a combination of integers, strings, and floats):</div><div style="font-size:12.8px"><p class="m_5315985348171188227gmail-m_7965936036501745560m_2160320856772879989gmail-m_4133516229890100231gmail-p1"><span class="m_5315985348171188227gmail-m_7965936036501745560m_2160320856772879989gmail-m_4133516229890100231gmail-s1"> <font face="monospace, monospace"> ;*****************************<wbr>*****************<br> ; Fill in all of the columns (location + lots of days), for each row (list of counties)<br> ;*****************************<wbr>*****************<br> nf_each_county = new(dimsizes(states),integer)<br> nf_each_county = nf<br> alist1 = NewList("fifo")<br> ListAppend(alist1,nf_each_coun<wbr>ty)<br> ListAppend(alist1,states)<br> ListAppend(alist1,county)<br> ListAppend(alist1,lat0)<br> ListAppend(alist1,lon0)</font><br></span></p>The problem is trying to get the columns of the 2d array appended to the list. I have tried everything I can think of.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">This does not work, jamming in a full 2d array.</div><div><br><span style="font-size:12.8px"> </span><font face="monospace, monospace" style="font-size:12.8px">ListAppend(alist1,x0(:,:))</font><p class="m_5315985348171188227gmail-m_7965936036501745560m_2160320856772879989gmail-p1" style="font-size:12.8px">This does not work, trying to use each column via an index:<br></p><p class="m_5315985348171188227gmail-m_7965936036501745560m_2160320856772879989gmail-m_4133516229890100231gmail-p1" style="font-size:12.8px"><span class="m_5315985348171188227gmail-m_7965936036501745560m_2160320856772879989gmail-m_4133516229890100231gmail-s1"><font face="monospace, monospace"> i = 0<br> do while(i.lt.nDays)<br> ListAppend(alist1,x0(i,:))<br> i=i+1<br> end do</font><br><br></span></p><p class="m_5315985348171188227gmail-m_7965936036501745560m_2160320856772879989gmail-p1" style="font-size:12.8px">This does not work, trying to use a temporary 1d array (I put in the delete because of complaints that I was trying to overwrite):<br></p><font face="monospace, monospace" style="font-size:12.8px"> i = 0<br> do while(i.lt.nDays)<br> xtemp = x0(i,:)<br> ListAppend(alist1,xtemp)<br> delete(xtemp)<br> i=i+1<br> end do</font><br><p class="m_5315985348171188227gmail-m_7965936036501745560m_2160320856772879989gmail-m_4133516229890100231gmail-p1" style="font-size:12.8px"><span class="m_5315985348171188227gmail-m_7965936036501745560m_2160320856772879989gmail-m_4133516229890100231gmail-s1">Unfortunately, the only thing that I have found that does work is to append each column separately, where a new 1d array is created for each column. This works when no deleting is going on.<br><br><font face="monospace, monospace"> xtemp0 = x0(0,:)<br> ListAppend(alist1,xtemp0)<br> xtemp1 = x0(1,:)<br> ListAppend(alist1,xtemp1)<br> xtemp2= x0(2,:)<br> ListAppend(alist1,xtemp2)</font><br></span></p><p class="m_5315985348171188227gmail-m_7965936036501745560m_2160320856772879989gmail-m_4133516229890100231gmail-p1" style="font-size:12.8px">As a hack, I can do this, but for several hundred extra coluns, this requires writing a script to write NCL code. The code is now quite brittle and not able to be generalized because of this set of assignments.</p><p class="m_5315985348171188227gmail-m_7965936036501745560m_2160320856772879989gmail-m_4133516229890100231gmail-p1" style="font-size:12.8px"><br></p>I also tried another method, using a list constructor.</div><div><div><br>This does not work:</div><div><br></div><div><font face="monospace, monospace"> alist1 = [/nf_each_county, states, county, lat0, lon0,\<br> x0(:,:)/]</font></div><div><br></div>As above, if I explicitly list out the columns (from the 2d array), then everything is OK:</div><div><br><font face="monospace, monospace"> alist1 = [/nf_each_county, states, county, lat0, lon0,\<br> x0(0,:),x0(1,:),x0(2,:)/]<br></font></div><div><br><p class="m_5315985348171188227gmail-m_7965936036501745560m_2160320856772879989gmail-m_4133516229890100231gmail-p1" style="font-size:12.8px">I would sure appreciate any advice - again, a real noob. Using version 6.1.2.</p><p class="m_5315985348171188227gmail-m_7965936036501745560m_2160320856772879989gmail-m_4133516229890100231gmail-p1" style="font-size:12.8px">Dave</p></div></div>
<br></div><br></div>