Basic Python Questions

10 views
Skip to first unread message

Clearscience

unread,
Dec 14, 2010, 12:02:02 AM12/14/10
to CCC GISTEMP discussion
Hi I am new to python and to the ccc-gistemp effort so bare with me.

I have limited programming experience (i've done things by hand more
or less in excel) although I have done some matlab work in the past.
My hopes is to be able to adjust the code so that I can conduct the
analysis on a Land-only region given specific Lat/Longs. I would like
to do this to the data which includes the environment Canada data.

Now I've got some pretty basic questions just for the first steps in
this whole attempt. I downloaded python 3.1 and I noticed that it has
a GUI and a command prompt version but I see very little difference
between the two. I was expecting a user interface similar to Matlab
which showed the directory I was working with and the .m (or in this
case .py) files which are in that directory, as well as a screen which
shows the variables that i've already assigned values to. Is there
something that I did not install perhaps?

If this sort of interface is not available then I may need some
instructions on moving to a directory (like where I have all the .py
files from ccc-gistemp) and subsequently running the .py files.

If I have this right I need to use the scraper tool (.py) to scrape
the GHCN data as well as the Canada data with the same tool?

Then afterwards I will make my adjustments to the code (such as
altering parameters) but I may need instructions on removing the SSTs
from the data. I could just comment every usage of SSTs out correct?

Sorry about all the questions but i'm just trying to learn.

David Jones

unread,
Dec 14, 2010, 3:42:03 AM12/14/10
to ccc-giste...@googlegroups.com
On 14 December 2010 05:02, Clearscience <clearsc...@gmail.com> wrote:
> Hi I am new to python and to the ccc-gistemp effort so bare with me.

The list is here to help. Personally, I'm pleased that your interest
in ccc-gistemp is sparking an interest in Python (all science should
be programmed in Python).

> I have limited programming experience (i've done things by hand more
> or less in excel) although I have done some matlab work in the past.
> My hopes is to be able to adjust the code so that I can conduct the
> analysis on a Land-only region given specific Lat/Longs. I would like
> to do this to the data which includes the environment Canada data.
>
> Now I've got some pretty basic questions just for the first steps in
> this whole attempt. I downloaded python 3.1 and I noticed that it has
> a GUI and a command prompt version but I see very little difference
> between the two. I was expecting a user interface similar to Matlab
> which showed the directory I was working with and the .m (or in this
> case .py) files which are in that directory, as well as a screen which
> shows the variables that i've already assigned values to. Is there
> something that I did not install perhaps?

Hmm. ccc-gistemp won't work with Python 3.1 (yet - John Keyes has
done some work on that). Sorry about that, but you need Python 2.7.
Python 3.1 is the way forward in the long term, but meanwhile the
Python 2.x and Python 3.x are sufficiently different that a lot of
software will still only work with Python 2.x. I'm curious, how did
you download Python3.1? On the Python download page it says: "If you
don't know which version to use, start with Python 2.7; more existing
third party software is compatible with Python 2 than Python 3 right
now.". The requirement for Python 2.x is also mentioned in the
ccc-gistemp readme.txt, but perhaps not clearly enough.

GUI. To be perfectly honest, I don't really use GUI programming
environments much, and I've only used Python's GUI a few times (and
I've never used Matlab). But I think you're right, the Python GUI is
just a thin wrapper around the command prompt.

>
> If this sort of interface is not available then I may need some
> instructions on moving to a directory (like where I have all the .py
> files from ccc-gistemp) and subsequently running the .py files.

Are you using Unix (Linux or OS X) or Windows?

Once you've unpacked the tarfile you will need to:
cd ccc-gistemp
(do this from the normal command prompt, not from Python).
the python files are then in two directories: "code" for the core
program; "tool" for all the supporting software including the
input/output routines. As per the readme.txt you can run ccc-gistemp
like this:
python tool/run.py
(do this from inside the ccc-gistemp directory)

> If I have this right I need to use the scraper tool (.py) to scrape
> the GHCN data as well as the Canada data with the same tool?

ccc-gistemp will normally automatically download the GHCN data (and
unfortunately the SST data and USHCN data, even when you're not
intending to use those).

>
> Then afterwards I will make my adjustments to the code (such as
> altering parameters) but I may need instructions on removing the SSTs
> from the data. I could just comment every usage of SSTs out correct?

Much easier than commenting out: The SST data is copied in Step 4 and
combined in Step 5. Skipping out Step 4 removes the SST data. You
can do this by:
python tool/run.py -s 0-3,5

> Sorry about all the questions but i'm just trying to learn.

Really niggly questions are probably best handled by chat, so if you
use IM feel free to add me:
on AIM: dcbtst
on jabber/gtalk: drj...@gmail.com

Do feel free to ask any more questions.

Cheers,
drj

Clearscience

unread,
Dec 14, 2010, 1:58:28 PM12/14/10
to CCC GISTEMP discussion
Hi all,
I have completed the ccc-gistemp analysis on my computer. It worked
fine and I got a nice result. Now I feel that I am a bit more familiar
and can move forward and continue with my analysis.

My workflow from my understanding will be the following:

(1)Use the cascrape tool
python tool/cascrape.py

followed by
(2)the camatch tool
python tool/camatch.py

(3) Change the parameters with given criteria mentioned previously

(4) Remove the Urban Adjustment (how can I do this?)

(5) conduct the analysis using the -s command with 0-3, 5 in order to
ignore SSTs.

(6) Conduct the grid over a specified lat long region. Any easy ways
to do this?

Have you noticed any issues with my workplan and are there any issues
that I have no addressed?

Thank you for your help.

On Dec 14, 3:42 am, David Jones <d...@pobox.com> wrote:

Richard Spencer

unread,
Dec 15, 2010, 4:37:30 AM12/15/10
to ccc-giste...@googlegroups.com
Hello!
For any other rookie Python programmers out there - like me! - I can heartily recommend the following book:
 
'Python Programming for the Absolute Beginner' (pub. Course Technology PTR) by Michael Dawson.
 
It is very readable and suitable for both programming newbies and programmers cross-training from other languages. Possibly the best - and certainly the most readable - pprogramming book I've come across.
 
Cheers,
Richard

 
> Date: Tue, 14 Dec 2010 10:58:28 -0800
> Subject: [ccc-gistemp] Re: Basic Python Questions
> From: clearsc...@gmail.com
> To: ccc-giste...@googlegroups.com
> --
> You received this message because you are subscribed to the Google Groups "CCC GISTEMP discussion" group.
> To post to this group, send email to ccc-giste...@googlegroups.com.
> To unsubscribe from this group, send email to ccc-gistemp-dis...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/ccc-gistemp-discuss?hl=en.
>

Clearscience

unread,
Dec 15, 2010, 2:01:12 PM12/15/10
to CCC GISTEMP discussion
Hey Richard,
Thank you for the help, I will try to look up the book potentially.

I believe I am currently (nearly at least) at the stage where I am
ready to begin trying to figure out how to specify the algorithm for
specific lats and longs. Any advice?

On Dec 15, 4:37 am, Richard Spencer <richard_n_spen...@hotmail.com>
wrote:
> Hello!
> For any other rookie Python programmers out there - like me! - I can heartily recommend the following book:
>
> 'Python Programming for the Absolute Beginner' (pub. Course Technology PTR) by Michael Dawson.
>
> It is very readable and suitable for both programming newbies and programmers cross-training from other languages. Possibly the best - and certainly the most readable - pprogramming book I've come across.
>
> Cheers,
> Richard
>
> > Date: Tue, 14 Dec 2010 10:58:28 -0800
> > Subject: [ccc-gistemp] Re: Basic Python Questions
> > From: clearscienc...@gmail.com
Reply all
Reply to author
Forward
0 new messages