From 74c7b631bf46822669215e2c7a7a5267295f9392 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Thu, 29 Feb 2024 08:14:00 -0500 Subject: [PATCH 01/35] remove suppress STDOUT call --- .../analysis_db/B01_SL_load_single_file.py | 289 +++++++++--------- 1 file changed, 144 insertions(+), 145 deletions(-) diff --git a/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py b/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py index 756ca3a8..91e0fd1b 100644 --- a/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py +++ b/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py @@ -91,7 +91,6 @@ def run_B01_SL_load_single_file( ID_flag: bool = True, plot_flag: bool = True, output_dir: str = typer.Option(..., callback=validate_output_dir), - verbose: bool = False, ): """ Open an ICEsat2 tbeam_stats.pyrack, apply filters and corrections, and output smoothed photon heights on a regular grid in an .nc file. @@ -109,171 +108,171 @@ def run_B01_SL_load_single_file( matplotlib.use("Agg") # prevent plot windows from opening # Select region and retrieve batch of tracks - with suppress_stdout(verbose): - track_name, batch_key, ID_flag = io.init_from_input( - [ - None, - track_name, - batch_key, - ID_flag, - ] # init_from_input expects sys.argv with 4 elements - ) # loads standard experiment - hemis = batch_key.split("_")[0] + track_name, batch_key, ID_flag = io.init_from_input( + [ + None, + track_name, + batch_key, + ID_flag, + ] # init_from_input expects sys.argv with 4 elements + ) # loads standard experiment + + hemis = batch_key.split("_")[0] + + workdir, plotsdir = update_paths_mconfig(output_dir, mconfig) + + save_path = Path(workdir, batch_key, "B01_regrid") + save_path.mkdir(parents=True, exist_ok=True) + + save_path_json = Path(workdir, batch_key, "A01b_ID") + save_path_json.mkdir(parents=True, exist_ok=True) + + ATL03_track_name = "ATL03_" + track_name + ".h5" + + # Configure SL Session + icesat2.init("slideruleearth.io") + + # plot the ground tracks in geographic location + # Generate ATL06-type segments using the ATL03-native photon classification + # Use the ocean classification for photons with a confidence parameter to 2 or higher (low confidence or better) + + # YAPC alternative + params_yapc = { + "srt": 1, + "len": 20, + "ats": 3, + "res": 10, + "dist_in_seg": False, # if False units of len and res are in meters + "track": 0, + "pass_invalid": False, + "cnf": 2, + "cnt": 20, + "sigma_r_max": 4, # maximum standard deviation of photon in extend + "maxi": 10, + "yapc": dict( + knn=0, win_h=6, win_x=11, min_ph=4, score=100 + ), # use the YAPC photon classifier; these are the recommended parameters, but the results might be more specific with a smaller win_h value, or a higher score cutoff + # "yapc": dict(knn=0, win_h=3, win_x=11, min_ph=4, score=50), # use the YAPC photon classifier; these are the recommended parameters, but the results might be more specific with a smaller win_h value, or a higher score cutoff + "atl03_geo_fields": ["dem_h"], + } - workdir, plotsdir = update_paths_mconfig(output_dir, mconfig) + maximum_height = 30 # (meters) maximum height past dem_h correction + print("STARTS") + print("Fetching ATL03 data from sliderule") + gdf = icesat2.atl06p(params_yapc, resources=[ATL03_track_name]) + print("ENDS") + gdf = sct.correct_and_remove_height(gdf, maximum_height) - save_path = Path(workdir, batch_key, "B01_regrid") - save_path.mkdir(parents=True, exist_ok=True) + cdict = dict() + for s, b in zip( + gdf["spot"].unique(), ["gt1l", "gt1r", "gt2l", "gt2r", "gt3l", "gt3r"] + ): + cdict[s] = color_schemes.rels[b] - save_path_json = Path(workdir, batch_key, "A01b_ID") - save_path_json.mkdir(parents=True, exist_ok=True) + font_for_pres() + F_atl06 = M.figure_axis_xy(6.5, 5, view_scale=0.6) + F_atl06.fig.suptitle(track_name) - ATL03_track_name = "ATL03_" + track_name + ".h5" + beam_stats.plot_ATL06_track_data(gdf, cdict) - # Configure SL Session - icesat2.init("slideruleearth.io") + # main routine for defining the x coordinate and sacing table data - # plot the ground tracks in geographic location - # Generate ATL06-type segments using the ATL03-native photon classification - # Use the ocean classification for photons with a confidence parameter to 2 or higher (low confidence or better) - - # YAPC alternative - params_yapc = { - "srt": 1, - "len": 20, - "ats": 3, - "res": 10, - "dist_in_seg": False, # if False units of len and res are in meters - "track": 0, - "pass_invalid": False, - "cnf": 2, - "cnt": 20, - "sigma_r_max": 4, # maximum standard deviation of photon in extend - "maxi": 10, - "yapc": dict( - knn=0, win_h=6, win_x=11, min_ph=4, score=100 - ), # use the YAPC photon classifier; these are the recommended parameters, but the results might be more specific with a smaller win_h value, or a higher score cutoff - # "yapc": dict(knn=0, win_h=3, win_x=11, min_ph=4, score=50), # use the YAPC photon classifier; these are the recommended parameters, but the results might be more specific with a smaller win_h value, or a higher score cutoff - "atl03_geo_fields": ["dem_h"], - } - - maximum_height = 30 # (meters) maximum height past dem_h correction - print("STARTS") - print("Fetching ATL03 data from sliderule") - gdf = icesat2.atl06p(params_yapc, resources=[ATL03_track_name]) - print("ENDS") - gdf = sct.correct_and_remove_height(gdf, maximum_height) - - cdict = dict() - for s, b in zip( - gdf["spot"].unique(), ["gt1l", "gt1r", "gt2l", "gt2r", "gt3l", "gt3r"] - ): - cdict[s] = color_schemes.rels[b] + # define reference point and then define 'x' + table_data = copy.copy(gdf) - font_for_pres() - F_atl06 = M.figure_axis_xy(6.5, 5, view_scale=0.6) - F_atl06.fig.suptitle(track_name) + # the reference point is defined as the most equatorward point of the polygon. + # It's distance from the equator is subtracted from the distance of each photon. + table_data = sct.define_x_coordinate_from_data(table_data) + table_time = table_data["time"] + table_data.drop(columns=["time"], inplace=True) - beam_stats.plot_ATL06_track_data(gdf, cdict) + # renames columns and splits beams + Ti = make_B01_dict(table_data, split_by_beam=True, to_hdf5=True) - # main routine for defining the x coordinate and sacing table data + with warnings.catch_warnings(): + warnings.simplefilter( + "ignore", category=SettingWithCopyWarning + ) # TODO: remove when warnings are handled + for kk in Ti.keys(): + Ti[kk]["dist"] = Ti[kk]["x"].copy() + Ti[kk]["heights_c_weighted_mean"] = Ti[kk]["h_mean"].copy() + Ti[kk]["heights_c_std"] = Ti[kk]["h_sigma"].copy() - # define reference point and then define 'x' - table_data = copy.copy(gdf) + segment = track_name.split("_")[1][-2:] + ID_name = sct.create_ID_name(gdf.iloc[0], segment=segment) + echoparam("ID_name", ID_name) + io.write_track_to_HDF5(Ti, ID_name + "_B01_binned", save_path) # regridding heights - # the reference point is defined as the most equatorward point of the polygon. - # It's distance from the equator is subtracted from the distance of each photon. - table_data = sct.define_x_coordinate_from_data(table_data) - table_time = table_data["time"] - table_data.drop(columns=["time"], inplace=True) + # plot the ground tracks in geographic location - # renames columns and splits beams - Ti = make_B01_dict(table_data, split_by_beam=True, to_hdf5=True) + all_beams = mconfig["beams"]["all_beams"] + high_beams = mconfig["beams"]["high_beams"] + low_beams = mconfig["beams"]["low_beams"] - with warnings.catch_warnings(): - warnings.simplefilter( - "ignore", category=SettingWithCopyWarning - ) # TODO: remove when warnings are handled - for kk in Ti.keys(): - Ti[kk]["dist"] = Ti[kk]["x"].copy() - Ti[kk]["heights_c_weighted_mean"] = Ti[kk]["h_mean"].copy() - Ti[kk]["heights_c_std"] = Ti[kk]["h_sigma"].copy() + D = beam_stats.derive_beam_statistics(Ti, all_beams, Lmeter=12.5e3, dx=10) - segment = track_name.split("_")[1][-2:] - ID_name = sct.create_ID_name(gdf.iloc[0], segment=segment) - echoparam("ID_name", ID_name) - io.write_track_to_HDF5(Ti, ID_name + "_B01_binned", save_path) # regridding heights + # save figure from above: + plot_path = Path(plotsdir, hemis, batch_key, ID_name) + plot_path.mkdir(parents=True, exist_ok=True) - # plot the ground tracks in geographic location + F_atl06.save_light(path=plot_path, name="B01b_ATL06_corrected.png") + plt.close() - all_beams = mconfig["beams"]["all_beams"] - high_beams = mconfig["beams"]["high_beams"] - low_beams = mconfig["beams"]["low_beams"] + if plot_flag: + font_for_pres() + F = M.figure_axis_xy(8, 4.3, view_scale=0.6) + beam_stats.plot_beam_statistics( + D, + high_beams, + low_beams, + color_schemes.rels, + track_name=track_name + + "| ascending =" + + str(sct.ascending_test_distance(gdf)), + ) + + F.save_light(path=plot_path, name="B01b_beam_statistics.png") + plt.close() - D = beam_stats.derive_beam_statistics(Ti, all_beams, Lmeter=12.5e3, dx=10) + # plot the ground tracks in geographic location + gdf[::100].plot(markersize=0.1, figsize=(4, 6)) + plt.title( + track_name + "\nascending =" + str(sct.ascending_test_distance(gdf)), + loc="left", + ) + M.save_anyfig(plt.gcf(), path=plot_path, name="B01_track.png") + plt.close() - # save figure from above: - plot_path = Path(plotsdir, hemis, batch_key, ID_name) - plot_path.mkdir(parents=True, exist_ok=True) + echo("write A01b .json") + DD = {"case_ID": ID_name, "tracks": {}} - F_atl06.save_light(path=plot_path, name="B01b_ATL06_corrected.png") - plt.close() + DD["tracks"]["ATL03"] = "ATL10-" + track_name + + start_pos = abs(table_data.lats).argmin() + end_pos = abs(table_data.lats).argmax() + + # add other pars: + DD["pars"] = { + "poleward": sct.ascending_test(gdf), + "region": "0", + "start": { + "longitude": table_data.lons[start_pos], + "latitude": table_data.lats[start_pos], + "seg_dist_x": float(table_data.x[start_pos]), + "delta_time": datetime.datetime.timestamp(table_time[start_pos]), + }, + "end": { + "longitude": table_data.lons[end_pos], + "latitude": table_data.lats[end_pos], + "seg_dist_x": float(table_data.x[end_pos]), + "delta_time": datetime.datetime.timestamp(table_time[end_pos]), + }, + } + + MT.json_save2(name="A01b_ID_" + ID_name, path=save_path_json, data=DD) - if plot_flag: - font_for_pres() - F = M.figure_axis_xy(8, 4.3, view_scale=0.6) - beam_stats.plot_beam_statistics( - D, - high_beams, - low_beams, - color_schemes.rels, - track_name=track_name - + "| ascending =" - + str(sct.ascending_test_distance(gdf)), - ) - - F.save_light(path=plot_path, name="B01b_beam_statistics.png") - plt.close() - - # plot the ground tracks in geographic location - gdf[::100].plot(markersize=0.1, figsize=(4, 6)) - plt.title( - track_name + "\nascending =" + str(sct.ascending_test_distance(gdf)), - loc="left", - ) - M.save_anyfig(plt.gcf(), path=plot_path, name="B01_track.png") - plt.close() - - echo("write A01b .json") - DD = {"case_ID": ID_name, "tracks": {}} - - DD["tracks"]["ATL03"] = "ATL10-" + track_name - - start_pos = abs(table_data.lats).argmin() - end_pos = abs(table_data.lats).argmax() - - # add other pars: - DD["pars"] = { - "poleward": sct.ascending_test(gdf), - "region": "0", - "start": { - "longitude": table_data.lons[start_pos], - "latitude": table_data.lats[start_pos], - "seg_dist_x": float(table_data.x[start_pos]), - "delta_time": datetime.datetime.timestamp(table_time[start_pos]), - }, - "end": { - "longitude": table_data.lons[end_pos], - "latitude": table_data.lats[end_pos], - "seg_dist_x": float(table_data.x[end_pos]), - "delta_time": datetime.datetime.timestamp(table_time[end_pos]), - }, - } - - MT.json_save2(name="A01b_ID_" + ID_name, path=save_path_json, data=DD) - - echo("done") + echo("done") load_file_app = makeapp(run_B01_SL_load_single_file, name="load-file") From c27a0adb2854d46a069433b2997217820e7a3a28 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Thu, 29 Feb 2024 08:15:59 -0500 Subject: [PATCH 02/35] replace print and echo calls with logger info calls --- .../analysis_db/B01_SL_load_single_file.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py b/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py index 91e0fd1b..b18553e2 100644 --- a/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py +++ b/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py @@ -7,6 +7,7 @@ import copy from pathlib import Path import warnings +import logging import xarray as xr from sliderule import icesat2 @@ -40,6 +41,8 @@ makeapp, ) +_logger = logging.getLogger(__name__) + def make_B01_dict(table_data, split_by_beam=True, to_hdf5=False): """ @@ -158,10 +161,10 @@ def run_B01_SL_load_single_file( } maximum_height = 30 # (meters) maximum height past dem_h correction - print("STARTS") - print("Fetching ATL03 data from sliderule") + _logger.info("STARTS") + _logger.info("Fetching ATL03 data from sliderule") gdf = icesat2.atl06p(params_yapc, resources=[ATL03_track_name]) - print("ENDS") + _logger.info("ENDS") gdf = sct.correct_and_remove_height(gdf, maximum_height) cdict = dict() @@ -244,7 +247,7 @@ def run_B01_SL_load_single_file( M.save_anyfig(plt.gcf(), path=plot_path, name="B01_track.png") plt.close() - echo("write A01b .json") + _logger.info("write A01b .json") DD = {"case_ID": ID_name, "tracks": {}} DD["tracks"]["ATL03"] = "ATL10-" + track_name @@ -272,7 +275,7 @@ def run_B01_SL_load_single_file( MT.json_save2(name="A01b_ID_" + ID_name, path=save_path_json, data=DD) - echo("done") + _logger.info("done") load_file_app = makeapp(run_B01_SL_load_single_file, name="load-file") From 32f28fd85b2d369c8c0043079b2d3b7d133e2431 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Thu, 29 Feb 2024 09:18:28 -0500 Subject: [PATCH 03/35] feat: add basi . logging support to b01 --- .../analysis_db/B01_SL_load_single_file.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py b/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py index b18553e2..5f9ba388 100644 --- a/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py +++ b/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py @@ -94,10 +94,27 @@ def run_B01_SL_load_single_file( ID_flag: bool = True, plot_flag: bool = True, output_dir: str = typer.Option(..., callback=validate_output_dir), + verbose: bool = False, + debug: bool = False, ): """ Open an ICEsat2 tbeam_stats.pyrack, apply filters and corrections, and output smoothed photon heights on a regular grid in an .nc file. """ + + logging.basicConfig() + + if debug: + _logger.setLevel(logging.DEBUG) + elif verbose: + _logger.setLevel(logging.INFO) + + _logger.critical("Here's a critical message") + _logger.warning("Here's warning") + _logger.debug("Here's a debug message") + _logger.info("Here's an info message") + import sys + sys.exit(1) + # report input parameters kwargs = { "track_name": track_name, From 6c732ae4605f814ad6a1345c2920aef5fac9ba2d Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Thu, 29 Feb 2024 10:38:25 -0500 Subject: [PATCH 04/35] feat: add basic logging to m_general_ph3 --- src/icesat2_tracks/local_modules/m_general_ph3.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/icesat2_tracks/local_modules/m_general_ph3.py b/src/icesat2_tracks/local_modules/m_general_ph3.py index 6e24a8d9..6cb76fee 100644 --- a/src/icesat2_tracks/local_modules/m_general_ph3.py +++ b/src/icesat2_tracks/local_modules/m_general_ph3.py @@ -25,7 +25,9 @@ from . import m_tools_ph3 as MT import numpy as np import matplotlib.pyplot as plt +import logging +_logger = logging.getLogger(__name__) class color: def __init__(self): @@ -128,10 +130,9 @@ def save(self,name=None,path=None, verbose=True): full_name= (os.path.join(savepath,name)) + extension #print(full_name) self.fig.savefig(full_name, bbox_inches='tight', format='pdf', dpi=180) - if verbose: - print('save at: '+name) + _logger.info('save at: '+name) - def save_pup(self,name=None,path=None, verbose=True): + def save_pup(self,name=None,path=None): import datetime import re name=re.sub("\.", '_', name) @@ -147,10 +148,9 @@ def save_pup(self,name=None,path=None, verbose=True): full_name= (os.path.join(savepath,name)) + extension #print(full_name) self.fig.savefig(full_name, bbox_inches='tight', format='pdf', dpi=300) - if verbose: - print('save at: ',full_name) + _logger.info('save at: ',full_name) - def save_light(self,name=None,path=None, verbose=True): + def save_light(self,name=None,path=None): import datetime savepath=path if path is not None else os.path.join(os.path.dirname(os.path.realpath('__file__')),'plot/') @@ -164,8 +164,7 @@ def save_light(self,name=None,path=None, verbose=True): full_name= (os.path.join(savepath,name)) + extension #print(full_name) self.fig.savefig(full_name, bbox_inches='tight', format='png', dpi=180) - if verbose: - print('save with: ',name) + _logger.info('save with: ',name) class subplot_routines(figure_axis_xy): def __init__(self, ax): From 36a24c83d529488c0b617beabab255f485ceb198 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Thu, 29 Feb 2024 10:38:54 -0500 Subject: [PATCH 05/35] feat: remove unneeded logging commands / arguments --- .../analysis_db/B01_SL_load_single_file.py | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py b/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py index 5f9ba388..e8867712 100644 --- a/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py +++ b/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py @@ -94,27 +94,11 @@ def run_B01_SL_load_single_file( ID_flag: bool = True, plot_flag: bool = True, output_dir: str = typer.Option(..., callback=validate_output_dir), - verbose: bool = False, - debug: bool = False, ): """ Open an ICEsat2 tbeam_stats.pyrack, apply filters and corrections, and output smoothed photon heights on a regular grid in an .nc file. """ - logging.basicConfig() - - if debug: - _logger.setLevel(logging.DEBUG) - elif verbose: - _logger.setLevel(logging.INFO) - - _logger.critical("Here's a critical message") - _logger.warning("Here's warning") - _logger.debug("Here's a debug message") - _logger.info("Here's an info message") - import sys - sys.exit(1) - # report input parameters kwargs = { "track_name": track_name, From 29a039997bc6bef4407d12c1a17e6ce221a9364e Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Thu, 29 Feb 2024 10:39:13 -0500 Subject: [PATCH 06/35] feat: aadd basic logging to b01 when run as __main__ --- src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py b/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py index e8867712..b0e3bdaf 100644 --- a/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py +++ b/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py @@ -282,4 +282,5 @@ def run_B01_SL_load_single_file( load_file_app = makeapp(run_B01_SL_load_single_file, name="load-file") if __name__ == "__main__": + logging.basicConfig(level=logging.NOTSET) load_file_app() From ecb45b8d08d2065875d8e5157f4d88552b4eb5a1 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Thu, 29 Feb 2024 10:39:27 -0500 Subject: [PATCH 07/35] feat: add logging and foncifto app --- src/icesat2_tracks/app.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/icesat2_tracks/app.py b/src/icesat2_tracks/app.py index 654a09b4..5c44c53e 100644 --- a/src/icesat2_tracks/app.py +++ b/src/icesat2_tracks/app.py @@ -2,6 +2,7 @@ """ Main CLI for icesat2waves. """ +import logging from typer import Typer, Option from icesat2_tracks.analysis_db.B01_SL_load_single_file import ( run_B01_SL_load_single_file as _loadfile, @@ -33,13 +34,23 @@ validate_output_dir, validate_track_name_steps_gt_1, ) +_logger = logging.getLogger(__name__) +logging.basicConfig() app = Typer(add_completion=False) validate_track_name_gt_1_opt = Option(..., callback=validate_track_name_steps_gt_1) validate_batch_key_opt = Option(..., callback=validate_batch_key) validate_output_dir_opt = Option(..., callback=validate_output_dir) +verbose_opt = Option(False, ) +def configure_logging(verbose: bool = False, debug: bool = False) -> None: + if debug: + _logger.setLevel(logging.DEBUG) + elif verbose: + _logger.setLevel(logging.INFO) + return + def run_job( analysis_func, track_name: str, @@ -47,7 +58,9 @@ def run_job( ID_flag: bool = True, output_dir: str = validate_output_dir_opt, verbose: bool = False, + debug: bool = False, ): + configure_logging(verbose=verbose, debug=debug) analysis_func(track_name, batch_key, ID_flag, output_dir, verbose) @@ -58,7 +71,9 @@ def load_file( ID_flag: bool = True, output_dir: str = validate_output_dir_opt, verbose: bool = False, + debug: bool = False, ): + configure_logging(verbose=verbose, debug=debug) run_job(_loadfile, track_name, batch_key, ID_flag, output_dir, verbose) @@ -69,7 +84,9 @@ def make_spectra( ID_flag: bool = True, output_dir: str = validate_output_dir_opt, verbose: bool = False, + debug: bool = False, ): + configure_logging(verbose=verbose, debug=debug) run_job(_makespectra, track_name, batch_key, ID_flag, output_dir, verbose) @@ -80,7 +97,9 @@ def plot_spectra( ID_flag: bool = True, output_dir: str = validate_output_dir_opt, verbose: bool = False, + debug: bool = False, ): + configure_logging(verbose=verbose, debug=debug) run_job(_plotspectra, track_name, batch_key, ID_flag, output_dir, verbose) @@ -90,7 +109,10 @@ def separate_var( batch_key: str = validate_batch_key_opt, ID_flag: bool = True, output_dir: str = validate_output_dir_opt, + verbose: bool = False, + debug: bool = False, ): + configure_logging(verbose=verbose, debug=debug) run_job(_plotspectra, track_name, batch_key, ID_flag, output_dir) @app.command(help=_threddsprior.__doc__) @@ -100,7 +122,9 @@ def make_iowaga_threads_prior( # TODO: revise naming @mochell ID_flag: bool = True, output_dir: str = validate_output_dir_opt, verbose: bool = False, + debug: bool = False, ): + configure_logging(verbose=verbose, debug=debug) run_job(_threddsprior, track_name, batch_key, ID_flag, output_dir, verbose) @@ -111,7 +135,9 @@ def make_b04_angle( # TODO: revise naming @mochell ID_flag: bool = True, output_dir: str = validate_output_dir_opt, verbose: bool = False, + debug: bool = False, ): + configure_logging(verbose=verbose, debug=debug) run_job(_run_B04_angle, track_name, batch_key, ID_flag, output_dir, verbose) @app.command(help=_define_angle.__doc__) @@ -121,7 +147,9 @@ def define_angle( ID_flag: bool = True, output_dir: str = validate_output_dir_opt, verbose: bool = False, + debug: bool = False, ): + configure_logging(verbose=verbose, debug=debug) run_job(_define_angle, track_name, batch_key, ID_flag, output_dir, verbose) @@ -132,7 +160,9 @@ def correct_separate( # TODO: rename with a verb or something ID_flag: bool = True, output_dir: str = validate_output_dir_opt, verbose: bool = False, + debug: bool = False, ): + configure_logging(verbose=verbose, debug=debug) run_job(_run_correct_separate_var, track_name, batch_key, ID_flag, output_dir) if __name__ == "__main__": From 9ad7d838c291f54bc519d88a121b45ed16ac2b73 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Thu, 29 Feb 2024 10:41:34 -0500 Subject: [PATCH 08/35] feat: add logging and debugs to colormanager --- .../local_modules/m_colormanager_ph3.py | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/icesat2_tracks/local_modules/m_colormanager_ph3.py b/src/icesat2_tracks/local_modules/m_colormanager_ph3.py index 17163538..c9e48000 100644 --- a/src/icesat2_tracks/local_modules/m_colormanager_ph3.py +++ b/src/icesat2_tracks/local_modules/m_colormanager_ph3.py @@ -7,6 +7,9 @@ import numpy as np import matplotlib.patches as mpatch import os +import logging + +_logger = logging.getLogger(__name__) #path='/Projects/2016_AA/others/color_def_mhell1.ase' @@ -16,12 +19,12 @@ def ase_to_json(path): A=swatch.parse(path) for i in A[0]['swatches']: - print(i['name'] + ' ' + str(i['data']['values'])) + _logger.debug(i['name'] + ' ' + str(i['data']['values'])) return A -def json_save(name, path, data, verbose=False, return_name=False): +def json_save(name, path, data, return_name=False): import json if not os.path.exists(path): os.makedirs(path) @@ -29,22 +32,20 @@ def json_save(name, path, data, verbose=False, return_name=False): full_name= (os.path.join(full_name_root+ '.json')) with open(full_name, 'w') as outfile: json.dump(data, outfile) - if verbose: - print('save at: ',full_name) + _logger.debug('save at: ',full_name) if return_name: return full_name_root else: return -def json_load(name, path, verbose=False): +def json_load(name, path): import json full_name= (os.path.join(path,name+ '.json')) with open(full_name, 'r') as ifile: data=json.load(ifile) - if verbose: - print('loaded from: ',full_name) + _logger.debug('loaded from: ',full_name) return data @@ -54,17 +55,17 @@ class color: def __init__(self, path=None, name=None): self.white=(1,1,1) if (path is not None) & (name is not None): - print('color theme: '+name) + _logger.debug('color theme: '+name) try: - theme=json_load(name, path, verbose=True) + theme=json_load(name, path) for k, v in theme.items(): setattr(self, k, v) #for k, v in theme['colors'].items(): - # print(k, v) + # _logger.debug(k, v) # setattr(self.colors, k, v) except: - print('fail load theme, fall back to default theme') - print(path+'mhell_colortheme17') + _logger.debug('fail load theme, fall back to default theme') + _logger.debug(path+'mhell_colortheme17') self.default_colors() else: @@ -176,11 +177,11 @@ def colormaps(self,n, gamma=None): def show(self): for key in self.__dict__.keys(): - print(key) + _logger.debug(key) - print(' rels dict:') + _logger.debug(' rels dict:') for key in self.rels.keys(): - print(' '+key) + _logger.debug(' '+key) #print(self.__dict__) def plot(self): From 648dd5b33ab402c7a2ee46e8cf6a66f9f628db53 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Thu, 29 Feb 2024 14:39:58 -0500 Subject: [PATCH 09/35] refactor: remove duplicated code --- src/icesat2_tracks/app.py | 103 ++++++++++++++++++++++---------------- 1 file changed, 59 insertions(+), 44 deletions(-) diff --git a/src/icesat2_tracks/app.py b/src/icesat2_tracks/app.py index 5c44c53e..778d7701 100644 --- a/src/icesat2_tracks/app.py +++ b/src/icesat2_tracks/app.py @@ -35,21 +35,11 @@ validate_track_name_steps_gt_1, ) _logger = logging.getLogger(__name__) -logging.basicConfig() app = Typer(add_completion=False) validate_track_name_gt_1_opt = Option(..., callback=validate_track_name_steps_gt_1) validate_batch_key_opt = Option(..., callback=validate_batch_key) validate_output_dir_opt = Option(..., callback=validate_output_dir) -verbose_opt = Option(False, ) - - -def configure_logging(verbose: bool = False, debug: bool = False) -> None: - if debug: - _logger.setLevel(logging.DEBUG) - elif verbose: - _logger.setLevel(logging.INFO) - return def run_job( analysis_func, @@ -57,11 +47,8 @@ def run_job( batch_key: str, ID_flag: bool = True, output_dir: str = validate_output_dir_opt, - verbose: bool = False, - debug: bool = False, ): - configure_logging(verbose=verbose, debug=debug) - analysis_func(track_name, batch_key, ID_flag, output_dir, verbose) + analysis_func(track_name=track_name, batch_key=batch_key, ID_flag=ID_flag, output_dir=output_dir) @app.command(help=_loadfile.__doc__) @@ -70,11 +57,9 @@ def load_file( batch_key: str = validate_batch_key_opt, ID_flag: bool = True, output_dir: str = validate_output_dir_opt, - verbose: bool = False, - debug: bool = False, ): - configure_logging(verbose=verbose, debug=debug) - run_job(_loadfile, track_name, batch_key, ID_flag, output_dir, verbose) + run_job(analysis_func=_loadfile, track_name=track_name, batch_key=batch_key, ID_flag=ID_flag, + output_dir=output_dir) @app.command(help=_makespectra.__doc__) @@ -83,11 +68,12 @@ def make_spectra( batch_key: str = validate_batch_key_opt, ID_flag: bool = True, output_dir: str = validate_output_dir_opt, - verbose: bool = False, - debug: bool = False, ): - configure_logging(verbose=verbose, debug=debug) - run_job(_makespectra, track_name, batch_key, ID_flag, output_dir, verbose) + run_job(analysis_func=_makespectra, + track_name=track_name, + batch_key=batch_key, + ID_flag=ID_flag, + output_dir=output_dir) @app.command(help=_plotspectra.__doc__) @@ -96,11 +82,14 @@ def plot_spectra( batch_key: str = validate_batch_key_opt, ID_flag: bool = True, output_dir: str = validate_output_dir_opt, - verbose: bool = False, - debug: bool = False, ): - configure_logging(verbose=verbose, debug=debug) - run_job(_plotspectra, track_name, batch_key, ID_flag, output_dir, verbose) + + run_job(analysis_func=_plotspectra, + track_name=track_name, + batch_key=batch_key, + ID_flag=ID_flag, + output_dir=output_dir + ) @app.command(help=_plotspectra.__doc__) @@ -109,11 +98,14 @@ def separate_var( batch_key: str = validate_batch_key_opt, ID_flag: bool = True, output_dir: str = validate_output_dir_opt, - verbose: bool = False, - debug: bool = False, + ): - configure_logging(verbose=verbose, debug=debug) - run_job(_plotspectra, track_name, batch_key, ID_flag, output_dir) + + run_job(analysis_func=_plotspectra, + track_name=track_name, + batch_key=batch_key, + ID_flag=ID_flag, + output_dir=output_dir) @app.command(help=_threddsprior.__doc__) def make_iowaga_threads_prior( # TODO: revise naming @mochell @@ -121,11 +113,13 @@ def make_iowaga_threads_prior( # TODO: revise naming @mochell batch_key: str = validate_batch_key_opt, ID_flag: bool = True, output_dir: str = validate_output_dir_opt, - verbose: bool = False, - debug: bool = False, ): - configure_logging(verbose=verbose, debug=debug) - run_job(_threddsprior, track_name, batch_key, ID_flag, output_dir, verbose) + + run_job(analysis_func=_threddsprior, + track_name=track_name, + batch_key=batch_key, + ID_flag=ID_flag, + output_dir=output_dir) @app.command(help=_run_B04_angle.__doc__) @@ -134,11 +128,13 @@ def make_b04_angle( # TODO: revise naming @mochell batch_key: str = validate_batch_key_opt, ID_flag: bool = True, output_dir: str = validate_output_dir_opt, - verbose: bool = False, - debug: bool = False, ): - configure_logging(verbose=verbose, debug=debug) - run_job(_run_B04_angle, track_name, batch_key, ID_flag, output_dir, verbose) + + run_job(analysis_func=_run_B04_angle, + track_name=track_name, + batch_key=batch_key, + ID_flag=ID_flag, + output_dir=output_dir) @app.command(help=_define_angle.__doc__) def define_angle( @@ -146,11 +142,15 @@ def define_angle( batch_key: str = validate_batch_key_opt, ID_flag: bool = True, output_dir: str = validate_output_dir_opt, - verbose: bool = False, - debug: bool = False, + ): - configure_logging(verbose=verbose, debug=debug) - run_job(_define_angle, track_name, batch_key, ID_flag, output_dir, verbose) + + run_job(analysis_func= _define_angle, + track_name=track_name, + batch_key=batch_key, + ID_flag=ID_flag, + output_dir=output_dir + ) @app.command(help=_run_correct_separate_var.__doc__) @@ -162,8 +162,23 @@ def correct_separate( # TODO: rename with a verb or something verbose: bool = False, debug: bool = False, ): - configure_logging(verbose=verbose, debug=debug) - run_job(_run_correct_separate_var, track_name, batch_key, ID_flag, output_dir) + + run_job(analysis_func=_run_correct_separate_var, + track_name=track_name, + batch_key=batch_key, + ID_flag=ID_flag, + output_dir=output_dir) + + +@app.callback() +def main(verbose: bool = False, debug: bool = False): + """ + Manage users in the awesome CLI app. + """ + if debug: + logging.basicConfig(level=logging.DEBUG) + elif verbose: + logging.basicConfig(level=logging.INFO) if __name__ == "__main__": app() From fbb7fe8d2baa597f9decf29be31ec8ac2a447638 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Thu, 29 Feb 2024 14:41:01 -0500 Subject: [PATCH 10/35] fix: string in debugger --- src/icesat2_tracks/local_modules/m_colormanager_ph3.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/icesat2_tracks/local_modules/m_colormanager_ph3.py b/src/icesat2_tracks/local_modules/m_colormanager_ph3.py index c9e48000..6b7e4a5a 100644 --- a/src/icesat2_tracks/local_modules/m_colormanager_ph3.py +++ b/src/icesat2_tracks/local_modules/m_colormanager_ph3.py @@ -32,7 +32,7 @@ def json_save(name, path, data, return_name=False): full_name= (os.path.join(full_name_root+ '.json')) with open(full_name, 'w') as outfile: json.dump(data, outfile) - _logger.debug('save at: ',full_name) + _logger.debug(f'save at: {full_name}') if return_name: return full_name_root else: @@ -45,7 +45,7 @@ def json_load(name, path): with open(full_name, 'r') as ifile: data=json.load(ifile) - _logger.debug('loaded from: ',full_name) + _logger.debug('loaded from: {full_name}') return data From c9dcd88f300ab1b691bbeaf12d2d82efaa019e0a Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Thu, 29 Feb 2024 16:46:13 -0500 Subject: [PATCH 11/35] revert changes to run_job calls --- src/icesat2_tracks/app.py | 54 +++++---------------------------------- 1 file changed, 7 insertions(+), 47 deletions(-) diff --git a/src/icesat2_tracks/app.py b/src/icesat2_tracks/app.py index 778d7701..c02f08e1 100644 --- a/src/icesat2_tracks/app.py +++ b/src/icesat2_tracks/app.py @@ -58,8 +58,7 @@ def load_file( ID_flag: bool = True, output_dir: str = validate_output_dir_opt, ): - run_job(analysis_func=_loadfile, track_name=track_name, batch_key=batch_key, ID_flag=ID_flag, - output_dir=output_dir) + run_job(_loadfile, track_name, batch_key, ID_flag, output_dir) @app.command(help=_makespectra.__doc__) @@ -69,11 +68,7 @@ def make_spectra( ID_flag: bool = True, output_dir: str = validate_output_dir_opt, ): - run_job(analysis_func=_makespectra, - track_name=track_name, - batch_key=batch_key, - ID_flag=ID_flag, - output_dir=output_dir) + run_job(_makespectra, track_name, batch_key, ID_flag, output_dir) @app.command(help=_plotspectra.__doc__) @@ -83,13 +78,7 @@ def plot_spectra( ID_flag: bool = True, output_dir: str = validate_output_dir_opt, ): - - run_job(analysis_func=_plotspectra, - track_name=track_name, - batch_key=batch_key, - ID_flag=ID_flag, - output_dir=output_dir - ) + run_job(_plotspectra, track_name, batch_key, ID_flag, output_dir) @app.command(help=_plotspectra.__doc__) @@ -98,14 +87,8 @@ def separate_var( batch_key: str = validate_batch_key_opt, ID_flag: bool = True, output_dir: str = validate_output_dir_opt, - ): - - run_job(analysis_func=_plotspectra, - track_name=track_name, - batch_key=batch_key, - ID_flag=ID_flag, - output_dir=output_dir) + run_job(_plotspectra, track_name, batch_key, ID_flag, output_dir) @app.command(help=_threddsprior.__doc__) def make_iowaga_threads_prior( # TODO: revise naming @mochell @@ -114,12 +97,7 @@ def make_iowaga_threads_prior( # TODO: revise naming @mochell ID_flag: bool = True, output_dir: str = validate_output_dir_opt, ): - - run_job(analysis_func=_threddsprior, - track_name=track_name, - batch_key=batch_key, - ID_flag=ID_flag, - output_dir=output_dir) + run_job(_threddsprior, track_name, batch_key, ID_flag, output_dir) @app.command(help=_run_B04_angle.__doc__) @@ -130,11 +108,7 @@ def make_b04_angle( # TODO: revise naming @mochell output_dir: str = validate_output_dir_opt, ): - run_job(analysis_func=_run_B04_angle, - track_name=track_name, - batch_key=batch_key, - ID_flag=ID_flag, - output_dir=output_dir) + run_job(_run_B04_angle, track_name, batch_key, ID_flag, output_dir) @app.command(help=_define_angle.__doc__) def define_angle( @@ -142,15 +116,9 @@ def define_angle( batch_key: str = validate_batch_key_opt, ID_flag: bool = True, output_dir: str = validate_output_dir_opt, - ): - run_job(analysis_func= _define_angle, - track_name=track_name, - batch_key=batch_key, - ID_flag=ID_flag, - output_dir=output_dir - ) + run_job(_define_angle, track_name, batch_key, ID_flag, output_dir) @app.command(help=_run_correct_separate_var.__doc__) @@ -159,16 +127,8 @@ def correct_separate( # TODO: rename with a verb or something batch_key: str = validate_batch_key_opt, ID_flag: bool = True, output_dir: str = validate_output_dir_opt, - verbose: bool = False, - debug: bool = False, ): - run_job(analysis_func=_run_correct_separate_var, - track_name=track_name, - batch_key=batch_key, - ID_flag=ID_flag, - output_dir=output_dir) - @app.callback() def main(verbose: bool = False, debug: bool = False): From 88477625d6c0a5277e9c0fe6dec26f0959ce45c9 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Thu, 29 Feb 2024 16:46:41 -0500 Subject: [PATCH 12/35] refactor: move main app callback to top --- src/icesat2_tracks/app.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/icesat2_tracks/app.py b/src/icesat2_tracks/app.py index c02f08e1..5e11de97 100644 --- a/src/icesat2_tracks/app.py +++ b/src/icesat2_tracks/app.py @@ -37,6 +37,16 @@ _logger = logging.getLogger(__name__) app = Typer(add_completion=False) + +@app.callback() +def main(verbose: bool = False, debug: bool = False): + """ Analyze data from the ICESAT2 satellite. """ + if debug: + logging.basicConfig(level=logging.DEBUG) + elif verbose: + logging.basicConfig(level=logging.INFO) + + validate_track_name_gt_1_opt = Option(..., callback=validate_track_name_steps_gt_1) validate_batch_key_opt = Option(..., callback=validate_batch_key) validate_output_dir_opt = Option(..., callback=validate_output_dir) @@ -128,17 +138,7 @@ def correct_separate( # TODO: rename with a verb or something ID_flag: bool = True, output_dir: str = validate_output_dir_opt, ): - - -@app.callback() -def main(verbose: bool = False, debug: bool = False): - """ - Manage users in the awesome CLI app. - """ - if debug: - logging.basicConfig(level=logging.DEBUG) - elif verbose: - logging.basicConfig(level=logging.INFO) + run_job(_run_correct_separate_var, track_name, batch_key, ID_flag, output_dir) if __name__ == "__main__": app() From 44a87eb095dfdc48b155f7e098b88b35d970f109 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Thu, 29 Feb 2024 17:00:11 -0500 Subject: [PATCH 13/35] Update src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py --- src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py b/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py index b0e3bdaf..cf085a1d 100644 --- a/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py +++ b/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py @@ -98,7 +98,6 @@ def run_B01_SL_load_single_file( """ Open an ICEsat2 tbeam_stats.pyrack, apply filters and corrections, and output smoothed photon heights on a regular grid in an .nc file. """ - # report input parameters kwargs = { "track_name": track_name, From 5523bd0fecb7195106c585e2405fea493d83bfd2 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Fri, 1 Mar 2024 09:57:49 -0500 Subject: [PATCH 14/35] fix: change default logging level for step 1 when run from the script directly to "warning" --- src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py b/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py index cf085a1d..21b9213b 100644 --- a/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py +++ b/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py @@ -281,5 +281,5 @@ def run_B01_SL_load_single_file( load_file_app = makeapp(run_B01_SL_load_single_file, name="load-file") if __name__ == "__main__": - logging.basicConfig(level=logging.NOTSET) + logging.basicConfig(level=logging.WARNING) load_file_app() From 58be37b45fc0dd676d9416e3598d036ec37afc32 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Mon, 4 Mar 2024 10:01:51 -0500 Subject: [PATCH 15/35] change to using an enum for log levels. --- src/icesat2_tracks/app.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/icesat2_tracks/app.py b/src/icesat2_tracks/app.py index 5e11de97..1ffea759 100644 --- a/src/icesat2_tracks/app.py +++ b/src/icesat2_tracks/app.py @@ -3,6 +3,8 @@ Main CLI for icesat2waves. """ import logging +from enum import Enum + from typer import Typer, Option from icesat2_tracks.analysis_db.B01_SL_load_single_file import ( run_B01_SL_load_single_file as _loadfile, @@ -34,17 +36,29 @@ validate_output_dir, validate_track_name_steps_gt_1, ) + _logger = logging.getLogger(__name__) app = Typer(add_completion=False) + +class _LogLevel(str, Enum): + QUIET = "quiet" # logging.CRITICAL + WARNING = "warning" # logging.WARNING + VERBOSE = "verbose" # logging.INFO + DEBUG = "debug" # logging.DEBUG + + @app.callback() -def main(verbose: bool = False, debug: bool = False): - """ Analyze data from the ICESAT2 satellite. """ - if debug: - logging.basicConfig(level=logging.DEBUG) - elif verbose: - logging.basicConfig(level=logging.INFO) +def main(log: _LogLevel = "warning"): + """Analyze data from the ICESAT2 satellite.""" + level = { + _LogLevel.QUIET: logging.CRITICAL, + _LogLevel.WARNING: logging.WARNING, + _LogLevel.VERBOSE: logging.INFO, + _LogLevel.DEBUG: logging.DEBUG, + }[log] + logging.basicConfig(level=level) validate_track_name_gt_1_opt = Option(..., callback=validate_track_name_steps_gt_1) From 5fa9c6630870ac710ee69bb45a7b8de82e73e4fa Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Mon, 4 Mar 2024 10:51:38 -0500 Subject: [PATCH 16/35] doc: add more documentation to the log level --- src/icesat2_tracks/app.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/icesat2_tracks/app.py b/src/icesat2_tracks/app.py index 1ffea759..ec70d3de 100644 --- a/src/icesat2_tracks/app.py +++ b/src/icesat2_tracks/app.py @@ -50,7 +50,12 @@ class _LogLevel(str, Enum): @app.callback() -def main(log: _LogLevel = "warning"): +def main( + log: Annotated[ + _LogLevel, + Option(help="Set the log level"), + ] = "warning" +): """Analyze data from the ICESAT2 satellite.""" level = { _LogLevel.QUIET: logging.CRITICAL, From 54cc478342bc27fb2d37198530a66407394b32ef Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Mon, 4 Mar 2024 10:52:12 -0500 Subject: [PATCH 17/35] fix: add invoke_without_command=True --- src/icesat2_tracks/app.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/icesat2_tracks/app.py b/src/icesat2_tracks/app.py index ec70d3de..27da4032 100644 --- a/src/icesat2_tracks/app.py +++ b/src/icesat2_tracks/app.py @@ -5,7 +5,9 @@ import logging from enum import Enum -from typer import Typer, Option +from typer import Typer, Option, Argument +from typing_extensions import Annotated + from icesat2_tracks.analysis_db.B01_SL_load_single_file import ( run_B01_SL_load_single_file as _loadfile, ) @@ -27,7 +29,9 @@ from icesat2_tracks.analysis_db.B05_define_angle import define_angle as _define_angle -from icesat2_tracks.analysis_db.B06_correct_separate_var import run_B06_correct_separate_var as _run_correct_separate_var +from icesat2_tracks.analysis_db.B06_correct_separate_var import ( + run_B06_correct_separate_var as _run_correct_separate_var, +) from icesat2_tracks.clitools import ( @@ -49,7 +53,7 @@ class _LogLevel(str, Enum): DEBUG = "debug" # logging.DEBUG -@app.callback() +@app.callback(invoke_without_command=True) def main( log: Annotated[ _LogLevel, @@ -70,6 +74,7 @@ def main( validate_batch_key_opt = Option(..., callback=validate_batch_key) validate_output_dir_opt = Option(..., callback=validate_output_dir) + def run_job( analysis_func, track_name: str, @@ -77,7 +82,12 @@ def run_job( ID_flag: bool = True, output_dir: str = validate_output_dir_opt, ): - analysis_func(track_name=track_name, batch_key=batch_key, ID_flag=ID_flag, output_dir=output_dir) + analysis_func( + track_name=track_name, + batch_key=batch_key, + ID_flag=ID_flag, + output_dir=output_dir, + ) @app.command(help=_loadfile.__doc__) @@ -119,6 +129,7 @@ def separate_var( ): run_job(_plotspectra, track_name, batch_key, ID_flag, output_dir) + @app.command(help=_threddsprior.__doc__) def make_iowaga_threads_prior( # TODO: revise naming @mochell track_name: str = validate_track_name_gt_1_opt, @@ -136,9 +147,9 @@ def make_b04_angle( # TODO: revise naming @mochell ID_flag: bool = True, output_dir: str = validate_output_dir_opt, ): - run_job(_run_B04_angle, track_name, batch_key, ID_flag, output_dir) + @app.command(help=_define_angle.__doc__) def define_angle( track_name: str = validate_track_name_gt_1_opt, @@ -146,9 +157,8 @@ def define_angle( ID_flag: bool = True, output_dir: str = validate_output_dir_opt, ): - run_job(_define_angle, track_name, batch_key, ID_flag, output_dir) - + @app.command(help=_run_correct_separate_var.__doc__) def correct_separate( # TODO: rename with a verb or something @@ -159,5 +169,6 @@ def correct_separate( # TODO: rename with a verb or something ): run_job(_run_correct_separate_var, track_name, batch_key, ID_flag, output_dir) + if __name__ == "__main__": app() From 0522dd17f9124ea2385ef431f7f1da17e5ad2526 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Mon, 4 Mar 2024 11:25:30 -0500 Subject: [PATCH 18/35] fix: remove invoke without command --- src/icesat2_tracks/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/icesat2_tracks/app.py b/src/icesat2_tracks/app.py index 27da4032..34b78352 100644 --- a/src/icesat2_tracks/app.py +++ b/src/icesat2_tracks/app.py @@ -53,7 +53,7 @@ class _LogLevel(str, Enum): DEBUG = "debug" # logging.DEBUG -@app.callback(invoke_without_command=True) +@app.callback() def main( log: Annotated[ _LogLevel, From 0fb9eb6ec75a280adcfa30c061ae78f34f1fb204 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Mon, 4 Mar 2024 13:50:21 -0500 Subject: [PATCH 19/35] chore: remove unused import --- src/icesat2_tracks/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/icesat2_tracks/app.py b/src/icesat2_tracks/app.py index b1791430..ea5096d3 100644 --- a/src/icesat2_tracks/app.py +++ b/src/icesat2_tracks/app.py @@ -5,7 +5,7 @@ import logging from enum import Enum -from typer import Typer, Option, Argument +from typer import Typer, Option from typing_extensions import Annotated from icesat2_tracks.analysis_db.B01_SL_load_single_file import ( From 16c3fc931a15c34b9d26486d77ae3c8ad703df54 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Mon, 4 Mar 2024 14:01:00 -0500 Subject: [PATCH 20/35] chore: refactor log level mapping --- src/icesat2_tracks/app.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/icesat2_tracks/app.py b/src/icesat2_tracks/app.py index ea5096d3..7d4bf83b 100644 --- a/src/icesat2_tracks/app.py +++ b/src/icesat2_tracks/app.py @@ -47,10 +47,18 @@ class _LogLevel(str, Enum): - QUIET = "quiet" # logging.CRITICAL - WARNING = "warning" # logging.WARNING - VERBOSE = "verbose" # logging.INFO - DEBUG = "debug" # logging.DEBUG + QUIET = "quiet" + WARNING = "warning" + VERBOSE = "verbose" + DEBUG = "debug" + + +_LOG_LEVEL_MAPPING = { + _LogLevel.QUIET: logging.CRITICAL, + _LogLevel.WARNING: logging.WARNING, + _LogLevel.VERBOSE: logging.INFO, + _LogLevel.DEBUG: logging.DEBUG, +} @app.callback() @@ -61,12 +69,7 @@ def main( ] = "warning" ): """Analyze data from the ICESAT2 satellite.""" - level = { - _LogLevel.QUIET: logging.CRITICAL, - _LogLevel.WARNING: logging.WARNING, - _LogLevel.VERBOSE: logging.INFO, - _LogLevel.DEBUG: logging.DEBUG, - }[log] + level = _LOG_LEVEL_MAPPING[log] logging.basicConfig(level=level) From 194dce18aa7e16b0ffea301e537da7a8031ad5ac Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Mon, 4 Mar 2024 14:33:37 -0500 Subject: [PATCH 21/35] fix: remove unused parameter from correct_separate --- src/icesat2_tracks/app.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/icesat2_tracks/app.py b/src/icesat2_tracks/app.py index 7d4bf83b..88a190e9 100644 --- a/src/icesat2_tracks/app.py +++ b/src/icesat2_tracks/app.py @@ -202,7 +202,6 @@ def correct_separate( # TODO: rename with a verb or something batch_key=batch_key, ID_flag=ID_flag, output_dir=output_dir, - verbose=verbose, ) From 73ebb24c81bfd42e6caac18ea85739867d41213d Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Mon, 4 Mar 2024 14:59:58 -0500 Subject: [PATCH 22/35] test: remove verbose flag from tests --- tests/test_steps.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/test_steps.py b/tests/test_steps.py index d477d202..5dbff8e4 100644 --- a/tests/test_steps.py +++ b/tests/test_steps.py @@ -2,19 +2,19 @@ """ This module contains a test suite for the following commands: - name: Step 1 B01_SL_load_single_file - cmd: load-file --track-name 20190502052058_05180312_005_01 --batch-key SH_testSLsinglefile2 --output-dir ./work --verbose + cmd: load-file --track-name 20190502052058_05180312_005_01 --batch-key SH_testSLsinglefile2 --output-dir ./work - name: second step make_spectra - cmd: make-spectra --track-name SH_20190502_05180312 --batch-key SH_testSLsinglefile2 --output-dir ./work --verbose + cmd: make-spectra --track-name SH_20190502_05180312 --batch-key SH_testSLsinglefile2 --output-dir ./work - name: third step plot_spectra - cmd: plot-spectra --track-name SH_20190502_05180312 --batch-key SH_testSLsinglefile2 --output-dir ./work --verbose + cmd: plot-spectra --track-name SH_20190502_05180312 --batch-key SH_testSLsinglefile2 --output-dir ./work - name: fourth step IOWAGA threads - cmd: make-iowaga-threads-prior --track-name SH_20190502_05180312 --batch-key SH_testSLsinglefile2 --output-dir ./work --verbose + cmd: make-iowaga-threads-prior --track-name SH_20190502_05180312 --batch-key SH_testSLsinglefile2 --output-dir ./work - name: fifth step B04_angle - cmd: make-b04-angle --track-name SH_20190502_05180312 --batch-key SH_testSLsinglefile2 --output-dir ./work --verbose + cmd: make-b04-angle --track-name SH_20190502_05180312 --batch-key SH_testSLsinglefile2 --output-dir ./work - name: sixth step B04_define_angle - cmd: define-angle --track-name SH_20190502_05180312 --batch-key SH_testSLsinglefile2 --output-dir ./work --verbose + cmd: define-angle --track-name SH_20190502_05180312 --batch-key SH_testSLsinglefile2 --output-dir ./work - name: seventh step B06_correct_separate - cmd: correct-separate --track-name SH_20190502_05180312 --batch-key SH_testSLsinglefile2 --output-dir ./work --verbose + cmd: correct-separate --track-name SH_20190502_05180312 --batch-key SH_testSLsinglefile2 --output-dir ./work To this end, it sets up a temporary directory within the `tests/` directory with subdirectories containing the required input data for each step. The tests are run in parallel using the `xdist` plugin, with each worker having its own copy of the input data. This allows the tests to modify the input data without affecting other workers. The `setup_module` function (fixture) is responsible for creating the temporary directory and setting up the input data for each step. It also prepares the target directories for each step by extracting the necessary files from tarballs in the `tests/testdata` directory and organizing them in the appropriate directory structure. @@ -99,7 +99,6 @@ def create_script(script_name, track_name="SH_20190502_05180312"): track_name, "--batch-key", "SH_testSLsinglefile2", - "--verbose", "--output-dir", ] base_path = "src/icesat2_tracks/analysis_db/" From 6e84db95f8f8d44262b7ac6fea82120e6d3a815b Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Mon, 4 Mar 2024 15:42:34 -0500 Subject: [PATCH 23/35] Update src/icesat2_tracks/app.py Co-authored-by: Carlos Paniagua --- src/icesat2_tracks/app.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/icesat2_tracks/app.py b/src/icesat2_tracks/app.py index 88a190e9..00ef49f7 100644 --- a/src/icesat2_tracks/app.py +++ b/src/icesat2_tracks/app.py @@ -52,15 +52,16 @@ class _LogLevel(str, Enum): VERBOSE = "verbose" DEBUG = "debug" - -_LOG_LEVEL_MAPPING = { - _LogLevel.QUIET: logging.CRITICAL, - _LogLevel.WARNING: logging.WARNING, - _LogLevel.VERBOSE: logging.INFO, - _LogLevel.DEBUG: logging.DEBUG, -} - - + @property + def level(self): + return { + _LogLevel.QUIET: logging.CRITICAL, + _LogLevel.WARNING: logging.WARNING, + _LogLevel.VERBOSE: logging.INFO, + _LogLevel.DEBUG: logging.DEBUG, + }[self.value] + + @app.callback() def main( log: Annotated[ @@ -69,8 +70,7 @@ def main( ] = "warning" ): """Analyze data from the ICESAT2 satellite.""" - level = _LOG_LEVEL_MAPPING[log] - logging.basicConfig(level=level) + logging.basicConfig(level=log.level) validate_track_name_gt_1_opt = Option(..., callback=validate_track_name_steps_gt_1) From 8e91491d940baa169afd0002aba86bad6824e8c5 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Tue, 5 Mar 2024 14:38:15 -0500 Subject: [PATCH 24/35] Update src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py Co-authored-by: Camilo Diaz --- src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py b/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py index 21b9213b..ce16fa49 100644 --- a/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py +++ b/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py @@ -131,7 +131,7 @@ def run_B01_SL_load_single_file( save_path_json = Path(workdir, batch_key, "A01b_ID") save_path_json.mkdir(parents=True, exist_ok=True) - ATL03_track_name = "ATL03_" + track_name + ".h5" + ATL03_track_name = f"ATL03_{track_name}.h5" # Configure SL Session icesat2.init("slideruleearth.io") From aaab734c96a75cf3c40e75915c630589fde8b23d Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Tue, 5 Mar 2024 14:38:35 -0500 Subject: [PATCH 25/35] Update src/icesat2_tracks/local_modules/m_colormanager_ph3.py Co-authored-by: Carlos Paniagua --- src/icesat2_tracks/local_modules/m_colormanager_ph3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/icesat2_tracks/local_modules/m_colormanager_ph3.py b/src/icesat2_tracks/local_modules/m_colormanager_ph3.py index 6b7e4a5a..0244d758 100644 --- a/src/icesat2_tracks/local_modules/m_colormanager_ph3.py +++ b/src/icesat2_tracks/local_modules/m_colormanager_ph3.py @@ -181,7 +181,7 @@ def show(self): _logger.debug(' rels dict:') for key in self.rels.keys(): - _logger.debug(' '+key) + _logger.debug(" %s", key) #print(self.__dict__) def plot(self): From f9779d5779cb385d05f66e46f9c6ca14f7ab8c3d Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Tue, 5 Mar 2024 14:38:44 -0500 Subject: [PATCH 26/35] Update src/icesat2_tracks/local_modules/m_colormanager_ph3.py Co-authored-by: Carlos Paniagua --- src/icesat2_tracks/local_modules/m_colormanager_ph3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/icesat2_tracks/local_modules/m_colormanager_ph3.py b/src/icesat2_tracks/local_modules/m_colormanager_ph3.py index 0244d758..9206275b 100644 --- a/src/icesat2_tracks/local_modules/m_colormanager_ph3.py +++ b/src/icesat2_tracks/local_modules/m_colormanager_ph3.py @@ -179,7 +179,7 @@ def show(self): for key in self.__dict__.keys(): _logger.debug(key) - _logger.debug(' rels dict:') + _logger.debug(' rels dict keys:') for key in self.rels.keys(): _logger.debug(" %s", key) From a044c61abea026614e3cdb95b93f3002e14d20d4 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Tue, 5 Mar 2024 14:38:59 -0500 Subject: [PATCH 27/35] Update src/icesat2_tracks/local_modules/m_colormanager_ph3.py Co-authored-by: Carlos Paniagua --- src/icesat2_tracks/local_modules/m_colormanager_ph3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/icesat2_tracks/local_modules/m_colormanager_ph3.py b/src/icesat2_tracks/local_modules/m_colormanager_ph3.py index 9206275b..6e2f8df3 100644 --- a/src/icesat2_tracks/local_modules/m_colormanager_ph3.py +++ b/src/icesat2_tracks/local_modules/m_colormanager_ph3.py @@ -65,7 +65,7 @@ def __init__(self, path=None, name=None): # setattr(self.colors, k, v) except: _logger.debug('fail load theme, fall back to default theme') - _logger.debug(path+'mhell_colortheme17') + _logger.debug("path: %s", path+'mhell_colortheme17')) self.default_colors() else: From 4cc2da5e8d8c32d32d17660f7f862c2f5afcb032 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Tue, 5 Mar 2024 14:39:18 -0500 Subject: [PATCH 28/35] Update src/icesat2_tracks/local_modules/m_colormanager_ph3.py Co-authored-by: Carlos Paniagua --- src/icesat2_tracks/local_modules/m_colormanager_ph3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/icesat2_tracks/local_modules/m_colormanager_ph3.py b/src/icesat2_tracks/local_modules/m_colormanager_ph3.py index 6e2f8df3..19fe156e 100644 --- a/src/icesat2_tracks/local_modules/m_colormanager_ph3.py +++ b/src/icesat2_tracks/local_modules/m_colormanager_ph3.py @@ -45,7 +45,7 @@ def json_load(name, path): with open(full_name, 'r') as ifile: data=json.load(ifile) - _logger.debug('loaded from: {full_name}') + _logger.debug('loaded from: %s', full_name) return data From cd12cd5ee7239e98ee82f18f9b79b8d5a4a40a57 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Tue, 5 Mar 2024 14:39:39 -0500 Subject: [PATCH 29/35] Update src/icesat2_tracks/local_modules/m_colormanager_ph3.py Co-authored-by: Carlos Paniagua --- src/icesat2_tracks/local_modules/m_colormanager_ph3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/icesat2_tracks/local_modules/m_colormanager_ph3.py b/src/icesat2_tracks/local_modules/m_colormanager_ph3.py index 19fe156e..74a8bec5 100644 --- a/src/icesat2_tracks/local_modules/m_colormanager_ph3.py +++ b/src/icesat2_tracks/local_modules/m_colormanager_ph3.py @@ -32,7 +32,7 @@ def json_save(name, path, data, return_name=False): full_name= (os.path.join(full_name_root+ '.json')) with open(full_name, 'w') as outfile: json.dump(data, outfile) - _logger.debug(f'save at: {full_name}') + _logger.debug('save at %s:', full_name) if return_name: return full_name_root else: From 3cc72fe240f44fa94be3a0164f5478d653446434 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Tue, 5 Mar 2024 14:39:51 -0500 Subject: [PATCH 30/35] Update src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py Co-authored-by: Camilo Diaz --- src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py b/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py index ce16fa49..367452da 100644 --- a/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py +++ b/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py @@ -250,7 +250,7 @@ def run_B01_SL_load_single_file( _logger.info("write A01b .json") DD = {"case_ID": ID_name, "tracks": {}} - DD["tracks"]["ATL03"] = "ATL10-" + track_name + DD["tracks"]["ATL03"] = f"ATL10-{track_name}" start_pos = abs(table_data.lats).argmin() end_pos = abs(table_data.lats).argmax() From fd26f772d0a7bc05d347563440b60ecd1274fdb3 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Tue, 5 Mar 2024 14:40:09 -0500 Subject: [PATCH 31/35] Update src/icesat2_tracks/local_modules/m_colormanager_ph3.py Co-authored-by: Carlos Paniagua --- src/icesat2_tracks/local_modules/m_colormanager_ph3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/icesat2_tracks/local_modules/m_colormanager_ph3.py b/src/icesat2_tracks/local_modules/m_colormanager_ph3.py index 74a8bec5..ee086b1e 100644 --- a/src/icesat2_tracks/local_modules/m_colormanager_ph3.py +++ b/src/icesat2_tracks/local_modules/m_colormanager_ph3.py @@ -19,7 +19,7 @@ def ase_to_json(path): A=swatch.parse(path) for i in A[0]['swatches']: - _logger.debug(i['name'] + ' ' + str(i['data']['values'])) + _logger.debug("swatch name: %s, swatch values: %s", i['name'], i['data']['values']) return A From 6ebff19bfa037ab07be6f3301af3580c5c2906cb Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Tue, 5 Mar 2024 14:40:18 -0500 Subject: [PATCH 32/35] Update src/icesat2_tracks/local_modules/m_colormanager_ph3.py Co-authored-by: Carlos Paniagua --- src/icesat2_tracks/local_modules/m_colormanager_ph3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/icesat2_tracks/local_modules/m_colormanager_ph3.py b/src/icesat2_tracks/local_modules/m_colormanager_ph3.py index ee086b1e..8e821d4d 100644 --- a/src/icesat2_tracks/local_modules/m_colormanager_ph3.py +++ b/src/icesat2_tracks/local_modules/m_colormanager_ph3.py @@ -55,7 +55,7 @@ class color: def __init__(self, path=None, name=None): self.white=(1,1,1) if (path is not None) & (name is not None): - _logger.debug('color theme: '+name) + _logger.debug("color theme: %s", name) try: theme=json_load(name, path) for k, v in theme.items(): From a8494579643bbe793ab302123ce8ed965ccd8574 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Tue, 5 Mar 2024 14:41:52 -0500 Subject: [PATCH 33/35] Apply suggestions from code review --- src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py b/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py index 367452da..fe464254 100644 --- a/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py +++ b/src/icesat2_tracks/analysis_db/B01_SL_load_single_file.py @@ -161,10 +161,9 @@ def run_B01_SL_load_single_file( } maximum_height = 30 # (meters) maximum height past dem_h correction - _logger.info("STARTS") _logger.info("Fetching ATL03 data from sliderule") gdf = icesat2.atl06p(params_yapc, resources=[ATL03_track_name]) - _logger.info("ENDS") + _logger.info("Finished fetching ATL03 data from sliderule") gdf = sct.correct_and_remove_height(gdf, maximum_height) cdict = dict() From 39b145f932892bc33084c856937bfc36db618810 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Tue, 5 Mar 2024 14:45:10 -0500 Subject: [PATCH 34/35] Update src/icesat2_tracks/local_modules/m_colormanager_ph3.py --- src/icesat2_tracks/local_modules/m_colormanager_ph3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/icesat2_tracks/local_modules/m_colormanager_ph3.py b/src/icesat2_tracks/local_modules/m_colormanager_ph3.py index 8e821d4d..dc2adaa4 100644 --- a/src/icesat2_tracks/local_modules/m_colormanager_ph3.py +++ b/src/icesat2_tracks/local_modules/m_colormanager_ph3.py @@ -65,7 +65,7 @@ def __init__(self, path=None, name=None): # setattr(self.colors, k, v) except: _logger.debug('fail load theme, fall back to default theme') - _logger.debug("path: %s", path+'mhell_colortheme17')) + _logger.debug("path: %s", path+'mhell_colortheme17') self.default_colors() else: From db8ea2b177668a14a9f6abb0d53103d01038cd87 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Wed, 13 Mar 2024 16:14:35 -0400 Subject: [PATCH 35/35] fix: some broken logger calls --- src/icesat2waves/local_modules/m_colormanager_ph3.py | 2 +- src/icesat2waves/local_modules/m_general_ph3.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/icesat2waves/local_modules/m_colormanager_ph3.py b/src/icesat2waves/local_modules/m_colormanager_ph3.py index 7af5fc15..fc8d55a0 100644 --- a/src/icesat2waves/local_modules/m_colormanager_ph3.py +++ b/src/icesat2waves/local_modules/m_colormanager_ph3.py @@ -61,7 +61,7 @@ def __init__(self, path=None, name=None): setattr(self, k, v) except: _logger.debug('fail load theme, fall back to default theme') - _logger.debug("path: %s", path+'mhell_colortheme17') + _logger.debug("path: %s%s", path, 'mhell_colortheme17') self.default_colors() else: diff --git a/src/icesat2waves/local_modules/m_general_ph3.py b/src/icesat2waves/local_modules/m_general_ph3.py index 5d57aa7e..6cbd59ee 100644 --- a/src/icesat2waves/local_modules/m_general_ph3.py +++ b/src/icesat2waves/local_modules/m_general_ph3.py @@ -133,7 +133,7 @@ def save(self, name=None, path=None, verbose=True): extension = ".pdf" full_name = (os.path.join(savepath, name)) + extension self.fig.savefig(full_name, bbox_inches="tight", format="pdf", dpi=180) - _logger.info("save at: " + name) + _logger.info("save at: %s", name) def save_pup(self, name=None, path=None): name = re.sub("\.", "_", name) @@ -148,7 +148,7 @@ def save_pup(self, name=None, path=None): extension = ".pdf" full_name = (os.path.join(savepath, name)) + extension self.fig.savefig(full_name, bbox_inches="tight", format="pdf", dpi=300) - _logger.info("save at: ", full_name) + _logger.info("save at: %s", full_name) def save_light(self, name=None, path=None): @@ -164,7 +164,7 @@ def save_light(self, name=None, path=None): extension = ".png" full_name = (os.path.join(savepath, name)) + extension self.fig.savefig(full_name, bbox_inches="tight", format="png", dpi=180) - _logger.info("save with: ", name) + _logger.info("save with: %s", name) class SubplotRoutines(FigureAxisXY):