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

chore: logging 5 - remove prints from local_modules directory #179

Merged
merged 39 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
01fce88
chore: replace print with logging in JONSWAP_gamma.py
hollandjg Mar 4, 2024
7430f57
chore: replace print with logging in m3_colormanager_ph3.py
hollandjg Mar 4, 2024
9da6708
chore: replace print with logging in m_general_ph3.py
hollandjg Mar 4, 2024
2cefaf5
chore: replace print with logging in m_spectrum_ph3
hollandjg Mar 4, 2024
39babe5
chore: replace print with logging in m_tools_ph3.py
hollandjg Mar 4, 2024
ed8ee0c
Merge branch 'feat-logger/4-replace-print-logger-config' into feat-lo…
hollandjg Mar 11, 2024
f7b3a5c
Merge branch 'feat-logger/4-replace-print-logger-config' into feat-lo…
hollandjg Mar 11, 2024
7da5c7b
Merge branch 'feat-logger/4-replace-print-logger-config' into feat-lo…
hollandjg Mar 13, 2024
5d220d3
fix: update formatting in logging
hollandjg Mar 13, 2024
397c300
fix: reformat debugs from prints
hollandjg Mar 13, 2024
044db60
revert change to boot.ci call
hollandjg Mar 13, 2024
5911294
fix: replace evaluated strings
hollandjg Mar 13, 2024
063c21e
chore: remove unused from __future__ import
hollandjg Mar 13, 2024
f33a6fb
make updates from PR review
hollandjg Mar 13, 2024
277bca8
Added more context
hollandjg Mar 13, 2024
c3dcebd
Updates from PR review
hollandjg Mar 13, 2024
0399770
Updates from PR review
hollandjg Mar 13, 2024
b9360de
Updates from PR review
hollandjg Mar 13, 2024
278af16
Update src/icesat2waves/local_modules/m_general_ph3.py
hollandjg Mar 15, 2024
4417d8a
chore: add more context to debugger
hollandjg Mar 15, 2024
d2cdb6b
chore: add more context to debugger
hollandjg Mar 15, 2024
f67c66c
chore: add more context to debugger
hollandjg Mar 15, 2024
7799236
chore: reordered and deduplicated logging calls
hollandjg Mar 15, 2024
01cc041
chore: add more logging context
hollandjg Mar 15, 2024
5501bfc
Merge remote-tracking branch 'origin/feat-logger/5-replace-print-logg…
hollandjg Mar 15, 2024
63a00d0
Update src/icesat2waves/local_modules/m_colormanager_ph3.py
hollandjg Mar 15, 2024
07d2190
Update src/icesat2waves/local_modules/m_tools_ph3.py
hollandjg Mar 18, 2024
f514e3c
Update src/icesat2waves/local_modules/m_general_ph3.py
hollandjg Mar 18, 2024
d4b31bc
update debugging calls with iter.
hollandjg Mar 18, 2024
eda0e16
Merge branch 'feat-logger/5-replace-print-logger-local_modules' of ht…
hollandjg Mar 18, 2024
e105dde
Update src/icesat2waves/local_modules/m_general_ph3.py
hollandjg Mar 19, 2024
fa7b492
Update src/icesat2waves/local_modules/m_tools_ph3.py
hollandjg Mar 19, 2024
c80198d
Update src/icesat2waves/local_modules/m_tools_ph3.py
hollandjg Mar 19, 2024
52c7320
Update src/icesat2waves/local_modules/m_general_ph3.py
hollandjg Mar 19, 2024
ece4f27
Update src/icesat2waves/local_modules/m_general_ph3.py
hollandjg Mar 19, 2024
d2d12e0
Merge branch 'feat-logger/4-replace-print-logger-config' into feat-lo…
hollandjg Mar 19, 2024
8afc4a7
Merge branch 'feat-logger/4-replace-print-logger-config' into feat-lo…
hollandjg Mar 20, 2024
d2ab30e
Merge branch 'feat-logger/4-replace-print-logger-config' into feat-lo…
hollandjg Mar 21, 2024
2c472f8
Merge branch 'main' into feat-logger/5-replace-print-logger-local_mod…
hollandjg Mar 22, 2024
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
42 changes: 22 additions & 20 deletions src/icesat2_tracks/local_modules/JONSWAP_gamma.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import os
from scipy.constants import g

Expand All @@ -16,6 +17,7 @@
import matplotlib.pyplot as plt
import numpy as np

_logger = logging.getLogger(__name__)

# %%
def normalize_time(time):
Expand Down Expand Up @@ -77,7 +79,7 @@ def gamma_time_normlized_amp_shifted(time, gammapar=2, loc=0.2, scale=0.1):
"""
gamma_mod = gamma(gammapar, loc=loc[0, :], scale=scale).pdf(time[0, :])
dloc = loc[0, :] - time[0, :][gamma_mod.argmax()]
# print(dloc)
# _logger.debug(dloc)
hollandjg marked this conversation as resolved.
Show resolved Hide resolved
gamma_mod = gamma(gammapar, loc=loc + dloc, scale=scale).pdf(time)
return gamma_mod / gamma_mod.max()

Expand Down Expand Up @@ -140,7 +142,7 @@ def pierson_moskowitz_fetch_limit(f, X, U):

alpha = 0.076 * (g * X / U**2) ** (-0.22) # non-dimentional
wp = 7.0 * np.pi * (g / U) * (g * X / U**2) ** (-0.33)
print("wp=" + str(wp))
_logger.debug("wp=%s", wp)

sigma_p = 0.07
sigma_pp = 0.09
Expand Down Expand Up @@ -173,8 +175,8 @@ def JONSWAP_default(f, X, U, gamma=3.3):

alpha = 0.076 * (g * X / U**2) ** (-0.22) # non-dimentional
wp = 7.0 * np.pi * (g / U) * (g * X / U**2) ** (-0.33)
# print('wp='+str(wp))
# print('nu='+str(wp*U/(g)))
# _logger.debug('wp='+str(wp))
# _logger.debug('nu='+str(wp*U/(g)))
hollandjg marked this conversation as resolved.
Show resolved Hide resolved

sigma_p = 0.07
sigma_pp = 0.09
Expand Down Expand Up @@ -257,21 +259,21 @@ def gamma_time_JONSWAP_default(
# intersectf=intersect-intersect/slopet
intersectF = -intersectT * slope_t
pfreq = time * slope_t + intersectF
# print('intersect F=' + str(intersectF))
# _logger.debug('intersect F=' + str(intersectF))

# intersectf=intersect#-intersect/slope
slopeF = 1 / slope_t
pfreq_forgamma = f * slopeF + intersectT

# rint(pfreq.shape)
tt, line = np.meshgrid(time, pfreq_forgamma)
# print(line)
# print(tt)
# _logger.debug(line)
# _logger.debug(tt)
hollandjg marked this conversation as resolved.
Show resolved Hide resolved
func_t = gamma_time_normlized_amp_shifted(
tt, gammapar=tgammapar, loc=line, scale=tscale
)
# func_t_temp= (tamp*np.exp(- (time-t_center )**4 / tsigma ))
# print(func_t.shape)
# _logger.debug(func_t.shape)

""" Define X(f_max and U) here """

Expand Down Expand Up @@ -338,21 +340,21 @@ def gamma_time_JONSWAP_nondim(
# intersectf=intersect-intersect/slopet
intersectF = -intersectT * slope_t
pfreq = time * slope_t + intersectF
# print('intersect F=' + str(intersectF))
# _logger.debug('intersect F=' + str(intersectF))

# intersectf=intersect#-intersect/slope
slopeF = 1 / slope_t
pfreq_forgamma = f * slopeF + intersectT

# rint(pfreq.shape)
tt, line = np.meshgrid(time, pfreq_forgamma)
# print(line)
# print(tt)
# _logger.debug(line)
# _logger.debug(tt)
func_t = gamma_time_normlized_amp_shifted(
tt, gammapar=tgammapar, loc=line, scale=tscale
)
# func_t_temp= (tamp*np.exp(- (time-t_center )**4 / tsigma ))
# print(func_t.shape)
# _logger.debug(func_t.shape)

def X(f_max, U10):
return 3.5**3.0 * g**2.0 / (U10 * f_max**3.0)
Expand Down Expand Up @@ -445,7 +447,7 @@ def residual_JONSWAP_default_gamma(
# tt, tt= np.meshgrid(time, ff)
model1d = model.reshape(model.shape[0] * model.shape[1])
model1d[np.isnan(model1d)] = 0
# print(model1d)
# _logger.debug(model1d)

if data is not None:
if np.size(data.shape) != 1:
Expand Down Expand Up @@ -475,7 +477,7 @@ def residual_JONSWAP_default_gamma(
if data is None:
return model1d
if weight is not None:
# print('use weight')
# _logger.debug('use weight')
d = (model1d - data1d) * weight1d
d[nan_track] = np.nan
return d
Expand Down Expand Up @@ -557,7 +559,7 @@ def residual_JONSWAP_nondim_gamma(
if data is None:
return model1d
if weight is not None:
# print('use weight')
# _logger.debug('use weight')
d = (model1d - data1d) * weight1d
d[nan_track] = np.nan
return d
Expand Down Expand Up @@ -719,7 +721,7 @@ def Jm_regulizer(value_dict, prior):

Jm = list()
for k, I in prior.items():
# print(I)
# _logger.debug(I)
if type(I["m_err"]) is float:
Jm.append((I["m0"] - vd[k]) / I["m_err"])
else:
Expand Down Expand Up @@ -770,7 +772,7 @@ def reg_func(p0, pi, p_err_unit):
return (pi / p0 - 1) / ppercent

for k, I in prior.items():
# print(I)
# _logger.debug(I)
if type(I["m_err"]) is float:
Jm.append(reg_func(I["m0"], vd[k], I["m_err"]))
# Jm.append( (I['m0']- vd[k] ) / I['m_err'] )
Expand Down Expand Up @@ -804,7 +806,7 @@ def reg_func(p0, pi, p_err_unit):
vd[k] = I * np.random.rand()

Jm = Jm_regulizer(vd, priors)
print(Jm)
_logger.debug(Jm)
hollandjg marked this conversation as resolved.
Show resolved Hide resolved


# %%
Expand Down Expand Up @@ -943,7 +945,7 @@ def cost(value_dict, time, f, data=None, weight=None, prior=False, eps=None):
# if prior is not None:
# Jm=Jm_regulizer(vdict, prior, alpha=5.0)
#
# #print(Jm)
# #_logger.debug(Jm)
#
# if data is None:
# return model1d
Expand All @@ -955,7 +957,7 @@ def cost(value_dict, time, f, data=None, weight=None, prior=False, eps=None):
# if (weight is not None) and (eps is None):
# d=(model1d - data1d)*weight
# d[nan_track]=np.nan
# #print(np.concatenate(( d,Jm )) )
# #_logger.debug(np.concatenate(( d,Jm )) )
# return np.concatenate(( d, Jm ))
#
# if (eps is None) and (weight is None):
Expand Down
14 changes: 7 additions & 7 deletions src/icesat2_tracks/local_modules/m_colormanager_ph3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("%s %s", i['name'], i['data']['values'])
hollandjg marked this conversation as resolved.
Show resolved Hide resolved

return A

Expand All @@ -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:
Expand All @@ -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


Expand All @@ -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():
Expand Down Expand Up @@ -177,13 +177,13 @@ def colormaps(self,n, gamma=None):

def show(self):
for key in self.__dict__.keys():
_logger.debug(key)
_logger.debug("%s",key)

_logger.debug(' rels dict:')
for key in self.rels.keys():
_logger.debug(' '+key)
_logger.debug(' %s', key)

#print(self.__dict__)
#_logger.debug(self.__dict__)
def plot(self):
dd=self.__dict__.copy()
dd_colors=dd['rels']
Expand Down
Loading
Loading