Skip to content

Commit 5496e35

Browse files
committed
in matlab tile file reader, synchronize field names with latest make_bcs commits (read_tile_file.m)
1 parent fa232ef commit 5496e35

File tree

1 file changed

+33
-39
lines changed

1 file changed

+33
-39
lines changed

GEOSldas_App/util/shared/matlab/read_tile_file.m

Lines changed: 33 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,6 @@
7979

8080
tmpdata = ncread( fname_til, this_varname );
8181

82-
% rename some fields
83-
84-
if strcmp(this_varname,'i_indg1' ), this_varname = 'i_indg'; end
85-
if strcmp(this_varname,'j_indg1' ), this_varname = 'j_indg'; end
86-
if strcmp(this_varname,'frac_cell1' ), this_varname = 'frac_cell'; end
87-
if strcmp(this_varname,'dummy_index1'), this_varname = 'dummy_index'; end
88-
8982
cmd = ['tile_coord.', this_varname, ' = tmpdata;'];
9083

9184
%disp(cmd)
@@ -232,24 +225,24 @@
232225
%
233226
% header line 2:
234227

235-
tile_coord.N_grids = fscanf( ifp, '%f', 1 );
228+
tile_coord.N_Grids = fscanf( ifp, '%f', 1 );
236229

237-
% verify N_grids (should be 1 for EASE and 2 for non-EASE)
230+
% verify N_Grids (should be 1 for EASE and 2 for non-EASE)
238231

239-
if isEASE & tile_coord.N_grids~=1, error(['unexpected N_grids for EASE tile space: ', num2str(tile_coord.N_grids)]), end
232+
if isEASE & tile_coord.N_Grids~=1, error(['unexpected N_Grids for EASE tile space: ', num2str(tile_coord.N_Grids)]), end
240233

241-
if ~isEASE & tile_coord.N_grids~=2, error(['unexpected N_grids for non-EASE tile space: ', num2str(tile_coord.N_grids)]), end
234+
if ~isEASE & tile_coord.N_Grids~=2, error(['unexpected N_Grids for non-EASE tile space: ', num2str(tile_coord.N_Grids)]), end
242235

243236
% Deal with older EASE bcs versions having (useless) header lines for grid 2,
244-
% despite having the correct value of N_grids=1 in header line 2.
237+
% despite having the correct value of N_Grids=1 in header line 2.
245238

246239
if isEASE & ( ~isempty(findstr('NL3',fname_til)) | ~isempty(findstr('NL4',fname_til)) )
247240

248241
tmp_n_grids = 2;
249242

250243
else
251244

252-
tmp_n_grids = tile_coord.N_grids;
245+
tmp_n_grids = tile_coord.N_Grids;
253246

254247
end
255248

@@ -267,11 +260,12 @@
267260

268261
if tmp_n_grids==2
269262

270-
% NOTE: EASE NL3 and NL4 contain additional header lines for second grid, despite (correct) N_grids=1
263+
% NOTE: EASE NL3 and NL4 contain additional header lines for second grid, despite (correct) N_Grids=1
264+
% For these old versions, read (and then ignore) additional header lines.
271265

272-
tile_coord.Grid2_Name = fscanf( ifp, '%s', 1 );
273-
tile_coord.IM2 = fscanf( ifp, '%f', 1 );
274-
tile_coord.JM2 = fscanf( ifp, '%f', 1 );
266+
tile_coord.Grid_ocn_Name = fscanf( ifp, '%s', 1 );
267+
tile_coord.IM_ocn = fscanf( ifp, '%f', 1 );
268+
tile_coord.JM_ocn = fscanf( ifp, '%f', 1 );
275269

276270
end
277271

@@ -318,41 +312,41 @@
318312
%
319313
% copy data into tile_coord structure
320314

321-
tile_coord.N_tile = size(tmpdata,1); % number of tiles (assign here in case of subsetting above)
315+
tile_coord.N_tile = size(tmpdata,1); % number of tiles (assign here in case of subsetting above)
322316

323317
% the following are universal (for EASE and non-EASE, all tile types)
324318

325-
tile_coord.tile_id = tmp_tileid; % tile ID
319+
tile_coord.tile_id = tmp_tileid; % tile ID
326320

327-
tile_coord.typ = tmpdata(:, 1); % tile type
321+
tile_coord.typ = tmpdata(:, 1); % tile type
328322

329-
tile_coord.com_lon = tmpdata(:, 3); % center-of-mass longitude of tile
330-
tile_coord.com_lat = tmpdata(:, 4); % center-of-mass latitude of tile
323+
tile_coord.com_lon = tmpdata(:, 3); % center-of-mass longitude of tile
324+
tile_coord.com_lat = tmpdata(:, 4); % center-of-mass latitude of tile
331325

332-
tile_coord.i_indg = tmpdata(:, 5); % i index of tile on global "atm" (or EASE) grid
333-
tile_coord.j_indg = tmpdata(:, 6); % j index of tile on global "atm" (or EASE) grid
334-
tile_coord.frac_cell = tmpdata(:, 7); % area fraction of "atm" (or EASE) grid cell
326+
tile_coord.i_indg = tmpdata(:, 5); % i index of tile on global "atm" (or EASE) grid
327+
tile_coord.j_indg = tmpdata(:, 6); % j index of tile on global "atm" (or EASE) grid
328+
tile_coord.frac_cell = tmpdata(:, 7); % area fraction of "atm" (or EASE) grid cell
335329

336330
% initialize remaining fields (to be filled below)
337331

338332
tmpNaN = NaN*ones(tile_coord.N_tile,1);
339333

340-
tile_coord.min_lon = tmpNaN; % min longitude of tile
341-
tile_coord.max_lon = tmpNaN; % max longitude of tile
342-
tile_coord.min_lat = tmpNaN; % min latitude of tile
343-
tile_coord.max_lat = tmpNaN; % max latitude of tile
334+
tile_coord.min_lon = tmpNaN; % min longitude of tile
335+
tile_coord.max_lon = tmpNaN; % max longitude of tile
336+
tile_coord.min_lat = tmpNaN; % min latitude of tile
337+
tile_coord.max_lat = tmpNaN; % max latitude of tile
344338

345-
tile_coord.elev = tmpNaN; % elevation of tile
339+
tile_coord.elev = tmpNaN; % elevation of tile
346340

347-
tile_coord.area = tmpNaN; % area of "atm" grid cell
348-
tile_coord.pfaf_index = tmpNaN; % index of (hydrological) Pfafstetter catchment
349-
tile_coord.frac_pfaf = tmpNaN; % area fraction of Pfafstetter catchment
341+
tile_coord.area = tmpNaN; % area of "atm" grid cell
342+
tile_coord.pfaf_index = tmpNaN; % index of (hydrological) Pfafstetter catchment
343+
tile_coord.frac_pfaf = tmpNaN; % area fraction of Pfafstetter catchment
350344

351345
if ~isEASE
352346

353-
tile_coord.i_indg2 = tmpNaN; % i index of tile on global "ocean" grid (grid 2)
354-
tile_coord.j_indg2 = tmpNaN; % j index of tile on global "ocean" grid (grid 2)
355-
tile_coord.frac_cell2 = tmpNaN; % area fraction of "ocean" grid cell (grid 2)
347+
tile_coord.i_indg_ocn = tmpNaN; % i index of tile on global "ocean" grid (grid 2)
348+
tile_coord.j_indg_ocn = tmpNaN; % j index of tile on global "ocean" grid (grid 2)
349+
tile_coord.frac_cell_ocn = tmpNaN; % area fraction of "ocean" grid cell (grid 2)
356350

357351
end
358352

@@ -409,9 +403,9 @@
409403

410404
tile_coord.frac_pfaf( ind_NOTocean) = tmpdata(ind_NOTocean, col_fracpfaf);
411405

412-
tile_coord.i_indg2( ind_ocean) = tmpdata(ind_ocean, 9);
413-
tile_coord.j_indg2( ind_ocean) = tmpdata(ind_ocean, 10);
414-
tile_coord.frac_cell2(ind_ocean) = tmpdata(ind_ocean, 11);
406+
tile_coord.i_indg_ocn( ind_ocean) = tmpdata(ind_ocean, 9);
407+
tile_coord.j_indg_ocn( ind_ocean) = tmpdata(ind_ocean, 10);
408+
tile_coord.frac_cell_ocn(ind_ocean) = tmpdata(ind_ocean, 11);
415409

416410
end
417411

0 commit comments

Comments
 (0)