Merge branch 'fixf'
[wrf-fire-matlab.git] / perimeter / read_file_perimeter.m
blob6a02e0e585a56083f51273d57ef04c77719a92b9
1 function [fxlong,fxlat,fire_area]=read_file_perimeter(wrfout,time)
2 % Volodymyr Kondratenko           April 3 2012
4 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 % Input:    data : String - data, that contains the name of the Text file.
7 %                  First 2 columns - coordinates of all the
8 %                  points on the boundary (lon,lat). 
9 %                  1rt row - time_now (second number is not needed, is set to 0);
10 %                  2nd row - size of the mesh;
11 %                  3rd row - coordinates of ignition point;
12 %                  All next rows - coordinates of all the
13 %                  points on the boundary (lon,lat). %       
14 %         wrfout : String with the name of the wrfout file,  
15 %                  It is needed for reading the latitude and longtitude
16 %                  coordinates of the mesh and also UNIT_FXLONG and
17 %                  UNIT_FXLAT variables
18 %        time    : coordinate in the wrfout array, that needs to be computed
19 %                  example FXLAT(:,:,time)  
20 % Output: 
21 %        unit_long = UNIT_FXLONG;
22 %        unit_lat = UNIT_FXLAT;
23 %        long = FXLONG, longtitude coordinates of the mesh
24 %        lat = FXLAT, latitude coordinates of the mesh 
25 %        time_now = time of ignition on the boundary
26 %        mesh_size = size of the mesh
27 %        ign_pnt - point of ignition
28 %        bound - set of ordered points of the boundary 1st=last 
29 %        bound(i,1)-horisontal; bound(i,1)-vertical coordinate
35 p=nc2struct(wrfout,{'UNIT_FXLONG','UNIT_FXLAT','FXLONG','FXLAT','FIRE_AREA'},{},time)
37 fxlong=p.fxlong*p.unit_fxlong;
38 fxlat=p.fxlat*p.unit_fxlat;
39 fire_area=p.fire_area;
41 end
44 function bound=read_perim_from_file(data,unit_long,unit_lat);
45 fid = fopen(data);
46 bound = fscanf(fid,'%17g %*1s %17g %*3s',[2 inf]);
48 bound = bound';
49 fclose(fid);
51 bound(:,1)=bound(:,1)*unit_long;
52 bound(:,2)=bound(:,2)*unit_lat;
53 end