Makefile MSLEEP
[wrf-fire-matlab.git] / ignition / read_file_ignition.m
blob1d409da9517799e10ff1c4c0541c7d350bdf895b
1 function [unit_long,unit_lat,long,lat,time_now,mesh_size,ign_pnt,bound]=read_file_ignition(data,wrfout)
3 % Volodymyr Kondratenko           April 3 2012
5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7 % Input:    data : String - data, that contains the name of the Text file.
8 %                  First 2 columns - coordinates of all the
9 %                  points on the boundary (lon,lat). 
10 %                  1rt row - time_now (second number is not needed, is set to 0);
11 %                  2nd row - size of the mesh;
12 %                  3rd row - coordinates of ignition point;
13 %                  All next rows - coordinates of all the
14 %                  points on the boundary (lon,lat). %       
15 %         wrfout : String with the name of the wrfout file,  
16 %                  It is needed for reading the latitude and longtitude
17 %                  coordinates of the mesh and also UNIT_FXLONG and
18 %                  UNIT_FXLAT variables
19 % Output: 
20 %        unit_long = UNIT_FXLONG;
21 %        unit_lat = UNIT_FXLAT;
22 %        long = FXLONG, longtitude coordinates of the mesh
23 %        lat = FXLAT, latitude coordinates of the mesh 
24 %        time_now = time of ignition on the boundary
25 %        mesh_size = size of the mesh
26 %        ign_pnt - point of ignition
27 %        bound - set of ordered points of the boundary 1st=last 
28 %        bound(i,1)-horisontal; bound(i,1)-vertical coordinate
33 format long
34 unit_long=ncread(wrfout,'UNIT_FXLONG');
35 unit_long
36 unit_lat
37 unit_lat=ncread(wrfout,'UNIT_FXLAT');
38 unit_long=unit_long(1);
39 unit_lat=unit_lat(1);
40 long=ncread(wrfout,'FXLONG');
41 lat=ncread(wrfout,'FXLAT');
42 long=long*unit_long;
43 lat=lat*unit_lat;
45 fid = fopen(data);
46 data = fscanf(fid,'%g %g',[2 inf]); % It has two rows now.
47 data = data';
48 fclose(fid)
49 data_size=size(data);
51 time_now=data(1,1);  
52 mesh_size=data(2,:); 
53 ign_pnt=data(3,:);    
54 ign_pnt
56 ign_pnt(1)=ign_pnt(1)*unit_long;
57 ign_pnt(2)=ign_pnt(2)*unit_lat;
58 bound=data(4:data_size(1),:); 
59 bound(:,1)=bound(:,1)*unit_long;
60 bound(:,2)=bound(:,2)*unit_lat;
62 plot(bound(:,1),bound(:,2),'-',ign_pnt(1),ign_pnt(2),'o')