Differences between revisions 5 and 10 (spanning 5 versions)
Revision 5 as of 2011-01-17 11:27:48
Size: 2756
Editor: anonymous
Comment:
Revision 10 as of 2011-01-17 11:57:45
Size: 1921
Editor: anonymous
Comment:
Deletions are marked like this. Additions are marked like this.
Line 13: Line 13:
== Example data from Argo system == = Example data from Argo system =
Line 21: Line 21:
We extract only the surface temperature to reduce the large amount of data. The next script generates an overview of the data and writes the surface temperature in a file [[attachment:lat_lon_T.tab]] which contains latitude, longitude and surface temperature. We can use this file in the following. We extract only the surface temperature to reduce the large amount of data. This [[/extract script]] generates an overview of the data and writes the surface temperature in a file [[attachment:lat_lon_T.tab]] which contains latitude, longitude and surface temperature. We can use this file in the following.
Line 25: Line 25:

Argo positions of measurements
Line 27: Line 30:
{{{#!python Measured temperature profiles (unfiltered data).
Line 29: Line 32:
import scipy.io as io
import glob
from pylab import *
from mpl_toolkits.basemap import Basemap
= Tools for 2-dimensional interpolation and gridding =
Line 34: Line 34:
tmp_dir='/scratch/clisap/seaice/TMP/u242023/ARGO/' == Python ==

== GMT ==

[[http://gmt.soest.hawaii.edu/|GMT]]
Line 37: Line 41:
file_liste=glob.glob(tmp_dir+'*.nc')
D={}# Empty dictionary to store selected profiles
for f in file_liste:# Loop over all data
Nearest neighbor gridding with 5 degree grid cell size
Line 41: Line 43:
{{{nearneighbor lat_lon_T.tab -Rd -I300m -S300m -N1 -Ggrid.nc}}}
Line 42: Line 45:
    # Open netcdf data file
    fid=io.netcdf_file(f,'r')
Generate color table:
{{{
makecpt -Crainbow -T-2/30/1 > g.cpt
}}}
Line 45: Line 50:
    # Read content into variables
    lat=fid.variables['LATITUDE'][:].copy()
    lon=fid.variables['LONGITUDE'][:].copy()
    T=fid.variables['TEMP'][:].copy()
    P=fid.variables['PRES'][:].copy()
    
    T[T>=99999]=nan # Set 99999.0 to "Not a Number"
    P[P>=99999]=nan
{{{
grdimage grid.nc -Rg -JG-45/0/4i -Cg.cpt -K > out.ps
}}}
Line 54: Line 54:
    (nr_profs,Z)=T.shape # Get dimension {{{
pscoast -Rd -JG-45/0/4i -B15g15 -Dc -Gblack -P -O >> out.ps
}}}
Line 56: Line 58:
    for i in range(nr_profs):
        D[(lon[i],lat[i])]=(T[i,:],P[i,:])
{{{
gv out.ps
}}}
Line 59: Line 62:
    # Close data file
    fid.close()

fid=open('lat_lon_T.tab','w')
for k in D.keys():# write position (lat,lon), surface temperature to file
    fid.write(str(k[0])+'\t'+str(k[1])+'\t'+str(D[k][0][0])+'\n')
fid.close()
stop


# Draw map of positions
m = Basemap(projection='ortho',lon_0=-45,lat_0=0,resolution='l')
m.bluemarble()
for lon,lat in D.keys():
    x,y=m(lon,lat) # Coordinate transfer
    m.plot(x,y,'r.')
    
savefig('argo_position.png',dpi=150)

# Plot profiles
figure()
for k in D.keys():
# print k
    plot(D[k][0][:],D[k][1][:])
axis([-2,30,2000,0])
xlabel('T')
ylabel('P')
show()
savefig('Argo_plot.png',dpi=75)
}}}
{{attachment:out.png}}

2-dimensional interpolation and gridding

2-dimensional interpolation and gridding is a common problem for the representation of measurements on a map. Usually measurements are taken at irregular sample points and not in a regular grid. There are various approaches for the problem and the best solution depends on the data.

In the following we will look at oceanographic parameters that have been measured with the Argo system.

Example data from Argo system

Argo observation system

Data are provided at, i.e. ftp://ftp.ifremer.fr//ifremer/argo/

First we have to download the data. Here is a /download script that can be used to retrieve one month of Argo data.

We extract only the surface temperature to reduce the large amount of data. This /extract script generates an overview of the data and writes the surface temperature in a file lat_lon_T.tab which contains latitude, longitude and surface temperature. We can use this file in the following.

argo_position.png

Argo positions of measurements

Argo_plot.png

Measured temperature profiles (unfiltered data).

Tools for 2-dimensional interpolation and gridding

Python

GMT

GMT

Nearest neighbor gridding with 5 degree grid cell size

nearneighbor lat_lon_T.tab -Rd -I300m -S300m -N1 -Ggrid.nc

Generate color table:

makecpt -Crainbow -T-2/30/1 > g.cpt

grdimage grid.nc -Rg -JG-45/0/4i -Cg.cpt -K  > out.ps

pscoast -Rd -JG-45/0/4i -B15g15 -Dc  -Gblack -P -O >> out.ps

gv out.ps

out.png

LehreWiki: OpenSource2010/Lesson12 (last edited 2011-01-17 13:34:14 by anonymous)