Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load2hdf5 --compression & view --faultline-min-dist #1062

Merged
merged 1 commit into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/mintpy/legacy/load2hdf5.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def create_parser():
# output
parser.add_argument('--dname','--dset-name', dest='dset_name', help='output dataset name(s)')
parser.add_argument('--meta', dest='metadata', nargs='*', help='add custom metadata')
parser.add_argument('--comp','--compression', dest='compression', choices={None, 'lzf', 'gzip'},
default=None, help='compression while writing to HDF5 file (default: %(default)s).')

parser.add_argument('-o', '--output', dest='outfile', required=True, help='output HDF5 file name')
parser.add_argument('--force', dest='force', action='store_true', help='enforce output data overwrite.')
Expand Down Expand Up @@ -132,7 +134,7 @@ def main(iargs=None):
# write
atr['LENGTH'] = box[3] - box[1]
atr['WIDTH'] = box[2] - box[0]
writefile.write(dsDict, out_file=inps.outfile, metadata=atr)
writefile.write(dsDict, out_file=inps.outfile, metadata=atr, compression=inps.compression)

return inps.outfile

Expand Down
3 changes: 3 additions & 0 deletions src/mintpy/utils/arg_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@ def add_map_argument(parser):
mapg.add_argument('--faultline-lw', '--faultline-linewidth', dest='faultline_linewidth',
metavar='NUM', type=float, default=0.5,
help='Faultline linewidth (default: %(default)s).')
mapg.add_argument('--faultline-min-dist','--faultline-min-len', dest='faultline_min_dist',
metavar='NUM', type=float, default=0.1,
help='Show fault segments with length >= X km (default: %(default)s).')

# lalo label
mapg.add_argument('--lalo-label', dest='lalo_label', action='store_true',
Expand Down
17 changes: 13 additions & 4 deletions src/mintpy/utils/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,11 @@ def auto_adjust_xaxis_date(ax, datevector, fontsize=12, every_year=None, buffer_

# auto param
if not every_year:
every_year = max(1, np.rint((xmax - xmin).days / 365.25 / 5).astype(int))
# take axes width into account
fig = ax.get_figure()
bbox = ax.get_window_extent().transformed(fig.dpi_scale_trans.inverted())
scale = 6.2 / bbox.width
every_year = max(1, np.rint(scale * (xmax - xmin).days / 365.25 / 5).astype(int))

if not every_month:
if every_year <= 3 : every_month = 1
Expand Down Expand Up @@ -1125,7 +1129,7 @@ def plot_gps(ax, SNWE, inps, metadata=dict(), print_msg=True):
site_names, site_lats, site_lons = gps.search_gps(SNWE, start_date, end_date)
if site_names.size == 0:
warnings.warn(f'No GNSS found within {SNWE} during {start_date} - {end_date}!')
print('Continue without GNSS plots.')
print(' continue without GNSS plots.')
return ax

# mask out stations not coincident with InSAR data
Expand Down Expand Up @@ -1424,7 +1428,7 @@ def plot_colorbar(inps, im, cax):
return inps, cbar


def plot_faultline(ax, faultline_file, SNWE, linewidth=0.5, print_msg=True):
def plot_faultline(ax, faultline_file, SNWE, linewidth=0.5, min_dist=0.1, print_msg=True):
"""Plot fault lines.

Parameters: ax - matplotlib.axes object
Expand All @@ -1442,10 +1446,15 @@ def plot_faultline(ax, faultline_file, SNWE, linewidth=0.5, print_msg=True):
faults = readfile.read_gmt_lonlat_file(
faultline_file,
SNWE=SNWE,
min_dist=0.1,
min_dist=min_dist,
print_msg=print_msg,
)

if len(faults) == 0:
warnings.warn(f'No fault lines found within {SNWE} with length >= {min_dist} km!')
print(' continue without fault lines.')
return ax, faults

# plot
print_msg = False if len(faults) < 1000 else print_msg
prog_bar = ptime.progressBar(maxValue=len(faults), print_msg=print_msg)
Expand Down
5 changes: 5 additions & 0 deletions src/mintpy/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ def plot_slice(ax, data, metadata, inps):
faultline_file=inps.faultline_file,
SNWE=SNWE,
linewidth=inps.faultline_linewidth,
min_dist=inps.faultline_min_dist,
print_msg=inps.print_msg,
)

Expand Down Expand Up @@ -731,6 +732,10 @@ def format_coord(x, y):

# 3.5 Tick labels
if inps.disp_tick:
# move x-axis tick label to the top if colorbar is at the bottom
if inps.cbar_loc == 'bottom':
ax.tick_params(labelbottom=False, labeltop=True)

# manually turn ON to enable tick labels for UTM with cartopy
# link: https://github.com/SciTools/cartopy/issues/491
ax.xaxis.set_visible(True)
Expand Down