Skip to content

Commit

Permalink
Merge pull request #6 from umr-lops/fix_log_and_workflow
Browse files Browse the repository at this point in the history
fix logging verbosity
  • Loading branch information
agrouaze authored Apr 9, 2024
2 parents 38617c4 + fdc8e1d commit 098b56f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ jobs:
publish:
name: Publish to PyPI
runs-on: ubuntu-latest
permissions:
contents: 'read'
id-token: 'write'
steps:
- uses: actions/checkout@v4
- name: Set up Python
Expand All @@ -29,4 +32,4 @@ jobs:
with:
password: ${{ secrets.pypi_token }}
repository_url: https://upload.pypi.org/legacy/
verify_metadata: true
verify_metadata: true
7 changes: 6 additions & 1 deletion sarwaveifrproc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@

__author__ = """Antoine Grouazel"""
__email__ = '[email protected]'
__version__ = '0.1.0'

try:
from importlib import metadata
except ImportError: # for Python<3.8
import importlib_metadata as metadata
__version__ = metadata.version('sarwaveifrproc')
8 changes: 5 additions & 3 deletions sarwaveifrproc/l2_wave.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import numpy as np
import os
import xarray as xr
import datatree as dtt
from scipy import special

import sarwaveifrproc

attributes_missing_variables = \
{
Expand Down Expand Up @@ -35,11 +36,11 @@ def generate_l2_wave_product(xdt, intraburst_model, interburst_model, intraburst
"""

kept_variables = ['corner_longitude', 'corner_latitude', 'land_flag', 'sigma0_filt', 'normalized_variance_filt', 'incidence', 'azimuth_cutoff', 'cwave_params']

ds_intraburst = generate_intermediate_product(xdt['intraburst'].ds, intraburst_model, intraburst_scaler, intraburst_bins, predicted_variables, kept_variables)
ds_interburst = generate_intermediate_product(xdt['interburst'].ds, interburst_model, interburst_scaler, interburst_bins, predicted_variables, kept_variables)

l2_wave_product = dtt.DataTree.from_dict({"intraburst": ds_intraburst, "interburst": ds_interburst})
l2_wave_product.attrs['input_sar_product'] = os.path.basename(xdt.encoding['source'])
return l2_wave_product


Expand Down Expand Up @@ -230,7 +231,8 @@ def format_dataset(ds, predictions, predicted_variables, kept_variables, bins):

ds = xr.merge([ds] + data_to_merge)
ds = ds.drop_vars(['tile_line', 'tile_sample'])

ds.attrs['l2_processor_name'] = 'sarwaveifrproc'
ds.attrs['l2_processor_version'] = sarwaveifrproc.__version__
ds.attrs.pop('name', None)
ds.attrs.pop('multidataset', None)

Expand Down
8 changes: 6 additions & 2 deletions sarwaveifrproc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,13 @@ def parse_args():
def main():

args = parse_args()

fmt = '%(asctime)s %(levelname)s %(filename)s(%(lineno)d) %(message)s'
if args.verbose:
logging.basicConfig(level=logging.INFO)
logging.basicConfig(level=logging.DEBUG, format=fmt,
datefmt='%d/%m/%Y %H:%M:%S',force=True)
else:
logging.basicConfig(level=logging.INFO, format=fmt,
datefmt='%d/%m/%Y %H:%M:%S',force=True)

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' # Suppress TensorFlow INFO and WARNING messages
os.environ['CUDA_VISIBLE_DEVICES'] = '-1' # Hide CUDA devices
Expand Down

0 comments on commit 098b56f

Please sign in to comment.