From d124eedad7bb4d5925d7bf517ef876184d7f3e3c Mon Sep 17 00:00:00 2001 From: Jan Mandel Date: Thu, 23 Jun 2016 21:39:36 -0600 Subject: [PATCH] splitting off fire_pixels3d.m --- other/Matlab/detection/detect_fit_level2.m | 3 +++ other/Matlab/detection/fire_pixels3d.m | 28 ++++++++++++++++++++++++++ other/Matlab/detection/stime.m | 2 +- other/Matlab/detection/subset_detection_time.m | 26 ++++++++++-------------- 4 files changed, 43 insertions(+), 16 deletions(-) create mode 100644 other/Matlab/detection/fire_pixels3d.m diff --git a/other/Matlab/detection/detect_fit_level2.m b/other/Matlab/detection/detect_fit_level2.m index 8a9c7697..22f164cc 100644 --- a/other/Matlab/detection/detect_fit_level2.m +++ b/other/Matlab/detection/detect_fit_level2.m @@ -85,6 +85,9 @@ p=sort_rsac_files(prefix); if isempty(time_bounds), time_bounds=subset_detection_time(red,p); end +print_time_bounds(red,'Simulation',red.start_datenum,red.end_datenum) +print_time_bounds(red,'Detections',time_bounds(1),time_bounds(2)) +print_time_bounds(red,'Spinup ',time_bounds(3),time_bounds(4)) g = load_subset_detections(prefix,p,red,time_bounds,fig); diff --git a/other/Matlab/detection/fire_pixels3d.m b/other/Matlab/detection/fire_pixels3d.m new file mode 100644 index 00000000..c9900c16 --- /dev/null +++ b/other/Matlab/detection/fire_pixels3d.m @@ -0,0 +1,28 @@ +function fire_pixels3d(obs,base_time) +% fire_pixels(obs,base_time) +% fire_pixels(obs,base_time,dim) +% in +% obs structure array of observations +% base_time the start of simulations +for i=1:length(obs) + x=obs(i); + kk=find(x.data(:)>=7); + if ~isempty(kk), + rlon=0.5*abs(x.lon(end)-x.lon(1))/(length(x.lon)-1); + rlat=0.5*abs(x.lat(end)-x.lat(1))/(length(x.lat)-1); + lon1=x.xlon(kk)-rlon; + lon2=x.xlon(kk)+rlon; + lat1=x.xlat(kk)-rlat; + lat2=x.xlat(kk)+rlat; + X=[lon1,lon2,lon2,lon1]'; + Y=[lat1,lat1,lat2,lat2]'; + Z=ones(size(X))*(x.time-base_time); + cmap=cmapmod14; + C=cmap(x.data(kk)'+1,:); + C=reshape(C,length(kk),1,3); + patch(X,Y,Z,C); + hold on + end +end +hold off +end \ No newline at end of file diff --git a/other/Matlab/detection/stime.m b/other/Matlab/detection/stime.m index 1005061e..6091fb0c 100644 --- a/other/Matlab/detection/stime.m +++ b/other/Matlab/detection/stime.m @@ -12,5 +12,5 @@ function str=stime(t,red) error('t must be a number') end str=sprintf('%s %g days from start',datestr(t,timefmt),... - t-red.start_datenum) + t-red.start_datenum); end diff --git a/other/Matlab/detection/subset_detection_time.m b/other/Matlab/detection/subset_detection_time.m index ecb2b4d2..86111efd 100644 --- a/other/Matlab/detection/subset_detection_time.m +++ b/other/Matlab/detection/subset_detection_time.m @@ -1,11 +1,11 @@ -function time_bounds=subset_detection_bounds(red,p) +function time_bounds=subset_detection_time(red,p) min_det_time=p.time(1); max_det_time=p.time(end); % choose time bounds -print_time_bounds('Simulation',red.start_datenum,red.end_datenum) -print_time_bounds('Detections',min_det_time,max_det_time) +print_time_bounds(red,'Simulation',red.start_datenum,red.end_datenum) +print_time_bounds(red,'Detections',min_det_time,max_det_time) b1=max(red.min_tign,min_det_time); b2=min(red.max_tign,max_det_time); ba=0.5*(b1+b2); @@ -16,29 +16,25 @@ default_time_bounds{3}=[b1,b1+0.5*bd]; default_time_bounds{4}=[ba-0.2*bd,ba+0.2*bd]; for i=1:length(default_time_bounds) str=sprintf('bounds %i',i); - print_time_bounds(str,default_time_bounds{i}(1),default_time_bounds{i}(2)) + print_time_bounds(red,str,default_time_bounds{i}(1),default_time_bounds{i}(2)) end time_bounds=input_num('bounds [min_time max_time] as datenum, or number of bounds above',3); if length(time_bounds)==1, time_bounds=default_time_bounds{time_bounds}; end -print_time_bounds('Using bounds',time_bounds(1),time_bounds(2)) +print_time_bounds(red,'Using bounds',time_bounds(1),time_bounds(2)) time_bounds(4)=input_num('perimeter time ',time_bounds(2)); aa=input_num('Spinup period (h)',12); time_bounds(3)=input_num('restart time ',rounddatenum2hours(time_bounds(4)-aa/24)); -print_time_bounds('Spinup from restart to perimeter time',time_bounds(3),time_bounds(4)) +print_time_bounds(red,'Spinup from restart to perimeter time',time_bounds(3),time_bounds(4)) - function print_time_bounds(str,time1,time2) - fprintf('%-10s datenum from %20.13g to %20.13g\n from %s to %s\n',... - str,time1,time2,stime(time1,red),stime(time2,red)) - end +end - function r=rounddatenum2hours(t) - % input t time in datenum format (days) - % output b rounded to whole hours - r=round(t*24)/24; - end +function r=rounddatenum2hours(t) + % input t time in datenum format (days) + % output b rounded to whole hours + r=round(t*24)/24; end -- 2.11.4.GIT