Extracting smaller matrix from larger one, using a coordinate systrem

3 views (last 30 days)
Cian Vaugh
Cian Vaugh on 16 Apr 2021
Answered: Abhishek Gupta on 19 Apr 2021
Im dealing with NIMROD weater data for a project . i have adapted and modifyed the program to extract the data into a large rain intensity matrix( rr_dat_mat), i only seed a subsection of the data between a certin coo ordinates but im having isssures going between easting northings and the index's
below is the the code that im running i cant provide the data files, However hopefull this is enbough to help with with my blunders
%% GLobal Var
utmzone = '29 U' %Universal Transverse Mercator coordinate system irelnad refrance
%%file handeling __________________________________________________________
scrsz = get(0,'ScreenSize');
fh1 = figure('OuterPosition',[1 scrsz(4)*.05 scrsz(3)*0.5 scrsz(4)* 0.95]);
disp('Extracting files')
files = gunzip(untar(MASTERFILE,'TempGz'),'TempDat');
%ectractedGz = gunzip('metoffice-c-band-rain-radar_uk_20210129_1km-composite.dat.gz')
NoFiles = length(files)
disp('files extracted')
%% Easting northing Isioation area _________________________________________
iosilationAreapoint1.easting = 156534;
iosilationAreapoint1.northing =187799 ;
[isolationAreaPoint1.Lat,isolationAreaPoint1.Lon] = ...
iosilationAreapoint2.easting =171582;
iosilationAreapoint2.northing = 166267;
[isolationAreaPoint2.Lat,isolationAreaPoint2.Lon] = ...
%geoplot([isolationAreaPoint2.Lat isolationAreaPoint1.Lat],...
% [isolationAreaPoint2.Lon isolationAreaPoint1.Lon],'g-*')
hold on
%% Frame loop itterator
for i = 1:6:NoFiles
% run rdnim1k to extract data items form .dat file
[int_gen_hd, rl_gen_hd, rl_datsp_hd, char_hd, int_datsp_hd, ...
rr_dat_mat] = rdnim1km( files{i} );
%test translation factor
Trans.x = rl_datsp_hd(2)-1; %matlab indexes start at 1
Trans.y = rl_datsp_hd(1)- 1;
%Get co ordnates for bottom left
grahOrigin.x = rl_datsp_hd(2);
grahOrigin.y = rl_datsp_hd(5);
%used to identify top right corener ( make sure orintation and endings
%configured correctly
% xmax = int_gen_hd(19);
% xmax = 157363.75;
% rr_dat_mat(1:20,xmax-19:xmax) = 600;
% Plot rain radar image on National Grid (NG) scale
% -------------------------------------------------
% Set colour limits for image and colourbar (1000=31.25mm/hr - you may
% need to increase this for extreme weather events).
clims = [ 0 1000 ];
% create x and y vectors one value for each pixel along edge of plot
%NB: yg is deliberately in descending order to allow correct display of
% both array and NG co-ordinates on plot y-axis
xg = linspace(rl_datsp_hd(2),rl_datsp_hd(4),int_gen_hd(19));
yg = linspace(rl_datsp_hd(1),rl_datsp_hd(5),int_gen_hd(18));
% display the rain radar data image
%test refrence system
rr_dat_mat(rl_datsp_hd(2)- Trans.x,rl_datsp_hd(1)-Trans.y)= 600;
%index and save rowes fo selected area
M = zeros;
for eastSave = (iosilationAreapoint1.easting- Trans.x):(iosilationAreapoint2.easting-Trans.x)
for northSave = (iosilationAreapoint1.northing- Trans.y):( iosilationAreapoint2.northing-Trans.y)
M = [M rr_dat_mat(eastSave,northSave)];
%highlight Area on Whole Pitcher
rr_dat_mat(eastSave,northSave) = 600;
%plot data
% use rainbow colour scheme
% display axis scales corresponding to...
% NG co-ordinates of area covered by image: left right bottom top
wholePicture = [rl_datsp_hd(2) rl_datsp_hd(4) rl_datsp_hd(5) rl_datsp_hd(1) ];%aquiered form header file
%windowedPitcher = [157363.75 172053.28 165807.68 187324.25]; % easting norting of bottom left and top right
windowedPitcher = [iosilationAreapoint1.easting iosilationAreapoint2.easting iosilationAreapoint2.northing iosilationAreapoint1.northing];
%comment or oncomment one of the 2 following lines in order to get differnt
axis xy
% ensure square grid i.e 1km easting is same as 1km northing
axis equal
% display uncompressed filename (which includes timestamp) as title
% display key to colours on rhs of plot
% allow successive plots to use same figure and plot area
hold on
grid on
% mark location of interest between white and red 'x'
hold on
disp( 'plotting seriies - loop number :' );

Answers (1)

Abhishek Gupta
Abhishek Gupta on 19 Apr 2021
As per my understanding, you want to extract a part of a matrix. Referring to the following MATLAB Answer, which might help you resolve the issue: -
For more information, check out the following documentation link: -




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!