Skip to content

Commit

Permalink
Created an examples folder to do testing on real data
Browse files Browse the repository at this point in the history
  • Loading branch information
mrayson committed Oct 27, 2020
1 parent 7a017be commit 32bf979
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# SFODA Examples
10 changes: 10 additions & 0 deletions examples/get_example_data.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Download example data
DATADIR=tmpdata
IWAVEATLASURL="https://cloudstor.aarnet.edu.au/plus/s/DnOYpT3ZPnqjNsS/download"
IWAVEATLASFILE=NWS_2km_GLORYS_hex_2013_2014_SSHBC_Harmonics.nc

# IWAVE atlas from a cloudstor public repo
cd $DATADIR
echo "Downloading internal wave atlas netcdf data ~160 GB"
echo $IWAVEATLASURL $IWAVEATLASFILE
curl $IWAVEATLASURL -o $IWAVEATLASFILE
30 changes: 30 additions & 0 deletions examples/load_suntans_nc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
Load an example suntans netcdf file
"""

import matplotlib.pyplot as plt
from sfoda.suntans import sunxray

# get the sfoda path
import os
import sfoda
_path = os.path.abspath(sfoda.__file__)
_dirpath = os.path.dirname(_path)


ncfile = "{}/../tmpdata/NWS_2km_GLORYS_hex_2013_2014_SSHBC_Harmonics.nc".format(_dirpath)
print('Loading suntans data from:\n\t{}'.format(ncfile))

sun = sunxray.Sunxray(ncfile)
print(sun)

# Xarray object is stored in the ._ds attribute
# To interface with the data
data = sun._ds['SSH_BC_var']
# Plot some data
print(data)
plt.figure()
sun.plotcelldata(data)
plt.show()


112 changes: 112 additions & 0 deletions examples/run_sfoda_cloudstor.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Shows how to install and run [SFODA](https://github.com/mrayson/sfoda.git) in a cloudstor SWAN session\n",
"\n",
"To install this notebook run:\n",
"\n",
" `!curl <insert_git_url> -o run_sfoda_cloudstor.ipynb` \n",
" \n",
"in a SWAN notebook"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Install SFODA and dependencies via pip\n",
"!pip install git+https://github.com/mrayson/sfoda.git --user"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Download some test netcdf data (~160 GB)\n",
"!curl https://cloudstor.aarnet.edu.au/plus/s/DnOYpT3ZPnqjNsS/download -o NWS_2km_GLORYS_hex_2013_2014_SSHBC_Harmonics.nc"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"from sfoda.suntans.sunxray import Sunxray\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Load the suntans object\n",
"basedir = './'\n",
"ncfile = 'NWS_2km_GLORYS_hex_2013_2014_SSHBC_Harmonics.nc'.format(basedir)\n",
"\n",
"sun = Sunxray(ncfile)\n",
"sun\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# The xarray obect is stored in the ._ds attribute\n",
"# data can be referenced directly via e.g.\n",
"data = sun._ds['SSH_BC_var']\n",
"data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Use inbuilt plotting methods for quick plotting\n",
"plt.figure(figsize=(12,6))\n",
"sun.plotcelldata(data, vmax=5e-3, cmap='Reds')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
File renamed without changes.
File renamed without changes.

0 comments on commit 32bf979

Please sign in to comment.