Quantcast

Help for to do a script

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Help for to do a script

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.

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

_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig

TIR.py (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Tutor] Help for to do a script

Joel Goldstick-2
On Fri, Mar 16, 2012 at 2:52 PM, Boris Vladimir Comi
<[hidden email]> wrote:

> 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
>
> _______________________________________________
> Tutor maillist  -  [hidden email]
> To unsubscribe or change subscription options:
> 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
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Tutor] Help for to do a script

Joel Goldstick-2
On Fri, Mar 16, 2012 at 2:58 PM, Joel Goldstick
<[hidden email]> wrote:

> On Fri, Mar 16, 2012 at 2:52 PM, Boris Vladimir Comi
> <[hidden email]> wrote:
>> 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
>>
>> _______________________________________________
>> Tutor maillist  -  [hidden email]
>> To unsubscribe or change subscription options:
>> 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

Sorry, also put : at end of if statements

--
Joel Goldstick
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Help for to do a script

pontissimo
In reply to this post by Boris Vladimir Comi
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 <[hidden email]> wrote:
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

_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig



_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Python-porting] Help for to do a script

Lennart Regebro-2
In reply to this post by Boris Vladimir Comi
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
<[hidden email]> wrote:

> 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
>
> _______________________________________________
> Python-porting mailing list
> [hidden email]
> http://mail.python.org/mailman/listinfo/python-porting
>
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Help for to do a script

Donn-11
In reply to this post by Boris Vladimir Comi
On 16/03/2012 20:52, Boris Vladimir Comi wrote:
>                if (data[0][i][j]>  199.5 and (data[0][i][j]<  200.5
>                    count = count + 1;

Looks like the if command does not close properly. It needs a brackets
and a colon.

Also, you don't need to use semi-colons, at all.

HTH
/d
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Help for to do a script

Chris Barker
In reply to this post by Boris Vladimir Comi
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
<[hidden email]> wrote:
> 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)

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

> 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

[hidden email]
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Loading...