-
Notifications
You must be signed in to change notification settings - Fork 1
/
tile_all_temporal.py
73 lines (55 loc) · 3.15 KB
/
tile_all_temporal.py
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
#! /usr/bin/env python
#
# Copyright 2023 California Institute of Technology
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Authors: Philip G. Brodrick, [email protected]
import os
import subprocess
import argparse
import glob
def main():
parser = argparse.ArgumentParser(description="Run visuals workflow")
parser.add_argument('dates', type=str, nargs='+')
parser.add_argument('--sourcedir', type=str, default='methane_20230813')
parser.add_argument('--type', type=str, default='ch4', choices=['co2','ch4'])
args = parser.parse_args()
path = os.environ['PATH']
path = path.replace('\Library\\bin;',':')
os.environ['PATH'] = path
tiled_basedir = os.path.join(args.sourcedir, f'{args.type}_mosaic_temporal_static')
tiled_basedir_refined = os.path.join(args.sourcedir, f'{args.type}_mosaic_temporal_refined_static')
for dname in [tiled_basedir, tiled_basedir_refined]:
if os.path.isdir(dname) is False:
subprocess.call(f'mkdir -p {dname}', shell=True)
if args.dates[0] == 'all':
dates = [os.path.basename(x) for x in glob.glob('/beegfs/store/emit/ops/data/acquisitions/202*')]
else:
dates = args.dates
for date in dates:
if args.type == 'ch4':
static_refined_file_list = os.path.join(tiled_basedir_refined, f'{date}_methane_refined_static.txt')
static_file_list = os.path.join(tiled_basedir, f'{date}_methane_static.txt')
elif args.type == 'co2':
static_refined_file_list = os.path.join(tiled_basedir_refined, f'{date}_co2_refined_static.txt')
static_file_list = os.path.join(tiled_basedir, f'{date}_co2_static.txt')
subprocess.call(f'find {os.path.join(args.sourcedir, date)} -name "emit{date}*_{args.type}_mf_refined_scaled_color_ort.tif" > {static_refined_file_list}',shell=True)
subprocess.call(f'find {os.path.join(args.sourcedir, date)} -name "emit{date}*_{args.type}_mf_scaled_color_ort.tif" > {static_file_list}',shell=True)
od_date = f'{date[:4]}-{date[4:6]}-{date[6:8]}T00_00_01Z-to-{date[:4]}-{date[4:6]}-{date[6:8]}T23_59_59Z'
out_fold_refined_static = os.path.join(tiled_basedir_refined, od_date)
out_fold_static = os.path.join(tiled_basedir, od_date)
#subprocess.call(f'sbatch -N 1 -c 40 --mem=180G --job-name {args.type}_tile_{date} --wrap="python daily_tiler.py {static_refined_file_list} {out_fold_refined_static}"',shell=True)
subprocess.call(f'sbatch -N 1 -c 40 --mem=180G --job-name {args.type}_tile_{date} --wrap="python daily_tiler.py {static_file_list} {out_fold_static}"',shell=True)
if __name__ == "__main__":
main()