Skip to content

Instantly share code, notes, and snippets.

View gmaze's full-sized avatar
🤩
Last argopy pre-release v0.1.14 is out !

Guillaume Maze gmaze

🤩
Last argopy pre-release v0.1.14 is out !
View GitHub Profile
@gmaze
gmaze / argo_read_doi.py
Created June 7, 2024 07:54
Read Argo index or data from a DOI snapshot download without untar/decompress
import tarfile
import gzip
import xarray as xr
import pandas as pd
# Work with a BGC-S doi snapshot
# Snapshot was downloaded from: https://www.seanoe.org/data/00311/42182/data/110195.tar.gz
file = '/Users/gmaze/Downloads/110195.tar.gz'
# Read one of the index file as a pandas dataframe:
@gmaze
gmaze / argo_nc2zarr.py
Created May 24, 2024 12:49
Convert an Argo multi-prof netcdf into zarr
#!/usr/bin/env python
# coding: utf-8
import xarray as xr
import argopy
from argopy.stores import httpstore
# Convert an Argo multi-prof netcdf into zarr
# 1st we get the url toward the netcdf file:
@gmaze
gmaze / argo-cloud-based-format-readme.md
Last active April 19, 2024 19:20
Better understanding how Argo data could be easily subset-ed from the "cloud"

"Is there already an interface that allows for subsetting of the data or do you imagine that additional tools will be developed on top of the structure as is done with the current https GDAC service? "
In short:

  1. additional tools are required mostly for Matlab users, Python users are already very well equipped.
  2. If there's only subsetting to address, the api/database approach is an alternative solution to changing format. But that's not the case, we also would like to improve raw data access/structure through an alternative file format to netcdf

With regard to better understanding how Argo data could be easily subset-ed from the "cloud", this is for me the opportunity to try to summarise some key points: see below and, sorry for some possible shortcomings and verbosity of the email !

Key points

In long:

@gmaze
gmaze / french_fleet.py
Last active February 9, 2024 12:32
A class to retrieve France Oceanographic Fleet vessel positions
import pandas as pd
import urllib
import urllib.parse
import json
class FrenchFleet:
"""
Examples
--------
@gmaze
gmaze / cmt_utils.py
Last active May 3, 2024 07:41
Copernicus Marine Toolbox: ARMOR3D and GLORYS loaders
import pandas as pd
import copernicusmarine
class Armor3d:
"""Global Ocean 1/4° Multi Observation Product ARMOR3D
Product description:
https://data.marine.copernicus.eu/product/MULTIOBS_GLO_PHY_TSUV_3D_MYNRT_015_012
If start_date + n_days <= 2022-12-28:
@gmaze
gmaze / clone.sh
Last active June 21, 2023 10:31
Clean cloning of a conda env (and add it to jupyter kernel list)
#!/bin/sh
#
# Clone a conda env and add it to jupyter kernel list
#
# This is basicaly a nice shortcut for:
# mamba create --name argopy-pull208 --clone argopy-py38-all-pinned
# python -m ipykernel install --user --name=argopy-pull208
#
#
# Created by G. Maze on 2023-06-21.
@gmaze
gmaze / example.py
Last active June 13, 2023 15:31
How to retrieve CMEMS product using xarray and opendap
# Must be installed in python env:
# - motuclient (via pip, https://github.com/clstoulouse/motu-client-python)
# - pydap (via conda, https://github.com/pydap/pydap)
import os
import requests
import xarray as xr
# Set-up a request session that will know how to authenticate on the CMEMS server
MOTU_USERNAME, MOTU_PASSWORD = (
@gmaze
gmaze / OceanOPS_Deployments.py
Last active January 27, 2023 15:04
A Python class to use the OceanOPS API for metadata access to retrieve Argo floats deployment information
import aiohttp
import asyncio
from aiohttp.helpers import URL
from aiohttp.web import HTTPException
import nest_asyncio
nest_asyncio.apply() # To be used in jupyter notebooks
class OceanOPS_Deployments:
""" Use the OceanOPS API for metadata access to retrieve Argo floats deployment information
@gmaze
gmaze / get_float_config.py
Created October 6, 2022 13:46
How to download an Argo float configuration from the Euro-Argo Fleet Monitoring API
import urllib.request
import json
import numpy as np
import pandas as pd
def get_float_config(wmo, cyc=None):
def id_mission(missionCycles, a_cyc):
this_mission = None
for im, mission in enumerate(missionCycles):

Import the library:

# Import the main fetcher:
from argopy import DataFetcher as ArgoDataFetcher

Define what you want to fetch:

# a region:
ArgoSet = ArgoDataFetcher().region([-85, -45, 10., 20., 0, 1000.])