Emails to SMS on a FoxBox

Our Belgian Earthquake Emergency Report System (BEERS) detects abnormal visitor fluxes on the http://www.seismologie.be website and sends emails & SMS whenever some threshold is met. Recently, we have upgraded our sms machinery to FoxBox and for some weird reasons, the whole did not behave normally. The process is simple : Detection → Send Email to sms…

Earthworm statmgr replacement

At ROB, we don’t use Earthworm (ew) for real time acquisition or monitoring, but we have installed it on our computer at the Kawah Ijen observatory in order to group all seismic fluxes on a single machine, and thus a single archive. Sometimes, for random reasons, some ew modules fail and crash and are marked…

Shaded Relief Map in Python

Today, we’ll combine different cool stuff: cartopy, Google Maps tiles, SRTM elevation data and shaded relief maps ! We will need cartopy (+ dependencies), which you can install from source, or from C. Gohlke’s prebuilt binaries for Windows users. The first map we create will simply show a 1 degree-square zone including Sudelfeld (where I…

Jacknife

The Jacknife  is also sometimes called the “Leave One Out” method, and is a method to somehow evaluate the stability of statistics done on data. By leaving one element out of the input array and studying the mean of the values, one can identify outliers. Here is a small Python implementation, generalised to “Leave N…

Pack an Enthought Traits app inside a .exe using py2exe (Canopy Edit)

10 months ago, I published the updated version of my tutorial to pack an Enthought TraitsUI based application inside an .exe Windows Executable file, using a standard Python 2.7 install and the Enthought Tool Suite 4.0 (ETS4.0). In April 2013, Enthought published their latest distribution called “Canopy”. This distribution marks a clear change in the…

North Korean nuclear tests with Obspy

This morning, North Korea tested some nuclear “bomb” somewhere in the middle of the country (confirmed by Pyongyang officials and CTBTO), and many seismic sensors worldwide recorded the triggered waveforms. The location of the test is the same as the 2009 one, confirmed by the location provided by global monitoring networks (USGS, GEOFON). To pythonise…

New Tutorial Series: Pandas

In the coming months, I’ll prepare some tutorials over an excellent data analysis package called pandas ! To show you the power of pandas, just take a look at this old tutorial, where I exploited the power of itertools to group sparse data into 5 seconds bins. The magic of pandas is that, when you…

Honoured !

This blog is cited in the excellent book of Wes McKinney: “Python for Data Analysis” (eds.O’Reilly)! Oh yeah! I’m proud! Thanks Wes!    

Matplotlib & Datetimes – Tutorial 02: Bar Plot

To add some interesting information to the previous tutorial, I’ve downloaded the number of licence plates given for new cars in Belgium for the same time span: 2005 587764 2006 633570 2007 644313 2008 652590 2009 571001 2010 642086 2011 679619 Load them in the same fashion: plates, number = np.loadtxt(‘newplates.txt’,skiprows=1,unpack=True) xdates2 = [datetime.datetime.strptime(str(int(date)),’%Y’) for…

Matplotlib Basemap tutorial 09: Drawing circles

In the previous tutorial, I defined a “shoot” method to compute the landing point of a shoot from one point, to a given azimuth and distance. Using this logic, it’s possible to find the points situated at a given distance from a “centre” point, a circle. The goal: Drawing circles of a given radius around…

Matplotlib Basemap tutorial 08: Shooting Great Circles

Following a question from Ricardo Gama (see his comment), I’ve prepared this new tutorial. He wondered if Basemap has a function similar to the track1 function in matlab (you know, that crappy costly thing…)… Here is what I obtained : The goal: Plotting great circles with Basemap, but knowing only the longitude, latitude, the azimuth…

Matplotlib Basemap: Tell me what you need !

Dear visitors, I’m always searching new ideas of preparing new tutorials for things doable with Basemap, but I’d like these examples to be as useful as possible, which means : If you have something you would like to appear here, please, use the Comment box below to tell me ! I’ll do my best to…

Numpy Trick 01

I usually forget how much Numpy makes life easy : Say, you have a 101 element array, e.g.: import numpy as np a = np.linspace(0,100,101) and you want to take every 4th item in that array, that’s as easy as : print a[::4] will output: array([0., 4., … , 96., 100.]) I love Numpy !

Numpy.ma not always necessary

I just discovered that there is an easier way to do this (e.g. from tutorial06): import numpy.ma as ma mask = ma.masked_where(countries[‘ISO’] != iso, countries[‘ISO’]) country = ma.array(countries[‘country’],mask=mask.mask).compressed()[0] by using the built-in numpy.where method: import numpy as np index = np.where(countries[‘ISO’] == iso) country = countries[‘country’][index][0] Yeah, that’s fun ! The numpy.where method takes two…

Matplotlib Basemap tutorial 06: Real Case pie charts

Here is a new tutorial that will include “a bit of all” tutorials previously published on this blog and some new cool stuff to play with ! Idea: Find some resources on the Internet and plot them on the map of Europe ! In brief: do that: Step 0: Input Preparation I found some statistics…

Update to ETS 3.5.0 !

Great news from last week : ETS 3.5.0 is out ! Note the change in the source-download process.. Now using an unique ets.py file instead of the ProjectTools ! http://blog.enthought.com/open-source/enthought-tool-suite-3-5-0-released/ http://www.optiniche.com/blog/117/wordpress-trackback-tutorial/

Matplotlib Basemap tutorial 04 : using inside_poly() to select data !

# remember to define the ax instance : ax = plt.subplot(111) zone = “Roetgen – Monschau” x,y = m(6.15,50.41) x2,y2 = m(6.59,50.67) x3,y3 = m(6.34,50.855) x4,y4 = m(5.83,50.65) data = np.array(([x,x2,x3,x4], [y,y2,y3,y4])) p = Polygon(data.T,edgecolor=’red’,linewidth=1.5,facecolor=’none’) ax.add_artist(p) Note that we have an array containing the points already projected using m(x,y) : basemapped_points x,y = m(data[:,0],data[:,1]) data[:,0]=x…

Matplotlib Basemap tutorial 03 : Masked arrays & Zoom

Here, we will focus on adding a “zoom box” on the top left corner of the plot. But before that, we will mask a part of the earthquakes, in order to have a “cleaner” map ! This is achieved by using the numpy.ma module : import numpy.ma as ma Mlon = ma.masked_outside(lon, 5.6, 7.5) #…

Matplotlib Basemap tutorial 02 : Let’s add some earthquakes !

Now, let’s imagine we have a dataset containing latitude/longitudes of earthquakes, plus their depth and magnitude. Of course, you don’t always have this dataset available, so let’s build a fake one : import numpy as np lon = np.random.random_integers(11,79,1000)/10. lat = np.random.random_integers(491,519,1000)/10. depth = np.random.random_integers(0,300,1000)/10. magnitude = np.random.random_integers(0,100,1000)/10. We create random integer values, and we…

Matplotlib Basemap tutorial 01 : Your first map

# # BaseMap example by geophysique.be # tutorial 01 from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt import numpy as np fig = plt.figure(figsize=(11.7,8.3)) #Custom adjust of the subplots plt.subplots_adjust(left=0.05,right=0.95,top=0.90,bottom=0.05,wspace=0.15,hspace=0.05) ax = plt.subplot(111) #Let’s create a basemap around Belgium m = Basemap(resolution=’i’,projection=’merc’, llcrnrlat=49.0,urcrnrlat=52.0,llcrnrlon=1.,urcrnrlon=8.0,lat_ts=51.0) m.drawcountries(linewidth=0.5) m.drawcoastlines(linewidth=0.5) m.drawparallels(np.arange(49.,53.,1.),labels=[1,0,0,0],color=’black’,dashes=[1,0],labelstyle=’+/-‘,linewidth=0.2) # draw parallels m.drawmeridians(np.arange(1.,9.,1.),labels=[0,0,0,1],color=’black’,dashes=[1,0],labelstyle=’+/-‘,linewidth=0.2) # draw meridians plt.show()

Installing EPD on Windows 7 (64bits)

I finally managed to install Enthought Python Distribution on my Windows 7 64bit box. In fact, I installed EPD 32bits (I’m a student, the academic licence is free). So, the solution was in the Mailing List Archive (enthought-dev) : Disable the UAC (User Account Control) of Windows 7 in order to let the msi installer…

Stop using griddata, use matplotlib.mlab.griddata !

I just discovered that I was using from griddata import griddata in quite a lot of python scripts I wrote for scientific data plotting. While struggling to recompile it under my new win7 x64 box, I googled a little and found out that it’s now included in matplotlib (which was already installed…). So, now, I’ll…

Bonjour tout le monde !

Premier billet de “Géophysique.be”, où je publierai des informations en relation avec la Géophysique, les méthodes de prospection, leur théorie, des exemples de codes informatiques de traitement de données scientifiques, … Un premier code python pour démarrer : print “Hello World !!” First note on “Geophysique.be”, where I’ll post information about Geophysics, prospection methodologies, the…