/[MITgcm]/MITgcm_contrib/gael/comm/course-idma2016/matlab/idma_box_subset.m
ViewVC logotype

Contents of /MITgcm_contrib/gael/comm/course-idma2016/matlab/idma_box_subset.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download)
Thu Jan 14 14:56:37 2016 UTC (10 years, 7 months ago) by gforget
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +22 -6 lines
- turn idma_box_mean.m and idma_box_subset.m into functions.
- add help to the each function.

1 function [prof_T,prof_Testim,prof_Tweight,...
2 prof_S,prof_Sestim,prof_Sweight]=idma_box_subset(box_l,box_L,box_D);
3 %
4 % IDMA_BOX_SUBSET extracts profiles located in a region defined
5 % by ranges of longitude (box_l), latitude (box_L), and
6 % depth (box_D) accross data collections. Reurns
7 % observed profiles (prof_T and prof_S) and ECCO v4
8 % profiles (prof_Testim and prof_Sestim) in MITprof format;
9 %
10 % Example: box_l=[-180 -140]; box_L=[-10 10]-30; box_D=[0 300];
11 % [prof_T,prof_Testim,prof_S,prof_Sestim]=idma_box_subset(box_l,box_L,box_D);
12
13 demoIO=1;%set this to one to activate additional demonstration of IO
14
15 %%add MITprof routines to matlab path:
16 dir_MITprof=[pwd filesep 'MITprof' filesep];
17 p = genpath(dir_MITprof); addpath(p);%TBE
18
19 %%set box location
20 fprintf('\n box definition: \n');
21 fprintf(' longitude range: %d %d \n',box_l);
22 fprintf(' latitude range: %d %d \n',box_L);
23 fprintf(' depth range: %d %d \n\n',box_D);
24
25 %%demo: load a netcdf file
26 if demoIO;
27 dir_nc='release1/MITprof_release1/';
28 ncload([dir_nc 'argo_feb2013_1992_to_2007_model.nc']);%TBE
29 clear prof_*;
30 end;
31
32 %%demo: MITprof_load and MITprof_subset
33 if demoIO;
34 dir_nc='release1/MITprof_release1/';
35 tmp1=MITprof_load([dir_nc 'argo_feb2013_1992_to_2007_model.nc']);%TBE
36
37 tmp2=MITprof_subset(tmp1,'lon',box_l,'lat',box_L,'depth',box_D);%TBE
38 figure; set(gca,'FontSize',12);
39 plot(tmp1.prof_lon,tmp1.prof_lat,'.');
40 hold on; plot(tmp2.prof_lon,tmp2.prof_lat,'r.');
41 axis([-180 180 -90 90]); title('selected profile locations');
42 xlabel('longitude'); ylabel('latitude')
43 clear tmp*;
44 end;
45
46 %%load complete data set for select variables
47 dir_nc='release1/MITprof_release1/';
48 list_nc={'argo_feb2013_1992_to_2007_model.nc','argo_feb2013_2008_to_2010_model.nc','argo_feb2013_2011_to_2012_model.nc',...
49 'climode_feb2013_model.nc','itp_feb2013_model.nc','seals_feb2013_model.nc'};
50 %note: ctd_feb2013_model.nc and xbt_feb2013_model.nc are left out here for simplicity
51 %note: it takes a couple minutes to load all of the data
52
53 list_var={'prof_T','prof_Testim','prof_Tweight',...
54 'prof_S','prof_Sestim','prof_Sweight'};%TBE
55
56 for vv=1:length(list_var);
57 tmp1=MITprof_stats_load(dir_nc,list_nc,'',list_var{vv});%TBE
58 tmp1=MITprof_subset(tmp1,'lon',box_l,'lat',box_L,'depth',box_D);%TBE
59 eval([list_var{vv} '=tmp1;']);%TBE
60 end;
61
62 clear tmp1 vv;
63

  ViewVC Help
Powered by ViewVC 1.1.22