Changeset 1121 for trunk/src/proj_field.m
- Timestamp:
- Dec 20, 2022, 2:00:18 PM (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/proj_field.m
r1116 r1121 1072 1072 end 1073 1073 1074 %% initiate Matlab structure for physical field open1074 %% initiate Matlab structure for physical field 1075 1075 [ProjData,errormsg]=proj_heading(FieldData,ObjectData); 1076 1076 if ~isempty(errormsg) … … 1345 1345 % two cases of projection for scattered coordinates 1346 1346 switch ProjMode{icell} 1347 case 'projection' 1347 case 'projection'% ptoject scattered data without interpolation 1348 1348 nbvar=0; 1349 1349 %nbvar=numel(ProjData.ListVarName); … … 1366 1366 end 1367 1367 end 1368 case 'interp_lin'%interpolate data on a regular grid1368 case 'interp_lin'%interpolate scattered data on a regular grid 1369 1369 if isfield(CellInfo{icell},'VarIndex_errorflag') 1370 1370 VarName_FF=FieldData.ListVarName{CellInfo{icell}.VarIndex_errorflag}; … … 1382 1382 end 1383 1383 % interpolate and calculate field on the grid 1384 1384 1385 1385 [VarVal,ListVarName,VarAttribute,errormsg]=calc_field_interp([coord_X coord_Y],FieldData,CellInfo{icell}.FieldName,XI,YI); 1386 1386 … … 1500 1500 end 1501 1501 1502 if strcmp(ProjMode{icell},'projection')% && (~testangle || test90y || test90x)1502 if strcmp(ProjMode{icell},'projection')% project gridded data without interpolation 1503 1503 if NbDim==2 && ~testXMin && ~testXMax && ~testYMin && ~testYMax% no range restriction 1504 1504 ListVarName=[ListVarName FieldData.ListVarName(VarIndex)]; … … 1606 1606 end 1607 1607 end 1608 else % casewith interpolation on a grid1608 else % project gridded data with interpolation on a grid 1609 1609 if NbDim==2 %2D case 1610 1610 if isequal(ProjMode{icell},'interp_tps') … … 1778 1778 1779 1779 %----------------------------------------------------------------- 1780 ProjData= FieldData;%default output1780 ProjData=[];%default output 1781 1781 1782 1782 %% axis origin … … 1809 1809 DY=0; %default 1810 1810 DZ=0; 1811 if isfield(ObjectData,'DX')&~isempty(ObjectData.DX) 1811 ProjMode=ObjectData.ProjMode; 1812 if isfield(ObjectData,'DX')&&~isempty(ObjectData.DX) 1812 1813 DX=abs(ObjectData.DX);%mesh of interpolation points 1813 1814 end 1814 if isfield(ObjectData,'DY')& ~isempty(ObjectData.DY)1815 if isfield(ObjectData,'DY')&&~isempty(ObjectData.DY) 1815 1816 DY=abs(ObjectData.DY);%mesh of interpolation points 1816 1817 end 1817 if isfield(ObjectData,'DZ')& ~isempty(ObjectData.DZ)1818 if isfield(ObjectData,'DZ')&&~isempty(ObjectData.DZ) 1818 1819 DZ=abs(ObjectData.DZ);%mesh of interpolation points 1819 1820 end … … 1872 1873 %----------------------------------------------------------------- 1873 1874 idimvar=0; 1875 1876 [CellInfo,NbDimArray,errormsg]=find_field_cells(FieldData); 1874 1877 % LOOP ON GROUPS OF VARIABLES SHARING THE SAME DIMENSIONS 1875 1878 % CellVarIndex=cells of variable index arrays … … 1878 1881 nbcoord=0;%number of added coordinate variables brought by projection 1879 1882 nbvar=0; 1880 for icell=1:length(Cell VarIndex)1881 NbDim=NbDim Vec(icell);1883 for icell=1:length(CellInfo) 1884 NbDim=NbDimArray(icell); 1882 1885 if NbDim<3 1883 1886 continue 1884 1887 end 1885 VarIndex=Cell VarIndex{icell};% indices of the selected variables in the list FieldData.ListVarName1886 VarType= VarTypeCell{icell};1888 VarIndex=CellInfo{icell}.VarIndex;% indices of the selected variables in the list FieldData.ListVarName 1889 VarType=CellInfo{icell}.VarType; 1887 1890 ivar_X=VarType.coord_x; 1888 ivar_Y=VarType.coor d_y;1891 ivar_Y=VarType.coorCeld_y; 1889 1892 ivar_Z=VarType.coord_z; 1890 1893 ivar_U=VarType.vector_x; … … 1897 1900 ivar_F=VarType.warnflag; 1898 1901 ivar_FF=VarType.errorflag; 1899 check_unstructured_coord=~isempty(ivar_X) && ~isempty(ivar_Y);1902 %check_unstructured_coord=~isempty(ivar_X) && ~isempty(ivar_Y); 1900 1903 DimCell=FieldData.VarDimName{VarIndex(1)}; 1901 1904 if ischar(DimCell) … … 1904 1907 1905 1908 %% case of input fields with unstructured coordinates 1906 if check_unstructured_coord1909 if strcmp(CellInfo{icell}.CoordType,'scattered') 1907 1910 XName=FieldData.ListVarName{ivar_X}; 1908 1911 YName=FieldData.ListVarName{ivar_Y}; 1909 eval(['coord_x=FieldData.' XName ';'])1910 eval(['coord_y=FieldData.' YName ';'])1912 coord_x=FieldData.(XName); 1913 coord_y=FieldData.(YName); 1911 1914 if length(ivar_Z)==1 1912 1915 ZName=FieldData.ListVarName{ivar_Z}; 1913 eval(['coord_z=FieldData.' ZName ';']) 1914 end 1915 1916 coord_z=FieldData.(ZName); 1917 end 1916 1918 % translate initial coordinates 1917 1919 coord_x=coord_x-ObjectData.Coord(1,1); … … 1988 1990 VarName=FieldData.ListVarName{ivar}; 1989 1991 if ivar==ivar_X %x coordinate 1990 eval(['ProjData.' VarName '=coord_X;'])1992 ProjData.(VarName)=coord_X; 1991 1993 elseif ivar==ivar_Y % y coordinate 1992 eval(['ProjData.' VarName '=coord_Y;'])1994 ProjData.(VarName)=coord_Y; 1993 1995 elseif isempty(ivar_Z) || ivar~=ivar_Z % other variables (except Z coordinate wyhich is not reproduced) 1994 eval(['ProjData.' VarName '=FieldData.' VarName ';'])1996 ProjData.(VarName)=FieldData.(VarName); 1995 1997 end 1996 1998 if isempty(ivar_Z) || ivar~=ivar_Z … … 2285 2287 test_interp_tps=0; 2286 2288 end 2287 eval(['ProjData.' AYName '=[coord_y_proj(1) coord_y_proj(end)];'])%record the new (projected ) y coordinates2288 eval(['ProjData.' AXName '=[coord_x_proj(1) coord_x_proj(end)];'])%record the new (projected ) x coordinates2289 ProjData.(AYName)=[coord_y_proj(1) coord_y_proj(end)]; %record the new (projected ) y coordinates 2290 ProjData.(AXName)=[coord_x_proj(1) coord_x_proj(end)]; %record the new (projected ) x coordinates 2289 2291 for ivar=VarIndex 2290 2292 VarName=FieldData.ListVarName{ivar}; … … 2354 2356 if testangle 2355 2357 if isempty(ivar_V) 2356 msgbox_uvmat('ERROR','v velocity component missing in proj_field.m')2358 errormsg='v velocity component missing in proj_field.m'; 2357 2359 return 2358 2360 end … … 2372 2374 end 2373 2375 end 2376 if isempty(ProjData.ListVarName) 2377 errormsg='input field is not 3D, no volume projection'; 2378 ProjData=[]; 2379 end 2374 2380 2375 2381 %------------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.