Skip to content

Commit 3bf7465

Browse files
committed
Skip processed zarr dates and flip zarr y axis
1 parent d5ff93c commit 3bf7465

File tree

2 files changed

+35
-21
lines changed

2 files changed

+35
-21
lines changed

bin/vizgen.py

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,34 @@ def zarr2tiff(input_file, config, process_existing=False, limit=-1, create_cog=F
7575
config.reproject = ''
7676

7777
counter += 1
78-
for idx, time in enumerate(time_data):
78+
for idx, time in (list(enumerate(time_data))):
7979
if time != '':
8080
datestring = '_' + datetime.fromtimestamp(time).strftime("%Y%m%d")
81+
doystring = datetime.fromtimestamp(time).strftime("%Y%j%H%M%S")
8182
else:
8283
datestring = ''
84+
doystring = ''
8385
for var in vars:
86+
# check if already processed
87+
print('\nChecking existing files in ' + config.output_dir + '/' + config.layer_prefix + '_' + var)
88+
mrfs = Path(config.output_dir + '/' + config.layer_prefix + '_' + var).rglob('*')
89+
skip = False
90+
for mrf in mrfs:
91+
if doystring in str(mrf):
92+
print(f'{mrf} exists - skipping\n')
93+
skip = True
94+
break
95+
if skip:
96+
continue
97+
8498
output_file = str(Path(config.working_dir).absolute()) \
8599
+ '/' + str(Path(input_file).stem) + '_' + var + datestring + '.tiff'
86-
print('Creating GeoTIFF file ' + output_file)
100+
print('\nCreating GeoTIFF file ' + output_file)
87101

88102
if not os.path.isfile(output_file):
89103
extents = config.extents.split(',')
90104
gdal_translate = ['gdal_translate', '-of', 'GTiff', '-a_srs', projection, '-a_ullr',
91-
extents[0], extents[3], extents[2], extents[1]]
105+
extents[0], extents[1], extents[2], extents[3]]
92106
if hasattr(config, 'nodata'):
93107
gdal_translate.append('-a_nodata')
94108
gdal_translate.append(str(config.nodata))
@@ -103,22 +117,22 @@ def zarr2tiff(input_file, config, process_existing=False, limit=-1, create_cog=F
103117
print(error.decode())
104118
print('Created GeoTIFF ' + output_file)
105119

106-
if config.is360:
107-
print('Converting coordinates from 0 - 360 to -180 - 180')
108-
output_file_360 = output_file.replace('.tiff', '_360.tiff')
109-
print('Creating GeoTIFF file ' + output_file_360)
110-
gdal_warp = ['gdalwarp', '-t_srs', 'WGS84', '-te', '-180', '-90', '180', '90', output_file,
111-
output_file_360, '-wo', 'SOURCE_EXTRA=1000', '--config', 'CENTER_LONG', '0']
112-
print(gdal_warp)
113-
process = subprocess.Popen(gdal_warp, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
114-
process.wait()
115-
for output in process.stdout:
116-
print(output.decode())
117-
for error in process.stderr:
118-
print(error.decode())
119-
print('Created GeoTIFF ' + output_file_360)
120-
shutil.move(output_file_360, output_file)
121-
print('Replaced ' + output_file)
120+
# TODO: Check if we need to flip y-axis
121+
print('Converting coordinates from 0 - 360 to -180 - 180')
122+
output_file_360 = output_file.replace('.tiff', '_360.tiff')
123+
print('Creating GeoTIFF file ' + output_file_360)
124+
gdal_warp = ['gdalwarp', '-t_srs', 'WGS84', '-te', '-180', '-90', '180', '90', output_file,
125+
output_file_360]
126+
print(gdal_warp)
127+
process = subprocess.Popen(gdal_warp, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
128+
process.wait()
129+
for output in process.stdout:
130+
print(output.decode())
131+
for error in process.stderr:
132+
print(error.decode())
133+
print('Created GeoTIFF ' + output_file_360)
134+
shutil.move(output_file_360, output_file)
135+
print('Replaced ' + output_file)
122136

123137
if create_cog:
124138
cog_file = str(Path(config.working_dir).absolute()) \
@@ -446,7 +460,7 @@ def create_mrf(input_files, config, layer_name, colormap, empty_tile):
446460
s3_url.netloc,
447461
s3_path_idx)
448462
print(data_response)
449-
os.remove(output_dir + '/' + mrf_file)
463+
# os.remove(output_dir + '/' + mrf_file)
450464
os.remove(output_dir + '/' + data_file)
451465
if config.idx_dir is None:
452466
os.remove(output_dir + '/' + idx_file)

version.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22

33
# The VIZGEN version to use in the Docker image tag (e.g. coverage/vizgen:{VIZGEN_VERSION}).
4-
export VIZGEN_VERSION=0.6.0
4+
export VIZGEN_VERSION=0.6.1

0 commit comments

Comments
 (0)