Skip to content

Commit

Permalink
more test for cmt
Browse files Browse the repository at this point in the history
  • Loading branch information
gmaze committed Feb 1, 2024
1 parent cd9aecc commit 260bb86
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 36 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/test_cmt.yml
Original file line number Diff line number Diff line change
@@ -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
55 changes: 19 additions & 36 deletions cli/load_aviso.py
Original file line number Diff line number Diff line change
@@ -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__":
Expand Down Expand Up @@ -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'])

0 comments on commit 260bb86

Please sign in to comment.