-
Notifications
You must be signed in to change notification settings - Fork 1
/
grd2gmtMap_create_RJ_options.m
51 lines (48 loc) · 2.52 KB
/
grd2gmtMap_create_RJ_options.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
function [MapRegionExtents, RJstring] = grd2gmtMap_create_RJ_options(...
lonRange, latRange, ExtentsBuffer, ForceExtents,...
SourceType, sourceLonLat,...
edgeBufferLon, edgeBufferLat)
%grd2gmtMap_create_RJ_options
RegionExtents = [lonRange, latRange]; % data extents [lon0 lon1 lat0 lat1]
if ForceExtents % [lon0 lon1 lat0 lat1] were provided, use those
MapRegionExtents = ExtentsBuffer;
else % edge buffer/trim was provided
switch SourceType % should we refer them to the grid coverage or around the centre point / fault plane?
case 'none'
% referring the edge buffer/trim to the grid extents 'RegionExtents'
MapRegionBuffer = [...
-edgeBufferLon, edgeBufferLon,...
-edgeBufferLat, edgeBufferLat]; % buffer/clip around data [lon0 lon1 lat0 lat1]
MapRegionExtents = RegionExtents + MapRegionBuffer; % map corners [lon0 lon1 lat0 lat1]
MapRegion_isPointReferred = false;
case 'point'
% referring the buffer around the centre point
MapRegion_isPointReferred = true;
MapRegion_sourceLonLat = sourceLonLat;
case 'rectangle'
% referring the buffer around the fault rectangle
MapRegion_isPointReferred = true;
% compute the rectangle center
% = along column average: [average lon, average lat]
MapRegion_sourceLonLat = mean(sourceLonLat, 1);
end
% avoid repetitions: the following apply if we are 'referring to point'
% (either point or center of rectangle)
if MapRegion_isPointReferred
% negative 'trim' is nonsense in this case
edgeBufferLon = abs(edgeBufferLon);
edgeBufferLat = abs(edgeBufferLat);
MapRegionExtents = [...
MapRegion_sourceLonLat(1) - edgeBufferLon, MapRegion_sourceLonLat(1) + edgeBufferLon,...
MapRegion_sourceLonLat(2) - edgeBufferLat, MapRegion_sourceLonLat(2) + edgeBufferLat];
end
end
Rstring = [... % extents, r option means lower left and upper right coords
'-R',num2str(MapRegionExtents(1)),'/',num2str(MapRegionExtents(3)), '/', ...
num2str(MapRegionExtents(2)),'/',num2str(MapRegionExtents(4)),'r ']; % extents
Jstring = ['-JA', ...
num2str(RegionExtents(1)+(RegionExtents(2)-RegionExtents(1))/2), '/', ... % lon0 center
num2str(RegionExtents(3)+(RegionExtents(4)-RegionExtents(3))/2), ... % lat0 center
'/6i']; % projection (-JA Lambert lon0/lat0/width)
RJstring = [Rstring, Jstring]; % extents and projection, concatenated
end