1 | #! /usr/bin/octave -qf |
---|
2 | |
---|
3 | # ----------------------------------------------- |
---|
4 | # thermal_build.m |
---|
5 | # Script to be used with GNU-Octave |
---|
6 | # > For NETCDF support, get 'octave-forge' pckg octcdf (install headers) |
---|
7 | # and install it in octave with 'pkg install octcdf-1.0.11.tar.gz' |
---|
8 | # (you also need libnetcdf-dev) |
---|
9 | # ----------------------------------------------- |
---|
10 | # Purpose: |
---|
11 | # Thermal inertia GCM NETCDF input |
---|
12 | # >> WRF geogrid tiles |
---|
13 | # Author: |
---|
14 | # A. Spiga - 03/2007 |
---|
15 | # ----------------------------------------------- |
---|
16 | |
---|
17 | # Locate NETCDF file |
---|
18 | filename = 'surface.nc'; |
---|
19 | resolution = 180; |
---|
20 | |
---|
21 | # Open NETCDF file - read-only |
---|
22 | nc = netcdf('surface.nc','r') |
---|
23 | |
---|
24 | # Read ... |
---|
25 | # Thermal inertia |
---|
26 | nv = ncvar(nc){4}; |
---|
27 | thermal = nv(:); |
---|
28 | size(thermal) |
---|
29 | |
---|
30 | # Flip North/South |
---|
31 | thermal = flipud(thermal); |
---|
32 | #thermal = fliplr(thermal); |
---|
33 | |
---|
34 | # Create 2 WRF data tiles for geogrid |
---|
35 | tile=resolution; |
---|
36 | # Eastern part |
---|
37 | part = thermal(1:1:tile,1:1:tile)'; |
---|
38 | #fid = fopen('00181-00360.00001-00180','wb','b'); |
---|
39 | fid = fopen('00001-00180.00001-00180','wb','b'); |
---|
40 | fwrite(fid,part,'integer*2'); |
---|
41 | |
---|
42 | # Western part |
---|
43 | part2 = thermal(1:1:tile,tile+1:1:2*tile)'; |
---|
44 | #fid = fopen('00001-00180.00001-00180','wb','b'); |
---|
45 | fid = fopen('00181-00360.00001-00180','wb','b'); |
---|
46 | fwrite(fid,part2,'integer*2'); |
---|
47 | |
---|
48 | # Check the resulting arrays |
---|
49 | yeah = part(1:1:tile,1:1:tile); |
---|
50 | yeah2 = part2(1:1:tile,1:1:tile); |
---|
51 | contour(yeah) |
---|
52 | contour(yeah2) |
---|