| 1 | cnh | 1.1 | function [bathy_obj]=load_cs_bathy(csg_obj,gdir,fname,prec); | 
| 2 |  |  | % | 
| 3 |  |  | % Load cube sphere bathymetry | 
| 4 |  |  | % e.g. load_cs_bathy(csg,'t32','bathy.bin','float64'); | 
| 5 |  |  | % returns bathymetry and polygons that define bathymetry. | 
| 6 |  |  | % | 
| 7 |  |  |  | 
| 8 |  |  | % 1 - Read land | 
| 9 |  |  | ng=csg_obj.ng; | 
| 10 |  |  | nb=csg_obj.nb; | 
| 11 |  |  | nr=csg_obj.nr; | 
| 12 |  |  | nxd=nb+1+nr+1+ng+1+nb+1; | 
| 13 |  |  | nyd=ng+1+nb+1+nr+1; | 
| 14 |  |  |  | 
| 15 |  |  | fnam=sprintf('%s/%s',gdir,fname); | 
| 16 |  |  | fid=fopen(fnam,'r','ieee-be'); | 
| 17 |  |  | tmparr=ones(ng*6*ng,1); | 
| 18 |  |  | tmparr=fread(fid,ng*ng*6,prec); | 
| 19 |  |  | tmparr=reshape(tmparr,[ng*6,ng]); | 
| 20 |  |  | fclose(fid); | 
| 21 |  |  | bathyarr=ones(nxd,nyd)*12345.6789; | 
| 22 |  |  | for i= 1:6 | 
| 23 |  |  | ilog=csg_obj.ilog(i); | 
| 24 |  |  | jlog=csg_obj.jlog(i); | 
| 25 |  |  | fx=csg_obj.fx(i); | 
| 26 |  |  | fy=csg_obj.fy(i); | 
| 27 |  |  | ihi=ilog+fx-1;jhi=jlog+fy-1; | 
| 28 |  |  | tmp=tmparr((i-1)*ng+1:i*ng,1:ng); | 
| 29 |  |  | bathyarr(ilog:ihi,jlog:jhi)=reshape(tmp,[fx fy]); | 
| 30 |  |  | end | 
| 31 |  |  | bathyarr(find(bathyarr==12345.6789))=NaN; | 
| 32 |  |  |  | 
| 33 |  |  | % Do some plots on a lat-lon figure | 
| 34 |  |  | clf | 
| 35 |  |  | axis([-180 180 -90 90]);hold on; | 
| 36 |  |  | xg=csg_obj.gridarr(:,:,csg_obj.xgpos); | 
| 37 |  |  | yg=csg_obj.gridarr(:,:,csg_obj.ygpos); | 
| 38 |  |  | clear xc yc; | 
| 39 |  |  | nc=0; | 
| 40 |  |  | np=0; | 
| 41 |  |  | clear xcoord ycoord; | 
| 42 |  |  | xcoord=ones(2,ng*ng*6*4); | 
| 43 |  |  | ycoord=ones(2,ng*ng*6*4); | 
| 44 |  |  | for t=1:6 | 
| 45 |  |  | ilo=csg_obj.ilog(t);jlo=csg_obj.jlog(t); | 
| 46 |  |  | ihi=csg_obj.ilog(t)+csg_obj.fx(t); | 
| 47 |  |  | jhi=csg_obj.jlog(t)+csg_obj.fy(t); | 
| 48 |  |  | nlo=nc+1; | 
| 49 |  |  | nhi=nc+(ihi-ilo)*(jhi-jlo); | 
| 50 |  |  | a=bathyarr(ilo:ihi-1,jlo:jhi-1); | 
| 51 |  |  | c(nlo:nhi)=a(:); | 
| 52 |  |  | nc=nc+(ihi-ilo)*(jhi-jlo); | 
| 53 |  |  |  | 
| 54 |  |  | end | 
| 55 |  |  | %clf | 
| 56 |  |  | %patch(px,py,c,'Edgecolor','none'); | 
| 57 |  |  | %patch(px,py,'r','Edgecolor','none'); | 
| 58 |  |  |  | 
| 59 |  |  | %set(gcf,'PaperSize',[16 8]); | 
| 60 |  |  | %set(gcf,'PaperPosition',[0 0 16 8]); | 
| 61 |  |  | %set(gca,'Position',[0 0 1 1]); | 
| 62 |  |  | %print -djpeg100 -r600 -painters foo.jpeg | 
| 63 |  |  |  | 
| 64 |  |  | bathy_obj.bathyarr=bathyarr; | 
| 65 |  |  | bathy_obj.c=c; | 
| 66 |  |  |  | 
| 67 |  |  | return |