[ncl-talk] Remove white-spaces from write_table output

swati shewale shewaleswati16 at gmail.com
Wed Sep 6 00:35:55 MDT 2017


Hiii
I did club all the 3 hrly output datafile from wrf output (total 8 files)
using ncrcat so that i get a single file, which now include 8 time step. to
handle this processed file, script is available. I hope the way i did might
be correct one. I am getting the plot attached here along with script.
please let me know whether it is correct one or not. Thanks to all for
participation and cooperation. As I am new to NCL, I may post queries
several times.

On Fri, Aug 11, 2017 at 8:17 PM, David Brown <dbrown at ucar.edu> wrote:

> Maybe a better idea would be to just use a setfileoption that would
> turn the default blank space into a non-space.
>  -dave
>
> On Fri, Aug 11, 2017 at 8:36 AM, Barry Lynn <barry.h.lynn at gmail.com>
> wrote:
> > Hi:
> >
> > It sounds like you've found a solution, but one should mention that a
> > fortran write statement (using WRAPIT) is easy to format.
> >
> > Barry
> >
> > On Fri, Aug 11, 2017 at 5:35 PM, Mary Haley <haley at ucar.edu> wrote:
> >>
> >> We could certainly do that, but the format string was set up to allow
> you
> >> to enter text in additional to format strings, for example:
> >>
> >>  i = ispan( 95,105, 1)
> >>  j = ispan(905,1005,10)
> >>
> >>  write_table("example4.txt","w",[/i,j/],"first_%05i second_%05i")
> >>
> >> which gives you:
> >>
> >> first_00095 second_00905
> >> first_00096 second_00915
> >> . . .
> >>
> >> Like you said, we would have to choose which special character could be
> >> used.  I suppose in the case of write_table, you could use
> setfileoption to
> >> set or change the special character.
> >>
> >> --Mary
> >>
> >>
> >>
> >>
> >> On Thu, Aug 10, 2017 at 2:31 PM, David Brown <dbrown at ucar.edu> wrote:
> >>>
> >>> I am wondering if we could provide a special formatting character that
> >>> could be part of the format string, maybe at the beginning, and would
> >>> signal that no automatic separator character be used. Of course which
> >>> character to use might be an issue, but hopefully that could be
> >>> solved.
> >>>  -dave
> >>>
> >>> On Thu, Aug 10, 2017 at 2:12 PM, Dennis Shea <shea at ucar.edu> wrote:
> >>> > Fortran (some other languages too!) has the capability to provide
> user
> >>> > specified granularity in parsing strings of numbers and characters.
> >>> >
> >>> > fortran:   format(i2,5i5)
> >>> >               2999999999999999999999999999999
> >>> >
> >>> > The problem is someone must tell you the structure. You could read as
> >>> > follows:
> >>> >               format(i2,i2,i3,i5,i4,i1,.......)
> >>> >
> >>> > However, any 'automatic' software must have some separator between
> the
> >>> > numbers.
> >>> >
> >>> > --
> >>> > NCDC has text files the include letters, numbers, periods (76.5) all
> >>> > together.
> >>> >
> >>> > ====
> >>> > fortran:   format(i2,5(1x,i5))
> >>> >               2 99999 99999 99999 99999 99999 99999
> >>> >
> >>> > Just a comment
> >>> > D
> >>> >
> >>> > On Thu, Aug 10, 2017 at 12:02 PM, Rabah Hachelaf <
> hachelaf at sca.uqam.ca>
> >>> > wrote:
> >>> >>
> >>> >> Hi Mary and Karin,
> >>> >>
> >>> >> Adding white-spaces by default is a limitation if we need to write
> >>> >> some
> >>> >> data using a FORTRAN format.
> >>> >> We could bypass this "issue" by removing one character starting from
> >>> >> the
> >>> >> 2nd variable but we would have liked to keep the same format between
> >>> >> FORTRAN
> >>> >> and NCL
> >>> >>
> >>> >> Regards,
> >>> >>
> >>> >> Rabah
> >>> >>
> >>> >> 2017-08-10 13:15 GMT-04:00 Mary Haley <haley at ucar.edu>:
> >>> >>>
> >>> >>> Hi Rabah,
> >>> >>>
> >>> >>> I see Karin already responded, and had the same response I was just
> >>> >>> about
> >>> >>> to send!
> >>> >>>
> >>> >>> I'll go ahead and include my response here. I've updated the
> >>> >>> documentation to indicate this behavior, and also created a ticket
> >>> >>> just in
> >>> >>> case.
> >>> >>>
> >>> >>> Unfortunately, I think this is a "feature" of write_table. Even if
> >>> >>> there's a case for declaring this a bug, we probably couldn't
> change
> >>> >>> the
> >>> >>> behavior because we'd likely break a bunch of existing scripts that
> >>> >>> depend
> >>> >>> on the space being there.
> >>> >>>
> >>> >>> I created a ticket on this (NCL-2646), in case it's an issue for
> >>> >>> other
> >>> >>> users.
> >>> >>>
> >>> >>> Meanwhile, as Karin pointed out, I think the only way around this
> is
> >>> >>> to
> >>> >>> concatenate the strings yourself:
> >>> >>>
> >>> >>> int1 = 2
> >>> >>> int2 = "99999"
> >>> >>> int3 = "99999"
> >>> >>> int4 = "99999"
> >>> >>> int5 = "99999"
> >>> >>> int6 = "99999"
> >>> >>> int7 = "99999"
> >>> >>> int_cat = int2+int3+int4+int5+int6+int7
> >>> >>> sounding_check = [/int1,int_cat/]
> >>> >>> write_table(outfile,"w",sounding_check,"%2i%s")
> >>> >>>
> >>> >>> In general, I would caution against writing numbers to a file
> without
> >>> >>> any
> >>> >>> spaces, because this makes it potentially very difficult for
> somebody
> >>> >>> else
> >>> >>> looking at the file to know how to read it.  However, I do
> understand
> >>> >>> that
> >>> >>> some of these files have historically been written this way for
> other
> >>> >>> purposes
> >>> >>>
> >>> >>> --Mary
> >>> >>>
> >>> >>>
> >>> >>>
> >>> >>> On Wed, Aug 9, 2017 at 3:13 PM, Rabah Hachelaf <
> hachelaf at sca.uqam.ca>
> >>> >>> wrote:
> >>> >>>>
> >>> >>>>
> >>> >>>> Hello,
> >>> >>>> I am wounding why there is a systematic white-spaces between
> values
> >>> >>>> although they are removed from the format specifier.
> >>> >>>> How can i remove white spaces from in this case.
> >>> >>>>
> >>> >>>> Thank you
> >>> >>>>
> >>> >>>>
> >>> >>>> begin
> >>> >>>> outfile = "test.txt"
> >>> >>>> sounding_check =
> >>> >>>> [/2,"99999","99999","99999","99999","99999","99999"/]
> >>> >>>> write_table(outfile,"a",sounding_check,"%2i%s%s%s%s%s%s")
> >>> >>>>
> >>> >>>> end
> >>> >>>>
> >>> >>>>
> >>> >>>> output :
> >>> >>>>  2 99999 99999 99999 99999 99999 99999
> >>> >>>> --
> >>> >>>> ------------------------------
> >>> >>>> Best regards,
> >>> >>>> Rabah Hachelaf
> >>> >>>>
> >>> >>>>
> >>> >>>>
> >>> >>>> _______________________________________________
> >>> >>>> ncl-talk mailing list
> >>> >>>> ncl-talk at ucar.edu
> >>> >>>> List instructions, subscriber options, unsubscribe:
> >>> >>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >>> >>>>
> >>> >>>
> >>> >>
> >>> >>
> >>> >>
> >>> >> --
> >>> >> ------------------------------
> >>> >> Cordialement,
> >>> >> Best regards,
> >>> >> Rabah Hachelaf
> >>> >>
> >>> >> _______________________________________________
> >>> >> 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
> >>> >
> >>
> >>
> >>
> >> _______________________________________________
> >> ncl-talk mailing list
> >> ncl-talk at ucar.edu
> >> List instructions, subscriber options, unsubscribe:
> >> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >>
> >
> >
> >
> > --
> > Barry H. Lynn, Ph.D
> > Senior Lecturer,
> > The Institute of the Earth Science,
> > The Hebrew University of Jerusalem,
> > Givat Ram, Jerusalem 91904, Israel
> > Tel: 972 547 231 170
> > Fax: (972)-25662581
> >
> > C.E.O, Weather It Is, LTD
> > Weather and Climate Focus
> > http://weather-it-is.com
> > Jerusalem, Israel
> > Local: 02 930 9525
> > Cell: 054 7 231 170
> > Int-IS: x972 2 930 9525
> > US 914 432 3108
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170906/b70ea317/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: panel_plot.ncl
Type: application/octet-stream
Size: 2417 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170906/b70ea317/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patna_temp.png
Type: image/png
Size: 271721 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170906/b70ea317/attachment-0001.png>


More information about the ncl-talk mailing list