1 | #! /usr/bin/env python |
---|
2 | |
---|
3 | ##file:///home/aymeric/Software/epd-7.0-2-rh5-x86/Doc/library/stdtypes.html?highlight=file#file.write |
---|
4 | ##file:///home/aymeric/Software/epd-7.0-2-rh5-x86/Doc/library/struct.html?highlight=endian |
---|
5 | |
---|
6 | ## marche pas probleme encodage... |
---|
7 | |
---|
8 | from myplot import getfield,definesubplot,smooth |
---|
9 | from netCDF4 import Dataset |
---|
10 | from matplotlib.pyplot import contourf,show,pcolor,subplot,figure |
---|
11 | from numpy import flipud,array,transpose |
---|
12 | from os import sys |
---|
13 | |
---|
14 | print sys.byteorder |
---|
15 | |
---|
16 | charvar = "albedo" |
---|
17 | charvar = "zMOL" |
---|
18 | #charvar = "thermal" |
---|
19 | charvar = "z0" |
---|
20 | |
---|
21 | nc = Dataset("surface.nc") |
---|
22 | |
---|
23 | var = getfield(nc,charvar)*1000. |
---|
24 | var = flipud(var) |
---|
25 | var = smooth(var,10) ##change le type! |
---|
26 | |
---|
27 | tile = 180 # resolution |
---|
28 | |
---|
29 | print var.shape |
---|
30 | |
---|
31 | # Eastern part |
---|
32 | epart = var[0:tile-1,tile:2*tile-1] |
---|
33 | epart = transpose(epart) |
---|
34 | fid = open('00181-00360.00001-00180','wb') |
---|
35 | #fid.write(str(part2)) |
---|
36 | #pickle.dump(epart,fid) |
---|
37 | #epart = array(epart,'<h') |
---|
38 | epart = array(epart,dtype='h') |
---|
39 | epart.tofile(fid) |
---|
40 | fid.close() |
---|
41 | #### integer*2 |
---|
42 | print epart.itemsize |
---|
43 | |
---|
44 | ## Western part |
---|
45 | wpart = var[0:tile-1,0:tile-1] |
---|
46 | wpart = transpose(wpart) |
---|
47 | fid2 = open('00001-00180.00001-00180','wb') |
---|
48 | #fid2.write(str(part)) |
---|
49 | #pickle.dump(wpart,fid2) |
---|
50 | #wpart = array(wpart,'<h') |
---|
51 | wpart = array(wpart,dtype='h') |
---|
52 | wpart.tofile(fid2) |
---|
53 | fid2.close() |
---|
54 | |
---|
55 | #fid = open('00181-00360.00001-00180','r') |
---|
56 | #epart = pickle.load(fid) |
---|
57 | #fid.close() |
---|
58 | # |
---|
59 | #fid2 = open('00001-00180.00001-00180','r') |
---|
60 | #wpart = pickle.load(fid2) |
---|
61 | #fid2.close() |
---|
62 | |
---|
63 | fig = figure() |
---|
64 | sub = definesubplot(2,fig) |
---|
65 | |
---|
66 | subplot(sub) |
---|
67 | contourf(epart) |
---|
68 | |
---|
69 | subplot(sub+1) |
---|
70 | contourf(wpart) |
---|
71 | |
---|
72 | show() |
---|
73 | |
---|
74 | |
---|