[ncl-talk] avoiding loops

Micah Sklut micahs2005 at gmail.com
Sun Sep 22 11:32:25 MDT 2019


Okay, thanks, Dave.  That sounds like what I need. I've always struggled
with the formatting in NCL, but I'll give that a go and see where I get.

On Sun, Sep 22, 2019 at 1:26 PM Dave Allured - NOAA Affiliate <
dave.allured at noaa.gov> wrote:

> Try write_matrix and the F0 format descriptor.  F0 format is part of
> fortran 90 and up.  It is described in modern fortran documentation.  It is
> like the common Fw.d format descriptor, except leading blanks to the left
> of the decimal point are suppressed.
>
> Reshape your array from, e.g. (lat,lon,time), to a 2-D array in the
> desired output order, (points,time).  Npoints = Nlats x Nlons.  Then a
> single call to write_matrix should write the entire output file:
>
>     opt = True
>     opt at fout = "temperature.csv"
>     write_matrix (data_out, "384(f0.1,','),f0.1", opt)
>
> You can add arbitrary extra numeric columns to the output array, if it
> would be helpful to have lats and lons, or other such metadata, on each
> line of output.
>
>
> On Sat, Sep 21, 2019 at 2:53 PM Micah Sklut via ncl-talk <
> ncl-talk at ucar.edu> wrote:
>
>> Hi,
>>
>> I have a task to take GFS data and concatenate variables across all the
>> forecast hours, for each grid point.
>>
>> For example, taking a temperature variable for each grid point, for all
>> latitude and longitudes, and creating a string that represents the values
>> for each forecast hour.
>> So, if we have for latitude y, and longitude x, there would be a string
>> value like "70.5,71.5,71.5,72.0,...nHours".  The end product will be a line
>> for each grid point for the variables i"m looking at that will be written
>> to a file to be imported into a database.
>>
>> Creating loops through all hours, latitudes, and longitudes will get the
>> job done, but is expensive and was looking to see if there were any NCL
>> functions that would help here.
>>
>> Thank you.
>>
>

-- 
Micah Sklut
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190922/934eebde/attachment.html>


More information about the ncl-talk mailing list