Skip to content

Instantly share code, notes, and snippets.

View raphaeldussin's full-sized avatar

raphael dussin raphaeldussin

View GitHub Profile
@raphaeldussin
raphaeldussin / read+write_input_mitgcm.py
Last active January 10, 2019 15:18
playing with MITgcm input files
#!/usr/bin/env python
import numpy as np
import sys
# playing with input files from tutorial_global_oce_latlon
filein = 'lev_t.bin'
# MITgcm likes its binary in big endian, float ('>f') or double ('>d')
raw = np.fromfile(filein, dtype='>f')
#!/usr/bin/env python
import numpy as np
import struct
def write_new_data(data,fileout):
fid = open(fileout, "wb")
flatdata = data.flatten()
for kk in np.arange(len(flatdata)):
tmp = struct.pack('>d',flatdata[kk])

Keybase proof

I hereby claim:

  • I am raphaeldussin on github.
  • I am raphaeldussin (https://keybase.io/raphaeldussin) on keybase.
  • I have a public key ASDelxZLvjXQhqoc0gM86v23mA7H7Z3QzcvuWKWvo51O0Ao

To claim this, I am signing this object:

@raphaeldussin
raphaeldussin / apple_keyboard_linux.txt
Last active April 26, 2019 17:30
french apple keyboard on macbook pro running debian
# this works with the laptop's keyboard fine:
>>> more /etc/default/keyboard
# KEYBOARD CONFIGURATION FILE
# Consult the keyboard(5) manual page.
XKBMODEL="macintosh"
XKBLAYOUT="fr"
pic_start = cftime.num2date(0, 'days since 0001-01-01')
pic_end = cftime.num2date(1200*365.25, 'days since 0001-01-01')
plt.figure(figsize=[8,6])
ax1 = plt.subplot(211)
plt.plot(ds_nadw_CM4_piC['time'], ds_nadw_CM4_piC['vol_nadw_atl'], 'k')
ax1.set_xlim([pic_start, pic_end])
ax2 = plt.subplot(212)
plt.plot(ds_nadw_CESM2_piC['time'], ds_nadw_CESM2_piC['vol_nadw_atl'], 'r')
ax2.set_xlim([pic_start, pic_end])
# this is a wrong & stupid computation, just here for example
pt = xr.apply_ufunc(gsw.pt0_from_t, ds.so, ds.thetao, ds.z_l, dask='parallelized', output_dtypes=[ds.so.dtype])
@raphaeldussin
raphaeldussin / roms_to_zarr.py
Last active June 8, 2020 13:50
convert ROMS output to zarr
#!/usr/bin/env python
# useful ref:
# http://xarray.pydata.org/en/stable/examples/ROMS_ocean_model.html
import xarray as xr
import glob
# list of files to convert
@raphaeldussin
raphaeldussin / mom6_slurm_job.bash
Created July 6, 2020 20:51
run script for MOM6 using SLURM batch scheduler
#!/bin/bash
#SBATCH -n 240
#SBATCH -J MOM6
#SBATCH --error=MOM6.err
#SBATCH --output=MOM6.out
#SBATCH --exclusive
njobs=40
#--------------------------------- system settings ----- ---------------------------
#!/bin/bash
# for PPAN, replace gfdl-ws by gfdl
git clone https://github.com/NOAA-GFDL/FRE-NCtools
pushd FRE-NCtools
here=$(pwd)
export CONFIG_SITE=${here}/site-configs/gfdl-ws/config.site
source ${here}/site-configs/gfdl-ws/env.sh
@raphaeldussin
raphaeldussin / func1_roms2zarr.py
Created December 3, 2020 02:09
function for the roms2zarr tutorial
def remove_all_small_variables(ds):
""" remove all the variables that have less than 3 dimensions
Parameters:
ds (xarray.Dataset): ROMS dataset
"""
for v in ds.variables:
if v not in ['Cs_r', 'Cs_w', 'hc', 'Vtransform', 'ocean_time']:
ds = ds.drop_vars(v) if len(ds[v].dims) < 3 else ds
return ds