Now we are going to see , how one developer going to share their snippet to launchpad domain.
( Here take screenshots when I shared one snippet to launchpad/python-snippets domain )
We will first need to grab the Python Snippets library from Launchpad
$ bzr branch lp:python-snippets
This command will grab all the python-snippet from launchpad and download in to current directory.
Assume we created our own snippet . Now its ready to share.
( This is gedit 2.30.0. )
Now we are going to share this snippet to launchpad via the following commands.
We now need to add our file in our branch using the add cmd:
$ bzr add your-snippet.py
Change the current working directory into correct path in python-snippets directory
$ bzr add mail.py
Now, commit our changes to our local branch with the following cmd:
$ bzr commit
Now nano editor is opened to save the information about commit changes.
Here we need to type our commit log message .
And then Press “Ctrl+O” for write and “Ctrl+M” to append and fianlly “Ctrl+x” to exit the nano editor.
In the above image , we can see the committed revision number after added our file.
The following 3 steps for initial setup to share our file to launchpad.
Now we are going to generate our own Public RSA Key to share our program in launchpad. It will help to download other user.
$ ssh-keygen -t rsa
Now it asks the file name and password to pulic key. we need to enter our public key. Here i entered simply as “Enter” button as public key.
Now we need to copy the our Public RSA Key from ~/.ssh folder.
$ cd ~
$ cd .ssh
$ gedit id_rsa.pub
Copy the above content fully.
Step 3 :
Now we need to paste the copied content ( public key ) in our launchpad ssh key.
Login to our launchpad account and grab the create/edit ssh key .
That should be like below image.
Paste the copied content in “public key line” in our launchpad ssh key page as shown below.
Now press the “Import Key”.
Now SSH Public Key is successfully added.
Here after we can upload many times our snippets into our launchpad account. The past 3 steps for one/first time process. Then lauchpad will remember our home folder and its .ssh public key. So no need to do the above 3 steps while doing next snippet upload/share from this system.
With our new snippet ready, it is time to propose it for inclusion in the main python-snippets library.sharing snippet)
Already we add our snippet (mail.py) and committed to our local bazzar.
Now push it to our own branch on Launchpad:
$ bzr push lp:~<your launchpad username>/python-snippets/<name of your branch>
$ bzr push lp:~tarulalan/python-snippets/webkit
Now its pushed into lauchpad and opeing the launchpad with our account in web browser.
This launchpad page will be automatically open. Here we will see our pushed file link and its status.
Here highlighted by within black boxes.
Now the status is “ This branch has not been scanned yet “.
So , we need to clcik “Propose For Merging”
Here we can write small description about our sharing snippet to understand by others.
We have “Extra Options” also. In that we can write Commit Message and extra informations.
Finally , Click ” Propose Merge “
Finished . we done proposal for merge our snippet with the public snippet library.
Now we can see the status has been changed into our description message.
At the end , we will receive the mail from launchpad about the shared snippet and its status and its reviewers.
By this way any one can share their own snippets in launchpad.
Hi to all,
Here i attached 51 images which is taken the output by automatted script using crontab in ubuntu .
see the time stamp on the top most right corner. Use slide show in picasa to view .!.
These output “isotherm_india” are generated by
1. webscraping the current temperature and barometer from the site http://www.timeanddate.com/weather/india to all the cities. Also getting values from china , pakistan , miyanmar, sri lankha, Nepal ,etc.,
2. Generate iso.nc which is plotting the current temperature over India map
3. Generate the Isothermal_over_india.png using “iso.nc” file
4. Send this “output image” and “to its source text file which contains ” latitude,longitude,temperature,barometer” to my mail id and ten of my friends mail id.
5. I automatted all the 4 steps for nearly 2 days for every half an hour.
I have the text source file , so i can regenerate the same output as same in the above image link .
Hi to all,
On 13 th March 2010, afternoon 3.30 pm i started to present my project deomo on “Creating Current Isotherm Lines on Over Cdat-India Map”.
In front of My guide Mr.Thyagarajan Shanmugham and other ilugc active members like Mr.Raman, Mr.Bharathi , Mr.Shrinivasan i was presented about cdat , contour lines and dynamic creation on contour demo using Reliance Net Card.
Also few of my friend Nandha kumar , Dhasthageer , Selvamai , Rajkumar were came to attend my project demo in ilugc.
Like wise more than 20 people were attend the ilugc meeting on that day.
Thanks to my guide and ilugc members to gave me a wonderful oppurtunity to present my project demo.
Hi to all,
While doing my project , i have to get current temperature for over all india cities.
For World : Current Temperature
For India : Current Temperature
I wrote one webscrap program to get all india cities current temperature from the above link.
And after running this python program then it will create “cities_and_its_temperatures_in_degree.txt” in your working directory.
To run this program , we need to install BeautifulSoup package.
$ sudo apt-get install python-setuptools
$ sudo easy_install BeautifulSoup
or install from the BeautifulSoup Source Package.
from BeautifulSoup import BeautifulSoup import re import urllib import unicodedata import os #open the url print("Start Reading the website- this may take some time - approx 2 mins ") filecontent= urllib.urlopen('http://www.timeanddate.com/weather/india').read() #convert it into beautiful soup content soupcontent = BeautifulSoup(filecontent) print("Printing the values, which have been parsed") #write the whole parsed soupcontent into temp.txt file f=open('temp.txt','w') s=str(soupcontent) f.write(s) f.close() #find and write the long string which contaning all the cities temperature values inside table from temp.txt into content.txt file1=open('temp.txt','r') for line in file1: loc=line.find("agra") if loc is not -1: content=line file1.close() file2=open('content.txt','w') file2.write(content) file2.close() file3=open('content.txt','r') file4=open('cities_and_its_temperatures_in_degree.txt','w') # find the temperature degree value from this line array by reverse finding method and writes into deg,city variable. then reverse those string variable value and write into cities_and_its_temperatures_in_degree.txt file for line in file3: #To find and Current time from the web link time_col=line.find('img') date_and_time='' time_col=time_col-21 date_and_time=date_and_time+line[time_col] flag0=1 while flag0: time_col=time_col-1 date_and_time=date_and_time+line[time_col] if line[time_col-1]==">": flag0=0 date_and_time = date_and_time[::-1] first_line="current temperature in all cities of india at this moment "+date_and_time file4.write(first_line) file4.write('\n') #To find degree of temp found=line.find(' °C') while found > -1: flag=1 column=found deg='' while flag: column=column-1 if line[column-1]==">": flag=0 deg=deg+line[column] deg = deg[::-1]# reverse the string value city='' flag1=1 while flag1: column=column-1 if line[column-1]==">": if line[column-2]=="a": column=column-5 while flag1: city=city+line[column] column=column-1 if line[column]==">": flag1=0 city = city[::-1]# reverse the string value city_and_temp='' city_and_temp=city+' '+deg+'\n' file4.write(city_and_temp) #print city #print deg found=line.find(' °C', found+1) file3.close() file4.close() print "cities_and_its_temperatures_in_degree.txt has successfully created\n please open this file to view all cities current temperature in degree" os.remove('temp.txt') os.remove('content.txt') print date_and_time
Please use pastebin site to download the above program.
Output on 23/03/2010 at 08.01 am. Its getting current temperature for around 404 cities in India.
I hope this may help to some one. :-)
Hi to all,
while doing my contour project , i feel the latitude longitude altitude for all over cities in India is essential thing to continue next step in my project.
So i collected all over cities lat lon alt_in_feet & alt_in_meter and converted in terms of csv ( comma Separated Value ).
This may help to some one.
For World :
Using this link i got all the data. While googling i got this link. I feel this is a good link among over other few links.
For India :
Here is my work :
Dadra & Nagarhaveli :
Jammu & Kashmir :
Tamil Nadu :
All Over Cities in India ( Combined all the above states ) :
I simply copied all the table content from the http://www.fallingrain.com/world/IN/ link and saved as .txt file.
Then i wrote simple Ruby Script to customize in terms of csv.
Finally i done.
:-) I hope , this work may help to any one of the Indian. :-)
I Love India
Hi to all,
Here i am going to explain about , ‘ how to edit world map in cdat ‘. Here i am going to share my experience about how to edit world map and create & adjust the Indian political map . While doing contour and isolines plotting on India map in cdat , My guide Mr.Thyagarajan Shanmugham and myself felt that our Indian Political Map wrongly depicted in CDAT as below.
Our first step in the long time goal :
Redrawing correct political map of india -
While asking help from Mr.Charles Doutriaux [ CDAT Developer ] regarding edit map in cdat, he gave the source data of cdat world map.
Here i edited india , partially
This Our India map , [ edited from cdat ]
I referred the India map from the link : http://www.fmisonline.org/Map/India/Outline.gif
code to convert the WORLD_COUNTRIES.shp binary data into text format and to view the world
map from this binary data.
In the following code i used “/home/arul/ “ . Instead of this , you have to use your user name to set the correct path.
#Begin code import vcs, cdms2, cdutil, time, os, sys import vcsaddons import vcsaddons v = vcs.init() filehandler=cdms2.open(sys.prefix+'/sample_data/clt.nc') mapregion=filehandler("clt",longitude=(60,100),latitude=(5,40)) world_continents = vcsaddons.continents.Guc(x=v) world_continents.types= world_continents.colors= world_continents.sources=['/home/arul/Desktop/WORLD_COUNTRIES.shp',] world_continents.list() v.plot(mapregion,world_continents,ratio='autot') v.png("india") data = world_continents.load_shapefile('/home/arul/Desktop/WORLD_COUNTRIES.shp') #wrting the data into out.txt file fileiter=open("/home/arul/Desktop/out.txt","w") print >> fileiter, data[:] fileiter.close() #End of code
Run the above program from the cdat environment. It will generate the world map data and saved
into “out.txt” file. It contains nearly 109300 lines.
In the out.txt file , we can see approximately 51950 data. These data only plotting the world in vcs.
Before going to below , please just go through the above link.
argument to continent in plot method
0: “0 signifies – No Continents”,
1: “1 signifies – Fine Continents”,
2: “2 signifies – Coarse # Continents”,
3: “3 signifies – United States Continents”,
4: “4 signifies – Political Borders Continents”,
5: “5 signifies – North American Rivers Continents”,
6: “6 signifies – User continent file data_continent_other7″,
7: “7 signifies – User continent file data_continent_other8″,
8: “8 signifies – User continent file data_continent_other9″,
9: “9 signifies – User continent file data_continent_other10″,
10: “10 signifies – User continent file data_continent_other11″,
11: “11 signifies – User continent file data_continent_other12″
Now copy the out.txt into data_continent_other7
$ cp out.txt data_continent_other7
and paste into PCMDI_GRAPHICS folder
$ cp data_continent_other7 ~/ PCMDI_GRAPHICS/
PCMDI_GRAPHICS folder was generated in our home folder by automatically.
Already we found the longitude=(60, 100), latitude = (5., 40.)) for India map from the world map in
Now we are going to plot the world map and india map from “ data_continent_other7 “.
# Import the modules needed for the tutorial import vcs, cdms2, cdutil, time, os, sys # Open data file: filepath = os.path.join(sys.prefix, 'sample_data/clt.nc') cdmsfile = cdms2.open( filepath ) # Extract a 3 dimensional data set and get a subset of the time dimension data = cdmsfile('clt', longitude=(-180, 180), latitude = (-180., 180.)) #data = cdmsfile('clt', longitude=(60, 100), latitude = (5., 40.)) # for india long(60,100) and lat(5,30) (5,40) # Initial VCS. v = vcs.init() # Assign the variable "cf_asd" to the persistent 'ASD' isofill graphics methods. cf_asd = v.getboxfill( 'ASD' ) cf_asd.datawc(1e20,1e20,1e20,1e20) # change to default region cf_asd.level_1=1e20 # change to default minimum level cf_asd.level_2=1e20 # change to default maximum level cf_asd.color_1=240 # change 1st color index value cf_asd.color_2=240 # change 2nd color index value # Plot the data using the above boxfill graphics method. v.plot( data, cf_asd,continents=6)# continents=6 for data_continent_other7 map print "Press the Return key to see next plot." sys.stdin.readline() data = cdmsfile('clt', longitude=(60, 100), latitude = (5., 40.)) v.plot( data, cf_asd,continents=6) sys.stdin.readline() #End of code
Now we will Try to understand out.txt or data_continent_other7 data allocation method.
The first line specifies the connection of six points of (latitude, longitude) coodinates in the upper
left corner of the plot.
From the second line they are represented the Y axis and X axis point. For eg:
24 1 49.955277 58.660553 -8.171667 1.749445
The entry ” -99 -99″ indicate that no more data are to be read in (i.e., denotes end-of-file).
Note the total number of points for any given line should not exceed 200 points.
By this way , the whole world data are split into many no of data sets. So from this , we have to
find out which region data is india map data and edited it.
Hack Methods :
I hacked this out.txt source file by two method.
In the following pdf , i explained more detailed about the cdat map editing with world data.
Download Link :
Download this pdf, where i elaborated the data handling methods of boundary of india, then merging the modified data with the world data set
I Love My India