Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
gbrencher committed May 30, 2024
2 parents 7bdeb59 + d3947c6 commit 5b78fa7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
27 changes: 16 additions & 11 deletions .github/workflows/batch_image_correlation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ on:
type: choice
required: true
description: number of pairs per image
default: '3'
default: '1'
options: ['3','2','1']

# Must duplicate inputs for workflow_call (https://github.com/orgs/community/discussions/39357)
Expand Down Expand Up @@ -78,6 +78,7 @@ jobs:
from dask.distributed import Client
import dask
import json
import pandas as pd
# GDAL environment variables for better performance
os.environ['AWS_REGION']='us-west-2'
Expand Down Expand Up @@ -114,22 +115,26 @@ jobs:
# filter to specified month range
sentinel2_stack_snowoff = sentinel2_stack.where((sentinel2_stack.time.dt.month >= ${{ inputs.start_month }}) & (sentinel2_stack.time.dt.month <= ${{ inputs.stop_month }}), drop=True)
image_dates = sentinel2_stack_snowoff.time.dt.strftime('%Y-%m-%d').values.tolist()
print('\n'.join(image_dates))
# select first image of each month
period_index = pd.PeriodIndex(sentinel2_stack_snowoff['time'].values, freq='M')
first_image_indices = sentinel2_stack_snowoff.groupby('year_month').apply(lambda x: x.isel(time=0))
product_names = first_image_indices['s2:product_uri'].values.tolist()
print('\n'.join(product_names))
# Create Matrix Job Mapping (JSON Array)
pairs = []
for r in range(len(image_dates) - ${{ inputs.npairs }}):
for r in range(len(product_names) - ${{ inputs.npairs }}):
for s in range(1, ${{ inputs.npairs }} + 1 ):
img1_date = image_dates[r]
img2_date = image_dates[r+s]
shortname = f'{img1_date}_{img2_date}'
pairs.append({'img1_date': img1_date, 'img2_date': img2_date, 'name':shortname})
img1_product_name = product_names[r]
img2_product_name = product_names[r+s]
shortname = f'{img1_product_name[11:19]}_{img2_product_name[11:19]}'
pairs.append({'img1_product_name': img1_product_name, 'img2_product_name': img2_product_name, 'name':shortname})
matrixJSON = f'{{"include":{json.dumps(pairs)}}}'
print(f'number of image pairs: {len(pairs)}')
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
print(f'IMAGE_DATES={image_dates}', file=f)
print(f'IMAGE_DATES={product_names}', file=f)
print(f'MATRIX_PARAMS_COMBINATIONS={matrixJSON}', file=f)
Expand All @@ -142,6 +147,6 @@ jobs:
name: ${{ matrix.name }}
uses: ./.github/workflows/image_correlation_pair.yml
with:
img1_date: ${{ matrix.img1_date }}
img2_date: ${{ matrix.img2_date }}
img1_date: ${{ matrix.img1_product_name }}
img2_date: ${{ matrix.img2_product_name }}
workflow_name: ${{ matrix.name }}
25 changes: 10 additions & 15 deletions .github/workflows/image_correlation_pair.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ run-name: ${{ inputs.workflow_name }}
on:
workflow_dispatch:
inputs:
img1_date:
img1_product_name:
type: string
required: true
description: S2 image 1 date
default: 2022-06-24
img2_date:
description: S2 image 1 product name
default: 'S2A_MSIL2A_20200629T054641_N0500_R048_T43SEA_20230505T184918.SAFE'
img2_product_name:
type: string
required: true
description: S2 image 2 date
default: 2022-09-27
description: S2 image 2 product name
default: 'S2B_MSIL2A_20200922T054639_N0500_R048_T43SEA_20230624T184729.SAFE'
workflow_name:
description: 'Custom workflow name'
required: false
Expand All @@ -27,10 +27,10 @@ on:
inputs:
img1_date:
type: string
description: S2 image 1 date
description: S2 image 1 product name
img2_date:
type: string
description: S2 image 2 date
description: S2 image 2 product name
workflow_name:
description: 'Custom workflow name'
type: string
Expand Down Expand Up @@ -62,13 +62,8 @@ jobs:
- name: download data and run autoRIFT software
run: |
python glacier_image_correlation/image_correlation.py \
${{ inputs.img1_date }} \
${{ inputs.img2_date }}
- name: Get Dates for Output Subfolder Name
run: |
PREFIX=${REF:17:8}_${SEC:17:8}
echo "PREFIX=${PREFIX}" >> $GITHUB_ENV
${{ inputs.img1_product_name }} \
${{ inputs.img2_product_name }}
- name: Upload velocity
uses: actions/upload-artifact@v4
Expand Down

0 comments on commit 5b78fa7

Please sign in to comment.