1 function fuel_adjust(restart_file)
2 %function adjust fuel moisture in a wrf file used for input wrfinput or
5 fire_choice = input_num('which fire? Patch: [0], Camp: [1], Cougar: [3]',1)
6 cycle = input_num('Which cycle? ',0);
7 load_str = sprintf('p_%d.mat',cycle);
10 %nned to beef up what's in red, below
11 w = read_wrfout_tign(restart_file);
12 %use analysis to et region for changing fuel moisture
13 w.tign_g = p.analysis;
15 red = subset_domain(w);
17 %use the wrfout file to find subset of detections
19 time_bounds(2) = red.max_tign;
20 time_bounds(1) = red.min_tign;
23 fire_name = 'Camp fire';
25 prefix='../campTIFs/';
26 elseif fire_choice == 0
27 fire_name = 'Patch Springs fire';
31 fire_name = 'Cougar Creek fire';
33 prefix = '../cougarTIFs/';
39 if exist('g_match.mat','file')
42 det_list=sort_rsac_files(prefix);
43 g = load_subset_detections(prefix,det_list,red,time_bounds,fig);
44 save('g_match.mat', 'g', '-v7.3')
46 %find list of detections
50 fm = g(i).fxdata >=min_con;
52 fm = fm + (g(i).fxdata >=min_con);
55 % flatten fm to height 1
58 forecast_area = red.tign <= g(i).time;
60 mult = input_num('Enter fuel moisture multiplier: ',1)
62 too_far = mult*(forecast_area-fm);
63 new2far = ones(size(too_far));
64 too_far_mask = too_far > 0;
65 new2far(too_far_mask) = too_far(too_far_mask);
67 fast_fuel = red.nfuel_cat(too_far_mask);
68 %figure,histogram(fast_fuel(:))
71 w_mask = ones(size(w.tign_g));
72 w_mask(red.ispan,red.jspan) = new2far;
75 fprintf('%s %s\n','Will write modified time into ',restart_file)
76 rewrite_bak=[restart_file,'.bak'];
77 q=input_num(['1 to copy ',restart_file,' to ',rewrite_bak],1);
79 if system(['cp ',restart_file,' ',rewrite_bak]),
80 warning('copy failed')
84 %%% change fuel moisture in restart file %%%
86 new_moist = new_moist.*w_mask;
87 ncreplace(restart_file,'FMC_G',new_moist)