Changeset 11173


Ignore:
Timestamp:
01/23/12 11:58:08 (13 years ago)
Author:
Mathieu Morlighem
Message:

more flexible and automated par file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/utils/LatLong/pargenerate.m

    r7544 r11173  
    1 function pargenerate(filename,title,data_format,nlines,ncols,secant_lat,meridian_long,corner_north,corner_east,posting_north,posting_east)
    2 %PARGENERATE generate parameter file for images ala Rignot
     1function pargenerate(filename,xm,ym,data,varargin)
     2%PARGENERATE - generate parameter file for images ala Rignot
    33%
    4 % Usage:
    5 %              pargenerate(filename,title,data_format,nlines,ncols,secant_lat,meridian_long,corner_north,corner_east,posting_north,posting_east)
     4%   Usage:
     5%      pargenerate(filename,data,xm,ym,options);
    66%
    7 %
     7%   Supported options:
     8%      - title: dataset title
     9%      - latitude: standard latitude (degree)
     10%      - meridian: meridian (degree)
     11%      - format: binary format
    812
     13%process options
     14options=pairoptions(varargin{:});
     15Title=getfieldvalue(options,'title','N/A');
     16latitude=getfieldvalue(options,'latitude','N/A');
     17meridian=getfieldvalue(options,'meridian','N/A');
     18format=getfieldvalue(options,'format','single');
     19
     20%Get data info
     21[nlines ncols]=size(data);
     22xmin=min(xm);
     23ymax=max(ym);
     24postx=abs(xm(2)-xm(1));
     25posty=abs(ym(2)-ym(1));
     26
     27%Open header file and get machine type
    928fid=fopen(filename,'wt');
     29[filename, permission, machineformat, encoding] = fopen(fid);
    1030
     31%write header file
    1132fprintf(fid,'%s\n','ISSM gridded dataset parameter file');
    12 fprintf(fid,'%s%s\n','title : ',title);
    13 fprintf(fid,'%s\n','DEM_projection :    PS');
    14 fprintf(fid,'%s%s\n','data_format :   ',data_format);
    15 fprintf(fid,'%s%d\n','width:      ',ncols);
    16 fprintf(fid,'%s%d\n','nlines:     ',nlines);
    17 fprintf(fid,'%s%g%s\n','PS_secant_lat:    ',secant_lat,'   decimal degrees');
    18 fprintf(fid,'%s%g%s\n','PS_meridian_long:    ',meridian_long,'   decimal degrees');
    19 fprintf(fid,'%s%g%s\n','PS_corner_north:    ',corner_north,'  m');
    20 fprintf(fid,'%s%g%s\n','PS_corner_east:    ',corner_east,'   m');
    21 fprintf(fid,'%s%g%s\n','PS_post_north:    ',posting_north,'   m');
    22 fprintf(fid,'%s%g%s\n','PS_post_east:    ',posting_east,'  m');
    23 
     33fprintf(fid,'%s%s\n','title: ',Title);
     34fprintf(fid,'%s  \n','DEM_projection: PS');
     35fprintf(fid,'%s%s\n','data_format: ',format);
     36fprintf(fid,'%s%s\n','endian:      ',machineformat);
     37fprintf(fid,'%s%d\n','width:  ',ncols);
     38fprintf(fid,'%s%d\n','nlines: ',nlines);
     39fprintf(fid,'%s%g%s\n','PS_secant_lat:    ',latitude,'   decimal degrees');
     40fprintf(fid,'%s%g%s\n','PS_meridian_long: ',meridian,'   decimal degrees');
     41fprintf(fid,'%s%-15.10g\n','PS_corner_north:  ',ymax);
     42fprintf(fid,'%s%-15.10g\n','PS_corner_east:   ',xmin);
     43fprintf(fid,'%s%g%s\n','PS_post_north:    ',postx,' m');
     44fprintf(fid,'%s%g%s\n','PS_post_east:     ',posty,' m');
    2445fclose(fid);
Note: See TracChangeset for help on using the changeset viewer.