-
Notifications
You must be signed in to change notification settings - Fork 0
executable file
·248 lines (235 loc) · 10.1 KB
/
combine_output.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
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
DX_M:
description: 'grid size (m) used to grid particle output. If None, If None, then a 50 x 50 regular grid is generated'
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_trajectories:
runs-on: ${{ inputs.RUNNER_NAME }}
steps:
- name: combine trajectories files
run: |
docker run \
--rm \
--user root \
-v ${{ env.DIR_WITH_DIRS }}:/mnt/tmp \
ghcr.io/saeon/somisana-opendrift_${{ inputs.BRANCH_REF }}:latest \
combine_trajectories \
--dir_with_dirs /mnt/tmp
combine_particle_density:
needs: [combine_trajectories]
runs-on: ${{ inputs.RUNNER_NAME }}
steps:
# I'm specifically not using the combine_gridded function here, as this creates the average over all runs
# This is more relevant for say oil thickness, but for particle density I think it is better to create
# The particle density again directly from the combined trajectories file (you can't do this for oil
# as you'll end up with unrealistic oil thicknesses as you keep adding runs...)
#- 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: combined gridded particle density from combined particles
run: |
docker run \
--rm \
--user root \
-v ${{ env.DIR_WITH_DIRS }}:/mnt/tmp \
ghcr.io/saeon/somisana-opendrift_${{ inputs.BRANCH_REF }}:latest \
grid_particles \
--config_dir /mnt/tmp/combined \
--fname trajectories.nc \
--fname_gridded gridded_particle_density.nc \
--grid_type density \
--extents ${{ inputs.EXTENTS }} \
--dx_m ${{ inputs.DX_M }}
- 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:
needs: [combine_trajectories]
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:
needs: [combine_trajectories]
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]
if: always() # Ensure this job runs, even if the oil jobs are skipped
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