From 260bb868ada06187114a82cf2e5fcf038bc58681 Mon Sep 17 00:00:00 2001 From: Guillaume Maze Date: Thu, 1 Feb 2024 15:01:28 +0100 Subject: [PATCH] more test for cmt --- .github/workflows/test_cmt.yml | 37 +++++++++++++++++++++++ cli/load_aviso.py | 55 ++++++++++++---------------------- 2 files changed, 56 insertions(+), 36 deletions(-) create mode 100644 .github/workflows/test_cmt.yml diff --git a/.github/workflows/test_cmt.yml b/.github/workflows/test_cmt.yml new file mode 100644 index 000000000..473ecba6d --- /dev/null +++ b/.github/workflows/test_cmt.yml @@ -0,0 +1,37 @@ +# This workflow aims to produce Near Real Time classification of profiles in BCs + +name: Test-CMT + +on: + workflow_dispatch: # allows you to trigger the workflow run manually + +jobs: + + classify-and-report: + + runs-on: ubuntu-latest + defaults: + run: + shell: bash -l {0} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + ref: 'main' + + - name: Set up Python 3.9 + uses: actions/setup-python@v4 + with: + python-version: '3.9' + + - name: Setup Micromamba + uses: mamba-org/setup-micromamba@v1 + with: + environment-name: bc-monitor + environment-file: environment39-free.yml + cache-environment: true + + - name: Classify and report + run: | + python cli/load_aviso.py diff --git a/cli/load_aviso.py b/cli/load_aviso.py index a4fbe5676..f580ad7bc 100644 --- a/cli/load_aviso.py +++ b/cli/load_aviso.py @@ -1,34 +1,24 @@ -import sys, os - -import numpy as np -# import pandas as pd -# import xarray as xr -# xr.set_options(display_style="html", display_expand_attrs=False) -import warnings -import matplotlib.pyplot as plt -from tqdm import tqdm - -import pyxpcm -import argopy -from argopy import DataFetcher +import os from argopy.stores.argo_index_pd import indexstore_pandas as indexstore - -sys.path.insert(0, os.sep.join([os.path.split(os.path.realpath(__file__))[0], '..'])) -from pcmbc.utilities import from_misc_pres_2_std_depth, load_aviso_nrt, load_aviso_mdt - - -def download_aviso_from_wekeo(a_box, a_date): - WEKEO_USERNAME, WEKEO_PASSWORD = ( - os.getenv("WEKEO_USERNAME"), - os.getenv("WEKEO_PASSWORD"), +import copernicusmarine + + +def load_aviso_nrt(a_box, a_date, vname='sla'): + if not isinstance(vname, list): + vname = [vname] + + ds = copernicusmarine.open_dataset( + dataset_id="cmems_obs-sl_glo_phy-ssh_nrt_allsat-l4-duacs-0.25deg_P1D", + minimum_longitude=a_box[0], + maximum_longitude=a_box[1], + minimum_latitude=a_box[2], + maximum_latitude=a_box[3], + start_datetime=a_date.strftime('%Y-%m-%d 00:00:00'), + end_datetime=a_date.strftime('%Y-%m-%d 00:00:00'), + variables=vname, ) - if not WEKEO_USERNAME: - raise ValueError("No WEKEO_USERNAME in environment ! ") - aviso = load_aviso_nrt(a_box, a_date, WEKEO_USERNAME, WEKEO_PASSWORD, vname="sla") - aviso_clim = load_aviso_mdt(a_box, WEKEO_USERNAME, WEKEO_PASSWORD, vname="mdt") - - return aviso, aviso_clim + return ds if __name__ == "__main__": @@ -72,13 +62,6 @@ def download_aviso_from_wekeo(a_box, a_date): WMO_list = idx.read_wmo() # Load AVISO data for the map: - aviso_nrt, aviso_mdt = download_aviso_from_wekeo(box, index["date"].max()) + aviso_nrt = load_aviso_nrt(box, index["date"].max()) print(aviso_nrt) - print(aviso_mdt) - - # Tear down - if aviso_nrt: - os.remove(aviso_nrt.attrs['local_file']) - if aviso_mdt: - os.remove(aviso_mdt.attrs['local_file'])