Scripts, small utilities & tutorials

‘Spectral’ colormap/palette for Matlab/Octave

This function implements the so-called ‘spectral’ palette of ColorBrewer into Matlab/Octave.

Ocean Data View (ODV) colormap/palette for Matlab/Octave

This function implements the colormap/palette from Ocean Data View (ODV) into Matlab/Octave.

Creation of a model grid for ROMS

I wrote down my notes on how I create a model grid for ROMS. It is a work in progress and I will be adding details gradually: doc_grid_creation_roms.pdf (2023-09-18)

Artificial ponding

Artificial ponding is when a hydrodynamic model struggles to reproduce the draining of flooded areas as the water level recedes, leading to the formation of artificial ponds (e.g., Deb et al. 2023). This Matlab/Octave function does not prevent artificial ponding from occurring but it is useful for masking the artificial ponds while visualizing outputs from Rutgers ROMS.

Streamfunctions

This utility fits a streamfunction to a 2-D flow field using Landweber iteration. The flow field is the only input required (in contrast with traditional methods requiring boundary conditions to be specified). The utility is written in Fortran-95 and includes a Matlab/Octave wrapper for convenience. The implementation assumes that the 2-D flow field is on an Arakawa-C grid of uniform mesh size (dx=dy=constant).
Download: get_strfct_landweber.zip

Energy spectral density heatmaps

I wrote down my notes on how to obtain an Energy Spectral Density (ESD) heatmap with time on the horizontal axis, frequency on the vertical axis, and a colorscale with units of squared amplitude / frequency. The latter is not always easy to obtain; many methods will produce a colorscale with relative units (e.g., decibels) that are meaningful within a specific ESD, but not comparable from one ESD to another. The ESD are computed in Matlab/Octave using the freely available LTFAT toolbox.
Download: Notes (PDF) (2021-06-28)

Portable video from still images

I wrote down my notes on how to create a portable video, i.e., one that will work across platforms and devices. In this case the video is created from still images.

  1. Generate the images sequentially with a suitable filename, e.g., frame0001.png, frame0002.png… In Octave/Matlab, it would look something like:
    print( '-dpng', [ 'frame' num2str( i, '%04u' ) '.png' ] );
  2. ffmpeg -i frame%04d.png -c:v libx264 -preset slow -pix_fmt yuv420p my_video.mp4

libx264 is the non-proprietary implementation of the H.264 video encoding format. The option -pix_fmt yuv420p is necessary for the video to work under QuickTime (Mac) and Windows Media Player. If the video plays too fast, a quick remedy is to repeat each frame a few times (three times in this example) during the encoding:
ffmpeg -i frame%04d.png -vf "setpts=3.0*PTS" -c:v libx264 -preset slow -pix_fmt yuv420p my_video.mp4

Archiving large datasets on an external drive (tutorial)

External drives of large capacity (≥ 5TB) are convenient tools to store/archive the datasets generated by remote HPC clusters (such a XSEDE). I wrote down my notes on how to directly transfer a dataset from the cluster to the drive using Globus and ensure its integrity. The procedure doesn't require scp/sftp access, doesn't require administrative (root) privileges on the local machine, and doesn't require local disk resources other than the external drive. The tutorial was written for graduate students at VIMS but should be easily adaptable.
Download: Tutorial (PDF) (2019-05-26)