-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add functions for combining multiple outputs, and add to operational …
…workflow
- Loading branch information
1 parent
db03947
commit 860ba32
Showing
5 changed files
with
362 additions
and
5 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,209 @@ | ||
name: combine output | ||
# combine output from all simulations (combinations of forcing) into single files | ||
# so the combined footprint can be viewed | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
MODEL_TYPE: | ||
description: 'what kind of model are we running e.g. oil - a user defined input in run_ops.yml' | ||
required: true | ||
type: string | ||
BRANCH_REF: | ||
description: 'what branch are we on - defined dynamically in run_ops.yml' | ||
required: true | ||
type: string | ||
CONFIG_NAME: | ||
description: 'configuration name - defined dynamically in run_ops.yml' | ||
required: true | ||
type: string | ||
RUN_DATE: | ||
description: 'time of T0 of the croco workflow in format YYYYMMDD_HH - defined dynamically in run_ops.yml' | ||
required: true | ||
type: string | ||
RUNNER_NAME: | ||
description: 'specify the runner name to determine what server we are running on' | ||
required: true | ||
type: string | ||
EXTENTS: | ||
description: 'spatial extent of the gridded output and plot, in format lon0,lon1,lat0,lat1. If None, then this is dynamically determined from the geographic extent of the particles' | ||
required: true | ||
type: string | ||
|
||
env: | ||
# path to the directory containing multiple run directories, as seen inside the local server | ||
DIR_WITH_DIRS: /home/somisana/ops/${{ inputs.BRANCH_REF }}/${{ inputs.RUN_DATE }}/opendrift_${{ inputs.MODEL_TYPE }}/${{ inputs.CONFIG_NAME }} | ||
|
||
jobs: | ||
combine_particle_density: | ||
runs-on: ${{ inputs.RUNNER_NAME }} | ||
steps: | ||
- name: combine gridded particle density files | ||
run: | | ||
docker run \ | ||
--rm \ | ||
--user root \ | ||
-v ${{ env.DIR_WITH_DIRS }}:/mnt/tmp \ | ||
ghcr.io/saeon/somisana-opendrift_${{ inputs.BRANCH_REF }}:latest \ | ||
combine_gridded \ | ||
--dir_with_dirs /mnt/tmp \ | ||
--fname_gridded gridded_particle_density.nc \ | ||
--var_name particle_density | ||
- name: animate the combined gridded particle density | ||
run: | | ||
docker run \ | ||
--rm \ | ||
--user root \ | ||
-v ${{ env.DIR_WITH_DIRS }}:/mnt/tmp \ | ||
ghcr.io/saeon/somisana-opendrift_${{ inputs.BRANCH_REF }}:latest \ | ||
animate \ | ||
--type gridded \ | ||
--config_dir /mnt/tmp/combined \ | ||
--fname_gridded gridded_particle_density.nc \ | ||
--extents ${{ inputs.EXTENTS }} \ | ||
--gif_out gridded_particle_density.gif | ||
- name: plot maximum combined gridded particle density | ||
run: | | ||
docker run \ | ||
--rm \ | ||
--user root \ | ||
-v ${{ env.DIR_WITH_DIRS }}:/mnt/tmp \ | ||
ghcr.io/saeon/somisana-opendrift_${{ inputs.BRANCH_REF }}:latest \ | ||
animate \ | ||
--type gridded_stats \ | ||
--config_dir /mnt/tmp/combined \ | ||
--fname_gridded gridded_particle_density.nc \ | ||
--var_str maximum \ | ||
--cbar_label 'max. particle density (%)' \ | ||
--extents ${{ inputs.EXTENTS }} \ | ||
--jpg_out gridded_particle_density_max.jpg | ||
- name: plot minimum time to arrival | ||
# this doesn't relate to particle density, but just sneaking it into this job | ||
run: | | ||
docker run \ | ||
--rm \ | ||
--user root \ | ||
-v ${{ env.DIR_WITH_DIRS }}:/mnt/tmp \ | ||
ghcr.io/saeon/somisana-opendrift_${{ inputs.BRANCH_REF }}:latest \ | ||
animate \ | ||
--type gridded_stats \ | ||
--config_dir /mnt/tmp/combined \ | ||
--fname_gridded gridded_particle_density.nc \ | ||
--var_str minimum_time \ | ||
--ticks 0,0.5,1,1.5,2,3,5,7 \ | ||
--cbar_label 'minimum time (days)' \ | ||
--extents ${{ inputs.EXTENTS }} \ | ||
--jpg_out gridded_min_time.jpg | ||
combine_surface_oil: | ||
runs-on: ${{ inputs.RUNNER_NAME }} | ||
if: ${{ inputs.MODEL_TYPE == 'oil' }} | ||
steps: | ||
- name: combined surface oil thickness from particles (average over all runs) | ||
run: | | ||
docker run \ | ||
--rm \ | ||
--user root \ | ||
-v ${{ env.DIR_WITH_DIRS }}:/mnt/tmp \ | ||
ghcr.io/saeon/somisana-opendrift_${{ inputs.BRANCH_REF }}:latest \ | ||
combine_gridded \ | ||
--dir_with_dirs /mnt/tmp \ | ||
--fname_gridded gridded_surface_oil.nc \ | ||
--var_name surface_thickness | ||
- name: animate the combined surface oil thickness | ||
run: | | ||
docker run \ | ||
--rm \ | ||
--user root \ | ||
-v ${{ env.DIR_WITH_DIRS }}:/mnt/tmp \ | ||
ghcr.io/saeon/somisana-opendrift_${{ inputs.BRANCH_REF }}:latest \ | ||
animate \ | ||
--type gridded \ | ||
--config_dir /mnt/tmp/combined \ | ||
--fname_gridded gridded_surface_oil.nc \ | ||
--extents ${{ inputs.EXTENTS }} \ | ||
--var_str surface_thickness \ | ||
--ticks 0,0.01,0.1,1,10 \ | ||
--cbar_label 'surface oil thickness ($\mu$m)' \ | ||
--cmap Greys \ | ||
--gif_out gridded_surface_oil.gif | ||
- name: plot maximum surface oil thickness | ||
run: | | ||
docker run \ | ||
--rm \ | ||
--user root \ | ||
-v ${{ env.DIR_WITH_DIRS }}:/mnt/tmp \ | ||
ghcr.io/saeon/somisana-opendrift_${{ inputs.BRANCH_REF }}:latest \ | ||
animate \ | ||
--type gridded_stats \ | ||
--config_dir /mnt/tmp/combined \ | ||
--fname_gridded gridded_surface_oil.nc \ | ||
--extents ${{ inputs.EXTENTS }} \ | ||
--var_str maximum \ | ||
--ticks 0,0.01,0.1,1,10 \ | ||
--cbar_label 'max. surface oil thickness ($\mu$m)' \ | ||
--cmap Greys \ | ||
--jpg_out gridded_surface_oil_max.jpg | ||
combine_stranded_oil: | ||
runs-on: ${{ inputs.RUNNER_NAME }} | ||
if: ${{ inputs.MODEL_TYPE == 'oil' }} | ||
steps: | ||
- name: combined gridded stranded oil concentration (average over all runs) | ||
run: | | ||
docker run \ | ||
--rm \ | ||
--user root \ | ||
-v ${{ env.DIR_WITH_DIRS }}:/mnt/tmp \ | ||
ghcr.io/saeon/somisana-opendrift_${{ inputs.BRANCH_REF }}:latest \ | ||
combine_gridded \ | ||
--dir_with_dirs /mnt/tmp \ | ||
--fname_gridded gridded_stranded_oil.nc \ | ||
--var_name stranded_oil | ||
- name: plot maximum stranded oil concentration | ||
run: | | ||
docker run \ | ||
--rm \ | ||
--user root \ | ||
-v ${{ env.DIR_WITH_DIRS }}:/mnt/tmp \ | ||
ghcr.io/saeon/somisana-opendrift_${{ inputs.BRANCH_REF }}:latest \ | ||
animate \ | ||
--type gridded_stats \ | ||
--config_dir /mnt/tmp/combined \ | ||
--fname_gridded gridded_stranded_oil.nc \ | ||
--extents ${{ inputs.EXTENTS }} \ | ||
--var_str maximum \ | ||
--ticks 0,10,20,50,100,200,500,1000 \ | ||
--cbar_label 'max. stranded oil (g m$^{-2}$)' \ | ||
--cmap plasma \ | ||
--jpg_out gridded_stranded_oil_max.jpg | ||
# copy data over to where it will be archived | ||
archive: | ||
needs: [combine_particle_density,combine_surface_oil,combine_stranded_oil] | ||
runs-on: ${{ inputs.RUNNER_NAME }} | ||
env: | ||
ARCHIVE_DIR: /mnt/saeon-somisana/data/opendrift/${{ inputs.RUN_DATE }}/${{ inputs.CONFIG_NAME }}/combined | ||
steps: | ||
- name: copy files to the archive directory if needed | ||
run: | | ||
# start by changing ownership of all files to the somisana user | ||
sudo chown -R somisana:somisana ${{ env.DIR_WITH_DIRS }}/combined | ||
# only copy if we're on the main branch | ||
# we need to use sudo since the archive directory is owned by root | ||
# we have set up the somisana user to be able to do this without the need for a password | ||
if [ ${{ inputs.BRANCH_REF }} = "main" ]; then | ||
if [ ! -d ${{ env.ARCHIVE_DIR }} ]; then | ||
sudo mkdir -p ${{ env.ARCHIVE_DIR }} | ||
sudo chmod -R 775 ${{ env.ARCHIVE_DIR }} | ||
fi | ||
sudo cp -f ${{ env.DIR_WITH_DIRS }}/combined/*.nc ${{ env.ARCHIVE_DIR }} | ||
sudo cp -f ${{ env.DIR_WITH_DIRS }}/combined/*.gif ${{ env.ARCHIVE_DIR }} | ||
sudo cp -f ${{ env.DIR_WITH_DIRS }}/combined/*.jpg ${{ env.ARCHIVE_DIR }} | ||
fi |
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
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
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
Oops, something went wrong.