Purpose: interact more with a pre-written class, test its methods, and then use the class to build a program which creates a FLEXPART AVAILABLE file
These exercises utilise data and programs that have been pre-packaged for this course. In the following,
<path to course>
refers to the path
/home/kurs/donmor/CourseFiles/
For the first part of this exercise, you should copy
<path to course>/LabExercises/Lab03/GFSData.py
into your $HOME working directory. Review this module and the class definition, then insert some code at the very bottom that creates a new object and invokes each of the methods and prints the return values. I have inserted a valid start time and part of the correct path to the source of data. You can replace the 2013033100 in the start time and directory name with 2013040400 for a second test with another set of data. In short, make sure that the GFSData class works for you!
Then, create a new Python program that imports this GFSData class and then performs the same tests.
Once you have this working, you have what you need to create an AVAILABLE file, necessary for FLEXPART to access previously downloaded meteorological data. This is what the AVAILABLE file for the 2013040400 input data looks like:
DATE TIME FILENAME SPECIFICATIONS
YYYYMMDD HHMISS
________ ______ __________ __________
20130404 000000 fh.0000_tl.press_gr.1p0deg ON DISC
20130404 030000 fh.0003_tl.press_gr.1p0deg ON DISC
20130404 060000 fh.0006_tl.press_gr.1p0deg ON DISC
20130404 090000 fh.0009_tl.press_gr.1p0deg ON DISC
20130404 120000 fh.0012_tl.press_gr.1p0deg ON DISC
20130404 150000 fh.0015_tl.press_gr.1p0deg ON DISC
20130404 180000 fh.0018_tl.press_gr.1p0deg ON DISC
20130404 210000 fh.0021_tl.press_gr.1p0deg ON DISC
20130405 000000 fh.0024_tl.press_gr.1p0deg ON DISC
You should write a program that creates output like this. Do your best on getting the same format, but don't worry too much about the trivial details like how many spaces are between fields. You can write it so it prints to the screen (like most of our examples so far), and then you can run like
./makeAVAILABLE.py > AVAILABLE
to redirect into a new AVAILABLE file.
Helpful advice -- we already know how to iterate through a single array --
for theItem in myArray:
print theItem
If I have two arrays, arr1 and arr2 of the same length, and I want to iterate through them synchronously, I can use the Python zip function to do so. An example follows:
for arr1Item, arr2Item in zip( arr1, arr2 ):
print arr1Item + ' ' + arr2Item
At each iteration, arr1Item stores the currently indexed value in arr1, and arr2Item the corresponding value in arr2.