[gradsusr] Error opening .txt file in a grads script

Jeff Duda jeffduda319 at gmail.com
Mon Nov 30 14:39:37 EST 2015


Keren,
You have a lot of extra spaces floating around in your commands. As far as
I know, when you're inserting script variables into a command in a grads
script, you need to be very explicit with the formatting of the command. In
other words, the spaces around your 'lat', 'lon', 'xloc', and 'yloc' may be
causing the syntax error. I recommend removing those spaces and trying
again. For example, change

"draw mark "flag " "xloc  " "yloc  " 0.1"

into

"draw mark "flag" "xloc" "yloc" 0.1"

Jeff

On Mon, Nov 30, 2015 at 1:30 PM, Keren Rosado - NOAA Affiliate <
keren.rosado at noaa.gov> wrote:

> Thanks Jeff,
>
> I already used the q w2xy and I don't see any error.
>
>
> Here is the rest of the script
>
> file ="lightning_from00z29April.004.txt"
> colors="1 2 3 4 5 6 7 8 9 10 11 12 13"
> ccount=0
>
> rc=1
> while (rc != 2)
>    data=read(file)
>    rc=sublin(data,1)
>    if (rc != 2)
>       line=sublin(data,2)
>       chk=substr(line,1,10)
>       if (chk != "----------")
>
>         lat=subwrd(line,1)
>         lon=subwrd(line,2)
>        flag=subwrd(line,3)
>       color=subwrd(line,4)
>
>
>         "q w2xy "lon " " lat
>          xloc=subwrd(result,3)
>          yloc=subwrd(result,6)
>          name=subwrd(ccount,1)
>
>           "set line "color" 1 5"
>           "set lat -20 20"
>           "set lon -40 25"
>           "draw mark "flag " "xloc  " "yloc  " 0.1"
> *         "draw mark 1 " xloc  " "yloc  " 0.06"
>       else
>          ccount=ccount+1
>       endif
>    endif
> endwhile
>
>
> 'set string 1 tc 1'
> 'set strsiz .30'
>
>
> ----
> Keren Rosado
> PhD Candidate/Howard University/NOAA EPP GRTSP Fellow
> Intern/NOAA/NWS/NCEP/EMC
> 5830 University Research CT
> Cubicle 2795
> College Park, MD 20740
> Tel: (301)-683-3816 <%28301%29-683-3763>
> Cel: *(407)-621-1676 *
> Email: Keren.Rosado at noaa.gov <Bin.Liu at noaa.gov>
>
> On Mon, Nov 30, 2015 at 2:06 PM, Jeff Duda <jeffduda319 at gmail.com> wrote:
>
>> Keren,
>>
>> The error tells you what the problem is. You must have a "draw mark"
>> command somewhere in your script that has a syntax error in it. You can use
>> the grads documentation index to determine values of the various arguments
>> to that function. I suspect you have an error in your x and y arguments in
>> the function call. The x and y arguments need to be in real page units, not
>> world coordinates. You'll need to use the 'query (position)' functions to
>> translate between world coordinates, grid coordinates, and page
>> coordinates. A commonly used one is 'q w2xy', which would convert world
>> coordinates to real page coordinates.
>>
>> Jeff Duda
>>
>> On Mon, Nov 30, 2015 at 12:51 PM, Keren Rosado - NOAA Affiliate <
>> keren.rosado at noaa.gov> wrote:
>>
>>> The text file is big but from what I can see is all numbers.
>>>
>>>  11.228   -73.969   1
>>>  13.983     5.299   1
>>>  13.790   -14.934   1
>>>  22.645   -51.073   1
>>>  11.254   -73.973   1
>>>   6.508   -61.990   1
>>>  11.405     4.011   1
>>>  29.012   -59.311   1
>>>  11.262   -74.027   1
>>>  10.631   -68.972   1
>>>  11.270   -73.941   1
>>>  11.341   -73.955   1
>>>  11.295   -73.604   1
>>>  11.269   -73.595   1
>>>  11.231   -73.537   1
>>>  11.254   -73.611   1
>>>
>>>
>>> When I type  "run namescript.gs" I get the following error:
>>>
>>>  DRAW error: Syntax is DRAW MARK marktype x y size
>>> DRAW error: Syntax is DRAW MARK marktype x y size
>>> DRAW error: Syntax is DRAW MARK marktype x y size
>>> DRAW error: Syntax is DRAW MARK marktype x y size
>>> DRAW error: Syntax is DRAW MARK marktype x y size
>>> DRAW error: Syntax is DRAW MARK marktype x y size
>>>
>>> But when I run the script line by line the first error I get is the one
>>> I send in the first email.
>>>
>>>
>>> Thanks
>>>
>>>
>>> ----
>>> Keren Rosado
>>> PhD Candidate/Howard University/NOAA EPP GRTSP Fellow
>>> Intern/NOAA/NWS/NCEP/EMC
>>> 5830 University Research CT
>>> Cubicle 2795
>>> College Park, MD 20740
>>> Tel: (301)-683-3816 <%28301%29-683-3763>
>>> Cel: *(407)-621-1676 <%28407%29-621-1676> *
>>> Email: Keren.Rosado at noaa.gov <Bin.Liu at noaa.gov>
>>>
>>> On Mon, Nov 30, 2015 at 1:16 PM, Jeff Duda <jeffduda319 at gmail.com>
>>> wrote:
>>>
>>>> The snippet of script code you included isn't consistent with the
>>>> output you included. I can't see from what you included what would be the
>>>> cause of the error. Do you have non-alphanumeric characters in your text
>>>> file? Otherwise I suspect you have a syntax error in your script somewhere
>>>> else.
>>>>
>>>> Jeff Duda
>>>>
>>>> On Mon, Nov 30, 2015 at 10:36 AM, Keren Rosado - NOAA Affiliate <
>>>> keren.rosado at noaa.gov> wrote:
>>>>
>>>>> Hello,
>>>>>
>>>>> I am trying to open a .txt file in a .gs grads script without luck.
>>>>> Grads version 2.0.1
>>>>>
>>>>>
>>>>> This is what I have
>>>>>
>>>>> 'open dummy.ctl'
>>>>> file = 'A20100826a.txt'
>>>>> colors="1 2 3 4 5 6 7 8 9 10 11 12 13"
>>>>> ccount=0
>>>>>
>>>>> rc=1
>>>>> while (rc != 2)
>>>>>    data=read(file)
>>>>>    rc=sublin(data,1)
>>>>>    if (rc != 2)
>>>>>       line=sublin(data,2)
>>>>>       chk=substr(line,1,10)
>>>>>       if (chk != "----------")
>>>>> .
>>>>> .
>>>>> .
>>>>> .
>>>>>  The code keeps going but the error is at the "file" line.
>>>>>
>>>>> Here is the error
>>>>> file = 'A20100826a.txt'
>>>>> Syntax Error:  Expected operand or '('
>>>>>   Error ocurred at column 1
>>>>> DEFINE error:  Invalid expression.
>>>>>
>>>>> Thanks!
>>>>>
>>>>>
>>>>>
>>>>> ----
>>>>> Keren Rosado
>>>>> PhD Candidate/Howard University/NOAA EPP GRTSP Fellow
>>>>> Intern/NOAA/NWS/NCEP/EMC
>>>>> 5830 University Research CT
>>>>> Cubicle 2795
>>>>> College Park, MD 20740
>>>>> Tel: (301)-683-3816 <%28301%29-683-3763>
>>>>> Cel: *(407)-621-1676 <%28407%29-621-1676> *
>>>>> Email: Keren.Rosado at noaa.gov <Bin.Liu at noaa.gov>
>>>>>
>>>>> _______________________________________________
>>>>> gradsusr mailing list
>>>>> gradsusr at gradsusr.org
>>>>> http://gradsusr.org/mailman/listinfo/gradsusr
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Jeff Duda
>>>> Graduate research assistant
>>>> University of Oklahoma School of Meteorology
>>>> Center for Analysis and Prediction of Storms
>>>>
>>>> _______________________________________________
>>>> gradsusr mailing list
>>>> gradsusr at gradsusr.org
>>>> http://gradsusr.org/mailman/listinfo/gradsusr
>>>>
>>>>
>>>
>>> _______________________________________________
>>> gradsusr mailing list
>>> gradsusr at gradsusr.org
>>> http://gradsusr.org/mailman/listinfo/gradsusr
>>>
>>>
>>
>>
>> --
>> Jeff Duda
>> Graduate research assistant
>> University of Oklahoma School of Meteorology
>> Center for Analysis and Prediction of Storms
>>
>> _______________________________________________
>> gradsusr mailing list
>> gradsusr at gradsusr.org
>> http://gradsusr.org/mailman/listinfo/gradsusr
>>
>>
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>


-- 
Jeff Duda
Graduate research assistant
University of Oklahoma School of Meteorology
Center for Analysis and Prediction of Storms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20151130/f92f8dc3/attachment-0001.html 


More information about the gradsusr mailing list