TUFLOW FV Get Ocean

From TUFLOW FV Wiki
Jump to navigation Jump to search

Introduction

This tutorial demonstrates how to run the Get Ocean python command line tool using conda. This tool is used to assist with downloading and processing HYCOM ocean data used for TUFLOW FV ocean boundary conditions, including:

  • Mean sea level surface anomaly
  • 3D ocean currents
  • 3D distribution of ocean salinity
  • 3D distribution of ocean temperature

All data is supplied by the HYCOM consortium. Please refer to the HYCOM data acknowledgement and disclaimer.

Example - Downloading HYCOM Data For The Gulf Of Carpentaria

To use Get Ocean, follow the steps outlined as follows:

1. Ensure that you have successfully created a TUFLOW FV Python environment by following the instructions within TUFLOW FV Python Environment - TUFLOW FV Wiki.
2. Open Anaconda Prompt, and activate your TUFLOW FV Python environment with the command:

  conda activate tfv-workspace

Activate tfv-workspace.png

3. In this example, we have chosen to work in the “C:\TUFLOW\Get_Tools\my_ocean” directory, however you can select any location you like. Navigate to the directory you wish to work in through the command:

  cd <directory>

GetOcean cd my ocean.png

Please note: To successfully change your directory location, you must be working out of the same drive that you wish to access. To change drives, enter the command:

  <drive>

GetOcean change drive.png

4. Enter the following command to see the program setup:

  GetOcean

This command will show the two sub-program options:

A)    GetOcean A Download raw data files

B)    GetOcean B Merge the raw data files

GetOcean.png


5. Prior to downloading any data we'll first check the arguments by calling program A, and typing “-h” for help:

  GetOcean A -h

GetOcean A -h.png

6. Form up a command with the minimum required positional arguments to now download the data, as per the example below:

  GetOcean A 2010-03-01 2010-05-01 135 143 -19 -7

This will download HYCOM files for 01/03/2010 to 01/05/2010 (dd/mm/yyyy) on a daily time interval (the default time interval) for the bounding box (bbox) of 135oE 143oE 19oS 7oS (Gulf of Carpentaria), for all depth levels.

By default, the files will be downloaded into the same directory from where the tool is being called, and will have the name format: “HYCOM_<date>.nc”

Optional arguments can be supplied to select a subset of z-levels, to put the data files into a sub-directory, to give the files a custom name prefix, or download higher temporal resolution data.

For example, the following command will download only the top 75m of data, save the data to the folder “raw_data” (must exist before running), will name the files “GoC_HYCOM_<date>.nc”, and will download 3-hourly data.

  GetOcean A -p raw_data -pf GoC_HYCOM -ts 3 -z 0 75 2010-03-01 2010-05-01 135 143 -19 -7

GetOcean download data.png

7. Now you wait. Downloading HYCOM can take several hours, particularly if you are collecting 3-hourly increment data.

To save time, you may have up to 2-concurrent connections to the HYCOM server per IP address, so you may run this program twice.  For example, if you are collecting data across two years, you could use two separate conda windows to concurrently download the first and second year.

Be careful that you are not using a shared PC when running this program - you don't want to lock yourself, or others, out of the HYCOM server.

If your download ends prematurely for any reason, you can simply restart the CLI tool and it will detect files that have already been collected, so long as the “—prefix” / “-pf” argument remains the same.

GetOcean download data complete.png


The downloaded HYCOM files should appear in your specified output directory as below.


GetOcean downloaded files.png


8. Once your data has finished downloading it can be merged ready for TUFLOW FV using the “GetOcean B” Program. Prior to merging your raw data we'll first check the arguments by calling program B, and typing “-h” for help:

  GetOcean B -h

GetOcean B -h.png


9. All arguments to this program are optional. By default, the program will try to merge all the files located in the (“./raw”) directory, and will automatically assign an output name, and provide a boundary condition file ready to be directly read in by TUFLOW FV.

This command can be customised to help with reprojection, add a local timezone, or pad nans downwards by depth.

A more complete example is shown below, which takes all the files located in “raw_data” and outputs a merged file called “GoC_HYCOM_20100301_20100501_AEST.nc” into “merged_data”.

This script also adds second time variable local_time that is offset by 10 hrs, and is labelled as "AEST".

  GetOcean B -i raw_data -o merged_data -tz 10 -ltz AEST -n GoC_HYCOM_20100301_20100501_AEST.nc

GetOcean merge data.png


Please note: It is highly recommended to add the start, end, and timezone to your output file name. For example MyArea_20220201_20220401_UTC.nc, indicates that the data in this file is available from the 1st of February, 2022 to 1st of April, 2022 and is in the UTC timezone. If this convention is adhered to, it can save time and reduce errors and confusion when dealing with boundary conditions.

Review Get Ocean Outputs

Get Ocean produces a single NetCDF file which contains the merged downloaded data. Using xarray to inspect this NetCDF, we see it has the structure and properties shown below:


GetOcean xarray netcdf.png


When Get Ocean merges the downloaded data into a single NetCDF file, it also creates an fvc file in the same location.


GetOcean outputs.png


Within this fvc file, you will find that Get Ocean has written your open ocean boundary conditions for you. All you need to do is list the open boundary nodestrings and replace “-0.5” with the relevant surface HYCOM mean sea level elevation offset for your study area and time period, as indicated below:


GetOcean fvc.png


These boundary conditions can then be incorporated into your TUFLOW FV model through an include statement, as shown below. This include statement will reference GoC_HYCOM_AEST.fvc, so that the commands it contains will be read by TUFLOW FV.


GetOcean include command.png

Conclusion

For further information on Get Ocean, please visit our GitLab page.

To learn how to use our other Python utilities, please visit our TUFLOW FV Python Toolbox, TUFLOW FV Get Tide and TUFLOW FV Get Atmos pages.

To see how to implement the most common TUFLOW FV model design features, please access our TUFLOW FV Example Models page.

To complete tutorials or learn more tips and tricks, please return to the TUFLOW FV Wiki Mainpage.

If you have any further queries, feedback or requests for new functionality, please feel free to get in contact with support@tuflow.com