Skip to content

Commit

Permalink
updates to code for release
Browse files Browse the repository at this point in the history
  • Loading branch information
slhowardESR committed Apr 16, 2021
1 parent 7ed9a8e commit c6c2df4
Show file tree
Hide file tree
Showing 6 changed files with 183 additions and 133 deletions.
Binary file modified documents/Readme.pdf
Binary file not shown.
7 changes: 5 additions & 2 deletions documents/Step_01_download_ross_front_atl06_data.html
Original file line number Diff line number Diff line change
Expand Up @@ -13084,8 +13084,11 @@ <h2 id="Download-ICESat-2-ATL06-files-in-the-vicinity-of-the-Ross-Ice-Shelf-(RIS
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>This notebook uses the icepyx library (Scheick et al., 2019; <a href="https://github.com/icesat2py/icepyx">https://github.com/icesat2py/icepyx</a>) to download spatially and temporally subsetted ATL06 granules from the National Snow and Ice Data Center. Running this notebook should result in the download of these granules in the location defined by the variable 'path' in last code block. Adjust path according to your own workflow.</p>
<p>This notebook uses the icepyx library (Scheick et al., 2019; <a href="https://github.com/icesat2py/icepyx">https://github.com/icesat2py/icepyx</a>) to download spatially and temporally subsetted ATL06 granules from the National Snow and Ice Data Center. Running this notebook should result in the download of these granules in the location defined by the variable 'path' in the last code block. The user should adjust the path according to their own workflow.</p>
<p>This script implements the ATL06-specific methods described in Subsection 2.2 of Becker et al. (2021).</p>
<p>Susan L. Howard, Earth and Space Research, showard@esr.org</p>
<p>Maya K. Becker, Scripps Institution of Oceanography, mayakbecker@gmail.com</p>
<p>Last updated April 15, 2021</p>

</div>
</div>
Expand Down Expand Up @@ -13245,7 +13248,7 @@ <h3 id="Check-the-total-number-of-granules-available-that-meet-the-Query-object'
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="Order-all-granules-that-meet-the-Query-object's-parameters.-We-do-not-use-any-variable-subsetting.">Order all granules that meet the Query object's parameters. We do not use any variable subsetting.<a class="anchor-link" href="#Order-all-granules-that-meet-the-Query-object's-parameters.-We-do-not-use-any-variable-subsetting.">&#182;</a></h3>
<h3 id="Order-all-granules-that-meet-the-Query-object's-parameters,-in-this-case-without-any-variable-subsetting">Order all granules that meet the Query object's parameters, in this case without any variable subsetting<a class="anchor-link" href="#Order-all-granules-that-meet-the-Query-object's-parameters,-in-this-case-without-any-variable-subsetting">&#182;</a></h3>
</div>
</div>
</div>
Expand Down
12 changes: 9 additions & 3 deletions scripts/Step_01_download_ross_front_atl06_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"This notebook uses the icepyx library (Scheick et al., 2019; https://github.com/icesat2py/icepyx) to download spatially and temporally subsetted ATL06 granules from the National Snow and Ice Data Center. Running this notebook should result in the download of these granules in the location defined by the variable 'path' in last code block. Adjust path according to your own workflow.\n",
"This notebook uses the icepyx library (Scheick et al., 2019; https://github.com/icesat2py/icepyx) to download spatially and temporally subsetted ATL06 granules from the National Snow and Ice Data Center. Running this notebook should result in the download of these granules in the location defined by the variable 'path' in the last code block. The user should adjust the path according to their own workflow.\n",
"\n",
"This script implements the ATL06-specific methods described in Subsection 2.2 of Becker et al. (2021)."
"This script implements the ATL06-specific methods described in Subsection 2.2 of Becker et al. (2021).\n",
"\n",
"Susan L. Howard, Earth and Space Research, showard@esr.org\n",
"\n",
"Maya K. Becker, Scripps Institution of Oceanography, mayakbecker@gmail.com\n",
"\n",
"Last updated April 15, 2021"
]
},
{
Expand Down Expand Up @@ -129,7 +135,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Order all granules that meet the Query object's parameters. We do not use any variable subsetting."
"### Order all granules that meet the Query object's parameters, in this case without any variable subsetting"
]
},
{
Expand Down
79 changes: 39 additions & 40 deletions scripts/Step_02_build_structure_from_h5_files.m
Original file line number Diff line number Diff line change
@@ -1,46 +1,44 @@
% This script builds and saves a MATLAB structure with all relevant information
% from the HDF5 files downloaded in Step 01 and plots the approximate ice-
% shelf front location for each ground track profile over the mask from Depoorter
% et al. (2013). The user should specify the location of the HDF5 files with
% variable 'data_dir,' which should match the path specified at the end of
% the Step 01 Jupyter Notebook, as well as the location of the *.mat file
% et al. (2013). The user should specify the location of (1) the HDF5 files
% with the variable 'data_dir,' which should match the path specified at the
% end of the Step 01 Jupyter Notebook, and (2) the location of the *.mat file
% containing the Depoorter et al. (2013) mask data.
%
% This script implements part of Step (i) described in Subsection 2.3 of
% Becker et al. (2021).
%
% NOTE: This script calls the Antarctic Mapping Tools 'll2ps' function
% (Greene et al., 2017), which can be downloaded from the Mathworks File
% (Greene et al., 2017), which can be downloaded from the MathWorks File
% Exchange:
% https://www.mathworks.com/matlabcentral/fileexchange/47638-antarctic-mapping-tools
% https://www.mathworks.com/matlabcentral/fileexchange/47638-antarctic-mapping-tools.
%
% Susan L. Howard, Earth and Space Research, showard@esr.org
% Maya K. Becker, Scripps Institution of Oceanography, mayakbecker@gmail.com
%
% Last update: April 14, 2021.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Last updated April 16, 2021

%%%%%%%%%%%%%%%%%%%%%%%%%%%% Begin user input %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

work_path = pwd;

out_filename = 'ross_files.mat'; % output filename
data_dir = 'D:\ICESat2\ross_data_download\ '; % should match the path specified at the end of the Step
% 01 Jupyter Notebook

load 'Depoorter_et_al_2013_mask.mat'; % Load mask from Depoorter et al.(2013)
data_dir = 'D:\ICESat2\ross_data_download\'; % change to match the path
% specified at the end of
% the Step 01 Jupyter Notebook

load 'Depoorter_et_al_2013_mask.mat'; % load mask from Depoorter et al. (2013)



%%%%%%%%%%%%%%%%%%% end user input %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%% End user input %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

cd(data_dir)
all_files = dir('*.h5');
number_of_files = length(all_files);

% Create variables for the approximate front locations in the ground track
% profiles-- for each front crossing, we keep track of the x and y locations
% on either side of crossing (ocean to ice shelf mask change, described
% below)
% profiles. For each front crossing, we keep track of the x and y locations
% on either side of the crossing (determined by the change in mask value
% from ocean to ice shelf, described below).

front_x = zeros(number_of_files,6,2);
front_y = zeros(number_of_files,6,2);
Expand All @@ -51,8 +49,8 @@

beams = ['1r'; '1l'; '2r'; '2l'; '3r'; '3l'];

% Use Depoorter et al.(2013) mask -- Mask values are: 0: ocean,
% 1: land and grounded ice, 2: ice shelf--and plot it as a basemap
% Plot the Depoorter et al. (2013) mask as a basemap. Mask values are as
% follows: 0 = ocean, 1 = land and grounded ice, and 2 = ice shelf.

[SM.X,SM.Y] = meshgrid(SM.x,SM.y);

Expand All @@ -63,19 +61,21 @@
axis([-700 550 -1550 -1075])
hold on

ross_files = struct;
structure_entry = 0;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Read relevant variables from each beam of each ATL06 file, check for
% front crossings based on mask, and store in structure
% Read the relevant variables from each beam of each ATL06 file, check for
% a front crossing based on the mask, and store the variables in the structure
% 'ross_files'
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

ross_files = struct;
structure_entry = 0;

for i = 1:number_of_files

% Loop through all six beams of each file, pulling all relevant
% variables--refer to ATL06 data dictionary for variable/attribute
% description: https://nsidc.org/data/atl06
% description:
% https://nsidc.org/sites/nsidc.org/files/technical-references/ATL06-data-dictionary-v001.pdf

for j = 1:length(beams)

Expand All @@ -94,7 +94,7 @@
dem_h = h5read([data_dir '/' all_files(i).name], ['/gt' beams(j,:) '/land_ice_segments/dem/dem_h']);
dem_flag = h5read([data_dir '/' all_files(i).name], ['/gt' beams(j,:) '/land_ice_segments/dem/dem_flag']);
sc_orient = h5read([data_dir '/' all_files(i).name], '/orbit_info/sc_orient');
% Flag values: ['0', '1', '2'], flag meanings: ['backward', 'forward', 'transition']
% spacecraft orientation parameter values: ['0', '1', '2']; value meanings: ['backward', 'forward', 'transition']
x_atc = h5read([data_dir '/' all_files(i).name], ['/gt' beams(j,:) '/land_ice_segments/ground_track/x_atc']);
y_atc = h5read([data_dir '/' all_files(i).name], ['/gt' beams(j,:) '/land_ice_segments/ground_track/y_atc']);
product = all_files(i).name(11:15);
Expand All @@ -103,7 +103,7 @@
region = all_files(i).name(38:39);

% Determine the beam type, i.e., whether it is strong or weak,
% using the value of 'sc_orient' (spacecraft orientation)
% using the value of 'sc_orient'

if sc_orient == 1

Expand Down Expand Up @@ -133,7 +133,7 @@
end

% Convert latitude and longitude coordinates to polar stereographic
% map coordinates using 'll2ps' function (Greene et al., 2017)
% map coordinates using the 'll2ps' function (Greene et al., 2017)

[x,y] = ll2ps(lat,lon);

Expand All @@ -148,8 +148,8 @@
[a,b] = size(mask_interp);

% Set the ellipsoidal height data ('h_li' in the ATL06 data
% dictionary) values greater than 3e38, and their corresponding
% locations, to NaN
% dictionary and here) values greater than 3e38, and their
% corresponding locations, to NaN

nan_idx = find(h_li > 3.e+38);

Expand All @@ -161,11 +161,12 @@

% Loop through the interpolated mask values, calculating the
% difference between each value and the next. A difference value
% greater than 1 denotes an ice-shelf front crossing (ocean = 0,
% ice shelves = 2); there should only be one ice-shelf front
% crossing per beam/ground track profile. Only information from
% beams that show a transition from ice shelf to ocean is
% included in the structure.
% greater than 1 denotes an ice-shelf front crossing (because
% the ocean mask value is 0 and the ice-shelf mask value is 2);
% there should only be one ice-shelf front crossing per
% beam/ground track profile. Only information from beams that
% show a transition from ice shelf to ocean is included in the
% structure.

for k = 1:a-1

Expand Down Expand Up @@ -259,9 +260,7 @@

gt_count = structure_entry;

% Save final 'ross_front_crossings' structure and other relevant parameters
% to a *.mat file
% Save final 'ross_files' structure and other relevant parameters to a
% *.mat file

save(out_filename, '-v7.3', 'ross_files', 'gt_count', 'front_y', 'front_x')


79 changes: 38 additions & 41 deletions scripts/Step_03_detect_front.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,69 +5,66 @@
% various data on the front crossing.
%
% This script implements part of Step (i) and steps (ii)-(iv) described in
% Subsection 2.3 of Becker et al. (2021).
% Subsection 2.3 of Becker et al. (2021). This text also describes choices
% for cleaning up the data, specifically assessed for Ross Ice Shelf.
%
% Susan L. Howard, Earth and Space Research, showard@esr.org
% Maya K. Becker, Scripps Institution of Oceanography, mayakbecker@gmail.com
%
% Last update: April 14, 2021.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Last updated April 16, 2021

%%%%%%%%%%%%%%%%%%%%%%%%%%%% Begin user input %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

load 'ross_files.mat' % *.mat file created in Step 02

out_filename = 'ross_front_crossing_data.mat'; % output filename

out_filename = 'ross_front_crossing_data.mat'; % output filename

ref_time = datenum(2018,01,01); % reference time for all ground track profiles

mdt = -1.4; % constant value to use for the MDT correction.


% set h_ss ((instantaneous sea surface) outlier values
hss_low=-5;
hss_high=100;
mdt = -1.4; % constant value to use for the MDT correction

h_ss_low = -5; % lowest allowable instantaneous sea surface (h_ss) value
h_ss_high = 100; % highest allowable h_ss value

% Set various criteria that a ground track profile jump must satisfy in
% order to be classified as representing the ice front by the
% front-detection algorithm

h_a_upper_limit = 2; % upper limit of the height of the ocean point in the
% front jump
h_diff_lower_limit = 10; % lower limit of the height increase that
% constitutes a front jump
h_diff_upper_limit = 100; % upper limit of the height increase that
% constitutes a front jump
h_a_upper_limit = 2; % upper limit of the height of the ocean
% point in the front jump

h_diff_lower_limit = 10; % lower limit of the height increase that
% constitutes a front jump

h_diff_upper_limit = 100; % upper limit of the height increase that
% constitutes a front jump

jump_x_dist_upper_limit = 80; % upper limit of the along-track distance over
% which a front jump could occur



%%%%%%%%%%%%%%%%%%%%%%% end user input %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%% End user input %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Clean data & apply geophysical corrections
% Clean up the structure and apply geophysical corrections to the data
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Clean up the structure from Step 02. Looping through each structure entry/
% ground track profile, first set the h_li values to NaN for segments for
% which the interpolated Depoorter et al. (2013) mask value indicates that
% which the interpolated Depoorter et al. (2013) mask values indicate that
% they occur over grounded ice, and then do the same for segments for which
% the quality summary parameter ('atl06_quality_summary' in the ATL06 data
% dictionary) value indicates some sort of data-quality issue.
% dictionary) values indicate data-quality issues.

ross_files_clean = ross_files;

for i = 1:gt_count

grounded_ice_inds = find(ross_files_clean(i).mask == 1);
% value of 1 indicates grounded ice
% mask value of 1 indicates grounded ice
ross_files_clean(i).h_li(grounded_ice_inds) = NaN;

bad_quality_inds = find(ross_files_clean(i).quality_summary_flag == 1);
% value of 1 indicates some potential data-quality problem
% parameter value of 1 indicates some potential data-quality problem
ross_files_clean(i).h_li(bad_quality_inds) = NaN;

end
Expand All @@ -77,8 +74,7 @@
% ocean tides, inverted barometer effects (IBE), and mean dynamic topography
% (MDT). Obtain values for the geoid height and ocean tides and IBE corrections
% from the ATL06 product itself; apply a constant value for the MDT
% correction.

% correction (which was set in the user input section).

for i = 1:gt_count

Expand All @@ -89,17 +85,17 @@

end

% For each ground track profile, remove outliers of h_ss (limits
% set in user input section), and generate a new variable, 'x_dist,'
% which gives the difference in along-track x-coordinate between the first
% ATL06 segment and each successive segment
% For each ground track profile, remove outliers of h_ss (the limits for
% which were set in the user input section), and generate a new variable,
% 'x_dist,' which gives the difference in along-track x-coordinate between
% the first ATL06 segment and each successive segment

for i = 1:gt_count

low_h_ss_inds = find(ross_files_clean(i).h_ss < hss_low);
low_h_ss_inds = find(ross_files_clean(i).h_ss < h_ss_low);
ross_files_clean(i).h_ss(low_h_ss_inds) = NaN;

high_h_ss_inds = find(ross_files_clean(i).h_ss > hss_high);
high_h_ss_inds = find(ross_files_clean(i).h_ss > h_ss_high);
ross_files_clean(i).h_ss(high_h_ss_inds) = NaN;

ross_files_clean(i).x_dist = ross_files_clean(i).x_atc - ...
Expand All @@ -108,7 +104,8 @@
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Create structure for ice front crossings
% Create a new structure, 'ross_front_crossing_data,' for the ice-front
% crossings
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Create a new structure that expands upon the cleaned-up version of the
Expand Down Expand Up @@ -152,6 +149,7 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Run the front-detection algorithm for each ground track profile
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

for i = 1:gt_count

disp(i)
Expand All @@ -177,9 +175,10 @@

% Calculate 'h_diff,' the difference between adjacent values of
% h_ss. If a pair of points meets the height, height difference,
% and along-track distance criteria defined in input section,
% take the pair as representing a front jump and gather data about
% the front crossing. Break out of this loop once the front is detected.
% and along-track distance criteria defined in the user input
% section, take the pair as representing a front jump and gather
% data about the front crossing. Break out of this loop once
% the front is detected.

h_diff = abs(h_ss_non_NaN_inds(j + 1) - h_ss_non_NaN_inds(j));

Expand Down Expand Up @@ -336,5 +335,3 @@
save(out_filename, '-v7.3', 'ross_front_crossing_data', 'gt_count', ...
'h_a_upper_limit', 'h_diff_lower_limit', 'h_diff_upper_limit', ...
'h_diff_upper_limit')


Loading

0 comments on commit c6c2df4

Please sign in to comment.