Skip to content

Instantly share code, notes, and snippets.

View gmaze's full-sized avatar
🏝️
argopy turns 5 !

Guillaume Maze gmaze

🏝️
argopy turns 5 !
View GitHub Profile

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.])
@gmaze
gmaze / get_WMO_and_position_QC.md
Last active September 23, 2022 08:24
Examples to work with position_QC and WMO from Ifremer ERDDAP

To get a list of WMO,CYC matching some QC position, you can do something like:

https://erddap.ifremer.fr/erddap/tabledap/ArgoFloats.htmlTable?platform_number,cycle_number,position_qc&platform_number=~%226903075|6903076%22&position_qc=~%221%22&distinct()&orderBy(%22platform_number,cycle_number%22)

This is an example where I select profiles from floats 6903075 and 6903076 having a QC position of 1

If you want to allow for more allowed QC, list them with a | in the request:

https://erddap.ifremer.fr/erddap/tabledap/ArgoFloats.htmlTable?platform_number,cycle_number,position_qc&platform_number=~%226903075|6903076%22&position_qc=~%220|1%22&distinct()&orderBy(%22platform_number,cycle_number%22)
@gmaze
gmaze / pca-Lilian.ipynb
Last active July 10, 2020 13:53
1st hands on PCA
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gmaze
gmaze / Compare_time_response_erddap.py
Last active April 8, 2020 09:41
Compare_time_response_erddap
#!/bin/env python
# -*coding: UTF-8 -*-
import requests
import time
# Request full data:
t0 = time.time()
url = 'http://www.ifremer.fr/erddap/tabledap/ArgoFloats.csv?data_mode,latitude,longitude,position_qc,time,time_qc,direction,platform_number,cycle_number,pres,temp,psal,pres_qc,temp_qc,psal_qc,pres_adjusted,temp_adjusted,psal_adjusted,pres_adjusted_qc,temp_adjusted_qc,psal_adjusted_qc,pres_adjusted_error,temp_adjusted_error,psal_adjusted_error&platform_number=~"5900446"&distinct()&orderBy("time,pres")'
requests.get(url)
@gmaze
gmaze / Parallel_images.py
Created March 20, 2020 12:44
Parallel figure generation in python
#!/usr/bin/env python
# coding: utf-8
#
# $ time ./Parallel_images.py
# Use 8 processes
# 107.249u 2.444s 0:17.10 641.4% 0+0k 0+0io 1056pf+0w
#
import os
import numpy as np
@gmaze
gmaze / GenerateMovie.sh
Last active March 20, 2020 11:03
Create a movie from a collection of image files
#!/usr/bin/env bash
#
# Gerenate mp4 videos from a collection of image files
#
# Video files are saved into ./videos
#
# Folder with image files:
src="/home/datawork-lops-oh/somovar/WP1/data/dashboard/img/monthly" # This is an example
@gmaze
gmaze / passing_options.py
Last active March 19, 2020 15:28
Passing/merging options from function to subfunctions
def base_fct(**kwargs):
defaults = {'sharey':'row', 'dpi':80, 'facecolor':'w', 'edgecolor':'k'}
options = {**defaults, **kwargs}
return options
def fct(**kwargs):
defaults = {'sharey':'cols'}
return base_fct(**{**defaults, **kwargs})
print("Default base options:\n", base_fct())
#~/usr/bin/env python
#
# Useful functions for xarray time series analysis
# (c) G. Maze, Ifremer
#
import numpy as np
import xarray as xr
import pandas as pd
from statsmodels.tsa.seasonal import seasonal_decompose
@gmaze
gmaze / obidam_storage.md
Last active May 17, 2018 09:27
OBIDAM: dataset fast access issue

To run data mining algorithms on ocean's large datasets, we need to optimise access to datasets with possibly up to 6-dimensions.

A generalised 6-dimensional dataset is [X,Y,Z,T,V,E] where:

  • X,Y,Z,T are the space/time dimensions,
  • V is the variable dimension (eg: temperature, salinity, zonal velocity) and,
  • E the ensemble dimensions (list of realisations or members).

Running data mining algorithms on this dataset mostly implies to re-arrange the 6 dimensions into 2-dimensional arrays with, following the statistics vocabulary "sampling" vs "features" dimensions. The sampling dimension is along rows, the features along columns. A large dataset can have billions of rows and hundreds of columns.

Eg:

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.