From vinay_sajip at yahoo.co.uk Sat Mar 3 13:21:10 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Sat, 3 Mar 2012 12:21:10 +0000 (UTC) Subject: [Python-porting] A question about running 2to3 on projects in progress Message-ID: Hi, Suppose a project is being ported using 2to3, and there are some parts of the codebase which have been converted and others which haven't. 2to3 currently doesn't like some 3 features when parsing, e.g. print('abc', file=sys.stdout) in the source causes a parse error at the '='. Is there any way around this, e.g. picking another grammar dynamically, or is it baked in? Regards, Vinay Sajip From regebro at gmail.com Sat Mar 3 13:25:17 2012 From: regebro at gmail.com (Lennart Regebro) Date: Sat, 3 Mar 2012 13:25:17 +0100 Subject: [Python-porting] A question about running 2to3 on projects in progress In-Reply-To: References: Message-ID: On Sat, Mar 3, 2012 at 13:21, Vinay Sajip wrote: > Hi, > > Suppose a project is being ported using 2to3, and there are some parts of the > codebase which have been converted and others which haven't. 2to3 currently > doesn't like some 3 features when parsing, e.g. print('abc', file=sys.stdout) in > the source causes a parse error at the '='. Is there any way around this, e.g. > picking another grammar dynamically, or is it baked in? Well, you have to convert only those files who haven't been converted. Or if you mean that some things (like print) has been converted already, you can skip those fixers. But code that are inconsistently mixing Python 2 and Python 3 idioms can't be converted with 2to3 as far as I know. //Lennart From vinay_sajip at yahoo.co.uk Sat Mar 3 13:59:48 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Sat, 3 Mar 2012 12:59:48 +0000 (UTC) Subject: [Python-porting] =?utf-8?q?A_question_about_running_2to3_on_proje?= =?utf-8?q?cts_in=09progress?= References: Message-ID: Lennart Regebro writes: > Well, you have to convert only those files who haven't been converted. > Or if you mean that some things (like print) has been converted > already, you can skip those fixers. > > But code that are inconsistently mixing Python 2 and Python 3 idioms > can't be converted with 2to3 as far as I know. I thought that might be the case, but no harm in checking! Thanks. Regards, Vinay Sajip From glez_b at comunidad.unam.mx Fri Mar 16 19:52:19 2012 From: glez_b at comunidad.unam.mx (Boris Vladimir Comi) Date: Fri, 16 Mar 2012 18:52:19 +0000 Subject: [Python-porting] Help for to do a script Message-ID: 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: TIR.py Type: text/x-python Size: 848 bytes Desc: not available URL: From regebro at gmail.com Fri Mar 16 20:14:59 2012 From: regebro at gmail.com (Lennart Regebro) Date: Fri, 16 Mar 2012 20:14:59 +0100 Subject: [Python-porting] Help for to do a script In-Reply-To: References: Message-ID: 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 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 > Python-porting at python.org > http://mail.python.org/mailman/listinfo/python-porting > From joel.goldstick at gmail.com Fri Mar 16 19:58:44 2012 From: joel.goldstick at gmail.com (Joel Goldstick) Date: Fri, 16 Mar 2012 14:58:44 -0400 Subject: [Python-porting] [Tutor] Help for to do a script In-Reply-To: References: Message-ID: On Fri, Mar 16, 2012 at 2:52 PM, Boris Vladimir Comi 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 ?- ?Tutor at python.org > 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 From joel.goldstick at gmail.com Fri Mar 16 19:59:45 2012 From: joel.goldstick at gmail.com (Joel Goldstick) Date: Fri, 16 Mar 2012 14:59:45 -0400 Subject: [Python-porting] [Tutor] Help for to do a script In-Reply-To: References: Message-ID: On Fri, Mar 16, 2012 at 2:58 PM, Joel Goldstick wrote: > On Fri, Mar 16, 2012 at 2:52 PM, Boris Vladimir Comi > 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 ?- ?Tutor at python.org >> 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 From wrybread at gmail.com Fri Mar 16 20:05:02 2012 From: wrybread at gmail.com (Alec Bennett) Date: Fri, 16 Mar 2012 12:05:02 -0700 Subject: [Python-porting] [Image-SIG] Help for to do a script In-Reply-To: References: Message-ID: 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 < glez_b at comunidad.unam.mx> 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 - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From glez_b at comunidad.unam.mx Fri Mar 16 22:46:19 2012 From: glez_b at comunidad.unam.mx (Boris Vladimir Comi) Date: Fri, 16 Mar 2012 21:46:19 +0000 Subject: [Python-porting] Help whith script Message-ID: Hello, corrected the code and it runs correctly. I run the script through a program called McIDAS-V. I guess when i run the script (TIR.py) as follows: / home / mcidasv / McIDAS-V-System / runMcV-islfile scm.py refers to the module AreaFile. My database is composed of monthly and is the Following: 200406010000.goes10ir 200406010000.goes10vis 200406010000.goes10wv 200406010000.goes12ir 200406010000.goes12vis 200406010000.goes12wv Each has 3 channels: ir(infrarred), vis (visible), wv(water vapor) with four variables: raw, radiance, brightness and temperature . I actually only interested in data format .goes12ir and variable temperature. How I can make that filter data and where in the code could add that filter ? After filtering the database, how could calculate the area of ??the cloud shield whose temperature is <219 K (see purple line in attached)? Note: when I deploy a data(200406010000.goes12ir) in the McIDAS-V, I get a satellite image that represents different values ??of brightness temperatures associated with the cloud that appears in the satellite image (see image in attached) Boris Vladimir Comi Gonzalez Universidad Nacional Aut?noma de M?xico Grupo de Tormentas Convecivas -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: TIR.py Type: text/x-python Size: 829 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: IMAGE-IR.jpg Type: image/jpeg Size: 333189 bytes Desc: not available URL: From chris.barker at noaa.gov Mon Mar 19 22:53:08 2012 From: chris.barker at noaa.gov (Chris Barker) Date: Mon, 19 Mar 2012 14:53:08 -0700 Subject: [Python-porting] [Image-SIG] Help for to do a script In-Reply-To: References: Message-ID: 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 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 Chris.Barker at noaa.gov