Skip to content

Commit faa41d2

Browse files
SmithBBen SmithBen SmithBenjamin P. Jelley
authored
Pre rel006 (#42)
* package_data/ATL11_output_attrs.csv: removed slope_change parameters * point.py : save values for reference surf across-track and along-track slopes * ATL11/get_xover_data.py: added missing LR and dh_fit_dx fields to the crossover fields * geoloc_biases_from_xovers.py: script for generating crossover bias estimates * ATL11/rtw_mask.py: minor changes of unclear significance * ATL11/package_data/xy_biases_rel006_c1_18_plateau__0_800km_3day.csv: bias estimates for rel006 through cycle 18 * ATL11/data.py: skip writing poly_exponent_list attribute for beam pair groups * c19_rel006_held_granules.csv: Avoid processing the last day of cycle 19 * scripts/geoloc_biases_from_xovers.py: make functions importable * moved the 2020 held_granules file to an 'ignore' directory * scripts/geoloc_biases_from_xovers.py: read the hold files * ATL11/package_data/xy_biases_rel006_c1_19_plateau__0_800km_3day.csv: xy biases calculated using version 2 of the April-15 granules * scripts/geoloc_biases_from_xovers.py: don't filter if there are not holds * Updated hold_list code to check crossover data * removed blacklists directory and files * ATL11/check_ATL06_hold_list.py : return if hold list is None, and move the hold_list reading code out of check_hold_list * adding xy_bias to scripts * add seg_azimuth to xover read * ATL06_to_ATL11.py: check for successful ATL06 read before calculating geolocation bias * accounting for empty ATL06 files --------- Co-authored-by: Ben Smith <bsmith@apl.washington.edu> Co-authored-by: Ben Smith <besmith@uw.edu> Co-authored-by: Benjamin P. Jelley <bjelley@discover13.prv.cube>
1 parent b21fa5d commit faa41d2

19 files changed

+2907
-129
lines changed

ATL11/check_ATL06_hold_list.py

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ def read_hold_files(hold_dir=None):
1414
if hold_dir is None:
1515
hold_dir = str(resources.files('ATL11').joinpath("package_data/held_granules"))
1616
rgt=[]; cycle=[]; subprod=[];
17-
for file in glob.glob(os.path.join(hold_dir, '*.csv')):
17+
hold_files=glob.glob(os.path.join(hold_dir, '*.csv'))
18+
if hold_files is None or len(hold_files)==0:
19+
return None
20+
for file in hold_files:
1821
with open(file,'r') as ff:
1922
for line in ff:
2023
try:
@@ -28,15 +31,67 @@ def read_hold_files(hold_dir=None):
2831
return hold_list
2932

3033

31-
def check_ATL06_hold_list(filenames, hold_list=None, hold_dir=None):
32-
if hold_list is None:
33-
hold_list=read_hold_files(hold_dir=hold_dir)
34+
def check_ATL06_hold_list(filenames, hold_list=None):
35+
"""
36+
Check if files should be held.
37+
38+
Parameters
39+
----------
40+
filenames : list or string
41+
Filenames to check against the hold list
42+
hold_list : list of iterables, optional
43+
list of cycle, rgt, subproducts to hole. The default is None.
44+
45+
Returns
46+
-------
47+
list of booleans
48+
Boolean for each file: True=skip, False=use.
49+
50+
"""
51+
3452
if isinstance(filenames, (str)):
3553
filenames=list(filenames)
3654

55+
if hold_list is None:
56+
return [False]*len(filenames)
57+
3758
r06=re.compile('ATL.._(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)_(\d\d\d\d)(\d\d)(\d\d)_(\d\d\d)_(\d\d).h5')
3859
bad=[]
3960
for filename in filenames:
4061
m=r06.search(filename)
4162
bad.append((int(m.group(8)), int(m.group(7)), int(m.group(9))) in hold_list)
4263
return bad
64+
65+
def check_ATL06_data_against_hold_list(D, hold_list=None):
66+
"""
67+
Remove held rgt/cycle combinations from a data object.
68+
69+
Parameters
70+
----------
71+
D : pc.data
72+
ATL06 data, must have cycle (or cycle_number) and rgt fields
73+
hold_list : list, optinal
74+
list of cycle, rgt combinations that will be excluded from
75+
analysis. The default is None.
76+
77+
Returns
78+
-------
79+
None.
80+
81+
"""
82+
83+
if hold_list is None:
84+
return
85+
86+
# assume that hold_list is cycle, rgt, subproduct
87+
if 'cycle_number' in D.fields:
88+
c=D.cycle_number
89+
else:
90+
c=D.cycle
91+
hold_arr=np.c_[hold_list]
92+
cr = np.round(c).astype(int)+1j*np.round(D.rgt).astype(int)
93+
good = ~np.in1d(cr, hold_arr[:,0]+1j*hold_arr[:,1])
94+
if good.ndim==2:
95+
good=np.all(good, axis=2)
96+
if not np.all(good):
97+
D.index(good)

ATL11/data.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,8 @@ def write_to_file(self, fileout, params_11=None):
334334

335335
# write each variable in params_11 as an attribute
336336
for param, val in vars(params_11).items():
337+
if param=="poly_exponent_list":
338+
continue
337339
if not isinstance(val,(dict,type(None))):
338340
try:
339341
if param == 'ATL06_xover_field_list':
@@ -573,6 +575,7 @@ def from_ATL06(self, D6, GI_files=None, beam_pair=1, cycles=[1, 12],\
573575
ref_pt_numbers=None, ref_pt_x=None, hemisphere=-1,\
574576
mission_time_bds=None, max_xover_latitude=90, \
575577
atc_shift_table=None, release_bias_dict=None,\
578+
hold_list=None,\
576579
verbose=False, DOPLOT=None,DEBUG=None, return_list=True):
577580
"""
578581
Fit a collection of ATL06 files with ATL11 surface models
@@ -589,6 +592,7 @@ def from_ATL06(self, D6, GI_files=None, beam_pair=1, cycles=[1, 12],\
589592
mission_time_bds: starting and ending times for the mission
590593
verbose: write fitting info to stdout if true
591594
atc_shift_table: dict giving the along-track bias correction as a function of time
595+
hold_list: list of cycle, rgt, subproduct combinations to exclude
592596
DOPLOT: list of plots to make
593597
DEBUG: output debugging info
594598
"""
@@ -713,6 +717,7 @@ def from_ATL06(self, D6, GI_files=None, beam_pair=1, cycles=[1, 12],\
713717
D_xover=ATL11.get_xover_data(x0, y0, P11.rgt, GI_files,
714718
D_xover_cache, index_bin_size, params_11,
715719
xy_bin=D6_xyB, release_bias_dict=release_bias_dict,
720+
hold_list=hold_list,
716721
verbose=verbose)
717722
P11.corr_xover_heights(D_xover, atc_shift_table=atc_shift_table)
718723
# if we have read any data for the current bin, run the crossover calculation

ATL11/get_xover_data.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import h5py
1414
import re
1515
from ATL11 import apply_release_bias
16+
from ATL11.check_ATL06_hold_list import check_ATL06_data_against_hold_list
1617

1718
def get_ATL06_release(D6):
1819
if D6 is None:
@@ -34,6 +35,7 @@ def get_ATL06_release(D6):
3435

3536
def get_xover_data(x0, y0, rgt, GI_files, xover_cache, index_bin_size, params_11,
3637
release_bias_dict=None,
38+
hold_list=None,
3739
verbose=False, xy_bin=None):
3840
"""
3941
Read the data from other tracks.
@@ -53,11 +55,12 @@ def get_xover_data(x0, y0, rgt, GI_files, xover_cache, index_bin_size, params_11
5355
D_xover=[]
5456
ATL06_fields = ['delta_time', 'latitude','longitude', 'h_li', 'h_li_sigma',
5557
'atl06_quality_summary', 'segment_id', 'sigma_geo_h',
56-
'x_atc', 'y_atc',
58+
'x_atc', 'y_atc', 'dh_fit_dx',
5759
'sigma_geo_at','sigma_geo_xt', 'sigma_geo_r',
58-
'ref_azimuth', 'ref_coelv',
60+
'ref_azimuth', 'ref_coelv', 'seg_azimuth',
5961
'tide_ocean', 'dac',
60-
'rgt', 'cycle_number', 'BP', 'spot',
62+
'rgt', 'cycle_number',
63+
'BP', 'spot', 'LR',
6164
'source_file_num']
6265

6366
for x0_ctr in x0_ctrs:
@@ -106,6 +109,8 @@ def get_xover_data(x0, y0, rgt, GI_files, xover_cache, index_bin_size, params_11
106109
D_xover.append(xover_cache[this_key]['D'][np.arange(i0, i1+1, dtype=int)])
107110
if len(D_xover) > 0:
108111
D_xover=pc.data().from_list(D_xover)
112+
if hold_list is not None:
113+
check_ATL06_data_against_hold_list(D_xover, hold_list)
109114

110115
# cleanup the cache if it is too large
111116
if len(xover_cache.keys()) > 5:

ATL11/package_data/ATL11_output_attrs.csv

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ ref_surf,poly_exponent_y,counts,N_coeffs,int8,"""exponents for the y factors in
2323
ref_surf,x_atc,meters,N_pts,Float64,"""Along-track coordinate of the reference point, measured along the RGT from its first equator crossing.""","""Along track distance""","""ATL06""",../delta_time ../latitude ../longitude,0.0,3600000.0
2424
ref_surf,y_atc,meters,N_pts,Float64,"""Across-track coordinate of the reference point, measured along the RGT from its first equator crossing.""","""Across track distance""","""ATL06""",../delta_time ../latitude ../longitude,-20000.0,20000.0
2525
ref_surf,rgt_azimuth,degrees,N_pts,Float32,"""Reference track azimuth, in degrees east of local north""","""RGT azimuth""","""ATL06""",../delta_time ../latitude ../longitude,-180.0,180.0
26-
ref_surf,slope_change_rate_x,years^-1,N_pts,Float32,"""rate of change of the x component of the surface slope""","""x component of slope chnage rate""","""derived, ATL11 algorithm""",../delta_time ../latitude ../longitude,,
27-
ref_surf,slope_change_rate_y,years^-1,N_pts,Float32,"""rate of change of the y component of the surface slope""","""y component of slope change rate""","""derived, ATL11 algorithm""",../delta_time ../latitude ../longitude,,
28-
ref_surf,slope_change_rate_x_sigma,years^-1,N_pts,Float32,"""Formal error in the rate of change of the x component of the surface slope""","""error of x component slope change rate""","""derived, ATL11 algorithm""",../delta_time ../latitude ../longitude,,
29-
ref_surf,slope_change_rate_y_sigma,years^-1,N_pts,Float32,"""Formal error in the rate of change of the y component of the surface slope""","""error of y component slope change rate""","""derived, ATL11 algorithm""",../delta_time ../latitude ../longitude,,
3026
ref_surf,misfit_chi2r,meters,N_pts,Float32,"""misfit chi square, divided by the number of degrees in the solution""","""misfit chi square""","""derived, ATL11 algorithm""",../delta_time ../latitude ../longitude,0.0,
3127
ref_surf,misfit_RMS,meters,N_pts,Float32,"""RMS misfit for the surface-polynomial fit""","""misfit RMS""","""derived, ATL11 algorithm""",../delta_time ../latitude ../longitude,0.0,
3228
ref_surf,dem_h,meters,N_pts,Float32,"""DEM elevation, derived from ATL06 /gtxx/atl06_segments/dem/dem_h""","""DEM elevation""","""ATL06""",../delta_time ../latitude ../longitude,-100.0,7500.0

ATL11/package_data/held_granules/all_held_granules_Feb_2020_Antarctic.csv renamed to ATL11/package_data/held_granules/ignore/all_held_granules_Feb_2020_Antarctic.csv

File renamed without changes.

ATL11/package_data/held_granules/all_held_granules_Feb_2020_Arctic.csv renamed to ATL11/package_data/held_granules/ignore/all_held_granules_Feb_2020_Arctic.csv

File renamed without changes.

0 commit comments

Comments
 (0)