Discussion:
Help for to do a script
Boris Vladimir Comi
2012-03-16 18:52:19 UTC
Permalink
Hello, I am writing to request your help in the realization of a script. I am new to this and I'm just learning the wonderful world of python and this has made me a little difficult.

Briefly I commented what I intend to do:

I detect a class of atmospheric phenomena known as Mesoscale Convective Systems (MCS). To accomplish this, I have a database of satellites by 2004, every half hour. These data were downloaded from the server: unidata2.ssec.wisc.edu and data format is: 200404271515.goes12ir (Area Format)

The first thing to do is detect a convective system in the satellite data, using the following characteristics:

MCS Criteria

Minimum Size: Continuous cold cloud shield (TIR <219 K and Must Have an area> 34000 km ²)

Duration: Definition of Minimum Size Must Be A Period of Exceed or ≥ 3h

Initiation: Time When the Minimum Size is met

Maximum Extention: Time when the continuous cloud shield (TIR <219 K) is at its maximum size

Termination: When the Time Minimun Size is not satisfied

where: Temperature Infrarred is TIR

To achieve this, first I created a script in python to identify a MCS in my database (script in attached)

The script is run from a linux terminal ($ python TIR.py), to run it I get the following error:

File "/home/mcidasv/JYTHON/TIR.py", line 22
count = count + 1;
^
SyntaxError: invalid syntax

If anyone can help me with this script or any idea you suggest to improve it, I would greatly appreciate.



Boris Vladimir Comi Gonzalez
Universidad Nacional Autónoma de México
Grupo de Tormentas Convecivas
Joel Goldstick
2012-03-16 18:58:44 UTC
Permalink
On Fri, Mar 16, 2012 at 2:52 PM, Boris Vladimir Comi
Post by Boris Vladimir Comi
Hello, I am writing to request your help in the realization of a script. I
am new to this and I'm just learning the wonderful world of python and this
has made me a little difficult.
I detect a class of atmospheric phenomena known as Mesoscale Convective
Systems (MCS). To accomplish this, I have a database of satellites by 2004,
unidata2.ssec.wisc.edu and data format is: 200404271515.goes12ir (Area
Format)
The first thing to do is detect a convective system in the satellite data,
MCS Criteria
Minimum Size: Continuous cold cloud shield (TIR <219 K and Must Have an
area> 34000 km ²)
Duration: Definition of Minimum Size Must Be A Period of Exceed or ≥ 3h
Initiation: Time When the Minimum Size is met
Maximum Extention: Time when the continuous cloud shield (TIR <219 K) is at
its maximum size
Termination: When the Time Minimun Size is not satisfied
where: Temperature Infrarred is TIR
To achieve this, first I created a script in python to identify a MCS in my
database (script in attached)
The script is run from a linux terminal ($ python TIR.py), to run it I get
File "/home/mcidasv/JYTHON/TIR.py", line 22
    count = count + 1;
        ^
SyntaxError: invalid syntax
If anyone can help me with this script or any idea you suggest to improve
it, I would greatly appreciate.
Boris Vladimir Comi Gonzalez
Universidad Nacional Autónoma de México
Grupo de Tormentas Convecivas
_______________________________________________
http://mail.python.org/mailman/listinfo/tutor
Here is your code:

for i in xrange(ad.getLines()):
for j in xrange(ad.getElements()):
if (data[0][i][j] > 199.5 and (data[0][i][j] < 200.5
count = count + 1;
print "For file",name," count = ",count

Notice that this line is broken:

if (data[0][i][j] > 199.5 and (data[0][i][j] < 200.5

change it to this and try running again:

if (data[0][i][j] > 199.5) and (data[0][i][j] < 200.5)
--
Joel Goldstick
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
http://m
Joel Goldstick
2012-03-16 18:59:45 UTC
Permalink
On Fri, Mar 16, 2012 at 2:58 PM, Joel Goldstick
Post by Joel Goldstick
On Fri, Mar 16, 2012 at 2:52 PM, Boris Vladimir Comi
Post by Boris Vladimir Comi
Hello, I am writing to request your help in the realization of a script. I
am new to this and I'm just learning the wonderful world of python and this
has made me a little difficult.
I detect a class of atmospheric phenomena known as Mesoscale Convective
Systems (MCS). To accomplish this, I have a database of satellites by 2004,
unidata2.ssec.wisc.edu and data format is: 200404271515.goes12ir (Area
Format)
The first thing to do is detect a convective system in the satellite data,
MCS Criteria
Minimum Size: Continuous cold cloud shield (TIR <219 K and Must Have an
area> 34000 km ²)
Duration: Definition of Minimum Size Must Be A Period of Exceed or ≥ 3h
Initiation: Time When the Minimum Size is met
Maximum Extention: Time when the continuous cloud shield (TIR <219 K) is at
its maximum size
Termination: When the Time Minimun Size is not satisfied
where: Temperature Infrarred is TIR
To achieve this, first I created a script in python to identify a MCS in my
database (script in attached)
The script is run from a linux terminal ($ python TIR.py), to run it I get
File "/home/mcidasv/JYTHON/TIR.py", line 22
    count = count + 1;
        ^
SyntaxError: invalid syntax
If anyone can help me with this script or any idea you suggest to improve
it, I would greatly appreciate.
Boris Vladimir Comi Gonzalez
Universidad Nacional Autónoma de México
Grupo de Tormentas Convecivas
_______________________________________________
http://mail.python.org/mailman/listinfo/tutor
             if (data[0][i][j] > 199.5 and (data[0][i][j] < 200.5
                 count = count + 1;
     print "For file",name," count = ",count
             if (data[0][i][j] > 199.5 and (data[0][i][j] < 200.5
--
Joel Goldstick
Sorry, also put : at end of if statements
--
Joel Goldstick
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
http://mail.python.org
Alan Gauld
2012-03-16 19:07:37 UTC
Permalink
*File "/home/mcidasv/JYTHON/TIR.py", line 22
count = count + 1;
^
SyntaxError: invalid syntax*
Error messages indicate where Python found the problem.
Often the real problem is a line or so before that.

In your case you omitted the colon after the if statement.

Note that Python does not require semi colons at
the end of lines. It rarely causes problems but
it doesn't help either.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Lennart Regebro
2012-03-16 19:14:59 UTC
Permalink
This mailing list is about porting from Python 2 to Python 3. For help
with specific programming errors I recommend stackoverflow.com.

ps. the error you made is probably on the row before

On Fri, Mar 16, 2012 at 19:52, Boris Vladimir Comi
Post by Boris Vladimir Comi
Hello, I am writing to request your help in the realization of a script. I
am new to this and I'm just learning the wonderful world of python and this
has made me a little difficult.
I detect a class of atmospheric phenomena known as Mesoscale Convective
Systems (MCS). To accomplish this, I have a database of satellites by 2004,
unidata2.ssec.wisc.edu and data format is: 200404271515.goes12ir (Area
Format)
The first thing to do is detect a convective system in the satellite data,
MCS Criteria
Minimum Size: Continuous cold cloud shield (TIR <219 K and Must Have an
area> 34000 km ²)
Duration: Definition of Minimum Size Must Be A Period of Exceed or ≥ 3h
Initiation: Time When the Minimum Size is met
Maximum Extention: Time when the continuous cloud shield (TIR <219 K) is at
its maximum size
Termination: When the Time Minimun Size is not satisfied
where: Temperature Infrarred is TIR
To achieve this, first I created a script in python to identify a MCS in my
database (script in attached)
The script is run from a linux terminal ($ python TIR.py), to run it I get
File "/home/mcidasv/JYTHON/TIR.py", line 22
    count = count + 1;
        ^
SyntaxError: invalid syntax
If anyone can help me with this script or any idea you suggest to improve
it, I would greatly appreciate.
Boris Vladimir Comi Gonzalez
Universidad Nacional Autónoma de México
Grupo de Tormentas Convecivas
_______________________________________________
Python-porting mailing list
http://mail.python.org/mailman/listinfo/python-porting
Alec Bennett
2012-03-16 19:05:02 UTC
Permalink
There's a lot wrong with it. I don't have the modules so I can't test, but
you need to chnage these two lines:

if (data[0][i][j] > 199.5 and (data[0][i][j] < 200.5

count = count + 1;

To something like:

if data[0][i][j] > 199.5 and data[0][i][j] < 200.5:

count = count + 1;

That's about very basic Python syntax, not the Image module, fyi.

Also, cross-posting to multiple email lists is considered very bad form.




On Fri, Mar 16, 2012 at 11:52 AM, Boris Vladimir Comi <
Post by Boris Vladimir Comi
Hello, I am writing to request your help in the realization of a script.
I am new to this and I'm just learning the wonderful world of python and
this has made me a little difficult.
I detect a class of atmospheric phenomena known as Mesoscale Convective
Systems (MCS). To accomplish this, I have a database of satellites by 2004,
unidata2.ssec.wisc.edu and data format is: 200404271515.goes12ir (Area
Format)
The first thing to do is detect a convective system in the satellite data,
*MCS Criteria*
*Minimum Size*: Continuous cold cloud shield (TIR <219 K and Must Have an
area> 34000 km ²)
*Duration*: Definition of Minimum Size Must Be A Period of Exceed or ≥ 3h
*Initiation*: Time When the Minimum Size is met
*
Maximum Extention*: Time when the continuous cloud shield (TIR <219 K) is
at its maximum size
*Termination:* When the Time Minimun Size is not satisfied
where: Temperature Infrarred is TIR
To achieve this, first I created a script in python to identify a MCS in my
database (script in attached)
The script is run from a linux terminal ($ python TIR.py), to run it I get the
*File "/home/mcidasv/JYTHON/TIR.py", line 22
count = count + 1;
^
SyntaxError: invalid syntax*
If anyone can help me with this script or any idea you suggest to improve
it, I would greatly appreciate.
****Boris Vladimir Comi Gonzalez
Universidad Nacional Autónoma de México
Grupo de Tormentas Convecivas
_______________________________________________
http://mail.python.org/mailman/listinfo/image-sig
Chris Barker
2012-03-19 21:53:08 UTC
Permalink
1) please don't multi-post like this -- this is really a "tutor"
question. i.e. your problem is very basic python

On Fri, Mar 16, 2012 at 11:52 AM, Boris Vladimir Comi
Post by Boris Vladimir Comi
I detect a class of atmospheric phenomena known as Mesoscale Convective
Systems (MCS). To accomplish this, I have a database of satellites by 2004,
unidata2.ssec.wisc.edu and data format is: 200404271515.goes12ir (Area
Format)
For this kind of work, you probably:

1) don't want to use Jython, unless there is a Java libary that will
do most of the work that you want to use

2) do want to use numpy/scipy -- and likely the ndimage package:

http://numpy.scipy.org/

http://www.scipy.org/SciPyPackages/Ndimage
Post by Boris Vladimir Comi
File "/home/mcidasv/JYTHON/TIR.py", line 22
    count = count + 1;
debuggin hint -- when the error is not obvious, ALWAYS look at the
proceeding line(s) of code:

for j in xrange(ad.getElements()):
if (data[0][i][j] > 199.5 and (data[0][i][j] < 200.5
count = count + 1;

the "if" needs two more end-parentheses, and a colon.

Also -- don't use semi-colons at the end of line -- they will just confuse you.

Get a good Python-aware editor -- it will help catch these really
simple kinds of syntax errors for you.

Good luck,

-Chris
--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

***@noaa.gov
_______________________________________________
Image-SIG maillist - Image-***@python.org
http://mail.python.org/mailman/listin
Loading...