-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created an examples folder to do testing on real data
- Loading branch information
Showing
6 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# SFODA Examples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.