IX11beta for CLIVAR P16 draft
authorA.M. Thurnherr <athurnherr@yahoo.com>
Mon, 23 Feb 2015 09:19:46 +0000
changeset 15 3746197831db
parent 14 f7f35d9629ab
child 16 54126cc9bb4a
IX11beta for CLIVAR P16
.hgignore
HISTORY
edit_data.m
geomag/.hg-disabled/00changelog.i
geomag/.hg-disabled/branch
geomag/.hg-disabled/branch.cache
geomag/.hg-disabled/dirstate
geomag/.hg-disabled/hgrc
geomag/.hg-disabled/requires
geomag/.hg-disabled/store/00changelog.i
geomag/.hg-disabled/store/00manifest.i
geomag/.hg-disabled/store/data/.hgignore.i
geomag/.hg-disabled/store/data/_i_g_r_f10.unx.i
geomag/.hg-disabled/store/data/_i_g_r_f11._c_o_f.i
geomag/.hg-disabled/store/data/_makefile.i
geomag/.hg-disabled/store/data/_r_e_a_d_m_e.txt.i
geomag/.hg-disabled/store/data/_w_m_m2005.unx.i
geomag/.hg-disabled/store/data/_w_m_m2010._c_o_f.i
geomag/.hg-disabled/store/data/geomag.h.i
geomag/.hg-disabled/store/data/geomag61.c.i
geomag/.hg-disabled/store/data/geomag__calc.c.i
geomag/.hg-disabled/store/data/igrf11.h.i
geomag/.hg-disabled/store/data/magdec.c.i
geomag/.hg-disabled/store/data/model__to__include.py.i
geomag/.hg-disabled/store/data/sample__coords.txt.i
geomag/.hg-disabled/store/data/sample__out___i_g_r_f10.txt.i
geomag/.hg-disabled/store/data/sample__out___w_m_m2005.txt.i
geomag/.hg-disabled/store/fncache
geomag/.hg-disabled/store/undo
geomag/.hg-disabled/undo.branch
geomag/.hg-disabled/undo.dirstate
geomag/Makefile
geomag/Makefile.mingw32cross
geomag/README.txt
geterr.m
loadrdi.m
process_cast.m
saveres.m
--- a/.hgignore	Tue Jul 08 21:50:22 2014 -0400
+++ b/.hgignore	Mon Feb 23 09:19:46 2015 +0000
@@ -1,9 +1,9 @@
 #======================================================================
 #                    . H G I G N O R E 
 #                    doc: Tue Oct 20 16:22:40 2009
-#                    dlm: Wed Mar  5 13:42:19 2014
+#                    dlm: Mon Feb 23 09:19:02 2015
 #                    (c) 2009 A.M. Thurnherr
-#                    uE-Info: 13 5 NIL 0 0 72 0 2 4 NIL ofnI
+#                    uE-Info: 14 4 NIL 0 0 72 0 2 4 NIL ofnI
 #======================================================================
 
 syntax: glob
@@ -11,3 +11,4 @@
 *.ignore
 *.debugged
 HowTo
+.hg-disabled
--- a/HISTORY	Tue Jul 08 21:50:22 2014 -0400
+++ b/HISTORY	Mon Feb 23 09:19:46 2015 +0000
@@ -1,9 +1,9 @@
 ======================================================================
                     H I S T O R Y 
                     doc: Tue Aug 16 11:41:46 2005
-                    dlm: Wed Jun 11 08:52:11 2014
+                    dlm: Sun Jan 25 11:00:11 2015
                     (c) 2005 A.M. Thurnherr
-                    uE-Info: 238 48 NIL 0 0 72 3 2 4 NIL ofnI
+                    uE-Info: 251 57 NIL 0 0 72 3 2 4 NIL ofnI
 ======================================================================
 
 NB: CHANGE VERSION IN [default.m] BEFORE UPLOADING
@@ -234,5 +234,18 @@
 	Mar 21, 2014:
 		- updated version to IX_11beta in [default.m] [.hg/hgrc]
 		- minor bug fix in [loadctd.m]
+	Jun  9, 2014:
+		- improved messages in [prepinv.m]
 	Jun 11, 2014:
 		- changed savecdf default in [default.m]
+	Jul 13, 2014:
+		- enabled automatic editing in [edit_data.m] when blanking distance is zero 
+	Sep 26, 2014:
+		- modified [process_cast.m] and [saveres.m] to add support for
+		  p.orig (patch provided by D. Torres)
+	Jan 23, 2015:
+		- made [loadrdi.m] croak when UL file is not found
+		- added new editing to [edit_data.m]
+	Jan 25, 2015:
+		- separated uc/dc in bin-averaged residual plots in [geterr.m]
+		  to facilitate detection of package-wake effects
--- a/edit_data.m	Tue Jul 08 21:50:22 2014 -0400
+++ b/edit_data.m	Mon Feb 23 09:19:46 2015 +0000
@@ -15,13 +15,17 @@
 %		 - disabled edit_spike_filter by default
 %		 - changed edit_spike_filter_max_curv default value
 %  Aug 13, 2013: - BUG: edit_sidelobes did not work for UL only data
+%  Jul 13, 2014: - automatically edit bins 1 when blanking distance is zero
+%  Jan 23, 2015: - BUG: automatic zero blanking editing had a typo
+%		 - BUG: automatic zero blanking editing did not work with DL-only data
+%		 - added p.edit_{dn,up}_bad_ensembles
 
 %======================================================================
 %                    E D I T _ D A T A . M 
 %                    doc: Sat Jul  3 17:13:05 2004
-%                    dlm: Tue Aug 13 15:34:27 2013
+%                    dlm: Fri Jan 23 21:40:14 2015
 %                    (c) 2004 A.M. Thurnherr
-%                    uE-Info: 122 0 NIL 0 0 72 3 2 8 NIL ofnI
+%                    uE-Info: 93 23 NIL 0 0 72 0 2 8 NIL ofnI
 %======================================================================
 
 %----------------------------------------------------------------------
@@ -81,10 +85,29 @@
 % [0 0 1 1].
 p=setdefv(p,'edit_skip_ensembles',[]);
 
+% the following vectors can be used to edit out blocks of bad ensembles,
+% caused, for example, by intermittent hardware failures. NOTE: it is
+% assumed that the ensembles are numbered consecutively, starting with 1,
+% i.e. the ensemble numbers in the data files are ignored. This may 
+% not work as intended if the data files are trimmed during the DL/UL
+% merge in [loardrdi.m]
+
+p=setdefv(p,'edit_dn_bad_ensembles',[]);
+p=setdefv(p,'edit_up_bad_ensembles',[]);
+
 %----------------------------------------------------------------------
 % Bin Masking
 %----------------------------------------------------------------------
 
+if length(d.zu)>0 && p.blnk_u==0
+  disp(sprintf(' bin masking               : masking uplooker bin 1 because of zero blanking distance'));
+  p.edit_mask_up_bins = [1 p.edit_mask_up_bins];
+end
+if p.blnk_d==0
+  disp(sprintf(' bin masking               : masking downlooker bin 1 because of zero blanking distance'));
+  p.edit_mask_dn_bins = [1 p.edit_mask_dn_bins];
+end
+
 if ~isempty(p.edit_mask_dn_bins) | ~isempty(p.edit_mask_up_bins)
 
   nbad = 0;
@@ -257,6 +280,28 @@
 end % if p.edit_skip_ensembles enabled
 
 %----------------------------------------------------------------------
+% remove blocks of bad ensembles from UL and/or DL data
+%----------------------------------------------------------------------
+
+if ~isempty(p.edit_dn_bad_ensembles) || ~isempty(p.edit_up_bad_ensembles)
+  if ~isempty(p.edit_dn_bad_ensembles)
+    dn_bad = 0; ibad = p.edit_dn_bad_ensembles;
+    for b=length(d.zu)+1:length(d.zu)+length(d.zd)
+      dn_bad = dn_bad + length(find(isfinite(d.weight(b,ibad))));
+      d.weight(b,ibad) = NaN; d.ts_edited(b,ibad) = NaN;
+    end
+  end
+  if ~isempty(p.edit_up_bad_ensembles)
+    up_bad = 0; ibad = p.edit_up_bad_ensembles;
+    for b=length(d.zu):-1:1
+      up_bad = up_bad + length(find(isfinite(d.weight(b,ibad))));
+      d.weight(b,ibad) = NaN; d.ts_edited(b,ibad) = NaN;
+    end
+  end
+  disp(sprintf(' DL/UL ensemble editing    : set %d/%d weights to NaN',dn_bad,up_bad));
+end
+
+%----------------------------------------------------------------------
 % Plot Results of Editing
 %----------------------------------------------------------------------
 
Binary file geomag/.hg-disabled/00changelog.i has changed
--- a/geomag/.hg-disabled/branch	Tue Jul 08 21:50:22 2014 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-default
--- a/geomag/.hg-disabled/branch.cache	Tue Jul 08 21:50:22 2014 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-7975fa5c28fd2b9ecd4ae3c5093f5d30bc5fcebf 26
-7975fa5c28fd2b9ecd4ae3c5093f5d30bc5fcebf default
Binary file geomag/.hg-disabled/dirstate has changed
--- a/geomag/.hg-disabled/hgrc	Tue Jul 08 21:50:22 2014 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-[paths]
-default = http://currents.soest.hawaii.edu/hgstage/hgwebdir.cgi/geomag
--- a/geomag/.hg-disabled/requires	Tue Jul 08 21:50:22 2014 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-revlogv1
-store
-fncache
Binary file geomag/.hg-disabled/store/00changelog.i has changed
Binary file geomag/.hg-disabled/store/00manifest.i has changed
Binary file geomag/.hg-disabled/store/data/.hgignore.i has changed
Binary file geomag/.hg-disabled/store/data/_i_g_r_f10.unx.i has changed
Binary file geomag/.hg-disabled/store/data/_i_g_r_f11._c_o_f.i has changed
Binary file geomag/.hg-disabled/store/data/_makefile.i has changed
Binary file geomag/.hg-disabled/store/data/_r_e_a_d_m_e.txt.i has changed
Binary file geomag/.hg-disabled/store/data/_w_m_m2005.unx.i has changed
Binary file geomag/.hg-disabled/store/data/_w_m_m2010._c_o_f.i has changed
Binary file geomag/.hg-disabled/store/data/geomag.h.i has changed
Binary file geomag/.hg-disabled/store/data/geomag61.c.i has changed
Binary file geomag/.hg-disabled/store/data/geomag__calc.c.i has changed
Binary file geomag/.hg-disabled/store/data/igrf11.h.i has changed
Binary file geomag/.hg-disabled/store/data/magdec.c.i has changed
Binary file geomag/.hg-disabled/store/data/model__to__include.py.i has changed
Binary file geomag/.hg-disabled/store/data/sample__coords.txt.i has changed
Binary file geomag/.hg-disabled/store/data/sample__out___i_g_r_f10.txt.i has changed
Binary file geomag/.hg-disabled/store/data/sample__out___w_m_m2005.txt.i has changed
--- a/geomag/.hg-disabled/store/fncache	Tue Jul 08 21:50:22 2014 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-data/.hgignore.i
-data/IGRF10.unx.i
-data/IGRF11.COF.i
-data/Makefile.i
-data/README.txt.i
-data/WMM2005.unx.i
-data/WMM2010.COF.i
-data/geomag.h.i
-data/geomag61.c.i
-data/geomag_calc.c.i
-data/igrf11.h.i
-data/magdec.c.i
-data/model_to_include.py.i
-data/sample_coords.txt.i
-data/sample_out_IGRF10.txt.i
-data/sample_out_WMM2005.txt.i
Binary file geomag/.hg-disabled/store/undo has changed
--- a/geomag/.hg-disabled/undo.branch	Tue Jul 08 21:50:22 2014 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-default
\ No newline at end of file
Binary file geomag/.hg-disabled/undo.dirstate has changed
--- a/geomag/Makefile	Tue Jul 08 21:50:22 2014 -0400
+++ b/geomag/Makefile	Mon Feb 23 09:19:46 2015 +0000
@@ -1,6 +1,4 @@
-CC = gcc
-RM = rm -f
-BIN = /usr/local/bin
+# Generic minimal makefile for linux.
 
 all: magdec
 
@@ -8,7 +6,7 @@
 	$(CC) -o $@ geomag_calc.o magdec.o -lm
 
 install: magdec
-	install magdec $(BIN)
+	install magdec /usr/local/bin
 
 clean:
 	$(RM) *.o  magdec
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/geomag/Makefile.mingw32cross	Mon Feb 23 09:19:46 2015 +0000
@@ -0,0 +1,18 @@
+# For using the debian (ubuntu) mingw cross compiler package
+# to compile a windows executable.
+# There is no install target.
+# *.o is removed before and after running make,
+# to avoid conflicts with the normal non-cross make
+
+
+CC=i586-mingw32msvc-gcc
+
+all: clean magdec.exe
+
+magdec.exe: geomag_calc.o magdec.o Makefile.mingw32cross igrf11.h
+	$(CC) -o $@ geomag_calc.o magdec.o -lm
+	$(RM) *.o
+
+clean:
+	$(RM) *.o
+
--- a/geomag/README.txt	Tue Jul 08 21:50:22 2014 -0400
+++ b/geomag/README.txt	Mon Feb 23 09:19:46 2015 +0000
@@ -36,7 +36,13 @@
 Rather than update the file parsing in geomag61.c, I deleted it,
 so now only magdec is provided.
 
+2010/08/20 EF
+Added a Makefile.mingw32cross, so that with the ubuntu mingw32 cross
+compiler packages installed, one can generate magdec.exe via:
 
+make -f Makefile.mingw32cross
+
+This will leave magdec.exe in the current directory.
 
 
 =============== Original README.txt below this line ===================
--- a/geterr.m	Tue Jul 08 21:50:22 2014 -0400
+++ b/geterr.m	Mon Feb 23 09:19:46 2015 +0000
@@ -1,9 +1,9 @@
 %======================================================================
 %                    G E T E R R . M 
 %                    doc: Wed Jun 30 23:24:51 2004
-%                    dlm: Wed Jul  6 20:26:14 2011
+%                    dlm: Wed Jan 28 09:46:12 2015
 %                    (c) 2004 ladcp@
-%                    uE-Info: 19 35 NIL 0 0 72 2 2 8 NIL ofnI
+%                    uE-Info: 21 42 NIL 0 0 72 2 2 8 NIL ofnI
 %======================================================================
 
 % MODIFICATIONS BY ANT:
@@ -17,6 +17,8 @@
 %		 - added ps.fig3_colormap, ps.fig3_err_y_axis, ps.fig3_avgerr
 %  Jun 30, 2011: - fixed fig.3 middle column plot title for median plot
 %  Jul  6, 2001: - fixed plot title
+%  Jan 25, 2015: - separated uc/dc in bin-averaged residual plots
+%  Jan 28, 2015: - BUG: figure legend typo
 
 function l=geterr(ps,dr,d,iplot)
 % function l=geterr(dr,d,iplot)
@@ -193,7 +195,10 @@
    clf
    orient landscape
    
+% find downcast/upcast separation
+  btmi = fix(median(find(isfinite(l.u_oce(end,:)))));
 
+% define color map
    if ps.fig3_colormap == 2
      colormap(polarmap(21));
    else
@@ -232,11 +237,11 @@
    
    subplot(232)
    if ps.fig3_avgerr == 2
-     plot(medianan(l.ru_err')',-ib)
-     title('median(U-err)')
+     plot(medianan(l.ru_err(:,1:btmi)')',-ib,'r',medianan(l.ru_err(:,btmi:end)')',-ib,'b');
+     title('median(U-err) [r/b: down-/up-cast]')
    else
-     plot(meannan(l.ru_err')',-ib)
-     title('mean(U-err)')
+     plot(meanan(l.ru_err(:,1:btmi)')',-ib,'r',meanan(l.ru_err(:,btmi:end)')',-ib,'b');
+     title('mean(U-err) [r/b: down-/up-cast]')
    end
    set(gca,'XLim',[-0.05 0.05]);
    set(gca,'Ylim',[-ib(end) -ib(1)]);
@@ -298,11 +303,11 @@
    
    subplot(235)
    if ps.fig3_avgerr == 2
-     plot(medianan(l.rv_err')',-ib)
-     title('median(V-err)')
+     plot(medianan(l.rv_err(:,1:btmi)')',-ib,'r',medianan(l.rv_err(:,btmi:end)')',-ib,'b');
+     title('median(V-err) [r/b: down-/up-cast]')
    else
-     plot(meannan(l.rv_err')',-ib)
-     title('mean(V-err)')
+     plot(meanan(l.rv_err(:,1:btmi)')',-ib,'r',meanan(l.rv_err(:,btmi:end)')',-ib,'b');
+     title('mean(V-err) [r/b: down-/up-cast]')
    end
    set(gca,'XLim',[-0.05 0.05]);
    set(gca,'Ylim',[-ib(end) -ib(1)]);
--- a/loadrdi.m	Tue Jul 08 21:50:22 2014 -0400
+++ b/loadrdi.m	Mon Feb 23 09:19:46 2015 +0000
@@ -13,9 +13,9 @@
 %======================================================================
 %                    L O A D R D I . M 
 %                    doc: Fri Jun 18 18:21:56 2004
-%                    dlm: Mon Jun 24 10:17:29 2013
+%                    dlm: Fri Jan 23 16:07:24 2015
 %                    (c) 2004 ladcp@
-%                    uE-Info: 48 72 NIL 0 0 72 2 2 8 NIL ofnI
+%                    uE-Info: 823 0 NIL 0 0 72 2 2 8 NIL ofnI
 %======================================================================
 
 % CHANGES BY ANT
@@ -46,6 +46,7 @@
 %  Aug 18, 2011: - added comment to coord-transformation code (gimbal pitch)
 %  Jun 24, 2013: - blen re-added but separately for DL/UL
 %		 - added separate nbin, blnk, dist for DL/UL to p struct
+%  Jan 23, 2015: - made updown() bomb when UL file is not found
 
 % p=setdefv(p,'pg_save',[1 2 3 4]);
 % Default =3 for loadctd_whoi.
@@ -796,14 +797,15 @@
 % load upward looking ADCP
 up = nargin>1;
 
+if strcmp(fup,'') || strcmp(fup,' ')
+  up = 0;
+end
+
 if up
   fid = fopen(fup,'r','l');
   if fid == -1
-    up = 0;
+    error(sprintf('%s: no such file or directory',fup));
   end
-end
-
-if up
 
   if length(bmax)<2, bmax(2)=bmax(1); end
   disp([' loading up-data ',fup])
--- a/process_cast.m	Tue Jul 08 21:50:22 2014 -0400
+++ b/process_cast.m	Mon Feb 23 09:19:46 2015 +0000
@@ -41,9 +41,9 @@
 %======================================================================
 %                    P R O C E S S _ C A S T . M 
 %                    doc: Thu Jun 24 16:54:23 2004
-%                    dlm: Thu Apr 26 11:02:01 2012
+%                    dlm: Fri Sep 26 15:57:32 2014
 %                    (c) 2004 A.M. Thurnherr
-%                    uE-Info: 82 56 NIL 0 0 72 2 2 8 NIL ofnI
+%                    uE-Info: 83 80 NIL 0 0 72 2 2 8 NIL ofnI
 %======================================================================
 
 % NOTES:
@@ -80,6 +80,7 @@
 %  Sep 18, 2008: - BUG: p.navdata was non-existent field when no nav
 %			data were loaded
 %  Apr 26, 2012: - finally removed finestructure kz code
+%  Sep 26, 2014: - added support for p.orig in [saveres.m] (patch by Dan Torres)
 
 %----------------------------------------------------------------------
 % STEP 0: EXECUTE ALWAYS
@@ -544,7 +545,7 @@
     % save results to ASCII, MATLAB and NETCD files
     %
     disp(' save results ')
-    saveres(dr,p,ps,f)
+    saveres(dr,p,ps,f,d)
     da=savearch(dr,d,p,ps,f,att);
   
     %
--- a/saveres.m	Tue Jul 08 21:50:22 2014 -0400
+++ b/saveres.m	Mon Feb 23 09:19:46 2015 +0000
@@ -1,10 +1,25 @@
-function []=saveres(dr,p,ps,f)
-% function []=saveres(dr,p,ps,f)
+%======================================================================
+%                    S A V E R E S . M 
+%                    doc: Fri Sep 26 15:55:18 2014
+%                    dlm: Fri Sep 26 16:04:57 2014
+%                    (c) 2014 A.M. Thurnherr
+%                    uE-Info: 19 46 NIL 0 0 72 0 2 4 NIL ofnI
+%======================================================================
+
+function []=saveres(dr,p,ps,f,d)
+% function []=saveres(dr,p,ps,f,d)
 %
 % store LADCP result in RODB format
 %
 
-eval(['save ',[f.res,'.mat'],' dr p ps f'])
+% MODIFICTIONS BY ANT:
+%	Sep 26, 2014: - added support for p.orig (patch by Dan Torres)
+
+if p.orig == 1
+	eval(['save ',[f.res,'.mat'],' dr p ps f d'])
+else
+	eval(['save ',[f.res,'.mat'],' dr p ps f'])
+end
 
 % version 0.1	last change 28.6.2000
 % open file