-
Notifications
You must be signed in to change notification settings - Fork 0
217 lines (190 loc) · 7.37 KB
/
timeseries_SLC.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
# n+1, n+2, n+3 pairs for a given burst + year
name: TimeseriesSLC
run-name: Phase ${{ inputs.year }} ${{ inputs.fullBurstID }} ${{ inputs.polarization }} ${{ inputs.nlooks }} ${{ inputs.npairs }}
on:
workflow_dispatch:
inputs:
fullBurstID:
type: string
required: true
description: ESA Burst Identifier (RelativeObit, ID, Subswath)
default: '012_023790_IW1'
polarization:
type: choice
required: true
description: Polarization
default: 'VV'
options: ['VV', 'VH', 'HH']
year:
type: string
required: true
description: Year
default: '2024'
nlooks:
type: choice
required: true
description: Range x Azimuth Looks
default: '20x4'
options: ['20x4','10x2','5x1']
npairs:
type: choice
required: true
description: Number of Pairs per Reference
default: '3'
options: ['3','2','1']
# Convert inputs to environment variables for all job steps
env:
FullBurstId: ${{ inputs.fullBurstID }}
Year: ${{ inputs.year }}
Polarization: ${{ inputs.polarization }}
NLooks: ${{ inputs.nlooks }}
NPairs: ${{ inputs.npairs }}
jobs:
searchASF:
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
BURST_IDS: ${{ steps.asf-search.outputs.BURST_IDS }}
MATRIX: ${{ steps.asf-search.outputs.MATRIX_PARAMS_COMBINATIONS }}
defaults:
run:
shell: bash -el {0}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install Conda environment with Micromamba
uses: mamba-org/setup-micromamba@v1
with:
cache-environment: true
environment-file: environment.yml
# https://words.yuvi.in/post/python-in-github-actions/
- name: Search ASF for bursts
id: asf-search
shell: bash -el -c "python -u {0}"
run: |
import asf_search as asf
import fsspec
import geopandas as gpd
import json
import os
# Parse Workflow inputs from environment variables
START = int(os.environ['Year'])
END = START+1
POL = os.environ['Polarization']
FULLBURSTID = os.environ['FullBurstId']
RELORB,BURSTID,SUBSWATH = FULLBURSTID.split('_')
print(RELORB,BURSTID,SUBSWATH)
# Get centroid of burst from database
url = 'https://github.com/relativeorbit/s1burstids/raw/main/burst_map_IW_000001_375887_brotli.parquet'
with fsspec.open(url) as file:
gfb = gpd.read_parquet(file,
filters=[('burst_id', '=', int(BURSTID)),
('subswath_name', '=', SUBSWATH)]
)
print(gfb)
# Search for SLCs
results = asf.search(platform=[asf.PLATFORM.SENTINEL1],
processingLevel=asf.PRODUCT_TYPE.SLC,
beamMode=asf.BEAMMODE.IW,
intersectsWith=gfb.iloc[0].geometry.centroid.wkt,
relativeOrbit=int(RELORB),
start=f"{START}-01-01",
end=f"{END}-03-01", #march to ensure we get some overlapping coverage for each year
)
gf = gpd.GeoDataFrame.from_features(results.geojson(), crs=4326)
print('Results:', len(gf))
# For case of frame overlap, ensure SLCs contain full burst
def get_overlap_area(gf, gfREF):
frame_area = gfREF.iloc[0].geometry.area
overlaps = gf.geometry.map(lambda x: x.intersection(gfREF.geometry.iloc[0]).area/frame_area)
return overlaps
gf['overlap'] = get_overlap_area(gf, gfb)
gf = gf.query('overlap >= 0.80').reset_index(drop=True)
# Sort chronological ascending
gf['datetime'] = gpd.pd.to_datetime(gf.startTime)
gf = gf.sort_values(by='datetime', ignore_index=True)
print('Number of Acquisitions: ', len(gf))
burstIDs = gf.sceneName.to_list()
print('\n'.join(burstIDs))
# Create Matrix Job Mapping (JSON Array)
idx_end_of_year = gf.index[gf.datetime.dt.year == START][-1]
pairs = []
for r in range(idx_end_of_year + 1):
for s in range(1, ${{ inputs.npairs }} + 1 ):
ref = burstIDs[r]
sec = burstIDs[r+s]
shortname = f'{ref[17:25]}_{sec[17:25]}'
pairs.append({'reference': ref, 'secondary': sec, 'name':shortname})
matrixJSON = f'{{"include":{json.dumps(pairs)}}}'
print(f'Number of Interferograms: {len(pairs)}')
print(matrixJSON)
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
print(f'BURST_IDS={burstIDs}', file=f)
print(f'MATRIX_PARAMS_COMBINATIONS={matrixJSON}', file=f)
hyp3-isce2:
needs: searchASF
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
strategy:
matrix: ${{ fromJson(needs.searchASF.outputs.MATRIX) }}
continue-on-error: true
name: ${{ matrix.name }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
repository: 'relativeorbit/hyp3-isce2'
ref: 'backprocess'
- name: Install Conda environment with Micromamba
uses: mamba-org/setup-micromamba@v1
with:
cache-environment: true
environment-file: environment.yml
- name: Development install
run: pip install -e .
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
- name: Get Bucket Prefix
env:
REF: ${{ matrix.reference }}
SEC: ${{ matrix.secondary }}
BURST: ${{ inputs.fullBurstID }}
YEAR: ${{ inputs.year }}
run: |
PREFIX=${BURST}/${YEAR}/${REF:17:8}_${SEC:17:8}
echo "PREFIX=${PREFIX}" >> $GITHUB_ENV
- name: Run Hyp3-ISCE2
env:
EARTHDATA_USERNAME: ${{ secrets.EARTHDATA_USERNAME }}
EARTHDATA_PASSWORD: ${{ secrets.EARTHDATA_PASSWORD}}
ESA_USERNAME: ${{ secrets.ESA_USERNAME }}
ESA_PASSWORD: ${{ secrets.ESA_PASSWORD}}
run: |
python -m hyp3_isce2 ++process insar_tops_fufiters \
${{ matrix.reference }} \
${{ matrix.secondary }} \
--burstId ${{ inputs.fullBurstID }} \
--polarization ${{ inputs.polarization }} \
--looks ${{ inputs.nlooks }} \
--apply-water-mask False
# - name: Create COGs + STAC Metadata
# run: |
# # Just install couple extra dependencies for script
# # pip install pystac rasterio rio-stac jsonschema
# ls
# python contrib/hyp3isce2stac.py
- name: Upload to AWS S3
run: |
OUTDIR=`ls -d S1_*`
aws s3 sync $OUTDIR s3://fufiters/backprocess/$PREFIX/$OUTDIR
# - name: Upload Hyp3 Output to GitHub
# uses: actions/upload-artifact@v4
# with:
# name: ${{ env.PREFIX }}
# path: S1*.zip