[ncl-talk] Fwd: data extraction into ASII file by distinct lat/long

Dennis Shea shea at ucar.edu
Sat Sep 5 08:54:56 MDT 2015


OP: Please *DO NOT* post multiple times to ncl-talk at ucar.edu

==
This is a national holiday 3-day weekend. Responses will be slow.
==
As suggested by AlanB  ... also, as noted by Alan, ascii is the most
inefficient way to store data

==
 brute force
==
   c = addfiles(files,"r")
   rain=c[:]->pcp               ; (time,lat,lon)   ... (0,1,2)

   lat   = rain&lat
   lon  = rain&lon

   LAT  = conform( rain, lat, 1)   ; (ntim,nlat,mlon)
   LON = conform( rain, lon,2)

   valstr = ndtooned(LAT)+"  "+ndtooned(LON)+"  "+ndtooned(rain)
or
    valstr = sprintf("%6.2f", ndtooned(LAT))+"  " \
               +sprintf("%6.2f", ndtooned(LON))+"  " \
               +sprintf("%8.3f", +ndtooned(rain))

    asciiwrite("rain_all_lats_long.txt",  valstr)

On Sat, Sep 5, 2015 at 8:37 AM, Alan Brammer <abrammer at albany.edu> wrote:
> Woops, crucial typo in my last line.
>
> Blank messages to bump threads are
> n't
>  necessary here. Especially within 24 hours on a weekend.
>
> On Sat, Sep 5, 2015 at 10:36 AM, Alan Brammer <abrammer at albany.edu> wrote:
>>
>> asciiwrite is the most basic of the functions.  Below are two of the more
>> complex functions with more options for layout and formatting.
>> ascii is probably one of the worst ways to store data however, depending
>> on the number of files and dimensions this could take up a lot of space.
>>
>> https://www.ncl.ucar.edu/Document/Functions/Built-in/write_matrix.shtml
>>
>> https://www.ncl.ucar.edu/Document/Functions/Built-in/write_table.shtml
>>
>>
>>
>> Good luck.
>>
>>
>> Keep replies to ncl-talk.
>>
>>
>>
>> On Sat, Sep 5, 2015 at 9:34 AM, Saurabh Singh
>> <saurabhsingh123op at gmail.com> wrote:
>>>
>>>
>>> NCL Version- 6.3.0
>>> OS: UBUNTU
>>>
>>> i have monthly netcdf files contaminating precipitation files are named
>>> as netcdf1,netcdf2 ...and so on.
>>> I need to extract rainfall rate(precipitation of all the lat/long in a
>>> text file, the code extracts the rainfall values, but all lat longs are in a
>>> single column, i want each lat/long time series separated by a tab or a
>>> comma but i cannot do it.
>>>
>>> though i tried it using an example listed in
>>> "https://www.ncl.ucar.edu/Document/Functions/Built-in/asciiwrite.shtml"
>>> (example 4) but this takes to long to execute an i failed to get output.
>>>
>>> my current code is following. kindly suggest me how to modify it so that
>>> i can distinct lat-long values.
>>>
>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>>>
>>> ;;----------------------------------------------------------------------
>>> files = systemfunc("ls -1 /home/saurabh/Desktop/trmm/netcdf*") + ".nc"
>>>
>>> c = addfiles(files,"r")
>>> rain=c[:]->pcp
>>> asciiwrite("rain_all_lats_long.txt",rain)
>>> --
>>>
>>>
>>> With regards
>>> Saurabh Kumar singh ntly netcdf diles
>>>
>>>
>>>
>>>  P :  Please consider the environment before printing this e-mail
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>


More information about the ncl-talk mailing list