Skip to content

Commit

Permalink
add FES2022 setup document
Browse files Browse the repository at this point in the history
  • Loading branch information
kvos committed Oct 3, 2024
1 parent f290f5b commit a25af4f
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 404,7 @@ In order to tidally-correct the time-series of shoreline change, two inputs are

In the notebook, the user has two options for the tide level time-series:
- **Option 1**: use a CSV file with the time-series of water levels (at least 15/30 min timestep). Note that this file should be formatted as the one provided in */examples* [NARRA_tides.csv](https://github.com/kvos/CoastSat/blob/master/examples/NARRA_tides.csv). Dates should be in UTC time and tides in metres above mean sea level.
- **Option 2**: use the [FES2022](https://www.aviso.altimetry.fr/en/data/products/auxiliary-products/global-tide-fes/release-fes22.html) global tide model to predict tide levels at your beach. This requires you to have FES2022 setup, instructions available here (TO BE COMPLETED).
- **Option 2**: use the [FES2022](https://www.aviso.altimetry.fr/en/data/products/auxiliary-products/global-tide-fes/release-fes22.html) global tide model to predict tide levels at your beach. This requires you to have FES2022 setup, follow the instructions in [this document](./doc/FES2022_setup). Once installed, you can predict tides for any dates at any location in the world!

![example_tides](https://github.com/user-attachments/assets/f0b0c29d-2db8-450c-86f2-73614a6a0940)

Expand Down
84 changes: 84 additions & 0 deletions doc/FES2022_setup.md
Original file line number Diff line number Diff line change
@@ -0,0 1,84 @@
# SETUP OF FES2022

This document shows how to setup the FES2022 global tide model to get modelled tides at a given location for a given time period.

## 1. Install CoastSat (starting by pyfes)
If you have already installed `coastsat` before, create a new environment with a new name, as you will need to install `pyfes` first otherwise there are conflicts with the python version.

1. Download Anaconda for your operating system https://docs.anaconda.com/anaconda/install/windows/
2. Open the Anaconda Prompt as Administrator and type the following commands:
```
conda clean --all -y
conda update -n base -c conda-forge conda -y
conda create -n coastsat
conda activate coastsat
conda install fbriol::pyfes -y
conda install -c conda-forge geopandas -y
conda install -c conda-forge earthengine-api scikit-image matplotlib astropy notebook -y
pip install pyqt5 imageio-ffmpeg
```
Now you have setup the `coastsat` python environment, which can be activated with `conda activate coastsat`.

Either clone the Github repository https://github.com/kvos/CoastSat or download the zip folder and unzip in a local folder.

## 2. Download FES2022 netcdf files

- Go to [this location](https://unsw-my.sharepoint.com/personal/z2273773_ad_unsw_edu_au/_layouts/15/onedrive.aspx?id=/personal/z2273773_ad_unsw_edu_au/Documents/RESEARCH2/FES 2022/fes2022b&ga=1) and download the all the files and put them in a folder. These are the netcdf file containing the tidal constituents for the whole world.

- Open the `fes2022.yaml` file in a text editor and change the path to each of the tidal constituents (individual netcdf files). Add the absolute path to each .nc file, an example is shown below. You can use find and replace to do this in one go. It should look like below:
```
radial:
cartesian:
amplitude: amplitude
latitude: lat
longitude: lon
paths:
2N2: C:\Users\kilia\Documents\GitHub\CoastSat\fes2022b\load_tide\2n2_fes2022.nc
Eps2: C:\Users\kilia\Documents\GitHub\CoastSat\fes2022b\load_tide\eps2_fes2022.nc
J1: C:\Users\kilia\Documents\GitHub\CoastSat\fes2022b\load_tide\j1_fes2022.nc
K1: C:\Users\kilia\Documents\GitHub\CoastSat\fes2022b\load_tide\k1_fes2022.nc
K2: C:\Users\kilia\Documents\GitHub\CoastSat\fes2022b\load_tide\k2_fes2022.nc
L2: C:\Users\kilia\Documents\GitHub\CoastSat\fes2022b\load_tide\l2_fes2022.nc
Lambda2: C:\Users\kilia\Documents\GitHub\CoastSat\fes2022b\load_tide\lambda2_fes2022.nc
etc...
```
Make sure to do this for both `radial` and `tide` parts of the file.
Your Python environment can map shorelines and predict tides anywhere in the world.
## Test that it's working
To test your installation, open the Anaconda Prompt.
Activate the coastsat environment and open Python:
- `conda activate coastsat`
- `python`
Locate the path to your `fes2022.yaml` file and copy it. Then type:
- `import pyfes`
- `filepath = PATH_TO_fes2022.yaml`
- `handlers = pyfes.load_config(config)`
This last command may take 5 minutes to run but if it doesn't return an error you are all good to go.
You can now generate tide time-series using FES2022 for any location and any dates.
## Example
```
# load pyfes and the global tide model (may take one minute)
import pyfes
filepath = os.path.join(os.pardir,'CoastSat.webgis','aviso-fes-main','data','fes2022b')
config = os.path.join(filepath, 'fes2022.yaml')
handlers = pyfes.load_config(config)
ocean_tide = handlers['tide']
load_tide = handlers['radial']
# load coastsat module to estimate slopes
from coastsat import SDS_slopes

# get centroid, date range and timestep
centroid = [151.3023463 -33.7239154]
date_range = [pytz.utc.localize(datetime(2024,1,1)),
pytz.utc.localize(datetime(2025,1,1))]
timestep = 900 # in seconds

# predict tides
dates_ts, tides_ts = SDS_slopes.compute_tide(centroid, date_range, timestep, ocean_tide, load_tide)
```
2 changes: 1 addition & 1 deletion example_jupyter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 853,7 @@
"For this example, measured water levels for Sydney are stored in a csv file located [here](https://github.com/kvos/CoastSat/blob/master/examples/NARRA_tides.csv) and we assume that the beach slope at Narrabeen-Collaroy is 0.1 along all transects.\n",
"\n",
"If you are running a different site, you have two options to get the tide levels:\n",
"- **Option 1**: use the [FES2022](https://www.aviso.altimetry.fr/en/data/products/auxiliary-products/global-tide-fes/release-fes22.html) global tide model to predict tide levels at the time of image acquisition. You can follow the instructions here to setup the model (TO BE COMPLETED).\n",
"- **Option 1**: use the [FES2022](https://www.aviso.altimetry.fr/en/data/products/auxiliary-products/global-tide-fes/release-fes22.html) global tide model to predict tide levels at the time of image acquisition. To setup FES2022 on your machine follow the instructions in [this document](https://github.com/kvos/CoastSat/blob/master/doc/FES2022_setup).\n",
"- **Option 2**: provide your own tide level time-series. When using your own file make sure that the dates are in UTC time, as the CoastSat shorelines are also in UTC, and the datum for the water levels is approx. Mean Sea Level.\n",
"\n",
"We will also see further down how to estimate beach slopes using the [CoastSat.slope](https://github.com/kvos/CoastSat.slope) repository (see [this publication](https://doi.org/10.1029/2020GL088365) for more details, open acess preprint [here](https://www.essoar.org/doi/10.1002/essoar.10502903.1)). Instructions on how to install the global tide model are available [here](https://github.com/kvos/CoastSat.slope/blob/master/doc/FES2014_installation.md)."
Expand Down

0 comments on commit a25af4f

Please sign in to comment.